]>
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" |
4bf6a362 | 56 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 57 | #include "bgpd/bgp_open.h" |
4bf6a362 | 58 | #include "bgpd/bgp_regex.h" |
718e3744 | 59 | #include "bgpd/bgp_route.h" |
c016b6c7 | 60 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 61 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 62 | #include "bgpd/bgp_table.h" |
94f2b392 | 63 | #include "bgpd/bgp_vty.h" |
165b5fff | 64 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 65 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 66 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 67 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 68 | #include "bgpd/bgp_io.h" |
94c2f693 | 69 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 70 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 71 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 72 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 73 | #include "bgpd/bgp_mac.h" |
dd65f45e | 74 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 75 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 76 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
77 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
78 | #endif | |
79 | ||
5d5393b9 | 80 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
81 | { |
82 | .val_bool = false, | |
83 | .match_profile = "traditional", | |
84 | .match_version = "< 7.4", | |
85 | }, | |
86 | { .val_bool = true }, | |
67b0f40c | 87 | ); |
5d5393b9 | 88 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
89 | { .val_bool = true, .match_profile = "datacenter", }, |
90 | { .val_bool = false }, | |
67b0f40c | 91 | ); |
aef999a2 DA |
92 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
93 | { .val_bool = true, .match_profile = "datacenter", }, | |
94 | { .val_bool = false }, | |
67b0f40c | 95 | ); |
5d5393b9 | 96 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
97 | { .val_bool = true, .match_profile = "datacenter", }, |
98 | { .val_bool = false }, | |
67b0f40c | 99 | ); |
5d5393b9 | 100 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
101 | { .val_bool = true, .match_profile = "datacenter", }, |
102 | { .val_bool = false }, | |
67b0f40c | 103 | ); |
5d5393b9 DL |
104 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
105 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
106 | { .val_ulong = 120 }, | |
67b0f40c | 107 | ); |
5d5393b9 DL |
108 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
109 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
110 | { .val_ulong = 180 }, | |
67b0f40c | 111 | ); |
5d5393b9 DL |
112 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
113 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
114 | { .val_ulong = 60 }, | |
67b0f40c | 115 | ); |
1d3fdccf DA |
116 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
117 | { .val_bool = false, .match_profile = "datacenter", }, | |
118 | { .val_bool = false, .match_version = "< 7.4", }, | |
119 | { .val_bool = true }, | |
67b0f40c | 120 | ); |
2adac256 DA |
121 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
122 | { .val_bool = false, .match_version = "< 7.6", }, | |
123 | { .val_bool = true }, | |
67b0f40c | 124 | ); |
5d5393b9 | 125 | |
dd65f45e DL |
126 | DEFINE_HOOK(bgp_inst_config_write, |
127 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
128 | (bgp, vty)); |
129 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 130 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 131 | |
d62a17ae | 132 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
133 | struct prefix *range, int exact); | |
134 | ||
055679e9 | 135 | /* Show BGP peer's information. */ |
136 | enum show_type { | |
137 | show_all, | |
138 | show_peer, | |
139 | show_ipv4_all, | |
140 | show_ipv6_all, | |
141 | show_ipv4_peer, | |
142 | show_ipv6_peer | |
143 | }; | |
144 | ||
36235319 QY |
145 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
146 | struct prefix *range, int exact); | |
2986cac2 | 147 | |
36235319 QY |
148 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
149 | struct bgp *bgp, | |
150 | bool use_json, | |
151 | json_object *json); | |
2986cac2 | 152 | |
36235319 QY |
153 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
154 | enum show_type type, | |
155 | const char *ip_str, | |
156 | afi_t afi, bool use_json); | |
2986cac2 | 157 | |
d62a17ae | 158 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
159 | { | |
160 | switch (afi) { | |
161 | case AFI_IP: | |
162 | switch (safi) { | |
163 | case SAFI_UNICAST: | |
164 | return BGP_IPV4_NODE; | |
d62a17ae | 165 | case SAFI_MULTICAST: |
166 | return BGP_IPV4M_NODE; | |
d62a17ae | 167 | case SAFI_LABELED_UNICAST: |
168 | return BGP_IPV4L_NODE; | |
d62a17ae | 169 | case SAFI_MPLS_VPN: |
170 | return BGP_VPNV4_NODE; | |
7c40bf39 | 171 | case SAFI_FLOWSPEC: |
172 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
173 | default: |
174 | /* not expected */ | |
175 | return BGP_IPV4_NODE; | |
d62a17ae | 176 | } |
177 | break; | |
178 | case AFI_IP6: | |
179 | switch (safi) { | |
180 | case SAFI_UNICAST: | |
181 | return BGP_IPV6_NODE; | |
d62a17ae | 182 | case SAFI_MULTICAST: |
183 | return BGP_IPV6M_NODE; | |
d62a17ae | 184 | case SAFI_LABELED_UNICAST: |
185 | return BGP_IPV6L_NODE; | |
d62a17ae | 186 | case SAFI_MPLS_VPN: |
187 | return BGP_VPNV6_NODE; | |
7c40bf39 | 188 | case SAFI_FLOWSPEC: |
189 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
190 | default: |
191 | /* not expected */ | |
192 | return BGP_IPV4_NODE; | |
d62a17ae | 193 | } |
194 | break; | |
195 | case AFI_L2VPN: | |
196 | return BGP_EVPN_NODE; | |
b26f891d | 197 | case AFI_UNSPEC: |
d62a17ae | 198 | case AFI_MAX: |
199 | // We should never be here but to clarify the switch statement.. | |
200 | return BGP_IPV4_NODE; | |
d62a17ae | 201 | } |
202 | ||
203 | // Impossible to happen | |
204 | return BGP_IPV4_NODE; | |
f51bae9c | 205 | } |
20eb8864 | 206 | |
5cb5f4d0 DD |
207 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
208 | { | |
7d0d37de DS |
209 | if (afi == AFI_IP) { |
210 | if (safi == SAFI_UNICAST) | |
211 | return "IPv4 Unicast"; | |
212 | if (safi == SAFI_MULTICAST) | |
213 | return "IPv4 Multicast"; | |
214 | if (safi == SAFI_LABELED_UNICAST) | |
215 | return "IPv4 Labeled Unicast"; | |
216 | if (safi == SAFI_MPLS_VPN) | |
217 | return "IPv4 VPN"; | |
218 | if (safi == SAFI_ENCAP) | |
219 | return "IPv4 Encap"; | |
220 | if (safi == SAFI_FLOWSPEC) | |
221 | return "IPv4 Flowspec"; | |
222 | } else if (afi == AFI_IP6) { | |
223 | if (safi == SAFI_UNICAST) | |
224 | return "IPv6 Unicast"; | |
225 | if (safi == SAFI_MULTICAST) | |
226 | return "IPv6 Multicast"; | |
227 | if (safi == SAFI_LABELED_UNICAST) | |
228 | return "IPv6 Labeled Unicast"; | |
229 | if (safi == SAFI_MPLS_VPN) | |
230 | return "IPv6 VPN"; | |
231 | if (safi == SAFI_ENCAP) | |
232 | return "IPv6 Encap"; | |
233 | if (safi == SAFI_FLOWSPEC) | |
234 | return "IPv6 Flowspec"; | |
235 | } else if (afi == AFI_L2VPN) { | |
236 | if (safi == SAFI_EVPN) | |
237 | return "L2VPN EVPN"; | |
238 | } | |
239 | ||
240 | return "Unknown"; | |
5cb5f4d0 DD |
241 | } |
242 | ||
243 | /* | |
244 | * Please note that we have intentionally camelCased | |
245 | * the return strings here. So if you want | |
246 | * to use this function, please ensure you | |
247 | * are doing this within json output | |
248 | */ | |
249 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
250 | { | |
7d0d37de DS |
251 | if (afi == AFI_IP) { |
252 | if (safi == SAFI_UNICAST) | |
253 | return "ipv4Unicast"; | |
254 | if (safi == SAFI_MULTICAST) | |
255 | return "ipv4Multicast"; | |
256 | if (safi == SAFI_LABELED_UNICAST) | |
257 | return "ipv4LabeledUnicast"; | |
258 | if (safi == SAFI_MPLS_VPN) | |
259 | return "ipv4Vpn"; | |
260 | if (safi == SAFI_ENCAP) | |
261 | return "ipv4Encap"; | |
262 | if (safi == SAFI_FLOWSPEC) | |
263 | return "ipv4Flowspec"; | |
264 | } else if (afi == AFI_IP6) { | |
265 | if (safi == SAFI_UNICAST) | |
266 | return "ipv6Unicast"; | |
267 | if (safi == SAFI_MULTICAST) | |
268 | return "ipv6Multicast"; | |
269 | if (safi == SAFI_LABELED_UNICAST) | |
270 | return "ipv6LabeledUnicast"; | |
271 | if (safi == SAFI_MPLS_VPN) | |
272 | return "ipv6Vpn"; | |
273 | if (safi == SAFI_ENCAP) | |
274 | return "ipv6Encap"; | |
275 | if (safi == SAFI_FLOWSPEC) | |
276 | return "ipv6Flowspec"; | |
277 | } else if (afi == AFI_L2VPN) { | |
278 | if (safi == SAFI_EVPN) | |
279 | return "l2VpnEvpn"; | |
280 | } | |
281 | ||
282 | return "Unknown"; | |
5cb5f4d0 DD |
283 | } |
284 | ||
718e3744 | 285 | /* Utility function to get address family from current node. */ |
d62a17ae | 286 | afi_t bgp_node_afi(struct vty *vty) |
287 | { | |
288 | afi_t afi; | |
289 | switch (vty->node) { | |
290 | case BGP_IPV6_NODE: | |
291 | case BGP_IPV6M_NODE: | |
292 | case BGP_IPV6L_NODE: | |
293 | case BGP_VPNV6_NODE: | |
7c40bf39 | 294 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 295 | afi = AFI_IP6; |
296 | break; | |
297 | case BGP_EVPN_NODE: | |
298 | afi = AFI_L2VPN; | |
299 | break; | |
300 | default: | |
301 | afi = AFI_IP; | |
302 | break; | |
303 | } | |
304 | return afi; | |
718e3744 | 305 | } |
306 | ||
307 | /* Utility function to get subsequent address family from current | |
308 | node. */ | |
d62a17ae | 309 | safi_t bgp_node_safi(struct vty *vty) |
310 | { | |
311 | safi_t safi; | |
312 | switch (vty->node) { | |
313 | case BGP_VPNV4_NODE: | |
314 | case BGP_VPNV6_NODE: | |
315 | safi = SAFI_MPLS_VPN; | |
316 | break; | |
317 | case BGP_IPV4M_NODE: | |
318 | case BGP_IPV6M_NODE: | |
319 | safi = SAFI_MULTICAST; | |
320 | break; | |
321 | case BGP_EVPN_NODE: | |
322 | safi = SAFI_EVPN; | |
323 | break; | |
324 | case BGP_IPV4L_NODE: | |
325 | case BGP_IPV6L_NODE: | |
326 | safi = SAFI_LABELED_UNICAST; | |
327 | break; | |
7c40bf39 | 328 | case BGP_FLOWSPECV4_NODE: |
329 | case BGP_FLOWSPECV6_NODE: | |
330 | safi = SAFI_FLOWSPEC; | |
331 | break; | |
d62a17ae | 332 | default: |
333 | safi = SAFI_UNICAST; | |
334 | break; | |
335 | } | |
336 | return safi; | |
718e3744 | 337 | } |
338 | ||
55f91488 QY |
339 | /** |
340 | * Converts an AFI in string form to afi_t | |
341 | * | |
342 | * @param afi string, one of | |
343 | * - "ipv4" | |
344 | * - "ipv6" | |
81cf0de5 | 345 | * - "l2vpn" |
55f91488 QY |
346 | * @return the corresponding afi_t |
347 | */ | |
d62a17ae | 348 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
349 | { | |
350 | afi_t afi = AFI_MAX; /* unknown */ | |
351 | if (strmatch(afi_str, "ipv4")) | |
352 | afi = AFI_IP; | |
353 | else if (strmatch(afi_str, "ipv6")) | |
354 | afi = AFI_IP6; | |
81cf0de5 CS |
355 | else if (strmatch(afi_str, "l2vpn")) |
356 | afi = AFI_L2VPN; | |
d62a17ae | 357 | return afi; |
358 | } | |
359 | ||
360 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
361 | afi_t *afi) | |
362 | { | |
363 | int ret = 0; | |
364 | if (argv_find(argv, argc, "ipv4", index)) { | |
365 | ret = 1; | |
366 | if (afi) | |
367 | *afi = AFI_IP; | |
368 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
369 | ret = 1; | |
370 | if (afi) | |
371 | *afi = AFI_IP6; | |
8688b3e7 DS |
372 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
373 | ret = 1; | |
374 | if (afi) | |
375 | *afi = AFI_L2VPN; | |
d62a17ae | 376 | } |
377 | return ret; | |
46f296b4 LB |
378 | } |
379 | ||
375a2e67 | 380 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 381 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
382 | { | |
383 | safi_t safi = SAFI_MAX; /* unknown */ | |
384 | if (strmatch(safi_str, "multicast")) | |
385 | safi = SAFI_MULTICAST; | |
386 | else if (strmatch(safi_str, "unicast")) | |
387 | safi = SAFI_UNICAST; | |
388 | else if (strmatch(safi_str, "vpn")) | |
389 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
390 | else if (strmatch(safi_str, "evpn")) |
391 | safi = SAFI_EVPN; | |
d62a17ae | 392 | else if (strmatch(safi_str, "labeled-unicast")) |
393 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 394 | else if (strmatch(safi_str, "flowspec")) |
395 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 396 | return safi; |
397 | } | |
398 | ||
399 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
400 | safi_t *safi) | |
401 | { | |
402 | int ret = 0; | |
403 | if (argv_find(argv, argc, "unicast", index)) { | |
404 | ret = 1; | |
405 | if (safi) | |
406 | *safi = SAFI_UNICAST; | |
407 | } else if (argv_find(argv, argc, "multicast", index)) { | |
408 | ret = 1; | |
409 | if (safi) | |
410 | *safi = SAFI_MULTICAST; | |
411 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
412 | ret = 1; | |
413 | if (safi) | |
414 | *safi = SAFI_LABELED_UNICAST; | |
415 | } else if (argv_find(argv, argc, "vpn", index)) { | |
416 | ret = 1; | |
417 | if (safi) | |
418 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
419 | } else if (argv_find(argv, argc, "evpn", index)) { |
420 | ret = 1; | |
421 | if (safi) | |
422 | *safi = SAFI_EVPN; | |
7c40bf39 | 423 | } else if (argv_find(argv, argc, "flowspec", index)) { |
424 | ret = 1; | |
425 | if (safi) | |
426 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 427 | } |
428 | return ret; | |
46f296b4 LB |
429 | } |
430 | ||
b16bcbba TA |
431 | /* |
432 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
433 | * | |
434 | * afi | |
435 | * address-family identifier | |
436 | * | |
437 | * safi | |
438 | * subsequent address-family identifier | |
439 | * | |
440 | * Returns: | |
441 | * default_af string corresponding to the supplied afi/safi pair. | |
442 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
443 | * return -1. | |
444 | */ | |
445 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
446 | { | |
447 | switch (afi) { | |
448 | case AFI_IP: | |
449 | switch (safi) { | |
450 | case SAFI_UNICAST: | |
451 | return "ipv4-unicast"; | |
452 | case SAFI_MULTICAST: | |
453 | return "ipv4-multicast"; | |
454 | case SAFI_MPLS_VPN: | |
455 | return "ipv4-vpn"; | |
456 | case SAFI_ENCAP: | |
457 | return "ipv4-encap"; | |
458 | case SAFI_LABELED_UNICAST: | |
459 | return "ipv4-labeled-unicast"; | |
460 | case SAFI_FLOWSPEC: | |
461 | return "ipv4-flowspec"; | |
462 | default: | |
463 | return "unknown-afi/safi"; | |
464 | } | |
465 | break; | |
466 | case AFI_IP6: | |
467 | switch (safi) { | |
468 | case SAFI_UNICAST: | |
469 | return "ipv6-unicast"; | |
470 | case SAFI_MULTICAST: | |
471 | return "ipv6-multicast"; | |
472 | case SAFI_MPLS_VPN: | |
473 | return "ipv6-vpn"; | |
474 | case SAFI_ENCAP: | |
475 | return "ipv6-encap"; | |
476 | case SAFI_LABELED_UNICAST: | |
477 | return "ipv6-labeled-unicast"; | |
478 | case SAFI_FLOWSPEC: | |
479 | return "ipv6-flowspec"; | |
480 | default: | |
481 | return "unknown-afi/safi"; | |
482 | } | |
483 | break; | |
484 | case AFI_L2VPN: | |
485 | switch (safi) { | |
486 | case SAFI_EVPN: | |
487 | return "l2vpn-evpn"; | |
488 | default: | |
489 | return "unknown-afi/safi"; | |
490 | } | |
491 | case AFI_UNSPEC: | |
492 | case AFI_MAX: | |
493 | return "unknown-afi/safi"; | |
494 | } | |
495 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
496 | return "unknown-afi/safi"; | |
497 | } | |
498 | ||
5d5393b9 DL |
499 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
500 | enum bgp_instance_type inst_type) | |
501 | { | |
502 | int ret = bgp_get(bgp, as, name, inst_type); | |
503 | ||
504 | if (ret == BGP_CREATED) { | |
505 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 506 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
507 | |
508 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 509 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 510 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 511 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
512 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
513 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 514 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 515 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 516 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 517 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
518 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
519 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
520 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
521 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
5d5393b9 DL |
522 | |
523 | ret = BGP_SUCCESS; | |
524 | } | |
525 | return ret; | |
526 | } | |
527 | ||
7eeee51e | 528 | /* |
f212a857 | 529 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 530 | * |
f212a857 DS |
531 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
532 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
533 | * to appropriate values for the calling function. This is to allow the |
534 | * calling function to make decisions appropriate for the show command | |
535 | * that is being parsed. | |
536 | * | |
537 | * The show commands are generally of the form: | |
d62a17ae | 538 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
539 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
540 | * |
541 | * Since we use argv_find if the show command in particular doesn't have: | |
542 | * [ip] | |
18c57037 | 543 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 544 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
545 | * The command parsing should still be ok. |
546 | * | |
547 | * vty -> The vty for the command so we can output some useful data in | |
548 | * the event of a parse error in the vrf. | |
549 | * argv -> The command tokens | |
550 | * argc -> How many command tokens we have | |
d62a17ae | 551 | * idx -> The current place in the command, generally should be 0 for this |
552 | * function | |
7eeee51e DS |
553 | * afi -> The parsed afi if it was included in the show command, returned here |
554 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 555 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 556 | * use_json -> json is configured or not |
7eeee51e DS |
557 | * |
558 | * The function returns the correct location in the parse tree for the | |
559 | * last token found. | |
0e37c258 DS |
560 | * |
561 | * Returns 0 for failure to parse correctly, else the idx position of where | |
562 | * it found the last token. | |
7eeee51e | 563 | */ |
d62a17ae | 564 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
565 | struct cmd_token **argv, int argc, | |
566 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 567 | struct bgp **bgp, bool use_json) |
d62a17ae | 568 | { |
569 | char *vrf_name = NULL; | |
570 | ||
571 | assert(afi); | |
572 | assert(safi); | |
573 | assert(bgp); | |
574 | ||
575 | if (argv_find(argv, argc, "ip", idx)) | |
576 | *afi = AFI_IP; | |
577 | ||
9a8bdf1c | 578 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 579 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
580 | else if (argv_find(argv, argc, "vrf", idx)) { |
581 | vrf_name = argv[*idx + 1]->arg; | |
582 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
583 | vrf_name = NULL; | |
584 | } | |
585 | if (vrf_name) { | |
d62a17ae | 586 | if (strmatch(vrf_name, "all")) |
587 | *bgp = NULL; | |
588 | else { | |
589 | *bgp = bgp_lookup_by_name(vrf_name); | |
590 | if (!*bgp) { | |
52e5b8c4 SP |
591 | if (use_json) { |
592 | json_object *json = NULL; | |
593 | json = json_object_new_object(); | |
594 | json_object_string_add( | |
595 | json, "warning", | |
596 | "View/Vrf is unknown"); | |
597 | vty_out(vty, "%s\n", | |
598 | json_object_to_json_string_ext(json, | |
599 | JSON_C_TO_STRING_PRETTY)); | |
600 | json_object_free(json); | |
601 | } | |
ca61fd25 DS |
602 | else |
603 | vty_out(vty, "View/Vrf %s is unknown\n", | |
604 | vrf_name); | |
d62a17ae | 605 | *idx = 0; |
606 | return 0; | |
607 | } | |
608 | } | |
609 | } else { | |
610 | *bgp = bgp_get_default(); | |
611 | if (!*bgp) { | |
52e5b8c4 SP |
612 | if (use_json) { |
613 | json_object *json = NULL; | |
614 | json = json_object_new_object(); | |
615 | json_object_string_add( | |
616 | json, "warning", | |
617 | "Default BGP instance not found"); | |
618 | vty_out(vty, "%s\n", | |
619 | json_object_to_json_string_ext(json, | |
620 | JSON_C_TO_STRING_PRETTY)); | |
621 | json_object_free(json); | |
622 | } | |
ca61fd25 DS |
623 | else |
624 | vty_out(vty, | |
625 | "Default BGP instance not found\n"); | |
d62a17ae | 626 | *idx = 0; |
627 | return 0; | |
628 | } | |
629 | } | |
630 | ||
631 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
632 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
633 | ||
634 | *idx += 1; | |
635 | return *idx; | |
636 | } | |
637 | ||
28c6e247 | 638 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 639 | { |
640 | struct interface *ifp = NULL; | |
641 | ||
642 | if (su->sa.sa_family == AF_INET) | |
643 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
644 | else if (su->sa.sa_family == AF_INET6) | |
645 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
646 | su->sin6.sin6_scope_id, | |
647 | bgp->vrf_id); | |
648 | ||
649 | if (ifp) | |
3dc339cd | 650 | return true; |
d62a17ae | 651 | |
3dc339cd | 652 | return false; |
718e3744 | 653 | } |
654 | ||
28c6e247 IR |
655 | /* Utility function for looking up peer from VTY. */ |
656 | /* This is used only for configuration, so disallow if attempted on | |
657 | * a dynamic neighbor. | |
658 | */ | |
659 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
660 | { | |
661 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
662 | int ret; | |
663 | union sockunion su; | |
664 | struct peer *peer; | |
665 | ||
666 | if (!bgp) { | |
667 | return NULL; | |
668 | } | |
669 | ||
670 | ret = str2sockunion(ip_str, &su); | |
671 | if (ret < 0) { | |
672 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
673 | if (!peer) { | |
674 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
675 | == NULL) { | |
676 | vty_out(vty, | |
677 | "%% Malformed address or name: %s\n", | |
678 | ip_str); | |
679 | return NULL; | |
680 | } | |
681 | } | |
682 | } else { | |
683 | peer = peer_lookup(bgp, &su); | |
684 | if (!peer) { | |
685 | vty_out(vty, | |
686 | "%% Specify remote-as or peer-group commands first\n"); | |
687 | return NULL; | |
688 | } | |
689 | if (peer_dynamic_neighbor(peer)) { | |
690 | vty_out(vty, | |
691 | "%% Operation not allowed on a dynamic neighbor\n"); | |
692 | return NULL; | |
693 | } | |
694 | } | |
695 | return peer; | |
696 | } | |
697 | ||
718e3744 | 698 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
699 | /* This is used only for configuration, so disallow if attempted on |
700 | * a dynamic neighbor. | |
701 | */ | |
d62a17ae | 702 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
703 | { | |
704 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
705 | int ret; | |
706 | union sockunion su; | |
707 | struct peer *peer = NULL; | |
708 | struct peer_group *group = NULL; | |
709 | ||
710 | if (!bgp) { | |
711 | return NULL; | |
712 | } | |
713 | ||
714 | ret = str2sockunion(peer_str, &su); | |
715 | if (ret == 0) { | |
716 | /* IP address, locate peer. */ | |
717 | peer = peer_lookup(bgp, &su); | |
718 | } else { | |
719 | /* Not IP, could match either peer configured on interface or a | |
720 | * group. */ | |
721 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
722 | if (!peer) | |
723 | group = peer_group_lookup(bgp, peer_str); | |
724 | } | |
725 | ||
726 | if (peer) { | |
727 | if (peer_dynamic_neighbor(peer)) { | |
728 | vty_out(vty, | |
729 | "%% Operation not allowed on a dynamic neighbor\n"); | |
730 | return NULL; | |
731 | } | |
732 | ||
733 | return peer; | |
734 | } | |
735 | ||
736 | if (group) | |
737 | return group->conf; | |
738 | ||
739 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
740 | ||
741 | return NULL; | |
742 | } | |
743 | ||
744 | int bgp_vty_return(struct vty *vty, int ret) | |
745 | { | |
746 | const char *str = NULL; | |
747 | ||
748 | switch (ret) { | |
749 | case BGP_ERR_INVALID_VALUE: | |
750 | str = "Invalid value"; | |
751 | break; | |
752 | case BGP_ERR_INVALID_FLAG: | |
753 | str = "Invalid flag"; | |
754 | break; | |
755 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
756 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
757 | break; | |
758 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
759 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
760 | break; | |
761 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
762 | str = "Specify remote-as or peer-group remote AS first"; | |
763 | break; | |
764 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
765 | str = "Cannot change the peer-group. Deconfigure first"; | |
766 | break; | |
767 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
768 | str = "Peer is not a member of this peer-group"; | |
769 | break; | |
770 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
771 | str = "Prefix/distribute list can not co-exist"; | |
772 | break; | |
773 | case BGP_ERR_NOT_INTERNAL_PEER: | |
774 | str = "Invalid command. Not an internal neighbor"; | |
775 | break; | |
776 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
777 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
778 | break; | |
779 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
780 | str = "Local-AS allowed only for EBGP peers"; | |
781 | break; | |
782 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
783 | str = "Cannot have local-as same as BGP AS number"; | |
784 | break; | |
785 | case BGP_ERR_TCPSIG_FAILED: | |
786 | str = "Error while applying TCP-Sig to session(s)"; | |
787 | break; | |
788 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
789 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
790 | break; | |
791 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
792 | str = "ttl-security only allowed for EBGP peers"; | |
793 | break; | |
794 | case BGP_ERR_AS_OVERRIDE: | |
795 | str = "as-override cannot be configured for IBGP peers"; | |
796 | break; | |
797 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
798 | str = "Invalid limit for number of dynamic neighbors"; | |
799 | break; | |
800 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
801 | str = "Dynamic neighbor listen range already exists"; | |
802 | break; | |
803 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
804 | str = "Operation not allowed on a dynamic neighbor"; | |
805 | break; | |
806 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
807 | str = "Operation not allowed on a directly connected neighbor"; | |
808 | break; | |
809 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 810 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 811 | break; |
812 | case BGP_ERR_GR_INVALID_CMD: | |
813 | str = "The Graceful Restart command used is not valid at this moment."; | |
814 | break; | |
815 | case BGP_ERR_GR_OPERATION_FAILED: | |
816 | str = "The Graceful Restart Operation failed due to an err."; | |
817 | break; | |
d62a17ae | 818 | } |
819 | if (str) { | |
820 | vty_out(vty, "%% %s\n", str); | |
821 | return CMD_WARNING_CONFIG_FAILED; | |
822 | } | |
823 | return CMD_SUCCESS; | |
718e3744 | 824 | } |
825 | ||
7aafcaca | 826 | /* BGP clear sort. */ |
d62a17ae | 827 | enum clear_sort { |
828 | clear_all, | |
829 | clear_peer, | |
830 | clear_group, | |
831 | clear_external, | |
832 | clear_as | |
7aafcaca DS |
833 | }; |
834 | ||
1ca2fd11 IR |
835 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
836 | safi_t safi, int error) | |
d62a17ae | 837 | { |
838 | switch (error) { | |
839 | case BGP_ERR_AF_UNCONFIGURED: | |
1ca2fd11 IR |
840 | vty_out(vty, |
841 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
842 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 843 | break; |
844 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
1ca2fd11 IR |
845 | vty_out(vty, |
846 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
d62a17ae | 847 | peer->host); |
848 | break; | |
849 | default: | |
850 | break; | |
851 | } | |
7aafcaca DS |
852 | } |
853 | ||
dc912615 | 854 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 855 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
856 | { |
857 | int ret = 0; | |
2adac256 | 858 | struct peer_af *paf; |
dc912615 DS |
859 | |
860 | /* if afi/.safi not specified, spin thru all of them */ | |
861 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
862 | afi_t tmp_afi; | |
863 | safi_t tmp_safi; | |
864 | ||
865 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
2adac256 DA |
866 | paf = peer_af_find(peer, tmp_afi, tmp_safi); |
867 | if (paf && paf->subgroup) | |
868 | SET_FLAG(paf->subgroup->sflags, | |
869 | SUBGRP_STATUS_FORCE_UPDATES); | |
870 | ||
dc912615 DS |
871 | if (!peer->afc[tmp_afi][tmp_safi]) |
872 | continue; | |
873 | ||
874 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 875 | ret = peer_clear(peer, nnode); |
dc912615 DS |
876 | else |
877 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
878 | stype); | |
879 | } | |
880 | /* if afi specified and safi not, spin thru safis on this afi */ | |
881 | } else if (safi == SAFI_UNSPEC) { | |
882 | safi_t tmp_safi; | |
883 | ||
884 | for (tmp_safi = SAFI_UNICAST; | |
885 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
886 | if (!peer->afc[afi][tmp_safi]) | |
887 | continue; | |
888 | ||
2adac256 DA |
889 | paf = peer_af_find(peer, afi, tmp_safi); |
890 | if (paf && paf->subgroup) | |
891 | SET_FLAG(paf->subgroup->sflags, | |
892 | SUBGRP_STATUS_FORCE_UPDATES); | |
893 | ||
dc912615 | 894 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 895 | ret = peer_clear(peer, nnode); |
dc912615 DS |
896 | else |
897 | ret = peer_clear_soft(peer, afi, | |
898 | tmp_safi, stype); | |
899 | } | |
900 | /* both afi/safi specified, let the caller know if not defined */ | |
901 | } else { | |
902 | if (!peer->afc[afi][safi]) | |
903 | return 1; | |
904 | ||
2adac256 DA |
905 | paf = peer_af_find(peer, afi, safi); |
906 | if (paf && paf->subgroup) | |
907 | SET_FLAG(paf->subgroup->sflags, | |
908 | SUBGRP_STATUS_FORCE_UPDATES); | |
909 | ||
dc912615 | 910 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 911 | ret = peer_clear(peer, nnode); |
dc912615 DS |
912 | else |
913 | ret = peer_clear_soft(peer, afi, safi, stype); | |
914 | } | |
915 | ||
916 | return ret; | |
917 | } | |
918 | ||
7aafcaca | 919 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 920 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 921 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 922 | const char *arg) |
d62a17ae | 923 | { |
dc912615 | 924 | int ret = 0; |
3ae8bfa5 | 925 | bool found = false; |
d62a17ae | 926 | struct peer *peer; |
dc95985f | 927 | |
928 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 929 | |
930 | /* Clear all neighbors. */ | |
931 | /* | |
932 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
933 | * nodes on the BGP instance as that may get freed if it is a |
934 | * doppelganger | |
d62a17ae | 935 | */ |
936 | if (sort == clear_all) { | |
937 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 938 | |
939 | bgp_peer_gr_flags_update(peer); | |
940 | ||
36235319 | 941 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 942 | gr_router_detected = true; |
943 | ||
c368171c | 944 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 945 | stype); |
d62a17ae | 946 | |
947 | if (ret < 0) | |
1ca2fd11 | 948 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 949 | } |
950 | ||
36235319 QY |
951 | if (gr_router_detected |
952 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 953 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
954 | } else if (!gr_router_detected |
955 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 956 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 957 | } |
d62a17ae | 958 | |
959 | /* This is to apply read-only mode on this clear. */ | |
960 | if (stype == BGP_CLEAR_SOFT_NONE) | |
961 | bgp->update_delay_over = 0; | |
962 | ||
963 | return CMD_SUCCESS; | |
7aafcaca DS |
964 | } |
965 | ||
3ae8bfa5 | 966 | /* Clear specified neighbor. */ |
d62a17ae | 967 | if (sort == clear_peer) { |
968 | union sockunion su; | |
d62a17ae | 969 | |
970 | /* Make sockunion for lookup. */ | |
971 | ret = str2sockunion(arg, &su); | |
972 | if (ret < 0) { | |
973 | peer = peer_lookup_by_conf_if(bgp, arg); | |
974 | if (!peer) { | |
975 | peer = peer_lookup_by_hostname(bgp, arg); | |
976 | if (!peer) { | |
1ca2fd11 IR |
977 | vty_out(vty, |
978 | "Malformed address or name: %s\n", | |
d62a17ae | 979 | arg); |
980 | return CMD_WARNING; | |
981 | } | |
982 | } | |
983 | } else { | |
984 | peer = peer_lookup(bgp, &su); | |
985 | if (!peer) { | |
1ca2fd11 IR |
986 | vty_out(vty, |
987 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
988 | arg); | |
d62a17ae | 989 | return CMD_WARNING; |
990 | } | |
991 | } | |
7aafcaca | 992 | |
dc95985f | 993 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
994 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
995 | ||
dc912615 DS |
996 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
997 | ||
998 | /* if afi/safi not defined for this peer, let caller know */ | |
999 | if (ret == 1) | |
3ae8bfa5 | 1000 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1001 | |
d62a17ae | 1002 | if (ret < 0) |
1ca2fd11 | 1003 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1004 | |
d62a17ae | 1005 | return CMD_SUCCESS; |
7aafcaca | 1006 | } |
7aafcaca | 1007 | |
3ae8bfa5 | 1008 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1009 | if (sort == clear_group) { |
1010 | struct peer_group *group; | |
7aafcaca | 1011 | |
d62a17ae | 1012 | group = peer_group_lookup(bgp, arg); |
1013 | if (!group) { | |
1ca2fd11 | 1014 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); |
d62a17ae | 1015 | return CMD_WARNING; |
1016 | } | |
1017 | ||
1018 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1019 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1020 | |
d62a17ae | 1021 | if (ret < 0) |
1ca2fd11 | 1022 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1023 | else |
1024 | found = true; | |
d62a17ae | 1025 | } |
3ae8bfa5 PM |
1026 | |
1027 | if (!found) | |
1ca2fd11 IR |
1028 | vty_out(vty, |
1029 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 1030 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1031 | |
d62a17ae | 1032 | return CMD_SUCCESS; |
7aafcaca | 1033 | } |
7aafcaca | 1034 | |
3ae8bfa5 | 1035 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1036 | if (sort == clear_external) { |
1037 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1038 | if (peer->sort == BGP_PEER_IBGP) | |
1039 | continue; | |
7aafcaca | 1040 | |
dc95985f | 1041 | bgp_peer_gr_flags_update(peer); |
1042 | ||
36235319 | 1043 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1044 | gr_router_detected = true; |
dc95985f | 1045 | |
c368171c | 1046 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1047 | |
d62a17ae | 1048 | if (ret < 0) |
1ca2fd11 | 1049 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1050 | else |
1051 | found = true; | |
d62a17ae | 1052 | } |
3ae8bfa5 | 1053 | |
36235319 QY |
1054 | if (gr_router_detected |
1055 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1056 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1057 | } else if (!gr_router_detected |
1058 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1059 | bgp_zebra_send_capabilities(bgp, true); |
1060 | } | |
1061 | ||
3ae8bfa5 | 1062 | if (!found) |
1ca2fd11 IR |
1063 | vty_out(vty, |
1064 | "%%BGP: No external %s peer is configured\n", | |
1065 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1066 | |
d62a17ae | 1067 | return CMD_SUCCESS; |
1068 | } | |
1069 | ||
3ae8bfa5 | 1070 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1071 | if (sort == clear_as) { |
3ae8bfa5 | 1072 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1073 | |
1074 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1075 | if (peer->as != as) | |
1076 | continue; | |
1077 | ||
dc95985f | 1078 | bgp_peer_gr_flags_update(peer); |
1079 | ||
36235319 | 1080 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1081 | gr_router_detected = true; |
dc95985f | 1082 | |
c368171c | 1083 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1084 | |
1085 | if (ret < 0) | |
1ca2fd11 | 1086 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1087 | else |
1088 | found = true; | |
d62a17ae | 1089 | } |
3ae8bfa5 | 1090 | |
36235319 QY |
1091 | if (gr_router_detected |
1092 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1093 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1094 | } else if (!gr_router_detected |
1095 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1096 | bgp_zebra_send_capabilities(bgp, true); |
1097 | } | |
1098 | ||
3ae8bfa5 | 1099 | if (!found) |
1ca2fd11 IR |
1100 | vty_out(vty, |
1101 | "%%BGP: No %s peer is configured with AS %s\n", | |
1102 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1103 | |
d62a17ae | 1104 | return CMD_SUCCESS; |
1105 | } | |
1106 | ||
1107 | return CMD_SUCCESS; | |
1108 | } | |
1109 | ||
1ca2fd11 IR |
1110 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1111 | safi_t safi, enum clear_sort sort, | |
1112 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1113 | { |
1114 | struct bgp *bgp; | |
1115 | ||
1116 | /* BGP structure lookup. */ | |
1117 | if (name) { | |
1118 | bgp = bgp_lookup_by_name(name); | |
1119 | if (bgp == NULL) { | |
1ca2fd11 | 1120 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1121 | return CMD_WARNING; |
1122 | } | |
1123 | } else { | |
1124 | bgp = bgp_get_default(); | |
1125 | if (bgp == NULL) { | |
1ca2fd11 | 1126 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1127 | return CMD_WARNING; |
1128 | } | |
1129 | } | |
1130 | ||
1ca2fd11 | 1131 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1132 | } |
1133 | ||
1134 | /* clear soft inbound */ | |
1ca2fd11 | 1135 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1136 | { |
99b3ebd3 NS |
1137 | afi_t afi; |
1138 | safi_t safi; | |
1139 | ||
1ca2fd11 IR |
1140 | FOREACH_AFI_SAFI (afi, safi) |
1141 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1142 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1143 | } |
1144 | ||
1145 | /* clear soft outbound */ | |
1ca2fd11 | 1146 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1147 | { |
99b3ebd3 NS |
1148 | afi_t afi; |
1149 | safi_t safi; | |
1150 | ||
1ca2fd11 IR |
1151 | FOREACH_AFI_SAFI (afi, safi) |
1152 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1153 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1154 | } |
1155 | ||
1156 | ||
f787d7a0 | 1157 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1158 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1159 | #endif |
1160 | ||
8029b216 AK |
1161 | DEFUN_HIDDEN (bgp_local_mac, |
1162 | bgp_local_mac_cmd, | |
093e3f23 | 1163 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1164 | BGP_STR |
1165 | "Local MAC config\n" | |
1166 | "VxLAN Network Identifier\n" | |
1167 | "VNI number\n" | |
1168 | "local mac\n" | |
1169 | "mac address\n" | |
1170 | "mac-mobility sequence\n" | |
1171 | "seq number\n") | |
1172 | { | |
1173 | int rv; | |
1174 | vni_t vni; | |
1175 | struct ethaddr mac; | |
1176 | struct ipaddr ip; | |
1177 | uint32_t seq; | |
1178 | struct bgp *bgp; | |
1179 | ||
1180 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1181 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1182 | vty_out(vty, "%% Malformed MAC address\n"); | |
1183 | return CMD_WARNING; | |
1184 | } | |
1185 | memset(&ip, 0, sizeof(ip)); | |
1186 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1187 | ||
1188 | bgp = bgp_get_default(); | |
1189 | if (!bgp) { | |
1190 | vty_out(vty, "Default BGP instance is not there\n"); | |
1191 | return CMD_WARNING; | |
1192 | } | |
1193 | ||
b5e140c8 AK |
1194 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1195 | zero_esi); | |
8029b216 AK |
1196 | if (rv < 0) { |
1197 | vty_out(vty, "Internal error\n"); | |
1198 | return CMD_WARNING; | |
1199 | } | |
1200 | ||
1201 | return CMD_SUCCESS; | |
1202 | } | |
1203 | ||
1204 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1205 | no_bgp_local_mac_cmd, | |
093e3f23 | 1206 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1207 | NO_STR |
1208 | BGP_STR | |
1209 | "Local MAC config\n" | |
1210 | "VxLAN Network Identifier\n" | |
1211 | "VNI number\n" | |
1212 | "local mac\n" | |
1213 | "mac address\n") | |
1214 | { | |
1215 | int rv; | |
1216 | vni_t vni; | |
1217 | struct ethaddr mac; | |
1218 | struct ipaddr ip; | |
1219 | struct bgp *bgp; | |
1220 | ||
1221 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1222 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1223 | vty_out(vty, "%% Malformed MAC address\n"); | |
1224 | return CMD_WARNING; | |
1225 | } | |
1226 | memset(&ip, 0, sizeof(ip)); | |
1227 | ||
1228 | bgp = bgp_get_default(); | |
1229 | if (!bgp) { | |
1230 | vty_out(vty, "Default BGP instance is not there\n"); | |
1231 | return CMD_WARNING; | |
1232 | } | |
1233 | ||
ec0ab544 | 1234 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1235 | if (rv < 0) { |
1236 | vty_out(vty, "Internal error\n"); | |
1237 | return CMD_WARNING; | |
1238 | } | |
1239 | ||
1240 | return CMD_SUCCESS; | |
1241 | } | |
1242 | ||
718e3744 | 1243 | DEFUN (no_synchronization, |
1244 | no_synchronization_cmd, | |
1245 | "no synchronization", | |
1246 | NO_STR | |
1247 | "Perform IGP synchronization\n") | |
1248 | { | |
d62a17ae | 1249 | return CMD_SUCCESS; |
718e3744 | 1250 | } |
1251 | ||
1252 | DEFUN (no_auto_summary, | |
1253 | no_auto_summary_cmd, | |
1254 | "no auto-summary", | |
1255 | NO_STR | |
1256 | "Enable automatic network number summarization\n") | |
1257 | { | |
d62a17ae | 1258 | return CMD_SUCCESS; |
718e3744 | 1259 | } |
3d515fd9 | 1260 | |
718e3744 | 1261 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1262 | DEFUN_NOSH (router_bgp, |
1263 | router_bgp_cmd, | |
1264 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1265 | ROUTER_STR | |
1266 | BGP_STR | |
1267 | AS_STR | |
1268 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1269 | { |
d62a17ae | 1270 | int idx_asn = 2; |
1271 | int idx_view_vrf = 3; | |
1272 | int idx_vrf = 4; | |
1ca2fd11 IR |
1273 | int is_new_bgp = 0; |
1274 | int ret; | |
d62a17ae | 1275 | as_t as; |
1276 | struct bgp *bgp; | |
1277 | const char *name = NULL; | |
1278 | enum bgp_instance_type inst_type; | |
1279 | ||
1280 | // "router bgp" without an ASN | |
1281 | if (argc == 2) { | |
1282 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1283 | bgp = bgp_get_default(); |
d62a17ae | 1284 | |
1abef40f | 1285 | if (bgp == NULL) { |
d62a17ae | 1286 | vty_out(vty, "%% No BGP process is configured\n"); |
1287 | return CMD_WARNING_CONFIG_FAILED; | |
1288 | } | |
1289 | ||
1290 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1291 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1292 | return CMD_WARNING_CONFIG_FAILED; |
1293 | } | |
1294 | } | |
1295 | ||
1296 | // "router bgp X" | |
1297 | else { | |
ff8a8a7a | 1298 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1299 | |
d62a17ae | 1300 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1301 | if (argc > 3) { | |
1302 | name = argv[idx_vrf]->arg; | |
1303 | ||
9a8bdf1c PG |
1304 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1305 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1306 | name = NULL; | |
1307 | else | |
1308 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1309 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1310 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1311 | } |
1312 | ||
1ca2fd11 IR |
1313 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1314 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1315 | |
1ca2fd11 IR |
1316 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1317 | switch (ret) { | |
1318 | case BGP_ERR_AS_MISMATCH: | |
1319 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1320 | return CMD_WARNING_CONFIG_FAILED; | |
1321 | case BGP_ERR_INSTANCE_MISMATCH: | |
1322 | vty_out(vty, | |
1323 | "BGP instance name and AS number mismatch\n"); | |
1324 | vty_out(vty, | |
1325 | "BGP instance is already running; AS is %u\n", | |
1326 | as); | |
1327 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1328 | } |
1ca2fd11 IR |
1329 | |
1330 | /* | |
1331 | * If we just instantiated the default instance, complete | |
1332 | * any pending VRF-VPN leaking that was configured via | |
1333 | * earlier "router bgp X vrf FOO" blocks. | |
1334 | */ | |
1335 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1336 | vpn_leak_postchange_all(); | |
1337 | ||
1338 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1339 | bgp_vpn_leak_export(bgp); | |
1340 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1341 | */ | |
d62a17ae | 1342 | } |
1343 | ||
1ca2fd11 IR |
1344 | /* unset the auto created flag as the user config is now present */ |
1345 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1346 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1347 | ||
1348 | return CMD_SUCCESS; | |
718e3744 | 1349 | } |
1350 | ||
718e3744 | 1351 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1352 | DEFUN (no_router_bgp, |
1353 | no_router_bgp_cmd, | |
1354 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1355 | NO_STR | |
1356 | ROUTER_STR | |
1357 | BGP_STR | |
1358 | AS_STR | |
1359 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1360 | { |
4fd9919e | 1361 | int idx_asn = 3; |
d62a17ae | 1362 | int idx_vrf = 5; |
1ca2fd11 | 1363 | as_t as; |
4fd9919e | 1364 | struct bgp *bgp; |
d62a17ae | 1365 | const char *name = NULL; |
718e3744 | 1366 | |
d62a17ae | 1367 | // "no router bgp" without an ASN |
1368 | if (argc == 3) { | |
1369 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1370 | bgp = bgp_get_default(); |
718e3744 | 1371 | |
8382083a | 1372 | if (bgp == NULL) { |
d62a17ae | 1373 | vty_out(vty, "%% No BGP process is configured\n"); |
1374 | return CMD_WARNING_CONFIG_FAILED; | |
1375 | } | |
7fb21a9f | 1376 | |
d62a17ae | 1377 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1378 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1379 | return CMD_WARNING_CONFIG_FAILED; |
1380 | } | |
4fd9919e | 1381 | |
4fd9919e IR |
1382 | if (bgp->l3vni) { |
1383 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1384 | bgp->l3vni); | |
1385 | return CMD_WARNING_CONFIG_FAILED; | |
1386 | } | |
d62a17ae | 1387 | } else { |
4fd9919e IR |
1388 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1389 | ||
1ca42c8d | 1390 | if (argc > 4) { |
d62a17ae | 1391 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1392 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1393 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1394 | name = NULL; | |
1395 | } | |
7fb21a9f | 1396 | |
4fd9919e IR |
1397 | /* Lookup bgp structure. */ |
1398 | bgp = bgp_lookup(as, name); | |
1399 | if (!bgp) { | |
1400 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1401 | return CMD_WARNING_CONFIG_FAILED; | |
1402 | } | |
1403 | ||
1404 | if (bgp->l3vni) { | |
1405 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1406 | bgp->l3vni); | |
1407 | return CMD_WARNING_CONFIG_FAILED; | |
1408 | } | |
1409 | ||
1410 | /* Cannot delete default instance if vrf instances exist */ | |
1411 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1412 | struct listnode *node; | |
1413 | struct bgp *tmp_bgp; | |
1414 | ||
1415 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1416 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1417 | continue; | |
1418 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1419 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1420 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1421 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1422 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1423 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1424 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1425 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1426 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1427 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1428 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1429 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1430 | (bgp == bgp_get_evpn() && | |
1431 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1432 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1433 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1434 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1435 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1436 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1437 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1438 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
1439 | (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { | |
1440 | vty_out(vty, | |
1441 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1442 | return CMD_WARNING_CONFIG_FAILED; | |
1443 | } | |
1444 | } | |
1445 | } | |
d62a17ae | 1446 | } |
718e3744 | 1447 | |
1ca2fd11 | 1448 | bgp_delete(bgp); |
718e3744 | 1449 | |
1ca2fd11 | 1450 | return CMD_SUCCESS; |
718e3744 | 1451 | } |
1452 | ||
718e3744 | 1453 | |
ff8a8a7a CS |
1454 | /* BGP router-id. */ |
1455 | ||
1ca2fd11 IR |
1456 | DEFPY (bgp_router_id, |
1457 | bgp_router_id_cmd, | |
1458 | "bgp router-id A.B.C.D", | |
1459 | BGP_STR | |
1460 | "Override configured router identifier\n" | |
1461 | "Manually configured router identifier\n") | |
718e3744 | 1462 | { |
1ca2fd11 IR |
1463 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1464 | bgp_router_id_static_set(bgp, router_id); | |
1465 | return CMD_SUCCESS; | |
ff8a8a7a | 1466 | } |
718e3744 | 1467 | |
1ca2fd11 IR |
1468 | DEFPY (no_bgp_router_id, |
1469 | no_bgp_router_id_cmd, | |
1470 | "no bgp router-id [A.B.C.D]", | |
1471 | NO_STR | |
1472 | BGP_STR | |
1473 | "Override configured router identifier\n" | |
1474 | "Manually configured router identifier\n") | |
ff8a8a7a | 1475 | { |
1ca2fd11 | 1476 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1477 | |
1ca2fd11 IR |
1478 | if (router_id_str) { |
1479 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1480 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1481 | return CMD_WARNING_CONFIG_FAILED; | |
1482 | } | |
1483 | } | |
718e3744 | 1484 | |
1ca2fd11 IR |
1485 | router_id.s_addr = 0; |
1486 | bgp_router_id_static_set(bgp, router_id); | |
1487 | ||
1488 | return CMD_SUCCESS; | |
ff8a8a7a | 1489 | } |
6b0655a2 | 1490 | |
ed0e57e3 | 1491 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1492 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1493 | NO_STR BGP_STR |
1494 | "Add community specific parameters\n" | |
1495 | "Create an alias for a community\n" | |
1496 | "Community (AA:BB or AA:BB:CC)\n" | |
1497 | "Alias name\n") | |
1498 | { | |
1499 | struct community_alias ca1; | |
1500 | struct community_alias ca2; | |
1501 | struct community_alias *lookup_community; | |
1502 | struct community_alias *lookup_alias; | |
1503 | ||
1504 | if (!community_str2com(community) && !lcommunity_str2com(community)) { | |
1505 | vty_out(vty, "Invalid community format\n"); | |
1506 | return CMD_WARNING; | |
1507 | } | |
1508 | ||
1509 | memset(&ca1, 0, sizeof(ca1)); | |
1510 | memset(&ca2, 0, sizeof(ca2)); | |
1511 | strlcpy(ca1.community, community, sizeof(ca1.community)); | |
b4ad2fae | 1512 | strlcpy(ca1.alias, alias_name, sizeof(ca1.alias)); |
ed0e57e3 DA |
1513 | |
1514 | lookup_community = bgp_ca_community_lookup(&ca1); | |
1515 | lookup_alias = bgp_ca_alias_lookup(&ca1); | |
1516 | ||
1517 | if (no) { | |
1518 | bgp_ca_alias_delete(&ca1); | |
1519 | bgp_ca_community_delete(&ca1); | |
1520 | } else { | |
1521 | if (lookup_alias) { | |
1522 | /* Lookup if community hash table has an item | |
1523 | * with the same alias name. | |
1524 | */ | |
1525 | strlcpy(ca2.community, lookup_alias->community, | |
1526 | sizeof(ca2.community)); | |
1527 | if (bgp_ca_community_lookup(&ca2)) { | |
1528 | vty_out(vty, | |
1529 | "community (%s) already has this alias (%s)\n", | |
1530 | lookup_alias->community, | |
1531 | lookup_alias->alias); | |
1532 | return CMD_WARNING; | |
1533 | } | |
1534 | bgp_ca_alias_delete(&ca1); | |
1535 | } | |
1536 | ||
1537 | if (lookup_community) | |
1538 | bgp_ca_community_delete(&ca1); | |
1539 | ||
1540 | bgp_ca_alias_insert(&ca1); | |
1541 | bgp_ca_community_insert(&ca1); | |
1542 | } | |
1543 | ||
1544 | return CMD_SUCCESS; | |
1545 | } | |
1546 | ||
9acb67cb DS |
1547 | DEFPY (bgp_global_suppress_fib_pending, |
1548 | bgp_global_suppress_fib_pending_cmd, | |
1549 | "[no] bgp suppress-fib-pending", | |
1550 | NO_STR | |
1551 | BGP_STR | |
1552 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1553 | { | |
1554 | bm_wait_for_fib_set(!no); | |
1555 | ||
1556 | return CMD_SUCCESS; | |
1557 | } | |
1558 | ||
c208c586 S |
1559 | DEFPY (bgp_suppress_fib_pending, |
1560 | bgp_suppress_fib_pending_cmd, | |
1561 | "[no] bgp suppress-fib-pending", | |
1562 | NO_STR | |
1563 | BGP_STR | |
1564 | "Advertise only routes that are programmed in kernel to peers\n") | |
1565 | { | |
1566 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1567 | ||
1568 | bgp_suppress_fib_pending_set(bgp, !no); | |
1569 | return CMD_SUCCESS; | |
1570 | } | |
1571 | ||
1572 | ||
718e3744 | 1573 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1574 | DEFUN (bgp_cluster_id, |
1575 | bgp_cluster_id_cmd, | |
1576 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1577 | BGP_STR | |
1578 | "Configure Route-Reflector Cluster-id\n" | |
1579 | "Route-Reflector Cluster-id in IP address format\n" | |
1580 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1581 | { |
1ca2fd11 | 1582 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1583 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1584 | int ret; |
1585 | struct in_addr cluster; | |
1586 | ||
1587 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1588 | if (!ret) { | |
1589 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1590 | return CMD_WARNING_CONFIG_FAILED; | |
1591 | } | |
718e3744 | 1592 | |
1ca2fd11 IR |
1593 | bgp_cluster_id_set(bgp, &cluster); |
1594 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1595 | |
1ca2fd11 | 1596 | return CMD_SUCCESS; |
718e3744 | 1597 | } |
1598 | ||
1ca2fd11 IR |
1599 | DEFUN (no_bgp_cluster_id, |
1600 | no_bgp_cluster_id_cmd, | |
1601 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1602 | NO_STR | |
1603 | BGP_STR | |
1604 | "Configure Route-Reflector Cluster-id\n" | |
1605 | "Route-Reflector Cluster-id in IP address format\n" | |
1606 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1607 | { |
1ca2fd11 IR |
1608 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1609 | bgp_cluster_id_unset(bgp); | |
1610 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1611 | |
1ca2fd11 | 1612 | return CMD_SUCCESS; |
718e3744 | 1613 | } |
1614 | ||
c163f297 DS |
1615 | DEFPY (bgp_norib, |
1616 | bgp_norib_cmd, | |
1617 | "bgp no-rib", | |
1618 | BGP_STR | |
1619 | "Disable BGP route installation to RIB (Zebra)\n") | |
1620 | { | |
1621 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1622 | vty_out(vty, | |
1623 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1624 | return CMD_SUCCESS; | |
1625 | } | |
1626 | ||
1627 | bgp_option_norib_set_runtime(); | |
1628 | ||
1629 | return CMD_SUCCESS; | |
1630 | } | |
1631 | ||
1632 | DEFPY (no_bgp_norib, | |
1633 | no_bgp_norib_cmd, | |
1634 | "no bgp no-rib", | |
1635 | NO_STR | |
1636 | BGP_STR | |
1637 | "Disable BGP route installation to RIB (Zebra)\n") | |
1638 | { | |
1639 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1640 | vty_out(vty, | |
1641 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1642 | return CMD_SUCCESS; | |
1643 | } | |
1644 | ||
1645 | bgp_option_norib_unset_runtime(); | |
1646 | ||
1647 | return CMD_SUCCESS; | |
1648 | } | |
1649 | ||
e46723a5 DS |
1650 | DEFPY (no_bgp_send_extra_data, |
1651 | no_bgp_send_extra_data_cmd, | |
1652 | "[no] bgp send-extra-data zebra", | |
1653 | NO_STR | |
1654 | BGP_STR | |
1655 | "Extra data to Zebra for display/use\n" | |
1656 | "To zebra\n") | |
1657 | { | |
ec0acb80 DA |
1658 | if (no) |
1659 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1660 | else | |
1661 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1662 | |
1663 | return CMD_SUCCESS; | |
1664 | } | |
1665 | ||
1ca2fd11 IR |
1666 | DEFUN (bgp_confederation_identifier, |
1667 | bgp_confederation_identifier_cmd, | |
1668 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1669 | BGP_STR |
1ca2fd11 IR |
1670 | "AS confederation parameters\n" |
1671 | "AS number\n" | |
1672 | "Set routing domain confederation AS\n") | |
718e3744 | 1673 | { |
1ca2fd11 | 1674 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1675 | int idx_number = 3; |
1ca2fd11 | 1676 | as_t as; |
718e3744 | 1677 | |
1ca2fd11 | 1678 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1679 | |
1ca2fd11 | 1680 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1681 | |
1ca2fd11 | 1682 | return CMD_SUCCESS; |
718e3744 | 1683 | } |
1684 | ||
1ca2fd11 IR |
1685 | DEFUN (no_bgp_confederation_identifier, |
1686 | no_bgp_confederation_identifier_cmd, | |
1687 | "no bgp confederation identifier [(1-4294967295)]", | |
1688 | NO_STR | |
e9273987 | 1689 | BGP_STR |
1ca2fd11 IR |
1690 | "AS confederation parameters\n" |
1691 | "AS number\n" | |
1692 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1693 | { |
1ca2fd11 IR |
1694 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1695 | bgp_confederation_id_unset(bgp); | |
1696 | ||
1697 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1698 | } |
1699 | ||
1ca2fd11 IR |
1700 | DEFUN (bgp_confederation_peers, |
1701 | bgp_confederation_peers_cmd, | |
1702 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1703 | BGP_STR |
1ca2fd11 IR |
1704 | "AS confederation parameters\n" |
1705 | "Peer ASs in BGP confederation\n" | |
1706 | AS_STR) | |
718e3744 | 1707 | { |
1ca2fd11 | 1708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1709 | int idx_asn = 3; |
1ca2fd11 | 1710 | as_t as; |
d62a17ae | 1711 | int i; |
718e3744 | 1712 | |
1ca2fd11 IR |
1713 | for (i = idx_asn; i < argc; i++) { |
1714 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1715 | |
1ca2fd11 IR |
1716 | if (bgp->as == as) { |
1717 | vty_out(vty, | |
1718 | "%% Local member-AS not allowed in confed peer list\n"); | |
1719 | continue; | |
1720 | } | |
1721 | ||
1722 | bgp_confederation_peers_add(bgp, as); | |
1723 | } | |
1724 | return CMD_SUCCESS; | |
718e3744 | 1725 | } |
1726 | ||
1ca2fd11 IR |
1727 | DEFUN (no_bgp_confederation_peers, |
1728 | no_bgp_confederation_peers_cmd, | |
1729 | "no bgp confederation peers (1-4294967295)...", | |
1730 | NO_STR | |
e9273987 | 1731 | BGP_STR |
1ca2fd11 IR |
1732 | "AS confederation parameters\n" |
1733 | "Peer ASs in BGP confederation\n" | |
1734 | AS_STR) | |
718e3744 | 1735 | { |
1ca2fd11 | 1736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1737 | int idx_asn = 4; |
1ca2fd11 | 1738 | as_t as; |
d62a17ae | 1739 | int i; |
718e3744 | 1740 | |
1ca2fd11 IR |
1741 | for (i = idx_asn; i < argc; i++) { |
1742 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1743 | |
1ca2fd11 IR |
1744 | bgp_confederation_peers_remove(bgp, as); |
1745 | } | |
1746 | return CMD_SUCCESS; | |
718e3744 | 1747 | } |
6b0655a2 | 1748 | |
5e242b0d DS |
1749 | /** |
1750 | * Central routine for maximum-paths configuration. | |
1751 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1752 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1753 | */ | |
585f1adc IR |
1754 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1755 | const char *mpaths, uint16_t options, | |
1756 | int set) | |
d62a17ae | 1757 | { |
585f1adc IR |
1758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1759 | uint16_t maxpaths = 0; | |
d62a17ae | 1760 | int ret; |
585f1adc IR |
1761 | afi_t afi; |
1762 | safi_t safi; | |
1763 | ||
1764 | afi = bgp_node_afi(vty); | |
1765 | safi = bgp_node_safi(vty); | |
d62a17ae | 1766 | |
1767 | if (set) { | |
585f1adc | 1768 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 1769 | if (maxpaths > multipath_num) { |
585f1adc | 1770 | vty_out(vty, |
d62a17ae | 1771 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1772 | maxpaths, multipath_num); | |
1773 | return CMD_WARNING_CONFIG_FAILED; | |
1774 | } | |
1775 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1776 | options); | |
1777 | } else | |
1778 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1779 | ||
1780 | if (ret < 0) { | |
585f1adc | 1781 | vty_out(vty, |
d62a17ae | 1782 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1783 | (set == 1) ? "" : "un", | |
1784 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1785 | maxpaths, afi, safi); | |
1786 | return CMD_WARNING_CONFIG_FAILED; | |
1787 | } | |
1788 | ||
1789 | bgp_recalculate_all_bestpaths(bgp); | |
1790 | ||
1791 | return CMD_SUCCESS; | |
165b5fff JB |
1792 | } |
1793 | ||
1ca2fd11 IR |
1794 | DEFUN (bgp_maxmed_admin, |
1795 | bgp_maxmed_admin_cmd, | |
1796 | "bgp max-med administrative ", | |
1797 | BGP_STR | |
1798 | "Advertise routes with max-med\n" | |
1799 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 1800 | { |
1ca2fd11 | 1801 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1802 | |
1ca2fd11 IR |
1803 | bgp->v_maxmed_admin = 1; |
1804 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 1805 | |
1ca2fd11 | 1806 | bgp_maxmed_update(bgp); |
abc920f8 | 1807 | |
1ca2fd11 | 1808 | return CMD_SUCCESS; |
ff8a8a7a CS |
1809 | } |
1810 | ||
1ca2fd11 IR |
1811 | DEFUN (bgp_maxmed_admin_medv, |
1812 | bgp_maxmed_admin_medv_cmd, | |
1813 | "bgp max-med administrative (0-4294967295)", | |
1814 | BGP_STR | |
1815 | "Advertise routes with max-med\n" | |
1816 | "Administratively applied, for an indefinite period\n" | |
1817 | "Max MED value to be used\n") | |
abc920f8 | 1818 | { |
1ca2fd11 | 1819 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1820 | int idx_number = 3; |
abc920f8 | 1821 | |
1ca2fd11 IR |
1822 | bgp->v_maxmed_admin = 1; |
1823 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1824 | |
1ca2fd11 | 1825 | bgp_maxmed_update(bgp); |
abc920f8 | 1826 | |
1ca2fd11 | 1827 | return CMD_SUCCESS; |
abc920f8 DS |
1828 | } |
1829 | ||
1ca2fd11 IR |
1830 | DEFUN (no_bgp_maxmed_admin, |
1831 | no_bgp_maxmed_admin_cmd, | |
1832 | "no bgp max-med administrative [(0-4294967295)]", | |
1833 | NO_STR | |
1834 | BGP_STR | |
1835 | "Advertise routes with max-med\n" | |
1836 | "Administratively applied, for an indefinite period\n" | |
1837 | "Max MED value to be used\n") | |
abc920f8 | 1838 | { |
1ca2fd11 IR |
1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1840 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1841 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1842 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 1843 | |
1ca2fd11 | 1844 | return CMD_SUCCESS; |
abc920f8 DS |
1845 | } |
1846 | ||
1ca2fd11 IR |
1847 | DEFUN (bgp_maxmed_onstartup, |
1848 | bgp_maxmed_onstartup_cmd, | |
1849 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1850 | BGP_STR | |
1851 | "Advertise routes with max-med\n" | |
1852 | "Effective on a startup\n" | |
1853 | "Time (seconds) period for max-med\n" | |
1854 | "Max MED value to be used\n") | |
abc920f8 | 1855 | { |
1ca2fd11 | 1856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1857 | int idx = 0; |
4668a151 | 1858 | |
d62a17ae | 1859 | argv_find(argv, argc, "(5-86400)", &idx); |
1ca2fd11 | 1860 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1861 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 1862 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1863 | else |
1ca2fd11 | 1864 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 1865 | |
1ca2fd11 IR |
1866 | bgp_maxmed_update(bgp); |
1867 | ||
1868 | return CMD_SUCCESS; | |
abc920f8 DS |
1869 | } |
1870 | ||
1ca2fd11 IR |
1871 | DEFUN (no_bgp_maxmed_onstartup, |
1872 | no_bgp_maxmed_onstartup_cmd, | |
1873 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1874 | NO_STR | |
1875 | BGP_STR | |
1876 | "Advertise routes with max-med\n" | |
1877 | "Effective on a startup\n" | |
1878 | "Time (seconds) period for max-med\n" | |
1879 | "Max MED value to be used\n") | |
abc920f8 | 1880 | { |
1ca2fd11 IR |
1881 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1882 | ||
1883 | /* Cancel max-med onstartup if its on */ | |
1884 | if (bgp->t_maxmed_onstartup) { | |
1885 | thread_cancel(&bgp->t_maxmed_onstartup); | |
1886 | bgp->maxmed_onstartup_over = 1; | |
1887 | } | |
abc920f8 | 1888 | |
1ca2fd11 IR |
1889 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1890 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1891 | |
1ca2fd11 IR |
1892 | bgp_maxmed_update(bgp); |
1893 | ||
1894 | return CMD_SUCCESS; | |
abc920f8 DS |
1895 | } |
1896 | ||
d70583f7 D |
1897 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1898 | uint16_t update_delay, | |
1899 | uint16_t establish_wait) | |
1900 | { | |
1901 | struct listnode *node, *nnode; | |
1902 | struct bgp *bgp; | |
1903 | bool vrf_cfg = false; | |
1904 | ||
1905 | /* | |
1906 | * See if update-delay is set per-vrf and warn user to delete it | |
1907 | * Note that we only need to check this if this is the first time | |
1908 | * setting the global config. | |
1909 | */ | |
1910 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1911 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1912 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1913 | vty_out(vty, | |
1914 | "%% update-delay configuration found in vrf %s\n", | |
1915 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1916 | ? VRF_DEFAULT_NAME | |
1917 | : bgp->name); | |
1918 | vrf_cfg = true; | |
1919 | } | |
1920 | } | |
1921 | } | |
1922 | ||
1923 | if (vrf_cfg) { | |
1924 | vty_out(vty, | |
1925 | "%%Failed: global update-delay config not permitted\n"); | |
1926 | return CMD_WARNING; | |
1927 | } | |
1928 | ||
1929 | if (!establish_wait) { /* update-delay <delay> */ | |
1930 | bm->v_update_delay = update_delay; | |
1931 | bm->v_establish_wait = bm->v_update_delay; | |
1932 | } else { | |
1933 | /* update-delay <delay> <establish-wait> */ | |
1934 | if (update_delay < establish_wait) { | |
1935 | vty_out(vty, | |
1936 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1937 | return CMD_WARNING_CONFIG_FAILED; | |
1938 | } | |
1939 | ||
1940 | bm->v_update_delay = update_delay; | |
1941 | bm->v_establish_wait = establish_wait; | |
1942 | } | |
1943 | ||
1944 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1945 | bgp->v_update_delay = bm->v_update_delay; | |
1946 | bgp->v_establish_wait = bm->v_establish_wait; | |
1947 | } | |
1948 | ||
1949 | return CMD_SUCCESS; | |
1950 | } | |
1951 | ||
1952 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
1953 | { | |
1954 | struct listnode *node, *nnode; | |
1955 | struct bgp *bgp; | |
1956 | ||
1957 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1958 | bm->v_establish_wait = bm->v_update_delay; | |
1959 | ||
1960 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1961 | bgp->v_update_delay = bm->v_update_delay; | |
1962 | bgp->v_establish_wait = bm->v_establish_wait; | |
1963 | } | |
1964 | ||
1965 | return CMD_SUCCESS; | |
1966 | } | |
1967 | ||
1968 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
1969 | uint16_t establish_wait) | |
f188f2c4 | 1970 | { |
d62a17ae | 1971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1972 | |
d70583f7 D |
1973 | /* if configured globally, per-instance config is not allowed */ |
1974 | if (bm->v_update_delay) { | |
1975 | vty_out(vty, | |
1976 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
1977 | return CMD_WARNING_CONFIG_FAILED; | |
1978 | } | |
1979 | ||
f188f2c4 | 1980 | |
d70583f7 | 1981 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 1982 | { |
1983 | bgp->v_update_delay = update_delay; | |
1984 | bgp->v_establish_wait = bgp->v_update_delay; | |
1985 | return CMD_SUCCESS; | |
1986 | } | |
f188f2c4 | 1987 | |
d62a17ae | 1988 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 1989 | if (update_delay < establish_wait) { |
1990 | vty_out(vty, | |
1991 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1992 | return CMD_WARNING_CONFIG_FAILED; | |
1993 | } | |
f188f2c4 | 1994 | |
d62a17ae | 1995 | bgp->v_update_delay = update_delay; |
1996 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1997 | |
d62a17ae | 1998 | return CMD_SUCCESS; |
f188f2c4 DS |
1999 | } |
2000 | ||
d62a17ae | 2001 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2002 | { |
d62a17ae | 2003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2004 | |
d70583f7 D |
2005 | /* If configured globally, cannot remove from one bgp instance */ |
2006 | if (bm->v_update_delay) { | |
2007 | vty_out(vty, | |
2008 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2009 | return CMD_WARNING_CONFIG_FAILED; | |
2010 | } | |
d62a17ae | 2011 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2012 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2013 | |
d62a17ae | 2014 | return CMD_SUCCESS; |
f188f2c4 DS |
2015 | } |
2016 | ||
2b791107 | 2017 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2018 | { |
d70583f7 D |
2019 | /* If configured globally, no need to display per-instance value */ |
2020 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2021 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2022 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2023 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2024 | vty_out(vty, "\n"); | |
2025 | } | |
f188f2c4 DS |
2026 | } |
2027 | ||
d70583f7 D |
2028 | /* Global update-delay configuration */ |
2029 | DEFPY (bgp_global_update_delay, | |
2030 | bgp_global_update_delay_cmd, | |
2031 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2032 | BGP_STR | |
2033 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2034 | "Max delay in seconds\n" | |
2035 | "Establish wait in seconds\n") | |
2036 | { | |
2037 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2038 | } | |
f188f2c4 | 2039 | |
d70583f7 D |
2040 | /* Global update-delay deconfiguration */ |
2041 | DEFPY (no_bgp_global_update_delay, | |
2042 | no_bgp_global_update_delay_cmd, | |
2043 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2044 | NO_STR | |
2045 | BGP_STR | |
f188f2c4 | 2046 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2047 | "Max delay in seconds\n" |
2048 | "Establish wait in seconds\n") | |
f188f2c4 | 2049 | { |
d70583f7 | 2050 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2051 | } |
2052 | ||
d70583f7 D |
2053 | /* Update-delay configuration */ |
2054 | ||
2055 | DEFPY (bgp_update_delay, | |
2056 | bgp_update_delay_cmd, | |
2057 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2058 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2059 | "Max delay in seconds\n" |
2060 | "Establish wait in seconds\n") | |
f188f2c4 | 2061 | { |
d70583f7 | 2062 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2063 | } |
2064 | ||
2065 | /* Update-delay deconfiguration */ | |
d70583f7 | 2066 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2067 | no_bgp_update_delay_cmd, |
838758ac DW |
2068 | "no update-delay [(0-3600) [(1-3600)]]", |
2069 | NO_STR | |
f188f2c4 | 2070 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2071 | "Max delay in seconds\n" |
2072 | "Establish wait in seconds\n") | |
f188f2c4 | 2073 | { |
d62a17ae | 2074 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2075 | } |
2076 | ||
5e242b0d | 2077 | |
1ca2fd11 IR |
2078 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2079 | bool set) | |
cb1faec9 | 2080 | { |
1ca2fd11 IR |
2081 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2082 | ||
8fa7732f QY |
2083 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2084 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2085 | |
2086 | return CMD_SUCCESS; | |
2087 | } | |
2088 | ||
1ca2fd11 IR |
2089 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2090 | bool set) | |
555e09d4 | 2091 | { |
1ca2fd11 IR |
2092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2093 | ||
8fa7732f QY |
2094 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2095 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2096 | |
d62a17ae | 2097 | return CMD_SUCCESS; |
cb1faec9 DS |
2098 | } |
2099 | ||
2b791107 | 2100 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2101 | { |
555e09d4 QY |
2102 | uint32_t quanta = |
2103 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2104 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2105 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2106 | } |
2107 | ||
555e09d4 QY |
2108 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2109 | { | |
2110 | uint32_t quanta = | |
2111 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2112 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2113 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2114 | } |
cb1faec9 | 2115 | |
8fa7732f QY |
2116 | /* Packet quanta configuration |
2117 | * | |
2118 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2119 | * thread. When changing these limits be careful to prevent stack overflow. | |
2120 | * | |
2121 | * Furthermore, the maximums used here should correspond to | |
2122 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2123 | */ | |
1ca2fd11 IR |
2124 | DEFPY (bgp_wpkt_quanta, |
2125 | bgp_wpkt_quanta_cmd, | |
2126 | "[no] write-quanta (1-64)$quanta", | |
2127 | NO_STR | |
2128 | "How many packets to write to peer socket per run\n" | |
2129 | "Number of packets\n") | |
2130 | { | |
2131 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2132 | } | |
cb1faec9 | 2133 | |
1ca2fd11 IR |
2134 | DEFPY (bgp_rpkt_quanta, |
2135 | bgp_rpkt_quanta_cmd, | |
2136 | "[no] read-quanta (1-10)$quanta", | |
2137 | NO_STR | |
2138 | "How many packets to read from peer socket per I/O cycle\n" | |
2139 | "Number of packets\n") | |
2140 | { | |
2141 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2142 | } |
2143 | ||
2b791107 | 2144 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2145 | { |
37a333fe | 2146 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2147 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2148 | } |
2149 | ||
4668a151 | 2150 | |
1ca2fd11 IR |
2151 | DEFUN (bgp_coalesce_time, |
2152 | bgp_coalesce_time_cmd, | |
2153 | "coalesce-time (0-4294967295)", | |
2154 | "Subgroup coalesce timer\n" | |
2155 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2156 | { |
1ca2fd11 | 2157 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2158 | |
1ca2fd11 | 2159 | int idx = 0; |
d62a17ae | 2160 | argv_find(argv, argc, "(0-4294967295)", &idx); |
1ca2fd11 IR |
2161 | bgp->heuristic_coalesce = false; |
2162 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2163 | return CMD_SUCCESS; | |
3f9c7369 DS |
2164 | } |
2165 | ||
1ca2fd11 IR |
2166 | DEFUN (no_bgp_coalesce_time, |
2167 | no_bgp_coalesce_time_cmd, | |
2168 | "no coalesce-time (0-4294967295)", | |
2169 | NO_STR | |
2170 | "Subgroup coalesce timer\n" | |
2171 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2172 | { |
1ca2fd11 | 2173 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2174 | |
1ca2fd11 IR |
2175 | bgp->heuristic_coalesce = true; |
2176 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2177 | return CMD_SUCCESS; | |
3f9c7369 DS |
2178 | } |
2179 | ||
5e242b0d | 2180 | /* Maximum-paths configuration */ |
585f1adc IR |
2181 | DEFUN (bgp_maxpaths, |
2182 | bgp_maxpaths_cmd, | |
2183 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2184 | "Forward packets over multiple paths\n" | |
2185 | "Number of paths\n") | |
5e242b0d | 2186 | { |
d62a17ae | 2187 | int idx_number = 1; |
585f1adc IR |
2188 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2189 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2190 | } |
2191 | ||
d62a17ae | 2192 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2193 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2194 | "Forward packets over multiple paths\n" | |
2195 | "Number of paths\n") | |
596c17ba | 2196 | |
585f1adc IR |
2197 | DEFUN (bgp_maxpaths_ibgp, |
2198 | bgp_maxpaths_ibgp_cmd, | |
2199 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2200 | "Forward packets over multiple paths\n" | |
2201 | "iBGP-multipath\n" | |
2202 | "Number of paths\n") | |
165b5fff | 2203 | { |
d62a17ae | 2204 | int idx_number = 2; |
585f1adc IR |
2205 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2206 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2207 | } |
165b5fff | 2208 | |
d62a17ae | 2209 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2210 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2211 | "Forward packets over multiple paths\n" | |
2212 | "iBGP-multipath\n" | |
2213 | "Number of paths\n") | |
596c17ba | 2214 | |
585f1adc IR |
2215 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2216 | bgp_maxpaths_ibgp_cluster_cmd, | |
2217 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2218 | "Forward packets over multiple paths\n" | |
2219 | "iBGP-multipath\n" | |
2220 | "Number of paths\n" | |
2221 | "Match the cluster length\n") | |
5e242b0d | 2222 | { |
d62a17ae | 2223 | int idx_number = 2; |
585f1adc IR |
2224 | return bgp_maxpaths_config_vty( |
2225 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2226 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
2227 | } |
2228 | ||
d62a17ae | 2229 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2230 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2231 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2232 | "Forward packets over multiple paths\n" | |
2233 | "iBGP-multipath\n" | |
2234 | "Number of paths\n" | |
2235 | "Match the cluster length\n") | |
596c17ba | 2236 | |
585f1adc IR |
2237 | DEFUN (no_bgp_maxpaths, |
2238 | no_bgp_maxpaths_cmd, | |
2239 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2240 | NO_STR | |
2241 | "Forward packets over multiple paths\n" | |
2242 | "Number of paths\n") | |
165b5fff | 2243 | { |
585f1adc | 2244 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2245 | } |
2246 | ||
d62a17ae | 2247 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2248 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2249 | "Forward packets over multiple paths\n" |
2250 | "Number of paths\n") | |
596c17ba | 2251 | |
585f1adc IR |
2252 | DEFUN (no_bgp_maxpaths_ibgp, |
2253 | no_bgp_maxpaths_ibgp_cmd, | |
2254 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2255 | NO_STR | |
2256 | "Forward packets over multiple paths\n" | |
2257 | "iBGP-multipath\n" | |
2258 | "Number of paths\n" | |
2259 | "Match the cluster length\n") | |
165b5fff | 2260 | { |
585f1adc | 2261 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2262 | } |
2263 | ||
d62a17ae | 2264 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2265 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2266 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2267 | NO_STR | |
2268 | "Forward packets over multiple paths\n" | |
2269 | "iBGP-multipath\n" | |
2270 | "Number of paths\n" | |
2271 | "Match the cluster length\n") | |
596c17ba | 2272 | |
dd65f45e DL |
2273 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2274 | afi_t afi, safi_t safi) | |
165b5fff | 2275 | { |
00908b7a | 2276 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2277 | vty_out(vty, " maximum-paths %d\n", |
2278 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2279 | } | |
165b5fff | 2280 | |
00908b7a | 2281 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2282 | vty_out(vty, " maximum-paths ibgp %d", |
2283 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2284 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2285 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2286 | vty_out(vty, " equal-cluster-length"); | |
2287 | vty_out(vty, "\n"); | |
2288 | } | |
165b5fff | 2289 | } |
6b0655a2 | 2290 | |
718e3744 | 2291 | /* BGP timers. */ |
2292 | ||
1ca2fd11 IR |
2293 | DEFUN (bgp_timers, |
2294 | bgp_timers_cmd, | |
2295 | "timers bgp (0-65535) (0-65535)", | |
2296 | "Adjust routing timers\n" | |
2297 | "BGP timers\n" | |
2298 | "Keepalive interval\n" | |
2299 | "Holdtime\n") | |
718e3744 | 2300 | { |
1ca2fd11 | 2301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2302 | int idx_number = 2; |
2303 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2304 | unsigned long keepalive = 0; |
2305 | unsigned long holdtime = 0; | |
718e3744 | 2306 | |
1ca2fd11 IR |
2307 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2308 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2309 | |
1ca2fd11 IR |
2310 | /* Holdtime value check. */ |
2311 | if (holdtime < 3 && holdtime != 0) { | |
2312 | vty_out(vty, | |
2313 | "%% hold time value must be either 0 or greater than 3\n"); | |
2314 | return CMD_WARNING_CONFIG_FAILED; | |
2315 | } | |
718e3744 | 2316 | |
1ca2fd11 IR |
2317 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2318 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2319 | |
1ca2fd11 | 2320 | return CMD_SUCCESS; |
718e3744 | 2321 | } |
2322 | ||
1ca2fd11 IR |
2323 | DEFUN (no_bgp_timers, |
2324 | no_bgp_timers_cmd, | |
2325 | "no timers bgp [(0-65535) (0-65535)]", | |
2326 | NO_STR | |
2327 | "Adjust routing timers\n" | |
2328 | "BGP timers\n" | |
2329 | "Keepalive interval\n" | |
2330 | "Holdtime\n") | |
718e3744 | 2331 | { |
1ca2fd11 IR |
2332 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2333 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2334 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2335 | |
1ca2fd11 | 2336 | return CMD_SUCCESS; |
718e3744 | 2337 | } |
2338 | ||
b042667a TI |
2339 | /* BGP minimum holdtime. */ |
2340 | ||
2341 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2342 | "bgp minimum-holdtime (1-65535)", | |
2343 | "BGP specific commands\n" | |
2344 | "BGP minimum holdtime\n" | |
2345 | "Seconds\n") | |
2346 | { | |
2347 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2348 | int idx_number = 2; | |
2349 | unsigned long min_holdtime; | |
2350 | ||
2351 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2352 | ||
2353 | bgp->default_min_holdtime = min_holdtime; | |
2354 | ||
2355 | return CMD_SUCCESS; | |
2356 | } | |
2357 | ||
2358 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2359 | "no bgp minimum-holdtime [(1-65535)]", | |
2360 | NO_STR | |
2361 | "BGP specific commands\n" | |
2362 | "BGP minimum holdtime\n" | |
2363 | "Seconds\n") | |
2364 | { | |
2365 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2366 | ||
2367 | bgp->default_min_holdtime = 0; | |
2368 | ||
2369 | return CMD_SUCCESS; | |
2370 | } | |
ff8a8a7a | 2371 | |
1ca2fd11 IR |
2372 | DEFUN (bgp_client_to_client_reflection, |
2373 | bgp_client_to_client_reflection_cmd, | |
2374 | "bgp client-to-client reflection", | |
e9273987 | 2375 | BGP_STR |
1ca2fd11 IR |
2376 | "Configure client to client route reflection\n" |
2377 | "reflection of routes allowed\n") | |
718e3744 | 2378 | { |
1ca2fd11 IR |
2379 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2380 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2381 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2382 | |
1ca2fd11 | 2383 | return CMD_SUCCESS; |
718e3744 | 2384 | } |
2385 | ||
1ca2fd11 IR |
2386 | DEFUN (no_bgp_client_to_client_reflection, |
2387 | no_bgp_client_to_client_reflection_cmd, | |
2388 | "no bgp client-to-client reflection", | |
2389 | NO_STR | |
e9273987 | 2390 | BGP_STR |
1ca2fd11 IR |
2391 | "Configure client to client route reflection\n" |
2392 | "reflection of routes allowed\n") | |
718e3744 | 2393 | { |
1ca2fd11 IR |
2394 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2395 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2396 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2397 | |
1ca2fd11 | 2398 | return CMD_SUCCESS; |
718e3744 | 2399 | } |
2400 | ||
2401 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2402 | DEFUN (bgp_always_compare_med, |
2403 | bgp_always_compare_med_cmd, | |
2404 | "bgp always-compare-med", | |
e9273987 | 2405 | BGP_STR |
1ca2fd11 | 2406 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2407 | { |
1ca2fd11 IR |
2408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2409 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2410 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2411 | |
1ca2fd11 | 2412 | return CMD_SUCCESS; |
718e3744 | 2413 | } |
2414 | ||
1ca2fd11 IR |
2415 | DEFUN (no_bgp_always_compare_med, |
2416 | no_bgp_always_compare_med_cmd, | |
2417 | "no bgp always-compare-med", | |
2418 | NO_STR | |
e9273987 | 2419 | BGP_STR |
1ca2fd11 | 2420 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2421 | { |
1ca2fd11 IR |
2422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2423 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2424 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2425 | |
1ca2fd11 | 2426 | return CMD_SUCCESS; |
2adac256 DA |
2427 | } |
2428 | ||
2adac256 | 2429 | |
1ca2fd11 IR |
2430 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2431 | "bgp ebgp-requires-policy", | |
e9273987 | 2432 | BGP_STR |
1ca2fd11 | 2433 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2434 | { |
1ca2fd11 IR |
2435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2436 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2437 | return CMD_SUCCESS; | |
2adac256 DA |
2438 | } |
2439 | ||
1ca2fd11 IR |
2440 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2441 | "no bgp ebgp-requires-policy", | |
2442 | NO_STR | |
e9273987 | 2443 | BGP_STR |
1ca2fd11 | 2444 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2445 | { |
1ca2fd11 IR |
2446 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2447 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2448 | return CMD_SUCCESS; | |
ff8a8a7a | 2449 | } |
9dac9fc8 | 2450 | |
1ca2fd11 IR |
2451 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2452 | "bgp suppress-duplicates", | |
e9273987 | 2453 | BGP_STR |
1ca2fd11 | 2454 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2455 | { |
1ca2fd11 IR |
2456 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2457 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2458 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2459 | } |
2460 | ||
1ca2fd11 IR |
2461 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2462 | "no bgp suppress-duplicates", | |
2463 | NO_STR | |
e9273987 | 2464 | BGP_STR |
1ca2fd11 | 2465 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2466 | { |
1ca2fd11 IR |
2467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2468 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2469 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2470 | } |
2471 | ||
fb29348a DA |
2472 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2473 | "bgp reject-as-sets", | |
e9273987 | 2474 | BGP_STR |
fb29348a DA |
2475 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2476 | { | |
2477 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2478 | struct listnode *node, *nnode; | |
2479 | struct peer *peer; | |
2480 | ||
7f972cd8 | 2481 | bgp->reject_as_sets = true; |
fb29348a DA |
2482 | |
2483 | /* Reset existing BGP sessions to reject routes | |
2484 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2485 | */ | |
2486 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2487 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2488 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2489 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2490 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2491 | } | |
2492 | } | |
2493 | ||
2494 | return CMD_SUCCESS; | |
2495 | } | |
2496 | ||
2497 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2498 | "no bgp reject-as-sets", | |
2499 | NO_STR | |
e9273987 | 2500 | BGP_STR |
fb29348a DA |
2501 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2502 | { | |
2503 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2504 | struct listnode *node, *nnode; | |
2505 | struct peer *peer; | |
2506 | ||
7f972cd8 | 2507 | bgp->reject_as_sets = false; |
fb29348a DA |
2508 | |
2509 | /* Reset existing BGP sessions to reject routes | |
2510 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2511 | */ | |
2512 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2513 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2514 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2515 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2516 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2517 | } | |
2518 | } | |
2519 | ||
2520 | return CMD_SUCCESS; | |
2521 | } | |
9dac9fc8 | 2522 | |
718e3744 | 2523 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2524 | DEFUN (bgp_deterministic_med, |
718e3744 | 2525 | bgp_deterministic_med_cmd, |
2526 | "bgp deterministic-med", | |
e9273987 | 2527 | BGP_STR |
718e3744 | 2528 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2529 | { | |
1ca2fd11 IR |
2530 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2531 | ||
2532 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2533 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2534 | bgp_recalculate_all_bestpaths(bgp); | |
2535 | } | |
7aafcaca | 2536 | |
1ca2fd11 | 2537 | return CMD_SUCCESS; |
718e3744 | 2538 | } |
2539 | ||
1ca2fd11 | 2540 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2541 | no_bgp_deterministic_med_cmd, |
2542 | "no bgp deterministic-med", | |
2543 | NO_STR | |
e9273987 | 2544 | BGP_STR |
718e3744 | 2545 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2546 | { | |
1ca2fd11 IR |
2547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2548 | int bestpath_per_as_used; | |
2549 | afi_t afi; | |
2550 | safi_t safi; | |
2551 | struct peer *peer; | |
2552 | struct listnode *node, *nnode; | |
2553 | ||
2554 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2555 | bestpath_per_as_used = 0; | |
2556 | ||
2557 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2558 | FOREACH_AFI_SAFI (afi, safi) | |
2559 | if (bgp_addpath_dmed_required( | |
2560 | peer->addpath_type[afi][safi])) { | |
2561 | bestpath_per_as_used = 1; | |
2562 | break; | |
2563 | } | |
2564 | ||
2565 | if (bestpath_per_as_used) | |
2566 | break; | |
2567 | } | |
2568 | ||
2569 | if (bestpath_per_as_used) { | |
2570 | vty_out(vty, | |
2571 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2572 | return CMD_WARNING_CONFIG_FAILED; | |
2573 | } else { | |
2574 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2575 | bgp_recalculate_all_bestpaths(bgp); | |
2576 | } | |
2577 | } | |
d62a17ae | 2578 | |
1ca2fd11 | 2579 | return CMD_SUCCESS; |
718e3744 | 2580 | } |
538621f2 | 2581 | |
055679e9 | 2582 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2583 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2584 | bgp_graceful_restart_cmd, |
2585 | "bgp graceful-restart", | |
e9273987 | 2586 | BGP_STR |
2ba1fe69 | 2587 | GR_CMD |
055679e9 | 2588 | ) |
538621f2 | 2589 | { |
055679e9 | 2590 | int ret = BGP_GR_FAILURE; |
2591 | ||
2592 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2593 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2594 | |
d62a17ae | 2595 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2596 | |
2597 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2598 | ||
36235319 QY |
2599 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2600 | ret); | |
5cce3f05 | 2601 | |
055679e9 | 2602 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2603 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2604 | vty_out(vty, |
2605 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2606 | return bgp_vty_return(vty, ret); |
538621f2 | 2607 | } |
2608 | ||
2609 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2610 | no_bgp_graceful_restart_cmd, |
2611 | "no bgp graceful-restart", | |
2612 | NO_STR | |
e9273987 | 2613 | BGP_STR |
2ba1fe69 | 2614 | NO_GR_CMD |
055679e9 | 2615 | ) |
538621f2 | 2616 | { |
d62a17ae | 2617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2618 | |
2619 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2620 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2621 | |
2622 | int ret = BGP_GR_FAILURE; | |
2623 | ||
2624 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2625 | ||
36235319 QY |
2626 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2627 | ret); | |
5cce3f05 | 2628 | |
055679e9 | 2629 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2630 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2631 | vty_out(vty, |
2632 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2633 | |
2634 | return bgp_vty_return(vty, ret); | |
538621f2 | 2635 | } |
2636 | ||
93406d87 | 2637 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2638 | bgp_graceful_restart_stalepath_time_cmd, |
2639 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2640 | BGP_STR |
2ba1fe69 | 2641 | "Graceful restart capability parameters\n" |
2642 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2643 | "Delay value (seconds)\n") | |
93406d87 | 2644 | { |
d62a17ae | 2645 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2646 | int idx_number = 3; | |
d7c0a89a | 2647 | uint32_t stalepath; |
93406d87 | 2648 | |
d62a17ae | 2649 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2650 | bgp->stalepath_time = stalepath; | |
2651 | return CMD_SUCCESS; | |
93406d87 | 2652 | } |
2653 | ||
eb6f1b41 | 2654 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2655 | bgp_graceful_restart_restart_time_cmd, |
2656 | "bgp graceful-restart restart-time (1-4095)", | |
e9273987 | 2657 | BGP_STR |
2ba1fe69 | 2658 | "Graceful restart capability parameters\n" |
2659 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2660 | "Delay value (seconds)\n") | |
eb6f1b41 | 2661 | { |
d62a17ae | 2662 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2663 | int idx_number = 3; | |
d7c0a89a | 2664 | uint32_t restart; |
eb6f1b41 | 2665 | |
d62a17ae | 2666 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2667 | bgp->restart_time = restart; | |
2668 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2669 | } |
2670 | ||
cfd47646 | 2671 | DEFUN (bgp_graceful_restart_select_defer_time, |
2672 | bgp_graceful_restart_select_defer_time_cmd, | |
2673 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2674 | BGP_STR |
cfd47646 | 2675 | "Graceful restart capability parameters\n" |
2676 | "Set the time to defer the BGP route selection after restart\n" | |
2677 | "Delay value (seconds, 0 - disable)\n") | |
2678 | { | |
2679 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2680 | int idx_number = 3; | |
2681 | uint32_t defer_time; | |
2682 | ||
2683 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2684 | bgp->select_defer_time = defer_time; | |
2685 | if (defer_time == 0) | |
892fedb6 | 2686 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2687 | else |
892fedb6 | 2688 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2689 | |
2690 | return CMD_SUCCESS; | |
2691 | } | |
2692 | ||
93406d87 | 2693 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2694 | no_bgp_graceful_restart_stalepath_time_cmd, |
2695 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2696 | NO_STR | |
e9273987 | 2697 | BGP_STR |
2ba1fe69 | 2698 | "Graceful restart capability parameters\n" |
2699 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2700 | "Delay value (seconds)\n") | |
93406d87 | 2701 | { |
d62a17ae | 2702 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2703 | |
d62a17ae | 2704 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2705 | return CMD_SUCCESS; | |
93406d87 | 2706 | } |
2707 | ||
eb6f1b41 | 2708 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2709 | no_bgp_graceful_restart_restart_time_cmd, |
2710 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2711 | NO_STR | |
e9273987 | 2712 | BGP_STR |
2ba1fe69 | 2713 | "Graceful restart capability parameters\n" |
2714 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2715 | "Delay value (seconds)\n") | |
eb6f1b41 | 2716 | { |
d62a17ae | 2717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2718 | |
d62a17ae | 2719 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2720 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2721 | } |
2722 | ||
cfd47646 | 2723 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2724 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2725 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2726 | NO_STR | |
e9273987 | 2727 | BGP_STR |
cfd47646 | 2728 | "Graceful restart capability parameters\n" |
2729 | "Set the time to defer the BGP route selection after restart\n" | |
2730 | "Delay value (seconds)\n") | |
2731 | { | |
2732 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2733 | ||
2734 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2735 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2736 | |
2737 | return CMD_SUCCESS; | |
2738 | } | |
2739 | ||
43fc21b3 | 2740 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2741 | bgp_graceful_restart_preserve_fw_cmd, |
2742 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 2743 | BGP_STR |
2ba1fe69 | 2744 | "Graceful restart capability parameters\n" |
2745 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2746 | { |
d62a17ae | 2747 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2748 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2749 | return CMD_SUCCESS; |
43fc21b3 JC |
2750 | } |
2751 | ||
2752 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2753 | no_bgp_graceful_restart_preserve_fw_cmd, |
2754 | "no bgp graceful-restart preserve-fw-state", | |
2755 | NO_STR | |
e9273987 | 2756 | BGP_STR |
2ba1fe69 | 2757 | "Graceful restart capability parameters\n" |
2758 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2759 | { |
d62a17ae | 2760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2761 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2762 | return CMD_SUCCESS; |
43fc21b3 JC |
2763 | } |
2764 | ||
055679e9 | 2765 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2766 | bgp_graceful_restart_disable_cmd, |
2767 | "bgp graceful-restart-disable", | |
e9273987 | 2768 | BGP_STR |
2ba1fe69 | 2769 | GR_DISABLE) |
055679e9 | 2770 | { |
2771 | int ret = BGP_GR_FAILURE; | |
2772 | ||
2773 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2774 | zlog_debug( | |
2ba1fe69 | 2775 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2776 | |
055679e9 | 2777 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2778 | ||
2779 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2780 | ||
dc95985f | 2781 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2782 | bgp->peer, ret); | |
5cce3f05 | 2783 | |
055679e9 | 2784 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2785 | zlog_debug( | |
2ba1fe69 | 2786 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2787 | vty_out(vty, |
2788 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2789 | ||
055679e9 | 2790 | return bgp_vty_return(vty, ret); |
2791 | } | |
2792 | ||
2793 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2794 | no_bgp_graceful_restart_disable_cmd, |
2795 | "no bgp graceful-restart-disable", | |
2796 | NO_STR | |
e9273987 | 2797 | BGP_STR |
2ba1fe69 | 2798 | NO_GR_DISABLE |
055679e9 | 2799 | ) |
2800 | { | |
2801 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2802 | ||
2803 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2804 | zlog_debug( | |
2ba1fe69 | 2805 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2806 | |
2807 | int ret = BGP_GR_FAILURE; | |
2808 | ||
2809 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2810 | ||
36235319 QY |
2811 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2812 | ret); | |
5cce3f05 | 2813 | |
055679e9 | 2814 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2815 | zlog_debug( | |
2ba1fe69 | 2816 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2817 | vty_out(vty, |
2818 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2819 | |
2820 | return bgp_vty_return(vty, ret); | |
2821 | } | |
2822 | ||
2823 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2824 | bgp_neighbor_graceful_restart_set_cmd, |
2825 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2826 | NEIGHBOR_STR | |
2827 | NEIGHBOR_ADDR_STR2 | |
2828 | GR_NEIGHBOR_CMD | |
055679e9 | 2829 | ) |
2830 | { | |
2831 | int idx_peer = 1; | |
2832 | struct peer *peer; | |
2833 | int ret = BGP_GR_FAILURE; | |
2834 | ||
dc95985f | 2835 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2836 | ||
055679e9 | 2837 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2838 | zlog_debug( | |
2ba1fe69 | 2839 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2840 | |
055679e9 | 2841 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2842 | if (!peer) | |
2843 | return CMD_WARNING_CONFIG_FAILED; | |
2844 | ||
2845 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2846 | ||
dc95985f | 2847 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2848 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2849 | |
2850 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2851 | zlog_debug( | |
2ba1fe69 | 2852 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2853 | vty_out(vty, |
2854 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2855 | |
2856 | return bgp_vty_return(vty, ret); | |
2857 | } | |
2858 | ||
2859 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2860 | no_bgp_neighbor_graceful_restart_set_cmd, |
2861 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2862 | NO_STR | |
2863 | NEIGHBOR_STR | |
2864 | NEIGHBOR_ADDR_STR2 | |
2865 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2866 | ) |
2867 | { | |
2868 | int idx_peer = 2; | |
2869 | int ret = BGP_GR_FAILURE; | |
2870 | struct peer *peer; | |
2871 | ||
dc95985f | 2872 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2873 | ||
055679e9 | 2874 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2875 | if (!peer) | |
2876 | return CMD_WARNING_CONFIG_FAILED; | |
2877 | ||
2878 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2879 | zlog_debug( | |
2ba1fe69 | 2880 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2881 | |
2882 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2883 | ||
dc95985f | 2884 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2885 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2886 | |
2887 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2888 | zlog_debug( | |
2ba1fe69 | 2889 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2890 | vty_out(vty, |
2891 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2892 | |
2893 | return bgp_vty_return(vty, ret); | |
2894 | } | |
2895 | ||
2896 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2897 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2898 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2899 | NEIGHBOR_STR | |
2900 | NEIGHBOR_ADDR_STR2 | |
2901 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2902 | ) |
2903 | { | |
2904 | int idx_peer = 1; | |
2905 | struct peer *peer; | |
2906 | int ret = BGP_GR_FAILURE; | |
2907 | ||
dc95985f | 2908 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2909 | ||
055679e9 | 2910 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2911 | zlog_debug( | |
2ba1fe69 | 2912 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2913 | |
055679e9 | 2914 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2915 | ||
055679e9 | 2916 | if (!peer) |
2917 | return CMD_WARNING_CONFIG_FAILED; | |
2918 | ||
2919 | ||
2920 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2921 | |
dc95985f | 2922 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2923 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2924 | |
055679e9 | 2925 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2926 | zlog_debug( | |
2ba1fe69 | 2927 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2928 | vty_out(vty, |
2929 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2930 | |
2931 | return bgp_vty_return(vty, ret); | |
2932 | } | |
2933 | ||
2934 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2935 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2936 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2937 | NO_STR | |
2938 | NEIGHBOR_STR | |
2939 | NEIGHBOR_ADDR_STR2 | |
2940 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2941 | ) |
2942 | { | |
2943 | int idx_peer = 2; | |
2944 | int ret = BGP_GR_FAILURE; | |
2945 | struct peer *peer; | |
2946 | ||
dc95985f | 2947 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2948 | ||
055679e9 | 2949 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2950 | if (!peer) | |
2951 | return CMD_WARNING_CONFIG_FAILED; | |
2952 | ||
2953 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2954 | zlog_debug( | |
2ba1fe69 | 2955 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2956 | |
36235319 | 2957 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2958 | |
dc95985f | 2959 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2960 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2961 | |
2962 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2963 | zlog_debug( | |
2ba1fe69 | 2964 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2965 | vty_out(vty, |
2966 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2967 | |
2968 | return bgp_vty_return(vty, ret); | |
2969 | } | |
2970 | ||
2971 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2972 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2973 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2974 | NEIGHBOR_STR | |
2975 | NEIGHBOR_ADDR_STR2 | |
2976 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2977 | ) |
2978 | { | |
2979 | int idx_peer = 1; | |
2980 | struct peer *peer; | |
2981 | int ret = BGP_GR_FAILURE; | |
2982 | ||
dc95985f | 2983 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2984 | ||
055679e9 | 2985 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2986 | zlog_debug( | |
2ba1fe69 | 2987 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2988 | |
2989 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2990 | if (!peer) | |
2991 | return CMD_WARNING_CONFIG_FAILED; | |
2992 | ||
36235319 | 2993 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2994 | |
2995 | if (peer->bgp->t_startup) | |
2996 | bgp_peer_gr_flags_update(peer); | |
2997 | ||
dc95985f | 2998 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2999 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3000 | ||
055679e9 | 3001 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3002 | zlog_debug( | |
2ba1fe69 | 3003 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3004 | vty_out(vty, |
3005 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3006 | |
3007 | return bgp_vty_return(vty, ret); | |
3008 | } | |
3009 | ||
3010 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3011 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3013 | NO_STR | |
3014 | NEIGHBOR_STR | |
3015 | NEIGHBOR_ADDR_STR2 | |
3016 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3017 | ) |
3018 | { | |
3019 | int idx_peer = 2; | |
3020 | int ret = BGP_GR_FAILURE; | |
3021 | struct peer *peer; | |
3022 | ||
dc95985f | 3023 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3024 | ||
055679e9 | 3025 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3026 | if (!peer) | |
3027 | return CMD_WARNING_CONFIG_FAILED; | |
3028 | ||
3029 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3030 | zlog_debug( | |
2ba1fe69 | 3031 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3032 | |
3033 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3034 | ||
dc95985f | 3035 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3036 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3037 | |
3038 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3039 | zlog_debug( | |
2ba1fe69 | 3040 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3041 | vty_out(vty, |
3042 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3043 | |
3044 | return bgp_vty_return(vty, ret); | |
3045 | } | |
3046 | ||
d6e3c15b | 3047 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3048 | bgp_graceful_restart_disable_eor_cmd, | |
3049 | "bgp graceful-restart disable-eor", | |
e9273987 | 3050 | BGP_STR |
d6e3c15b | 3051 | "Graceful restart configuration parameters\n" |
3052 | "Disable EOR Check\n") | |
3053 | { | |
3054 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3055 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3056 | |
d6e3c15b | 3057 | return CMD_SUCCESS; |
3058 | } | |
3059 | ||
3060 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3061 | no_bgp_graceful_restart_disable_eor_cmd, | |
3062 | "no bgp graceful-restart disable-eor", | |
3063 | NO_STR | |
e9273987 | 3064 | BGP_STR |
d6e3c15b | 3065 | "Graceful restart configuration parameters\n" |
3066 | "Disable EOR Check\n") | |
3067 | { | |
3068 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3069 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3070 | |
3071 | return CMD_SUCCESS; | |
3072 | } | |
3073 | ||
3074 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3075 | bgp_graceful_restart_rib_stale_time_cmd, | |
3076 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3077 | BGP_STR |
dc95985f | 3078 | "Graceful restart configuration parameters\n" |
3079 | "Specify the stale route removal timer in rib\n" | |
3080 | "Delay value (seconds)\n") | |
3081 | { | |
3082 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3083 | int idx_number = 3; | |
3084 | uint32_t stale_time; | |
3085 | ||
3086 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3087 | bgp->rib_stale_time = stale_time; | |
3088 | /* Send the stale timer update message to RIB */ | |
3089 | if (bgp_zebra_stale_timer_update(bgp)) | |
3090 | return CMD_WARNING; | |
3091 | ||
3092 | return CMD_SUCCESS; | |
3093 | } | |
3094 | ||
3095 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3096 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3097 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3098 | NO_STR | |
e9273987 | 3099 | BGP_STR |
dc95985f | 3100 | "Graceful restart configuration parameters\n" |
3101 | "Specify the stale route removal timer in rib\n" | |
3102 | "Delay value (seconds)\n") | |
3103 | { | |
3104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3105 | ||
3106 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3107 | /* Send the stale timer update message to RIB */ | |
3108 | if (bgp_zebra_stale_timer_update(bgp)) | |
3109 | return CMD_WARNING; | |
3110 | ||
d6e3c15b | 3111 | return CMD_SUCCESS; |
3112 | } | |
3113 | ||
1ca2fd11 IR |
3114 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3115 | struct bgp *bgp) | |
05bd726c | 3116 | { |
3117 | bgp_static_redo_import_check(bgp); | |
3118 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3119 | bgp_clear_star_soft_out(vty, bgp->name); |
3120 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3121 | } |
3122 | ||
3123 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3124 | { | |
3125 | struct listnode *node, *nnode; | |
3126 | struct bgp *bgp; | |
3127 | bool vrf_cfg = false; | |
3128 | ||
3129 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3130 | return CMD_SUCCESS; | |
3131 | ||
3132 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3133 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3134 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3135 | vty_out(vty, | |
3136 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3137 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3138 | VRF_DEFAULT_NAME : bgp->name); | |
3139 | vrf_cfg = true; | |
3140 | } | |
3141 | } | |
3142 | ||
3143 | if (vrf_cfg) { | |
3144 | vty_out(vty, | |
3145 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3146 | return CMD_WARNING; | |
3147 | } | |
3148 | ||
3149 | /* Set flag globally */ | |
3150 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3151 | ||
3152 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3153 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3154 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3155 | |
3156 | return CMD_SUCCESS; | |
3157 | } | |
3158 | ||
3159 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3160 | { | |
3161 | struct listnode *node, *nnode; | |
3162 | struct bgp *bgp; | |
3163 | ||
3164 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3165 | return CMD_SUCCESS; | |
3166 | ||
3167 | /* Unset flag globally */ | |
3168 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3169 | ||
3170 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3171 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3172 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3173 | |
3174 | return CMD_SUCCESS; | |
3175 | } | |
3176 | ||
7f323236 DW |
3177 | /* "bgp graceful-shutdown" configuration */ |
3178 | DEFUN (bgp_graceful_shutdown, | |
3179 | bgp_graceful_shutdown_cmd, | |
3180 | "bgp graceful-shutdown", | |
3181 | BGP_STR | |
3182 | "Graceful shutdown parameters\n") | |
3183 | { | |
05bd726c | 3184 | if (vty->node == CONFIG_NODE) |
3185 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3186 | ||
1ca2fd11 | 3187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3188 | |
1ca2fd11 IR |
3189 | /* if configured globally, per-instance config is not allowed */ |
3190 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3191 | vty_out(vty, | |
3192 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3193 | return CMD_WARNING_CONFIG_FAILED; | |
3194 | } | |
3195 | ||
3196 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3197 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3198 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3199 | } | |
3200 | ||
3201 | return CMD_SUCCESS; | |
7f323236 DW |
3202 | } |
3203 | ||
1ca2fd11 | 3204 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3205 | no_bgp_graceful_shutdown_cmd, |
3206 | "no bgp graceful-shutdown", | |
3207 | NO_STR | |
3208 | BGP_STR | |
3209 | "Graceful shutdown parameters\n") | |
3210 | { | |
05bd726c | 3211 | if (vty->node == CONFIG_NODE) |
3212 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3213 | ||
1ca2fd11 | 3214 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3215 | |
1ca2fd11 IR |
3216 | /* If configured globally, cannot remove from one bgp instance */ |
3217 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3218 | vty_out(vty, | |
3219 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3220 | return CMD_WARNING_CONFIG_FAILED; | |
3221 | } | |
7f323236 | 3222 | |
1ca2fd11 IR |
3223 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3224 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3225 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3226 | } | |
3227 | ||
3228 | return CMD_SUCCESS; | |
7f323236 DW |
3229 | } |
3230 | ||
718e3744 | 3231 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3232 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3233 | bgp_fast_external_failover_cmd, |
3234 | "bgp fast-external-failover", | |
3235 | BGP_STR | |
3236 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3237 | { | |
1ca2fd11 IR |
3238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3239 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3240 | return CMD_SUCCESS; | |
718e3744 | 3241 | } |
3242 | ||
1ca2fd11 | 3243 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3244 | no_bgp_fast_external_failover_cmd, |
3245 | "no bgp fast-external-failover", | |
3246 | NO_STR | |
3247 | BGP_STR | |
3248 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3249 | { | |
1ca2fd11 IR |
3250 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3251 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3252 | return CMD_SUCCESS; | |
718e3744 | 3253 | } |
6b0655a2 | 3254 | |
718e3744 | 3255 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3256 | DEFUN (bgp_bestpath_compare_router_id, |
3257 | bgp_bestpath_compare_router_id_cmd, | |
3258 | "bgp bestpath compare-routerid", | |
e9273987 | 3259 | BGP_STR |
1ca2fd11 IR |
3260 | "Change the default bestpath selection\n" |
3261 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3262 | { |
1ca2fd11 IR |
3263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3264 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3265 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3266 | |
1ca2fd11 | 3267 | return CMD_SUCCESS; |
718e3744 | 3268 | } |
3269 | ||
1ca2fd11 IR |
3270 | DEFUN (no_bgp_bestpath_compare_router_id, |
3271 | no_bgp_bestpath_compare_router_id_cmd, | |
3272 | "no bgp bestpath compare-routerid", | |
3273 | NO_STR | |
e9273987 | 3274 | BGP_STR |
1ca2fd11 IR |
3275 | "Change the default bestpath selection\n" |
3276 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3277 | { |
1ca2fd11 IR |
3278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3279 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3280 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3281 | |
1ca2fd11 | 3282 | return CMD_SUCCESS; |
718e3744 | 3283 | } |
6b0655a2 | 3284 | |
718e3744 | 3285 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3286 | DEFUN (bgp_bestpath_aspath_ignore, |
3287 | bgp_bestpath_aspath_ignore_cmd, | |
3288 | "bgp bestpath as-path ignore", | |
e9273987 | 3289 | BGP_STR |
1ca2fd11 IR |
3290 | "Change the default bestpath selection\n" |
3291 | "AS-path attribute\n" | |
3292 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3293 | { |
1ca2fd11 IR |
3294 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3295 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3296 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3297 | |
1ca2fd11 | 3298 | return CMD_SUCCESS; |
718e3744 | 3299 | } |
3300 | ||
1ca2fd11 IR |
3301 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3302 | no_bgp_bestpath_aspath_ignore_cmd, | |
3303 | "no bgp bestpath as-path ignore", | |
3304 | NO_STR | |
e9273987 | 3305 | BGP_STR |
1ca2fd11 IR |
3306 | "Change the default bestpath selection\n" |
3307 | "AS-path attribute\n" | |
3308 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3309 | { |
1ca2fd11 IR |
3310 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3311 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3312 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3313 | |
1ca2fd11 | 3314 | return CMD_SUCCESS; |
718e3744 | 3315 | } |
6b0655a2 | 3316 | |
6811845b | 3317 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3318 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3319 | bgp_bestpath_aspath_confed_cmd, |
3320 | "bgp bestpath as-path confed", | |
e9273987 | 3321 | BGP_STR |
6811845b | 3322 | "Change the default bestpath selection\n" |
3323 | "AS-path attribute\n" | |
3324 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3325 | { | |
1ca2fd11 IR |
3326 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3327 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3328 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3329 | |
1ca2fd11 | 3330 | return CMD_SUCCESS; |
6811845b | 3331 | } |
3332 | ||
1ca2fd11 | 3333 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3334 | no_bgp_bestpath_aspath_confed_cmd, |
3335 | "no bgp bestpath as-path confed", | |
3336 | NO_STR | |
e9273987 | 3337 | BGP_STR |
6811845b | 3338 | "Change the default bestpath selection\n" |
3339 | "AS-path attribute\n" | |
3340 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3341 | { | |
1ca2fd11 IR |
3342 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3343 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3344 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3345 | |
1ca2fd11 | 3346 | return CMD_SUCCESS; |
6811845b | 3347 | } |
6b0655a2 | 3348 | |
2fdd455c | 3349 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3350 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3351 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3352 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3353 | BGP_STR |
16fc1eec DS |
3354 | "Change the default bestpath selection\n" |
3355 | "AS-path attribute\n" | |
3356 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3357 | "Generate an AS_SET\n" |
16fc1eec DS |
3358 | "Do not generate an AS_SET\n") |
3359 | { | |
1ca2fd11 | 3360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3361 | int idx = 0; |
1ca2fd11 | 3362 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3363 | |
1ca2fd11 IR |
3364 | /* no-as-set is now the default behavior so we can silently |
3365 | * ignore it */ | |
d62a17ae | 3366 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3367 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3368 | else |
1ca2fd11 | 3369 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3370 | |
1ca2fd11 IR |
3371 | bgp_recalculate_all_bestpaths(bgp); |
3372 | ||
3373 | return CMD_SUCCESS; | |
16fc1eec DS |
3374 | } |
3375 | ||
1ca2fd11 | 3376 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3377 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3378 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3379 | NO_STR |
e9273987 | 3380 | BGP_STR |
16fc1eec DS |
3381 | "Change the default bestpath selection\n" |
3382 | "AS-path attribute\n" | |
3383 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3384 | "Generate an AS_SET\n" |
16fc1eec DS |
3385 | "Do not generate an AS_SET\n") |
3386 | { | |
1ca2fd11 IR |
3387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3388 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3389 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3390 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3391 | |
1ca2fd11 | 3392 | return CMD_SUCCESS; |
2fdd455c | 3393 | } |
6b0655a2 | 3394 | |
ee88563a JM |
3395 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3396 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3397 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3398 | "bgp bestpath peer-type multipath-relax", | |
3399 | BGP_STR | |
3400 | "Change the default bestpath selection\n" | |
3401 | "Peer type\n" | |
3402 | "Allow load sharing across routes learned from different peer types\n") | |
3403 | { | |
3404 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3405 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3406 | bgp_recalculate_all_bestpaths(bgp); | |
3407 | ||
3408 | return CMD_SUCCESS; | |
3409 | } | |
3410 | ||
3411 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3412 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3413 | "no bgp bestpath peer-type multipath-relax", | |
3414 | NO_STR BGP_STR | |
3415 | "Change the default bestpath selection\n" | |
3416 | "Peer type\n" | |
3417 | "Allow load sharing across routes learned from different peer types\n") | |
3418 | { | |
3419 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3420 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3421 | bgp_recalculate_all_bestpaths(bgp); | |
3422 | ||
3423 | return CMD_SUCCESS; | |
3424 | } | |
3425 | ||
848973c7 | 3426 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3427 | DEFUN (bgp_log_neighbor_changes, |
3428 | bgp_log_neighbor_changes_cmd, | |
3429 | "bgp log-neighbor-changes", | |
e9273987 | 3430 | BGP_STR |
1ca2fd11 | 3431 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3432 | { |
1ca2fd11 IR |
3433 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3434 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3435 | return CMD_SUCCESS; | |
848973c7 | 3436 | } |
3437 | ||
1ca2fd11 IR |
3438 | DEFUN (no_bgp_log_neighbor_changes, |
3439 | no_bgp_log_neighbor_changes_cmd, | |
3440 | "no bgp log-neighbor-changes", | |
3441 | NO_STR | |
e9273987 | 3442 | BGP_STR |
1ca2fd11 | 3443 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3444 | { |
1ca2fd11 IR |
3445 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3446 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3447 | return CMD_SUCCESS; | |
848973c7 | 3448 | } |
6b0655a2 | 3449 | |
718e3744 | 3450 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3451 | DEFUN (bgp_bestpath_med, |
718e3744 | 3452 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3453 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3454 | BGP_STR |
718e3744 | 3455 | "Change the default bestpath selection\n" |
3456 | "MED attribute\n" | |
3457 | "Compare MED among confederation paths\n" | |
838758ac DW |
3458 | "Treat missing MED as the least preferred one\n" |
3459 | "Treat missing MED as the least preferred one\n" | |
3460 | "Compare MED among confederation paths\n") | |
718e3744 | 3461 | { |
1ca2fd11 | 3462 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3463 | |
1ca2fd11 | 3464 | int idx = 0; |
d62a17ae | 3465 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3466 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3467 | idx = 0; |
3468 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3469 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3470 | |
1ca2fd11 | 3471 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3472 | |
1ca2fd11 | 3473 | return CMD_SUCCESS; |
718e3744 | 3474 | } |
3475 | ||
1ca2fd11 | 3476 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3477 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3478 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3479 | NO_STR |
e9273987 | 3480 | BGP_STR |
718e3744 | 3481 | "Change the default bestpath selection\n" |
3482 | "MED attribute\n" | |
3483 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3484 | "Treat missing MED as the least preferred one\n" |
3485 | "Treat missing MED as the least preferred one\n" | |
3486 | "Compare MED among confederation paths\n") | |
718e3744 | 3487 | { |
1ca2fd11 | 3488 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3489 | |
1ca2fd11 | 3490 | int idx = 0; |
d62a17ae | 3491 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3492 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3493 | idx = 0; |
3494 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3495 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3496 | ||
3497 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3498 | |
1ca2fd11 | 3499 | return CMD_SUCCESS; |
718e3744 | 3500 | } |
3501 | ||
f7e1c681 | 3502 | /* "bgp bestpath bandwidth" configuration. */ |
3503 | DEFPY (bgp_bestpath_bw, | |
3504 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3505 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3506 | BGP_STR |
f7e1c681 | 3507 | "Change the default bestpath selection\n" |
3508 | "Link Bandwidth attribute\n" | |
3509 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3510 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3511 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3512 | { | |
3513 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3514 | afi_t afi; | |
3515 | safi_t safi; | |
3516 | ||
ad36d216 DS |
3517 | if (!bw_cfg) { |
3518 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3519 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3520 | } |
ad36d216 DS |
3521 | if (!strcmp(bw_cfg, "ignore")) |
3522 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3523 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3524 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3525 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3526 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3527 | else | |
3528 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3529 | |
3530 | /* This config is used in route install, so redo that. */ | |
3531 | FOREACH_AFI_SAFI (afi, safi) { | |
3532 | if (!bgp_fibupd_safi(safi)) | |
3533 | continue; | |
3534 | bgp_zebra_announce_table(bgp, afi, safi); | |
3535 | } | |
3536 | ||
3537 | return CMD_SUCCESS; | |
3538 | } | |
3539 | ||
ad36d216 DS |
3540 | DEFPY (no_bgp_bestpath_bw, |
3541 | no_bgp_bestpath_bw_cmd, | |
3542 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3543 | NO_STR | |
e9273987 | 3544 | BGP_STR |
ad36d216 DS |
3545 | "Change the default bestpath selection\n" |
3546 | "Link Bandwidth attribute\n" | |
3547 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3548 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3549 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3550 | { | |
3551 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3552 | afi_t afi; | |
3553 | safi_t safi; | |
3554 | ||
3555 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3556 | ||
3557 | /* This config is used in route install, so redo that. */ | |
3558 | FOREACH_AFI_SAFI (afi, safi) { | |
3559 | if (!bgp_fibupd_safi(safi)) | |
3560 | continue; | |
3561 | bgp_zebra_announce_table(bgp, afi, safi); | |
3562 | } | |
3563 | return CMD_SUCCESS; | |
3564 | } | |
3565 | ||
b16bcbba | 3566 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3567 | "[no] bgp default <ipv4-unicast|" |
3568 | "ipv4-multicast|" | |
3569 | "ipv4-vpn|" | |
3570 | "ipv4-labeled-unicast|" | |
3571 | "ipv4-flowspec|" | |
3572 | "ipv6-unicast|" | |
3573 | "ipv6-multicast|" | |
3574 | "ipv6-vpn|" | |
3575 | "ipv6-labeled-unicast|" | |
3576 | "ipv6-flowspec|" | |
3577 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3578 | NO_STR |
e9273987 | 3579 | BGP_STR |
e84c59af | 3580 | "Configure BGP defaults\n" |
b16bcbba | 3581 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3582 | "Activate ipv4-multicast for a peer by default\n" |
3583 | "Activate ipv4-vpn for a peer by default\n" | |
3584 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3585 | "Activate ipv4-flowspec for a peer by default\n" | |
3586 | "Activate ipv6-unicast for a peer by default\n" | |
3587 | "Activate ipv6-multicast for a peer by default\n" | |
3588 | "Activate ipv6-vpn for a peer by default\n" | |
3589 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3590 | "Activate ipv6-flowspec for a peer by default\n" | |
3591 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3592 | { |
3593 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3594 | char afi_safi_str[strlen(afi_safi) + 1]; |
3595 | char *afi_safi_str_tok; | |
e84c59af | 3596 | |
b16bcbba TA |
3597 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3598 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3599 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3600 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3601 | safi_t safi; |
e84c59af | 3602 | |
38d11af5 TA |
3603 | if (strmatch(safi_str, "labeled")) |
3604 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3605 | else | |
3606 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3607 | |
3608 | if (no) | |
3609 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3610 | else { |
3611 | if ((safi == SAFI_LABELED_UNICAST | |
3612 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3613 | || (safi == SAFI_UNICAST | |
3614 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3615 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3616 | else | |
3617 | bgp->default_af[afi][safi] = true; | |
3618 | } | |
718e3744 | 3619 | |
d62a17ae | 3620 | return CMD_SUCCESS; |
718e3744 | 3621 | } |
6b0655a2 | 3622 | |
04b6bdc0 | 3623 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3624 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3625 | bgp_default_show_hostname_cmd, |
3626 | "bgp default show-hostname", | |
e9273987 | 3627 | BGP_STR |
04b6bdc0 | 3628 | "Configure BGP defaults\n" |
0437e105 | 3629 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3630 | { |
1ca2fd11 IR |
3631 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3632 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3633 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3634 | } |
3635 | ||
1ca2fd11 IR |
3636 | DEFUN (no_bgp_default_show_hostname, |
3637 | no_bgp_default_show_hostname_cmd, | |
3638 | "no bgp default show-hostname", | |
3639 | NO_STR | |
e9273987 | 3640 | BGP_STR |
1ca2fd11 IR |
3641 | "Configure BGP defaults\n" |
3642 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3643 | { |
1ca2fd11 IR |
3644 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3645 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3646 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3647 | } |
3648 | ||
aef999a2 | 3649 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3650 | DEFUN (bgp_default_show_nexthop_hostname, |
3651 | bgp_default_show_nexthop_hostname_cmd, | |
3652 | "bgp default show-nexthop-hostname", | |
e9273987 | 3653 | BGP_STR |
1d80f243 IR |
3654 | "Configure BGP defaults\n" |
3655 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3656 | { |
1ca2fd11 IR |
3657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3658 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3659 | return CMD_SUCCESS; | |
aef999a2 DA |
3660 | } |
3661 | ||
3662 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3663 | no_bgp_default_show_nexthop_hostname_cmd, | |
3664 | "no bgp default show-nexthop-hostname", | |
3665 | NO_STR | |
e9273987 | 3666 | BGP_STR |
aef999a2 DA |
3667 | "Configure BGP defaults\n" |
3668 | "Show hostname for nexthop in certain command outputs\n") | |
3669 | { | |
1ca2fd11 IR |
3670 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3671 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3672 | return CMD_SUCCESS; | |
aef999a2 DA |
3673 | } |
3674 | ||
8233ef81 | 3675 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
3676 | DEFUN (bgp_network_import_check, |
3677 | bgp_network_import_check_cmd, | |
3678 | "bgp network import-check", | |
e9273987 | 3679 | BGP_STR |
1ca2fd11 IR |
3680 | "BGP network command\n" |
3681 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3682 | { |
1ca2fd11 IR |
3683 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3684 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3685 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3686 | bgp_static_redo_import_check(bgp); | |
3687 | } | |
078430f6 | 3688 | |
1ca2fd11 | 3689 | return CMD_SUCCESS; |
718e3744 | 3690 | } |
3691 | ||
d62a17ae | 3692 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3693 | "bgp network import-check exact", | |
e9273987 | 3694 | BGP_STR |
d62a17ae | 3695 | "BGP network command\n" |
3696 | "Check BGP network route exists in IGP\n" | |
3697 | "Match route precisely\n") | |
8233ef81 | 3698 | |
1ca2fd11 IR |
3699 | DEFUN (no_bgp_network_import_check, |
3700 | no_bgp_network_import_check_cmd, | |
3701 | "no bgp network import-check", | |
3702 | NO_STR | |
e9273987 | 3703 | BGP_STR |
1ca2fd11 IR |
3704 | "BGP network command\n" |
3705 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3706 | { |
1ca2fd11 IR |
3707 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3708 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3709 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3710 | bgp_static_redo_import_check(bgp); | |
3711 | } | |
6b0655a2 | 3712 | |
1ca2fd11 | 3713 | return CMD_SUCCESS; |
ff8a8a7a | 3714 | } |
718e3744 | 3715 | |
1ca2fd11 IR |
3716 | DEFUN (bgp_default_local_preference, |
3717 | bgp_default_local_preference_cmd, | |
3718 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 3719 | BGP_STR |
1ca2fd11 IR |
3720 | "Configure BGP defaults\n" |
3721 | "local preference (higher=more preferred)\n" | |
3722 | "Configure default local preference value\n") | |
ff8a8a7a | 3723 | { |
1ca2fd11 | 3724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3725 | int idx_number = 3; |
1ca2fd11 | 3726 | uint32_t local_pref; |
718e3744 | 3727 | |
1ca2fd11 | 3728 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3729 | |
1ca2fd11 IR |
3730 | bgp_default_local_preference_set(bgp, local_pref); |
3731 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3732 | |
1ca2fd11 | 3733 | return CMD_SUCCESS; |
718e3744 | 3734 | } |
3735 | ||
1ca2fd11 IR |
3736 | DEFUN (no_bgp_default_local_preference, |
3737 | no_bgp_default_local_preference_cmd, | |
3738 | "no bgp default local-preference [(0-4294967295)]", | |
3739 | NO_STR | |
e9273987 | 3740 | BGP_STR |
1ca2fd11 IR |
3741 | "Configure BGP defaults\n" |
3742 | "local preference (higher=more preferred)\n" | |
3743 | "Configure default local preference value\n") | |
ff8a8a7a | 3744 | { |
1ca2fd11 IR |
3745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3746 | bgp_default_local_preference_unset(bgp); | |
3747 | bgp_clear_star_soft_in(vty, bgp->name); | |
3748 | ||
3749 | return CMD_SUCCESS; | |
ff8a8a7a | 3750 | } |
6b0655a2 | 3751 | |
ff8a8a7a | 3752 | |
1ca2fd11 IR |
3753 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3754 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3755 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 3756 | BGP_STR |
1ca2fd11 IR |
3757 | "Configure BGP defaults\n" |
3758 | "subgroup-pkt-queue-max\n" | |
3759 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3760 | { |
1ca2fd11 | 3761 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3762 | int idx_number = 3; |
1ca2fd11 | 3763 | uint32_t max_size; |
3f9c7369 | 3764 | |
1ca2fd11 | 3765 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3766 | |
1ca2fd11 | 3767 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 3768 | |
1ca2fd11 | 3769 | return CMD_SUCCESS; |
8bd9d948 DS |
3770 | } |
3771 | ||
1ca2fd11 IR |
3772 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
3773 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3774 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3775 | NO_STR | |
e9273987 | 3776 | BGP_STR |
1ca2fd11 IR |
3777 | "Configure BGP defaults\n" |
3778 | "subgroup-pkt-queue-max\n" | |
3779 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 3780 | { |
1ca2fd11 IR |
3781 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3782 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3783 | return CMD_SUCCESS; | |
ff8a8a7a | 3784 | } |
813d4307 | 3785 | |
8bd9d948 | 3786 | |
1ca2fd11 IR |
3787 | DEFUN (bgp_rr_allow_outbound_policy, |
3788 | bgp_rr_allow_outbound_policy_cmd, | |
3789 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 3790 | BGP_STR |
1ca2fd11 IR |
3791 | "Allow modifications made by out route-map\n" |
3792 | "on ibgp neighbors\n") | |
ff8a8a7a | 3793 | { |
1ca2fd11 | 3794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3795 | |
1ca2fd11 IR |
3796 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3797 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3798 | update_group_announce_rrclients(bgp); | |
3799 | bgp_clear_star_soft_out(vty, bgp->name); | |
3800 | } | |
8bd9d948 | 3801 | |
1ca2fd11 IR |
3802 | return CMD_SUCCESS; |
3803 | } | |
ff8a8a7a | 3804 | |
1ca2fd11 IR |
3805 | DEFUN (no_bgp_rr_allow_outbound_policy, |
3806 | no_bgp_rr_allow_outbound_policy_cmd, | |
3807 | "no bgp route-reflector allow-outbound-policy", | |
3808 | NO_STR | |
e9273987 | 3809 | BGP_STR |
1ca2fd11 IR |
3810 | "Allow modifications made by out route-map\n" |
3811 | "on ibgp neighbors\n") | |
8bd9d948 | 3812 | { |
1ca2fd11 | 3813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3814 | |
1ca2fd11 IR |
3815 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3816 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3817 | update_group_announce_rrclients(bgp); | |
3818 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 3819 | } |
8bd9d948 | 3820 | |
1ca2fd11 | 3821 | return CMD_SUCCESS; |
8bd9d948 DS |
3822 | } |
3823 | ||
1ca2fd11 IR |
3824 | DEFUN (bgp_listen_limit, |
3825 | bgp_listen_limit_cmd, | |
3826 | "bgp listen limit (1-65535)", | |
e9273987 | 3827 | BGP_STR |
1ca2fd11 IR |
3828 | "BGP Dynamic Neighbors listen commands\n" |
3829 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3830 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3831 | { |
1ca2fd11 | 3832 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3833 | int idx_number = 3; |
1ca2fd11 IR |
3834 | int listen_limit; |
3835 | ||
3836 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 3837 | |
1ca2fd11 | 3838 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3839 | |
1ca2fd11 | 3840 | return CMD_SUCCESS; |
f14e6fdb DS |
3841 | } |
3842 | ||
1ca2fd11 IR |
3843 | DEFUN (no_bgp_listen_limit, |
3844 | no_bgp_listen_limit_cmd, | |
3845 | "no bgp listen limit [(1-65535)]", | |
3846 | NO_STR | |
e9273987 | 3847 | BGP_STR |
1ca2fd11 IR |
3848 | "BGP Dynamic Neighbors listen commands\n" |
3849 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3850 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3851 | { |
1ca2fd11 IR |
3852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3853 | bgp_listen_limit_unset(bgp); | |
3854 | return CMD_SUCCESS; | |
f14e6fdb DS |
3855 | } |
3856 | ||
3857 | ||
20eb8864 | 3858 | /* |
3859 | * Check if this listen range is already configured. Check for exact | |
3860 | * match or overlap based on input. | |
3861 | */ | |
d62a17ae | 3862 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3863 | struct prefix *range, int exact) | |
3864 | { | |
3865 | struct listnode *node, *nnode; | |
3866 | struct listnode *node1, *nnode1; | |
3867 | struct peer_group *group; | |
3868 | struct prefix *lr; | |
3869 | afi_t afi; | |
3870 | int match; | |
3871 | ||
3872 | afi = family2afi(range->family); | |
3873 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3874 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3875 | lr)) { | |
3876 | if (exact) | |
3877 | match = prefix_same(range, lr); | |
3878 | else | |
3879 | match = (prefix_match(range, lr) | |
3880 | || prefix_match(lr, range)); | |
3881 | if (match) | |
3882 | return group; | |
3883 | } | |
3884 | } | |
3885 | ||
3886 | return NULL; | |
20eb8864 | 3887 | } |
3888 | ||
f14e6fdb DS |
3889 | DEFUN (bgp_listen_range, |
3890 | bgp_listen_range_cmd, | |
d7b9898c | 3891 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 3892 | BGP_STR |
d7fa34c1 QY |
3893 | "Configure BGP dynamic neighbors listen range\n" |
3894 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3895 | NEIGHBOR_ADDR_STR |
3896 | "Member of the peer-group\n" | |
3897 | "Peer-group name\n") | |
f14e6fdb | 3898 | { |
d62a17ae | 3899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3900 | struct prefix range; | |
3901 | struct peer_group *group, *existing_group; | |
3902 | afi_t afi; | |
3903 | int ret; | |
3904 | int idx = 0; | |
3905 | ||
3906 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3907 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3908 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3909 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3910 | char *peergroup = argv[idx]->arg; |
3911 | ||
3912 | /* Convert IP prefix string to struct prefix. */ | |
3913 | ret = str2prefix(prefix, &range); | |
3914 | if (!ret) { | |
3915 | vty_out(vty, "%% Malformed listen range\n"); | |
3916 | return CMD_WARNING_CONFIG_FAILED; | |
3917 | } | |
3918 | ||
3919 | afi = family2afi(range.family); | |
3920 | ||
3921 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3922 | vty_out(vty, | |
3923 | "%% Malformed listen range (link-local address)\n"); | |
3924 | return CMD_WARNING_CONFIG_FAILED; | |
3925 | } | |
3926 | ||
3927 | apply_mask(&range); | |
3928 | ||
3929 | /* Check if same listen range is already configured. */ | |
3930 | existing_group = listen_range_exists(bgp, &range, 1); | |
3931 | if (existing_group) { | |
3932 | if (strcmp(existing_group->name, peergroup) == 0) | |
3933 | return CMD_SUCCESS; | |
3934 | else { | |
3935 | vty_out(vty, | |
3936 | "%% Same listen range is attached to peer-group %s\n", | |
3937 | existing_group->name); | |
3938 | return CMD_WARNING_CONFIG_FAILED; | |
3939 | } | |
3940 | } | |
3941 | ||
3942 | /* Check if an overlapping listen range exists. */ | |
3943 | if (listen_range_exists(bgp, &range, 0)) { | |
3944 | vty_out(vty, | |
3945 | "%% Listen range overlaps with existing listen range\n"); | |
3946 | return CMD_WARNING_CONFIG_FAILED; | |
3947 | } | |
3948 | ||
3949 | group = peer_group_lookup(bgp, peergroup); | |
3950 | if (!group) { | |
3951 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3952 | return CMD_WARNING_CONFIG_FAILED; | |
3953 | } | |
3954 | ||
3955 | ret = peer_group_listen_range_add(group, &range); | |
3956 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3957 | } |
3958 | ||
3959 | DEFUN (no_bgp_listen_range, | |
3960 | no_bgp_listen_range_cmd, | |
d7b9898c | 3961 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3962 | NO_STR |
e9273987 | 3963 | BGP_STR |
d7fa34c1 QY |
3964 | "Unconfigure BGP dynamic neighbors listen range\n" |
3965 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3966 | NEIGHBOR_ADDR_STR | |
3967 | "Member of the peer-group\n" | |
3968 | "Peer-group name\n") | |
f14e6fdb | 3969 | { |
d62a17ae | 3970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3971 | struct prefix range; | |
3972 | struct peer_group *group; | |
3973 | afi_t afi; | |
3974 | int ret; | |
3975 | int idx = 0; | |
3976 | ||
3977 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3978 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3979 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3980 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3981 | char *peergroup = argv[idx]->arg; |
3982 | ||
3983 | /* Convert IP prefix string to struct prefix. */ | |
3984 | ret = str2prefix(prefix, &range); | |
3985 | if (!ret) { | |
3986 | vty_out(vty, "%% Malformed listen range\n"); | |
3987 | return CMD_WARNING_CONFIG_FAILED; | |
3988 | } | |
3989 | ||
3990 | afi = family2afi(range.family); | |
3991 | ||
3992 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3993 | vty_out(vty, | |
3994 | "%% Malformed listen range (link-local address)\n"); | |
3995 | return CMD_WARNING_CONFIG_FAILED; | |
3996 | } | |
3997 | ||
3998 | apply_mask(&range); | |
3999 | ||
4000 | group = peer_group_lookup(bgp, peergroup); | |
4001 | if (!group) { | |
4002 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4003 | return CMD_WARNING_CONFIG_FAILED; | |
4004 | } | |
4005 | ||
4006 | ret = peer_group_listen_range_del(group, &range); | |
4007 | return bgp_vty_return(vty, ret); | |
4008 | } | |
4009 | ||
2b791107 | 4010 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4011 | { |
4012 | struct peer_group *group; | |
4013 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4014 | struct prefix *range; | |
4015 | afi_t afi; | |
d62a17ae | 4016 | |
4017 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4018 | vty_out(vty, " bgp listen limit %d\n", | |
4019 | bgp->dynamic_neighbors_limit); | |
4020 | ||
4021 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4022 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4023 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4024 | nrnode, range)) { | |
d62a17ae | 4025 | vty_out(vty, |
2dbe669b DA |
4026 | " bgp listen range %pFX peer-group %s\n", |
4027 | range, group->name); | |
d62a17ae | 4028 | } |
4029 | } | |
4030 | } | |
f14e6fdb DS |
4031 | } |
4032 | ||
4033 | ||
1ca2fd11 IR |
4034 | DEFUN (bgp_disable_connected_route_check, |
4035 | bgp_disable_connected_route_check_cmd, | |
4036 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4037 | BGP_STR |
1ca2fd11 | 4038 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4039 | { |
1ca2fd11 IR |
4040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4041 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4042 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4043 | |
1ca2fd11 | 4044 | return CMD_SUCCESS; |
907f92c8 DS |
4045 | } |
4046 | ||
1ca2fd11 IR |
4047 | DEFUN (no_bgp_disable_connected_route_check, |
4048 | no_bgp_disable_connected_route_check_cmd, | |
4049 | "no bgp disable-ebgp-connected-route-check", | |
4050 | NO_STR | |
e9273987 | 4051 | BGP_STR |
1ca2fd11 | 4052 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4053 | { |
1ca2fd11 IR |
4054 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4055 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4056 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4057 | |
1ca2fd11 | 4058 | return CMD_SUCCESS; |
d62a17ae | 4059 | } |
4060 | ||
4061 | ||
28c6e247 IR |
4062 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4063 | const char *as_str) | |
4064 | { | |
4065 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4066 | int ret; | |
4067 | as_t as; | |
4068 | int as_type = AS_SPECIFIED; | |
4069 | union sockunion su; | |
4070 | ||
4071 | if (as_str[0] == 'i') { | |
4072 | as = 0; | |
4073 | as_type = AS_INTERNAL; | |
4074 | } else if (as_str[0] == 'e') { | |
4075 | as = 0; | |
4076 | as_type = AS_EXTERNAL; | |
4077 | } else { | |
4078 | /* Get AS number. */ | |
4079 | as = strtoul(as_str, NULL, 10); | |
4080 | } | |
4081 | ||
4082 | /* If peer is peer group or interface peer, call proper function. */ | |
4083 | ret = str2sockunion(peer_str, &su); | |
4084 | if (ret < 0) { | |
4085 | struct peer *peer; | |
4086 | ||
4087 | /* Check if existing interface peer */ | |
4088 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4089 | ||
4090 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4091 | ||
4092 | /* if not interface peer, check peer-group settings */ | |
4093 | if (ret < 0 && !peer) { | |
4094 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4095 | if (ret < 0) { | |
4096 | vty_out(vty, | |
4097 | "%% Create the peer-group or interface first\n"); | |
4098 | return CMD_WARNING_CONFIG_FAILED; | |
4099 | } | |
4100 | return CMD_SUCCESS; | |
4101 | } | |
4102 | } else { | |
4103 | if (peer_address_self_check(bgp, &su)) { | |
4104 | vty_out(vty, | |
4105 | "%% Can not configure the local system as neighbor\n"); | |
4106 | return CMD_WARNING_CONFIG_FAILED; | |
4107 | } | |
4108 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4109 | } | |
4110 | ||
4111 | /* This peer belongs to peer group. */ | |
4112 | switch (ret) { | |
4113 | case BGP_ERR_PEER_GROUP_MEMBER: | |
4114 | vty_out(vty, | |
4115 | "%% Peer-group member cannot override remote-as of peer-group\n"); | |
4116 | return CMD_WARNING_CONFIG_FAILED; | |
4117 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
4118 | vty_out(vty, | |
4119 | "%% Peer-group members must be all internal or all external\n"); | |
4120 | return CMD_WARNING_CONFIG_FAILED; | |
4121 | } | |
4122 | return bgp_vty_return(vty, ret); | |
4123 | } | |
4124 | ||
1ca2fd11 IR |
4125 | DEFUN (bgp_default_shutdown, |
4126 | bgp_default_shutdown_cmd, | |
4127 | "[no] bgp default shutdown", | |
4128 | NO_STR | |
4129 | BGP_STR | |
4130 | "Configure BGP defaults\n" | |
4131 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4132 | { |
1ca2fd11 IR |
4133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4134 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4135 | return CMD_SUCCESS; | |
f26845f9 QY |
4136 | } |
4137 | ||
736b68f3 DS |
4138 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4139 | BGP_STR | |
9ddf4b81 | 4140 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4141 | "Add a shutdown message (RFC 8203)\n" |
4142 | "Shutdown message\n") | |
9cf59432 | 4143 | { |
736b68f3 | 4144 | char *msgstr = NULL; |
8389c83a | 4145 | |
9cf59432 DS |
4146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4147 | ||
8389c83a | 4148 | if (argc > 3) |
f80e35b6 | 4149 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4150 | |
4151 | bgp_shutdown_enable(bgp, msgstr); | |
4152 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4153 | |
4154 | return CMD_SUCCESS; | |
4155 | } | |
4156 | ||
736b68f3 | 4157 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4158 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4159 | { |
4160 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4161 | ||
4162 | bgp_shutdown_enable(bgp, NULL); | |
4163 | ||
4164 | return CMD_SUCCESS; | |
4165 | } | |
8389c83a | 4166 | |
736b68f3 | 4167 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4168 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4169 | { |
4170 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4171 | ||
4172 | bgp_shutdown_disable(bgp); | |
4173 | ||
4174 | return CMD_SUCCESS; | |
4175 | } | |
4176 | ||
9ddf4b81 | 4177 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4178 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4179 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4180 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4181 | |
28c6e247 IR |
4182 | DEFUN (neighbor_remote_as, |
4183 | neighbor_remote_as_cmd, | |
4184 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4185 | NEIGHBOR_STR | |
4186 | NEIGHBOR_ADDR_STR2 | |
4187 | "Specify a BGP neighbor\n" | |
4188 | AS_STR | |
4189 | "Internal BGP peer\n" | |
4190 | "External BGP peer\n") | |
718e3744 | 4191 | { |
d62a17ae | 4192 | int idx_peer = 1; |
4193 | int idx_remote_as = 3; | |
28c6e247 IR |
4194 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4195 | argv[idx_remote_as]->arg); | |
d62a17ae | 4196 | } |
f852eb98 PG |
4197 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4198 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4199 | * when nexthop becomes unreachable | |
4200 | */ | |
4201 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4202 | BGP_STR "Fast convergence for bgp sessions\n") | |
4203 | { | |
4204 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4205 | bgp->fast_convergence = true; | |
4206 | ||
4207 | return CMD_SUCCESS; | |
4208 | } | |
4209 | ||
4210 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4211 | "no bgp fast-convergence", | |
4212 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4213 | { | |
4214 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4215 | bgp->fast_convergence = false; | |
4216 | ||
4217 | return CMD_SUCCESS; | |
4218 | } | |
d62a17ae | 4219 | |
28c6e247 IR |
4220 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4221 | int v6only, | |
4222 | const char *peer_group_name, | |
4223 | const char *as_str) | |
d62a17ae | 4224 | { |
28c6e247 IR |
4225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4226 | as_t as = 0; | |
4227 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4228 | struct peer *peer; |
4229 | struct peer_group *group; | |
4230 | int ret = 0; | |
d62a17ae | 4231 | |
4232 | group = peer_group_lookup(bgp, conf_if); | |
4233 | ||
4234 | if (group) { | |
28c6e247 IR |
4235 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4236 | return CMD_WARNING_CONFIG_FAILED; | |
4237 | } | |
4238 | ||
4239 | if (as_str) { | |
4240 | if (as_str[0] == 'i') { | |
4241 | as_type = AS_INTERNAL; | |
4242 | } else if (as_str[0] == 'e') { | |
4243 | as_type = AS_EXTERNAL; | |
4244 | } else { | |
4245 | /* Get AS number. */ | |
4246 | as = strtoul(as_str, NULL, 10); | |
4247 | as_type = AS_SPECIFIED; | |
4248 | } | |
d62a17ae | 4249 | } |
4250 | ||
4251 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4252 | if (peer) { | |
28c6e247 | 4253 | if (as_str) |
e84c59af | 4254 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4255 | } else { |
e84c59af DA |
4256 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4257 | NULL); | |
d62a17ae | 4258 | |
4259 | if (!peer) { | |
28c6e247 IR |
4260 | vty_out(vty, "%% BGP failed to create peer\n"); |
4261 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4262 | } |
4263 | ||
4264 | if (v6only) | |
527de3dc | 4265 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4266 | |
4267 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4268 | * this | |
4269 | * any unnumbered peer in order to not worry about run-time | |
4270 | * transitions | |
4271 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4272 | * address | |
4273 | * gets deleted later etc.) | |
4274 | */ | |
4275 | if (peer->ifp) | |
4276 | bgp_zebra_initiate_radv(bgp, peer); | |
4277 | } | |
4278 | ||
4279 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4280 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4281 | if (v6only) | |
527de3dc | 4282 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4283 | else |
527de3dc | 4284 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4285 | |
4286 | /* v6only flag changed. Reset bgp seesion */ | |
4287 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4288 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4289 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4290 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4291 | } else | |
4292 | bgp_session_reset(peer); | |
4293 | } | |
4294 | ||
9fb964de PM |
4295 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4296 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4297 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4298 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4299 | } |
d62a17ae | 4300 | |
4301 | if (peer_group_name) { | |
4302 | group = peer_group_lookup(bgp, peer_group_name); | |
4303 | if (!group) { | |
28c6e247 IR |
4304 | vty_out(vty, "%% Configure the peer-group first\n"); |
4305 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4306 | } |
4307 | ||
8395c1f8 | 4308 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4309 | } |
4310 | ||
28c6e247 | 4311 | return bgp_vty_return(vty, ret); |
a80beece DS |
4312 | } |
4313 | ||
28c6e247 IR |
4314 | DEFUN (neighbor_interface_config, |
4315 | neighbor_interface_config_cmd, | |
4316 | "neighbor WORD interface [peer-group PGNAME]", | |
4317 | NEIGHBOR_STR | |
4318 | "Interface name or neighbor tag\n" | |
4319 | "Enable BGP on interface\n" | |
4320 | "Member of the peer-group\n" | |
4321 | "Peer-group name\n") | |
4c48cf63 | 4322 | { |
d62a17ae | 4323 | int idx_word = 1; |
4324 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4325 | |
d62a17ae | 4326 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4327 | return peer_conf_interface_get( |
4328 | vty, argv[idx_word]->arg, 0, | |
4329 | argv[idx_peer_group_word]->arg, NULL); | |
4330 | else | |
4331 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4332 | NULL, NULL); | |
4c48cf63 DW |
4333 | } |
4334 | ||
28c6e247 IR |
4335 | DEFUN (neighbor_interface_config_v6only, |
4336 | neighbor_interface_config_v6only_cmd, | |
4337 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4338 | NEIGHBOR_STR | |
4339 | "Interface name or neighbor tag\n" | |
4340 | "Enable BGP on interface\n" | |
4341 | "Enable BGP with v6 link-local only\n" | |
4342 | "Member of the peer-group\n" | |
4343 | "Peer-group name\n") | |
4c48cf63 | 4344 | { |
d62a17ae | 4345 | int idx_word = 1; |
4346 | int idx_peer_group_word = 5; | |
31500417 | 4347 | |
d62a17ae | 4348 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4349 | return peer_conf_interface_get( |
4350 | vty, argv[idx_word]->arg, 1, | |
4351 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4352 | |
28c6e247 | 4353 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4354 | } |
4355 | ||
a80beece | 4356 | |
28c6e247 IR |
4357 | DEFUN (neighbor_interface_config_remote_as, |
4358 | neighbor_interface_config_remote_as_cmd, | |
4359 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4360 | NEIGHBOR_STR | |
4361 | "Interface name or neighbor tag\n" | |
4362 | "Enable BGP on interface\n" | |
4363 | "Specify a BGP neighbor\n" | |
4364 | AS_STR | |
4365 | "Internal BGP peer\n" | |
4366 | "External BGP peer\n") | |
b3a39dc5 | 4367 | { |
d62a17ae | 4368 | int idx_word = 1; |
4369 | int idx_remote_as = 4; | |
28c6e247 IR |
4370 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4371 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4372 | } |
4373 | ||
28c6e247 IR |
4374 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4375 | neighbor_interface_v6only_config_remote_as_cmd, | |
4376 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4377 | NEIGHBOR_STR | |
4378 | "Interface name or neighbor tag\n" | |
4379 | "Enable BGP with v6 link-local only\n" | |
4380 | "Enable BGP on interface\n" | |
4381 | "Specify a BGP neighbor\n" | |
4382 | AS_STR | |
4383 | "Internal BGP peer\n" | |
4384 | "External BGP peer\n") | |
b3a39dc5 | 4385 | { |
d62a17ae | 4386 | int idx_word = 1; |
4387 | int idx_remote_as = 5; | |
28c6e247 IR |
4388 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4389 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4390 | } |
4391 | ||
28c6e247 IR |
4392 | DEFUN (neighbor_peer_group, |
4393 | neighbor_peer_group_cmd, | |
4394 | "neighbor WORD peer-group", | |
4395 | NEIGHBOR_STR | |
4396 | "Interface name or neighbor tag\n" | |
4397 | "Configure peer-group\n") | |
718e3744 | 4398 | { |
28c6e247 | 4399 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4400 | int idx_word = 1; |
28c6e247 IR |
4401 | struct peer *peer; |
4402 | struct peer_group *group; | |
718e3744 | 4403 | |
28c6e247 IR |
4404 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4405 | if (peer) { | |
4406 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4407 | return CMD_WARNING_CONFIG_FAILED; | |
4408 | } | |
718e3744 | 4409 | |
28c6e247 IR |
4410 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4411 | if (!group) { | |
4412 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4413 | return CMD_WARNING_CONFIG_FAILED; | |
4414 | } | |
718e3744 | 4415 | |
28c6e247 | 4416 | return CMD_SUCCESS; |
718e3744 | 4417 | } |
4418 | ||
1d80f243 IR |
4419 | DEFUN (no_neighbor, |
4420 | no_neighbor_cmd, | |
4421 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4422 | NO_STR | |
4423 | NEIGHBOR_STR | |
4424 | NEIGHBOR_ADDR_STR2 | |
4425 | "Specify a BGP neighbor\n" | |
4426 | AS_STR | |
4427 | "Internal BGP peer\n" | |
4428 | "External BGP peer\n") | |
718e3744 | 4429 | { |
28c6e247 | 4430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4431 | int idx_peer = 2; |
28c6e247 | 4432 | int ret; |
d62a17ae | 4433 | union sockunion su; |
28c6e247 IR |
4434 | struct peer_group *group; |
4435 | struct peer *peer; | |
4436 | struct peer *other; | |
d62a17ae | 4437 | |
28c6e247 IR |
4438 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4439 | if (ret < 0) { | |
4440 | /* look up for neighbor by interface name config. */ | |
4441 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4442 | if (peer) { | |
4443 | /* Request zebra to terminate IPv6 RAs on this | |
4444 | * interface. */ | |
4445 | if (peer->ifp) | |
4446 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4447 | peer_notify_unconfig(peer); | |
4448 | peer_delete(peer); | |
4449 | return CMD_SUCCESS; | |
d62a17ae | 4450 | } |
28c6e247 IR |
4451 | |
4452 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4453 | if (group) { | |
4454 | peer_group_notify_unconfig(group); | |
4455 | peer_group_delete(group); | |
4e2786df | 4456 | } else { |
28c6e247 | 4457 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4458 | return CMD_WARNING_CONFIG_FAILED; |
4459 | } | |
28c6e247 IR |
4460 | } else { |
4461 | peer = peer_lookup(bgp, &su); | |
4462 | if (peer) { | |
4463 | if (peer_dynamic_neighbor(peer)) { | |
4464 | vty_out(vty, | |
4465 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4466 | return CMD_WARNING_CONFIG_FAILED; | |
4467 | } | |
d62a17ae | 4468 | |
28c6e247 | 4469 | other = peer->doppelganger; |
f4b8ec07 | 4470 | |
28c6e247 IR |
4471 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4472 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4473 | |
28c6e247 IR |
4474 | peer_notify_unconfig(peer); |
4475 | peer_delete(peer); | |
4476 | if (other && other->status != Deleted) { | |
4477 | peer_notify_unconfig(other); | |
4478 | peer_delete(other); | |
4479 | } | |
4480 | } | |
4481 | } | |
4482 | ||
4483 | return CMD_SUCCESS; | |
a80beece DS |
4484 | } |
4485 | ||
28c6e247 IR |
4486 | DEFUN (no_neighbor_interface_config, |
4487 | no_neighbor_interface_config_cmd, | |
4488 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4489 | NO_STR | |
4490 | NEIGHBOR_STR | |
4491 | "Interface name\n" | |
4492 | "Configure BGP on interface\n" | |
4493 | "Enable BGP with v6 link-local only\n" | |
4494 | "Member of the peer-group\n" | |
4495 | "Peer-group name\n" | |
4496 | "Specify a BGP neighbor\n" | |
4497 | AS_STR | |
4498 | "Internal BGP peer\n" | |
4499 | "External BGP peer\n") | |
718e3744 | 4500 | { |
28c6e247 | 4501 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4502 | int idx_word = 2; |
28c6e247 | 4503 | struct peer *peer; |
718e3744 | 4504 | |
28c6e247 IR |
4505 | /* look up for neighbor by interface name config. */ |
4506 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4507 | if (peer) { | |
4508 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4509 | if (peer->ifp) | |
4510 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4511 | peer_notify_unconfig(peer); | |
4512 | peer_delete(peer); | |
4513 | } else { | |
4514 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4515 | return CMD_WARNING_CONFIG_FAILED; | |
4516 | } | |
4517 | return CMD_SUCCESS; | |
718e3744 | 4518 | } |
4519 | ||
28c6e247 IR |
4520 | DEFUN (no_neighbor_peer_group, |
4521 | no_neighbor_peer_group_cmd, | |
4522 | "no neighbor WORD peer-group", | |
4523 | NO_STR | |
4524 | NEIGHBOR_STR | |
4525 | "Neighbor tag\n" | |
4526 | "Configure peer-group\n") | |
718e3744 | 4527 | { |
28c6e247 IR |
4528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4529 | int idx_word = 2; | |
4530 | struct peer_group *group; | |
f4b8ec07 | 4531 | |
28c6e247 IR |
4532 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4533 | if (group) { | |
4534 | peer_group_notify_unconfig(group); | |
4535 | peer_group_delete(group); | |
f4b8ec07 | 4536 | } else { |
28c6e247 | 4537 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4538 | return CMD_WARNING_CONFIG_FAILED; |
4539 | } | |
28c6e247 IR |
4540 | return CMD_SUCCESS; |
4541 | } | |
f4b8ec07 | 4542 | |
28c6e247 IR |
4543 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4544 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4545 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4546 | NO_STR | |
4547 | NEIGHBOR_STR | |
4548 | "Interface name or neighbor tag\n" | |
4549 | "Specify a BGP neighbor\n" | |
4550 | AS_STR | |
4551 | "Internal BGP peer\n" | |
4552 | "External BGP peer\n") | |
4553 | { | |
4554 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4555 | int idx_word = 2; | |
4556 | struct peer_group *group; | |
4557 | struct peer *peer; | |
f4b8ec07 | 4558 | |
28c6e247 IR |
4559 | /* look up for neighbor by interface name config. */ |
4560 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4561 | if (peer) { | |
4562 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4563 | return CMD_SUCCESS; | |
4564 | } | |
f4b8ec07 | 4565 | |
28c6e247 IR |
4566 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4567 | if (group) | |
4568 | peer_group_remote_as_delete(group); | |
4569 | else { | |
4570 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4571 | return CMD_WARNING_CONFIG_FAILED; | |
4572 | } | |
4573 | return CMD_SUCCESS; | |
718e3744 | 4574 | } |
6b0655a2 | 4575 | |
28c6e247 IR |
4576 | DEFUN (neighbor_local_as, |
4577 | neighbor_local_as_cmd, | |
4578 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4579 | NEIGHBOR_STR | |
4580 | NEIGHBOR_ADDR_STR2 | |
4581 | "Specify a local-as number\n" | |
4582 | "AS number used as local AS\n") | |
718e3744 | 4583 | { |
d62a17ae | 4584 | int idx_peer = 1; |
4585 | int idx_number = 3; | |
28c6e247 IR |
4586 | struct peer *peer; |
4587 | int ret; | |
4588 | as_t as; | |
718e3744 | 4589 | |
28c6e247 IR |
4590 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4591 | if (!peer) | |
d62a17ae | 4592 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4593 | |
28c6e247 IR |
4594 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4595 | ret = peer_local_as_set(peer, as, 0, 0); | |
4596 | return bgp_vty_return(vty, ret); | |
718e3744 | 4597 | } |
4598 | ||
28c6e247 IR |
4599 | DEFUN (neighbor_local_as_no_prepend, |
4600 | neighbor_local_as_no_prepend_cmd, | |
4601 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4602 | NEIGHBOR_STR | |
4603 | NEIGHBOR_ADDR_STR2 | |
4604 | "Specify a local-as number\n" | |
4605 | "AS number used as local AS\n" | |
4606 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4607 | { |
d62a17ae | 4608 | int idx_peer = 1; |
4609 | int idx_number = 3; | |
28c6e247 IR |
4610 | struct peer *peer; |
4611 | int ret; | |
4612 | as_t as; | |
718e3744 | 4613 | |
28c6e247 IR |
4614 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4615 | if (!peer) | |
d62a17ae | 4616 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4617 | |
28c6e247 IR |
4618 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4619 | ret = peer_local_as_set(peer, as, 1, 0); | |
4620 | return bgp_vty_return(vty, ret); | |
718e3744 | 4621 | } |
4622 | ||
28c6e247 IR |
4623 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4624 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4625 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4626 | NEIGHBOR_STR | |
4627 | NEIGHBOR_ADDR_STR2 | |
4628 | "Specify a local-as number\n" | |
4629 | "AS number used as local AS\n" | |
4630 | "Do not prepend local-as to updates from ebgp peers\n" | |
4631 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4632 | { |
d62a17ae | 4633 | int idx_peer = 1; |
4634 | int idx_number = 3; | |
28c6e247 IR |
4635 | struct peer *peer; |
4636 | int ret; | |
4637 | as_t as; | |
9d3f9705 | 4638 | |
28c6e247 IR |
4639 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4640 | if (!peer) | |
d62a17ae | 4641 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4642 | |
28c6e247 IR |
4643 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4644 | ret = peer_local_as_set(peer, as, 1, 1); | |
4645 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4646 | } |
4647 | ||
28c6e247 IR |
4648 | DEFUN (no_neighbor_local_as, |
4649 | no_neighbor_local_as_cmd, | |
4650 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4651 | NO_STR | |
4652 | NEIGHBOR_STR | |
4653 | NEIGHBOR_ADDR_STR2 | |
4654 | "Specify a local-as number\n" | |
4655 | "AS number used as local AS\n" | |
4656 | "Do not prepend local-as to updates from ebgp peers\n" | |
4657 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4658 | { |
d62a17ae | 4659 | int idx_peer = 2; |
28c6e247 IR |
4660 | struct peer *peer; |
4661 | int ret; | |
718e3744 | 4662 | |
28c6e247 IR |
4663 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4664 | if (!peer) | |
d62a17ae | 4665 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4666 | |
28c6e247 IR |
4667 | ret = peer_local_as_unset(peer); |
4668 | return bgp_vty_return(vty, ret); | |
718e3744 | 4669 | } |
4670 | ||
718e3744 | 4671 | |
3f9c7369 DS |
4672 | DEFUN (neighbor_solo, |
4673 | neighbor_solo_cmd, | |
9ccf14f7 | 4674 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4675 | NEIGHBOR_STR |
4676 | NEIGHBOR_ADDR_STR2 | |
4677 | "Solo peer - part of its own update group\n") | |
4678 | { | |
d62a17ae | 4679 | int idx_peer = 1; |
4680 | struct peer *peer; | |
4681 | int ret; | |
3f9c7369 | 4682 | |
d62a17ae | 4683 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4684 | if (!peer) | |
4685 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4686 | |
d62a17ae | 4687 | ret = update_group_adjust_soloness(peer, 1); |
4688 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4689 | } |
4690 | ||
4691 | DEFUN (no_neighbor_solo, | |
4692 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4693 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4694 | NO_STR |
4695 | NEIGHBOR_STR | |
4696 | NEIGHBOR_ADDR_STR2 | |
4697 | "Solo peer - part of its own update group\n") | |
4698 | { | |
d62a17ae | 4699 | int idx_peer = 2; |
4700 | struct peer *peer; | |
4701 | int ret; | |
3f9c7369 | 4702 | |
d62a17ae | 4703 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4704 | if (!peer) | |
4705 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4706 | |
d62a17ae | 4707 | ret = update_group_adjust_soloness(peer, 0); |
4708 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4709 | } |
4710 | ||
28c6e247 IR |
4711 | DEFUN (neighbor_password, |
4712 | neighbor_password_cmd, | |
4713 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4714 | NEIGHBOR_STR | |
4715 | NEIGHBOR_ADDR_STR2 | |
4716 | "Set a password\n" | |
4717 | "The password\n") | |
0df7c91f | 4718 | { |
d62a17ae | 4719 | int idx_peer = 1; |
4720 | int idx_line = 3; | |
28c6e247 IR |
4721 | struct peer *peer; |
4722 | int ret; | |
0df7c91f | 4723 | |
28c6e247 IR |
4724 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4725 | if (!peer) | |
d62a17ae | 4726 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4727 | |
28c6e247 IR |
4728 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4729 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4730 | } |
4731 | ||
28c6e247 IR |
4732 | DEFUN (no_neighbor_password, |
4733 | no_neighbor_password_cmd, | |
4734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4735 | NO_STR | |
4736 | NEIGHBOR_STR | |
4737 | NEIGHBOR_ADDR_STR2 | |
4738 | "Set a password\n" | |
4739 | "The password\n") | |
0df7c91f | 4740 | { |
d62a17ae | 4741 | int idx_peer = 2; |
28c6e247 IR |
4742 | struct peer *peer; |
4743 | int ret; | |
0df7c91f | 4744 | |
28c6e247 IR |
4745 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4746 | if (!peer) | |
d62a17ae | 4747 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4748 | |
28c6e247 IR |
4749 | ret = peer_password_unset(peer); |
4750 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4751 | } |
6b0655a2 | 4752 | |
28c6e247 IR |
4753 | DEFUN (neighbor_activate, |
4754 | neighbor_activate_cmd, | |
4755 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4756 | NEIGHBOR_STR | |
4757 | NEIGHBOR_ADDR_STR2 | |
4758 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4759 | { |
d62a17ae | 4760 | int idx_peer = 1; |
28c6e247 IR |
4761 | int ret; |
4762 | struct peer *peer; | |
56ceae84 | 4763 | |
28c6e247 IR |
4764 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4765 | if (!peer) | |
d62a17ae | 4766 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4767 | |
28c6e247 IR |
4768 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4769 | return bgp_vty_return(vty, ret); | |
718e3744 | 4770 | } |
4771 | ||
d62a17ae | 4772 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4773 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4774 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4775 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4776 | |
28c6e247 IR |
4777 | DEFUN (no_neighbor_activate, |
4778 | no_neighbor_activate_cmd, | |
4779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4780 | NO_STR | |
4781 | NEIGHBOR_STR | |
4782 | NEIGHBOR_ADDR_STR2 | |
4783 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4784 | { |
d62a17ae | 4785 | int idx_peer = 2; |
28c6e247 IR |
4786 | int ret; |
4787 | struct peer *peer; | |
f4b8ec07 | 4788 | |
28c6e247 IR |
4789 | /* Lookup peer. */ |
4790 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4791 | if (!peer) | |
d62a17ae | 4792 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4793 | |
28c6e247 IR |
4794 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4795 | return bgp_vty_return(vty, ret); | |
718e3744 | 4796 | } |
6b0655a2 | 4797 | |
d62a17ae | 4798 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4800 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4801 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4802 | |
28c6e247 IR |
4803 | DEFUN (neighbor_set_peer_group, |
4804 | neighbor_set_peer_group_cmd, | |
4805 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4806 | NEIGHBOR_STR | |
4807 | NEIGHBOR_ADDR_STR2 | |
4808 | "Member of the peer-group\n" | |
4809 | "Peer-group name\n") | |
718e3744 | 4810 | { |
28c6e247 | 4811 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4812 | int idx_peer = 1; |
4813 | int idx_word = 3; | |
28c6e247 IR |
4814 | int ret; |
4815 | as_t as; | |
4816 | union sockunion su; | |
4817 | struct peer *peer; | |
4818 | struct peer_group *group; | |
4819 | ||
4820 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4821 | if (ret < 0) { | |
4822 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4823 | if (!peer) { | |
4824 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4825 | argv[idx_peer]->arg); | |
4826 | return CMD_WARNING_CONFIG_FAILED; | |
4827 | } | |
4828 | } else { | |
4829 | if (peer_address_self_check(bgp, &su)) { | |
4830 | vty_out(vty, | |
4831 | "%% Can not configure the local system as neighbor\n"); | |
4832 | return CMD_WARNING_CONFIG_FAILED; | |
4833 | } | |
2a059a54 | 4834 | |
28c6e247 IR |
4835 | /* Disallow for dynamic neighbor. */ |
4836 | peer = peer_lookup(bgp, &su); | |
4837 | if (peer && peer_dynamic_neighbor(peer)) { | |
4838 | vty_out(vty, | |
4839 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4840 | return CMD_WARNING_CONFIG_FAILED; | |
4841 | } | |
4842 | } | |
4843 | ||
4844 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4845 | if (!group) { | |
4846 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 4847 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 4848 | } |
d62a17ae | 4849 | |
28c6e247 | 4850 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 4851 | |
28c6e247 IR |
4852 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
4853 | vty_out(vty, | |
4854 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4855 | as); | |
4856 | return CMD_WARNING_CONFIG_FAILED; | |
4857 | } | |
4858 | ||
4859 | return bgp_vty_return(vty, ret); | |
d62a17ae | 4860 | } |
4861 | ||
4862 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4863 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4864 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4865 | "Member of the peer-group\n" | |
4866 | "Peer-group name\n") | |
596c17ba | 4867 | |
28c6e247 IR |
4868 | DEFUN (no_neighbor_set_peer_group, |
4869 | no_neighbor_set_peer_group_cmd, | |
4870 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4871 | NO_STR | |
4872 | NEIGHBOR_STR | |
4873 | NEIGHBOR_ADDR_STR2 | |
4874 | "Member of the peer-group\n" | |
4875 | "Peer-group name\n") | |
718e3744 | 4876 | { |
28c6e247 | 4877 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4878 | int idx_peer = 2; |
28c6e247 IR |
4879 | int idx_word = 4; |
4880 | int ret; | |
4881 | struct peer *peer; | |
4882 | struct peer_group *group; | |
d62a17ae | 4883 | |
28c6e247 IR |
4884 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
4885 | if (!peer) | |
d62a17ae | 4886 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4887 | |
28c6e247 IR |
4888 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4889 | if (!group) { | |
4890 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4891 | return CMD_WARNING_CONFIG_FAILED; | |
4892 | } | |
718e3744 | 4893 | |
28c6e247 IR |
4894 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4895 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4896 | ||
4897 | peer_notify_unconfig(peer); | |
4898 | ret = peer_delete(peer); | |
4899 | ||
4900 | return bgp_vty_return(vty, ret); | |
718e3744 | 4901 | } |
6b0655a2 | 4902 | |
d62a17ae | 4903 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 4904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4905 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4906 | "Member of the peer-group\n" | |
4907 | "Peer-group name\n") | |
596c17ba | 4908 | |
d62a17ae | 4909 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4910 | uint32_t flag, int set) |
718e3744 | 4911 | { |
d62a17ae | 4912 | int ret; |
4913 | struct peer *peer; | |
718e3744 | 4914 | |
d62a17ae | 4915 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4916 | if (!peer) | |
4917 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4918 | |
7ebe625c QY |
4919 | /* |
4920 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4921 | * we should not accept disable-connected-check. | |
4922 | */ | |
4923 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4924 | vty_out(vty, | |
3efd0893 | 4925 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4926 | ip_str); |
4927 | return CMD_WARNING_CONFIG_FAILED; | |
4928 | } | |
4929 | ||
d62a17ae | 4930 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4931 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4932 | |
d62a17ae | 4933 | if (set) |
4934 | ret = peer_flag_set(peer, flag); | |
4935 | else | |
4936 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4937 | |
d62a17ae | 4938 | return bgp_vty_return(vty, ret); |
718e3744 | 4939 | } |
4940 | ||
47cbc09b | 4941 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4942 | { |
d62a17ae | 4943 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4944 | } |
4945 | ||
d62a17ae | 4946 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4947 | uint32_t flag) |
718e3744 | 4948 | { |
d62a17ae | 4949 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4950 | } |
4951 | ||
4952 | /* neighbor passive. */ | |
28c6e247 IR |
4953 | DEFUN (neighbor_passive, |
4954 | neighbor_passive_cmd, | |
4955 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
4956 | NEIGHBOR_STR | |
4957 | NEIGHBOR_ADDR_STR2 | |
4958 | "Don't send open messages to this neighbor\n") | |
718e3744 | 4959 | { |
d62a17ae | 4960 | int idx_peer = 1; |
28c6e247 | 4961 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 4962 | } |
4963 | ||
28c6e247 IR |
4964 | DEFUN (no_neighbor_passive, |
4965 | no_neighbor_passive_cmd, | |
4966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
4967 | NO_STR | |
4968 | NEIGHBOR_STR | |
4969 | NEIGHBOR_ADDR_STR2 | |
4970 | "Don't send open messages to this neighbor\n") | |
718e3744 | 4971 | { |
d62a17ae | 4972 | int idx_peer = 2; |
28c6e247 | 4973 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 4974 | } |
6b0655a2 | 4975 | |
718e3744 | 4976 | /* neighbor shutdown. */ |
28c6e247 IR |
4977 | DEFUN (neighbor_shutdown_msg, |
4978 | neighbor_shutdown_msg_cmd, | |
4979 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4980 | NEIGHBOR_STR | |
4981 | NEIGHBOR_ADDR_STR2 | |
4982 | "Administratively shut down this neighbor\n" | |
4983 | "Add a shutdown message (RFC 8203)\n" | |
4984 | "Shutdown message\n") | |
718e3744 | 4985 | { |
d62a17ae | 4986 | int idx_peer = 1; |
73d70fa6 | 4987 | |
d62a17ae | 4988 | if (argc >= 5) { |
28c6e247 IR |
4989 | struct peer *peer = |
4990 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 4991 | char *message; |
73d70fa6 | 4992 | |
28c6e247 IR |
4993 | if (!peer) |
4994 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4995 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
4996 | peer_tx_shutdown_message_set(peer, message); |
4997 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 4998 | } |
73d70fa6 | 4999 | |
28c6e247 | 5000 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5001 | } |
5002 | ||
1d80f243 | 5003 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5004 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5005 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5006 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5007 | |
28c6e247 IR |
5008 | DEFUN (no_neighbor_shutdown_msg, |
5009 | no_neighbor_shutdown_msg_cmd, | |
5010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5011 | NO_STR | |
5012 | NEIGHBOR_STR | |
5013 | NEIGHBOR_ADDR_STR2 | |
5014 | "Administratively shut down this neighbor\n" | |
5015 | "Remove a shutdown message (RFC 8203)\n" | |
5016 | "Shutdown message\n") | |
718e3744 | 5017 | { |
d62a17ae | 5018 | int idx_peer = 2; |
73d70fa6 | 5019 | |
28c6e247 IR |
5020 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5021 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5022 | } |
6b0655a2 | 5023 | |
1d80f243 | 5024 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5025 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5026 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5027 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5028 | |
8336c896 DA |
5029 | DEFUN(neighbor_shutdown_rtt, |
5030 | neighbor_shutdown_rtt_cmd, | |
5031 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5032 | NEIGHBOR_STR | |
5033 | NEIGHBOR_ADDR_STR2 | |
5034 | "Administratively shut down this neighbor\n" | |
5035 | "Shutdown if round-trip-time is higher than expected\n" | |
5036 | "Round-trip-time in milliseconds\n" | |
5037 | "Specify the number of keepalives before shutdown\n" | |
5038 | "The number of keepalives with higher RTT to shutdown\n") | |
5039 | { | |
5040 | int idx_peer = 1; | |
5041 | int idx_rtt = 4; | |
5042 | int idx_count = 0; | |
5043 | struct peer *peer; | |
5044 | ||
5045 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5046 | ||
5047 | if (!peer) | |
5048 | return CMD_WARNING_CONFIG_FAILED; | |
5049 | ||
5050 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5051 | ||
5052 | if (argv_find(argv, argc, "count", &idx_count)) | |
5053 | peer->rtt_keepalive_conf = | |
5054 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5055 | ||
5056 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5057 | PEER_FLAG_RTT_SHUTDOWN); | |
5058 | } | |
5059 | ||
5060 | DEFUN(no_neighbor_shutdown_rtt, | |
5061 | no_neighbor_shutdown_rtt_cmd, | |
5062 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5063 | NO_STR | |
5064 | NEIGHBOR_STR | |
5065 | NEIGHBOR_ADDR_STR2 | |
5066 | "Administratively shut down this neighbor\n" | |
5067 | "Shutdown if round-trip-time is higher than expected\n" | |
5068 | "Round-trip-time in milliseconds\n" | |
5069 | "Specify the number of keepalives before shutdown\n" | |
5070 | "The number of keepalives with higher RTT to shutdown\n") | |
5071 | { | |
5072 | int idx_peer = 2; | |
5073 | struct peer *peer; | |
5074 | ||
5075 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5076 | ||
5077 | if (!peer) | |
5078 | return CMD_WARNING_CONFIG_FAILED; | |
5079 | ||
5080 | peer->rtt_expected = 0; | |
5081 | peer->rtt_keepalive_conf = 1; | |
5082 | ||
5083 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5084 | PEER_FLAG_RTT_SHUTDOWN); | |
5085 | } | |
5086 | ||
718e3744 | 5087 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5088 | DEFUN (neighbor_capability_dynamic, |
5089 | neighbor_capability_dynamic_cmd, | |
5090 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5091 | NEIGHBOR_STR | |
5092 | NEIGHBOR_ADDR_STR2 | |
5093 | "Advertise capability to the peer\n" | |
5094 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5095 | { |
d62a17ae | 5096 | int idx_peer = 1; |
28c6e247 IR |
5097 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5098 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5099 | } |
5100 | ||
28c6e247 IR |
5101 | DEFUN (no_neighbor_capability_dynamic, |
5102 | no_neighbor_capability_dynamic_cmd, | |
5103 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5104 | NO_STR | |
5105 | NEIGHBOR_STR | |
5106 | NEIGHBOR_ADDR_STR2 | |
5107 | "Advertise capability to the peer\n" | |
5108 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5109 | { |
d62a17ae | 5110 | int idx_peer = 2; |
28c6e247 IR |
5111 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5112 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5113 | } |
6b0655a2 | 5114 | |
718e3744 | 5115 | /* neighbor dont-capability-negotiate */ |
5116 | DEFUN (neighbor_dont_capability_negotiate, | |
5117 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5118 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5119 | NEIGHBOR_STR |
5120 | NEIGHBOR_ADDR_STR2 | |
5121 | "Do not perform capability negotiation\n") | |
5122 | { | |
d62a17ae | 5123 | int idx_peer = 1; |
5124 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5125 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5126 | } |
5127 | ||
5128 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5129 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5131 | NO_STR |
5132 | NEIGHBOR_STR | |
5133 | NEIGHBOR_ADDR_STR2 | |
5134 | "Do not perform capability negotiation\n") | |
5135 | { | |
28c6e247 IR |
5136 | int idx_peer = 2; |
5137 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5138 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5139 | } |
5140 | ||
28c6e247 IR |
5141 | /* neighbor capability extended next hop encoding */ |
5142 | DEFUN (neighbor_capability_enhe, | |
5143 | neighbor_capability_enhe_cmd, | |
5144 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5145 | NEIGHBOR_STR | |
5146 | NEIGHBOR_ADDR_STR2 | |
5147 | "Advertise capability to the peer\n" | |
5148 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5149 | { |
28c6e247 IR |
5150 | int idx_peer = 1; |
5151 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5152 | PEER_FLAG_CAPABILITY_ENHE); | |
5153 | } | |
f4b8ec07 | 5154 | |
28c6e247 IR |
5155 | DEFUN (no_neighbor_capability_enhe, |
5156 | no_neighbor_capability_enhe_cmd, | |
5157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5158 | NO_STR | |
5159 | NEIGHBOR_STR | |
5160 | NEIGHBOR_ADDR_STR2 | |
5161 | "Advertise capability to the peer\n" | |
5162 | "Advertise extended next-hop capability to the peer\n") | |
5163 | { | |
5164 | int idx_peer = 2; | |
5165 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5166 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5167 | } |
5168 | ||
d62a17ae | 5169 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5170 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5171 | int set) |
718e3744 | 5172 | { |
d62a17ae | 5173 | int ret; |
5174 | struct peer *peer; | |
718e3744 | 5175 | |
d62a17ae | 5176 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5177 | if (!peer) | |
5178 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5179 | |
d62a17ae | 5180 | if (set) |
5181 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5182 | else | |
5183 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5184 | |
d62a17ae | 5185 | return bgp_vty_return(vty, ret); |
718e3744 | 5186 | } |
5187 | ||
d62a17ae | 5188 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5189 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5190 | { |
d62a17ae | 5191 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5192 | } |
5193 | ||
d62a17ae | 5194 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5195 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5196 | { |
d62a17ae | 5197 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5198 | } |
6b0655a2 | 5199 | |
718e3744 | 5200 | /* neighbor capability orf prefix-list. */ |
5201 | DEFUN (neighbor_capability_orf_prefix, | |
5202 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5203 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5204 | NEIGHBOR_STR |
5205 | NEIGHBOR_ADDR_STR2 | |
5206 | "Advertise capability to the peer\n" | |
5207 | "Advertise ORF capability to the peer\n" | |
5208 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5209 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5210 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5211 | "Capability to SEND the ORF to this neighbor\n") | |
5212 | { | |
d62a17ae | 5213 | int idx_send_recv = 5; |
db45f64d DS |
5214 | char *peer_str = argv[1]->arg; |
5215 | struct peer *peer; | |
5216 | afi_t afi = bgp_node_afi(vty); | |
5217 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5218 | |
db45f64d DS |
5219 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5220 | if (!peer) | |
d62a17ae | 5221 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5222 | |
db45f64d DS |
5223 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5224 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5225 | PEER_FLAG_ORF_PREFIX_SM); | |
5226 | ||
5227 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5228 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5229 | PEER_FLAG_ORF_PREFIX_RM); | |
5230 | ||
5231 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5232 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5233 | PEER_FLAG_ORF_PREFIX_SM) | |
5234 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5235 | PEER_FLAG_ORF_PREFIX_RM); | |
5236 | ||
5237 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5238 | } |
5239 | ||
5240 | ALIAS_HIDDEN( | |
5241 | neighbor_capability_orf_prefix, | |
5242 | neighbor_capability_orf_prefix_hidden_cmd, | |
5243 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5244 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5245 | "Advertise capability to the peer\n" | |
5246 | "Advertise ORF capability to the peer\n" | |
5247 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5248 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5249 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5250 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5251 | |
718e3744 | 5252 | DEFUN (no_neighbor_capability_orf_prefix, |
5253 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5255 | NO_STR |
5256 | NEIGHBOR_STR | |
5257 | NEIGHBOR_ADDR_STR2 | |
5258 | "Advertise capability to the peer\n" | |
5259 | "Advertise ORF capability to the peer\n" | |
5260 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5261 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5262 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5263 | "Capability to SEND the ORF to this neighbor\n") | |
5264 | { | |
d62a17ae | 5265 | int idx_send_recv = 6; |
db45f64d DS |
5266 | char *peer_str = argv[2]->arg; |
5267 | struct peer *peer; | |
5268 | afi_t afi = bgp_node_afi(vty); | |
5269 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5270 | |
db45f64d DS |
5271 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5272 | if (!peer) | |
d62a17ae | 5273 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5274 | |
db45f64d DS |
5275 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5276 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5277 | PEER_FLAG_ORF_PREFIX_SM); | |
5278 | ||
5279 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5280 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5281 | PEER_FLAG_ORF_PREFIX_RM); | |
5282 | ||
5283 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5284 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5285 | PEER_FLAG_ORF_PREFIX_SM) | |
5286 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5287 | PEER_FLAG_ORF_PREFIX_RM); | |
5288 | ||
5289 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5290 | } |
5291 | ||
5292 | ALIAS_HIDDEN( | |
5293 | no_neighbor_capability_orf_prefix, | |
5294 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5295 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5296 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5297 | "Advertise capability to the peer\n" | |
5298 | "Advertise ORF capability to the peer\n" | |
5299 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5300 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5301 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5302 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5303 | |
718e3744 | 5304 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5305 | DEFUN (neighbor_nexthop_self, |
5306 | neighbor_nexthop_self_cmd, | |
5307 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5308 | NEIGHBOR_STR | |
5309 | NEIGHBOR_ADDR_STR2 | |
5310 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5311 | { |
d62a17ae | 5312 | int idx_peer = 1; |
28c6e247 IR |
5313 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5314 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5315 | } |
9e7a53c1 | 5316 | |
d62a17ae | 5317 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5318 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5319 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5320 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5321 | |
f4b8ec07 | 5322 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5323 | DEFUN (neighbor_nexthop_self_force, |
5324 | neighbor_nexthop_self_force_cmd, | |
5325 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5326 | NEIGHBOR_STR | |
5327 | NEIGHBOR_ADDR_STR2 | |
5328 | "Disable the next hop calculation for this neighbor\n" | |
5329 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5330 | { |
5331 | int idx_peer = 1; | |
28c6e247 IR |
5332 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5333 | bgp_node_safi(vty), | |
5334 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5335 | } |
5336 | ||
d62a17ae | 5337 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5338 | neighbor_nexthop_self_force_hidden_cmd, | |
5339 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5340 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5341 | "Disable the next hop calculation for this neighbor\n" | |
5342 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5343 | |
1bc4e531 DA |
5344 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5345 | neighbor_nexthop_self_all_hidden_cmd, | |
5346 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5347 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5348 | "Disable the next hop calculation for this neighbor\n" | |
5349 | "Set the next hop to self for reflected routes\n") | |
5350 | ||
28c6e247 IR |
5351 | DEFUN (no_neighbor_nexthop_self, |
5352 | no_neighbor_nexthop_self_cmd, | |
5353 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5354 | NO_STR | |
5355 | NEIGHBOR_STR | |
5356 | NEIGHBOR_ADDR_STR2 | |
5357 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5358 | { |
d62a17ae | 5359 | int idx_peer = 2; |
28c6e247 IR |
5360 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5361 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5362 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5363 | } |
6b0655a2 | 5364 | |
d62a17ae | 5365 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5366 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5367 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5368 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5369 | |
28c6e247 IR |
5370 | DEFUN (no_neighbor_nexthop_self_force, |
5371 | no_neighbor_nexthop_self_force_cmd, | |
5372 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5373 | NO_STR | |
5374 | NEIGHBOR_STR | |
5375 | NEIGHBOR_ADDR_STR2 | |
5376 | "Disable the next hop calculation for this neighbor\n" | |
5377 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5378 | { |
d62a17ae | 5379 | int idx_peer = 2; |
28c6e247 IR |
5380 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5381 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5382 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5383 | } |
a538debe | 5384 | |
d62a17ae | 5385 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5386 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5387 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5388 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5389 | "Disable the next hop calculation for this neighbor\n" | |
5390 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5391 | |
1bc4e531 DA |
5392 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5393 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5394 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5395 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5396 | "Disable the next hop calculation for this neighbor\n" | |
5397 | "Set the next hop to self for reflected routes\n") | |
5398 | ||
c7122e14 | 5399 | /* neighbor as-override */ |
28c6e247 IR |
5400 | DEFUN (neighbor_as_override, |
5401 | neighbor_as_override_cmd, | |
5402 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5403 | NEIGHBOR_STR | |
5404 | NEIGHBOR_ADDR_STR2 | |
5405 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5406 | { |
d62a17ae | 5407 | int idx_peer = 1; |
28c6e247 IR |
5408 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5409 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5410 | } |
5411 | ||
d62a17ae | 5412 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5413 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5414 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5415 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5416 | |
28c6e247 IR |
5417 | DEFUN (no_neighbor_as_override, |
5418 | no_neighbor_as_override_cmd, | |
5419 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5420 | NO_STR | |
5421 | NEIGHBOR_STR | |
5422 | NEIGHBOR_ADDR_STR2 | |
5423 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5424 | { |
d62a17ae | 5425 | int idx_peer = 2; |
28c6e247 IR |
5426 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5427 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5428 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5429 | } |
5430 | ||
d62a17ae | 5431 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5433 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5434 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5435 | |
718e3744 | 5436 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5437 | DEFUN (neighbor_remove_private_as, |
5438 | neighbor_remove_private_as_cmd, | |
5439 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5440 | NEIGHBOR_STR | |
5441 | NEIGHBOR_ADDR_STR2 | |
5442 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5443 | { |
d62a17ae | 5444 | int idx_peer = 1; |
28c6e247 IR |
5445 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5446 | bgp_node_safi(vty), | |
5447 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5448 | } |
5449 | ||
d62a17ae | 5450 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5451 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5452 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5453 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5454 | |
28c6e247 IR |
5455 | DEFUN (neighbor_remove_private_as_all, |
5456 | neighbor_remove_private_as_all_cmd, | |
5457 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5458 | NEIGHBOR_STR | |
5459 | NEIGHBOR_ADDR_STR2 | |
5460 | "Remove private ASNs in outbound updates\n" | |
5461 | "Apply to all AS numbers\n") | |
5000f21c | 5462 | { |
d62a17ae | 5463 | int idx_peer = 1; |
28c6e247 IR |
5464 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5465 | bgp_node_safi(vty), | |
5466 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5467 | } |
5468 | ||
d62a17ae | 5469 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5470 | neighbor_remove_private_as_all_hidden_cmd, | |
5471 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5472 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5473 | "Remove private ASNs in outbound updates\n" | |
5474 | "Apply to all AS numbers") | |
596c17ba | 5475 | |
28c6e247 IR |
5476 | DEFUN (neighbor_remove_private_as_replace_as, |
5477 | neighbor_remove_private_as_replace_as_cmd, | |
5478 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5479 | NEIGHBOR_STR | |
5480 | NEIGHBOR_ADDR_STR2 | |
5481 | "Remove private ASNs in outbound updates\n" | |
5482 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5483 | { |
d62a17ae | 5484 | int idx_peer = 1; |
28c6e247 IR |
5485 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5486 | bgp_node_safi(vty), | |
5487 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5488 | } |
5489 | ||
d62a17ae | 5490 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5491 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5492 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5493 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5494 | "Remove private ASNs in outbound updates\n" | |
5495 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5496 | |
28c6e247 IR |
5497 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5498 | neighbor_remove_private_as_all_replace_as_cmd, | |
5499 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5500 | NEIGHBOR_STR | |
5501 | NEIGHBOR_ADDR_STR2 | |
5502 | "Remove private ASNs in outbound updates\n" | |
5503 | "Apply to all AS numbers\n" | |
5504 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5505 | { |
d62a17ae | 5506 | int idx_peer = 1; |
28c6e247 IR |
5507 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5508 | bgp_node_safi(vty), | |
5509 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5510 | } |
5511 | ||
d62a17ae | 5512 | ALIAS_HIDDEN( |
5513 | neighbor_remove_private_as_all_replace_as, | |
5514 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5515 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5516 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5517 | "Remove private ASNs in outbound updates\n" | |
5518 | "Apply to all AS numbers\n" | |
5519 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5520 | |
28c6e247 IR |
5521 | DEFUN (no_neighbor_remove_private_as, |
5522 | no_neighbor_remove_private_as_cmd, | |
5523 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5524 | NO_STR | |
5525 | NEIGHBOR_STR | |
5526 | NEIGHBOR_ADDR_STR2 | |
5527 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5528 | { |
d62a17ae | 5529 | int idx_peer = 2; |
28c6e247 IR |
5530 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5531 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5532 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5533 | } |
6b0655a2 | 5534 | |
d62a17ae | 5535 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5536 | no_neighbor_remove_private_as_hidden_cmd, | |
5537 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5538 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5539 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5540 | |
28c6e247 IR |
5541 | DEFUN (no_neighbor_remove_private_as_all, |
5542 | no_neighbor_remove_private_as_all_cmd, | |
5543 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5544 | NO_STR | |
5545 | NEIGHBOR_STR | |
5546 | NEIGHBOR_ADDR_STR2 | |
5547 | "Remove private ASNs in outbound updates\n" | |
5548 | "Apply to all AS numbers\n") | |
88b8ed8d | 5549 | { |
d62a17ae | 5550 | int idx_peer = 2; |
28c6e247 IR |
5551 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5552 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5553 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5554 | } |
5000f21c | 5555 | |
d62a17ae | 5556 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5557 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5558 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5559 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5560 | "Remove private ASNs in outbound updates\n" | |
5561 | "Apply to all AS numbers\n") | |
596c17ba | 5562 | |
28c6e247 IR |
5563 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5564 | no_neighbor_remove_private_as_replace_as_cmd, | |
5565 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5566 | NO_STR | |
5567 | NEIGHBOR_STR | |
5568 | NEIGHBOR_ADDR_STR2 | |
5569 | "Remove private ASNs in outbound updates\n" | |
5570 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5571 | { |
d62a17ae | 5572 | int idx_peer = 2; |
28c6e247 IR |
5573 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5574 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5575 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5576 | } |
5000f21c | 5577 | |
d62a17ae | 5578 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5579 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5580 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5581 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5582 | "Remove private ASNs in outbound updates\n" | |
5583 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5584 | |
28c6e247 IR |
5585 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5586 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5587 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5588 | NO_STR | |
5589 | NEIGHBOR_STR | |
5590 | NEIGHBOR_ADDR_STR2 | |
5591 | "Remove private ASNs in outbound updates\n" | |
5592 | "Apply to all AS numbers\n" | |
5593 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5594 | { |
d62a17ae | 5595 | int idx_peer = 2; |
28c6e247 IR |
5596 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5597 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5598 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5599 | } |
5000f21c | 5600 | |
d62a17ae | 5601 | ALIAS_HIDDEN( |
5602 | no_neighbor_remove_private_as_all_replace_as, | |
5603 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5604 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5605 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5606 | "Remove private ASNs in outbound updates\n" | |
5607 | "Apply to all AS numbers\n" | |
5608 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5609 | |
5000f21c | 5610 | |
718e3744 | 5611 | /* neighbor send-community. */ |
28c6e247 IR |
5612 | DEFUN (neighbor_send_community, |
5613 | neighbor_send_community_cmd, | |
5614 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5615 | NEIGHBOR_STR | |
5616 | NEIGHBOR_ADDR_STR2 | |
5617 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5618 | { |
d62a17ae | 5619 | int idx_peer = 1; |
27c05d4d | 5620 | |
f63d4054 IR |
5621 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5622 | bgp_node_safi(vty), | |
5623 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5624 | } |
5625 | ||
d62a17ae | 5626 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5627 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5628 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5629 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5630 | |
28c6e247 IR |
5631 | DEFUN (no_neighbor_send_community, |
5632 | no_neighbor_send_community_cmd, | |
5633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5634 | NO_STR | |
5635 | NEIGHBOR_STR | |
5636 | NEIGHBOR_ADDR_STR2 | |
5637 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5638 | { |
d62a17ae | 5639 | int idx_peer = 2; |
27c05d4d | 5640 | |
f63d4054 IR |
5641 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5642 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5643 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5644 | } |
6b0655a2 | 5645 | |
d62a17ae | 5646 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5647 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5648 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5649 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5650 | |
718e3744 | 5651 | /* neighbor send-community extended. */ |
28c6e247 IR |
5652 | DEFUN (neighbor_send_community_type, |
5653 | neighbor_send_community_type_cmd, | |
5654 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5655 | NEIGHBOR_STR | |
5656 | NEIGHBOR_ADDR_STR2 | |
5657 | "Send Community attribute to this neighbor\n" | |
5658 | "Send Standard and Extended Community attributes\n" | |
5659 | "Send Standard, Large and Extended Community attributes\n" | |
5660 | "Send Extended Community attributes\n" | |
5661 | "Send Standard Community attributes\n" | |
5662 | "Send Large Community attributes\n") | |
718e3744 | 5663 | { |
27c05d4d | 5664 | const char *type = argv[argc - 1]->text; |
db45f64d | 5665 | char *peer_str = argv[1]->arg; |
28c6e247 | 5666 | struct peer *peer; |
db45f64d | 5667 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 5668 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 5669 | |
28c6e247 IR |
5670 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5671 | if (!peer) | |
5672 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 5673 | |
28c6e247 IR |
5674 | if (strmatch(type, "standard")) |
5675 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5676 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5677 | |
28c6e247 IR |
5678 | if (strmatch(type, "extended")) |
5679 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5680 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5681 | |
28c6e247 IR |
5682 | if (strmatch(type, "large")) |
5683 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5684 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 5685 | |
28c6e247 IR |
5686 | if (strmatch(type, "both")) { |
5687 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5688 | PEER_FLAG_SEND_COMMUNITY) | |
5689 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5690 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5691 | } |
28c6e247 IR |
5692 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5693 | PEER_FLAG_SEND_COMMUNITY) | |
5694 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5695 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5696 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5697 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5698 | } |
5699 | ||
5700 | ALIAS_HIDDEN( | |
5701 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5703 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5704 | "Send Community attribute to this neighbor\n" | |
5705 | "Send Standard and Extended Community attributes\n" | |
5706 | "Send Standard, Large and Extended Community attributes\n" | |
5707 | "Send Extended Community attributes\n" | |
5708 | "Send Standard Community attributes\n" | |
5709 | "Send Large Community attributes\n") | |
596c17ba | 5710 | |
28c6e247 IR |
5711 | DEFUN (no_neighbor_send_community_type, |
5712 | no_neighbor_send_community_type_cmd, | |
5713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5714 | NO_STR | |
5715 | NEIGHBOR_STR | |
5716 | NEIGHBOR_ADDR_STR2 | |
5717 | "Send Community attribute to this neighbor\n" | |
5718 | "Send Standard and Extended Community attributes\n" | |
5719 | "Send Standard, Large and Extended Community attributes\n" | |
5720 | "Send Extended Community attributes\n" | |
5721 | "Send Standard Community attributes\n" | |
5722 | "Send Large Community attributes\n") | |
718e3744 | 5723 | { |
d62a17ae | 5724 | const char *type = argv[argc - 1]->text; |
db45f64d | 5725 | char *peer_str = argv[2]->arg; |
28c6e247 | 5726 | struct peer *peer; |
db45f64d DS |
5727 | afi_t afi = bgp_node_afi(vty); |
5728 | safi_t safi = bgp_node_safi(vty); | |
5729 | ||
28c6e247 IR |
5730 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5731 | if (!peer) | |
f4b8ec07 CS |
5732 | return CMD_WARNING_CONFIG_FAILED; |
5733 | ||
28c6e247 IR |
5734 | if (strmatch(type, "standard")) |
5735 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5736 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5737 | |
28c6e247 IR |
5738 | if (strmatch(type, "extended")) |
5739 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5740 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5741 | |
28c6e247 IR |
5742 | if (strmatch(type, "large")) |
5743 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5744 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
5745 | |
5746 | if (strmatch(type, "both")) { | |
db45f64d | 5747 | |
28c6e247 IR |
5748 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5749 | PEER_FLAG_SEND_COMMUNITY) | |
5750 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5751 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5752 | } |
5753 | ||
28c6e247 IR |
5754 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5755 | PEER_FLAG_SEND_COMMUNITY) | |
5756 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5757 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5758 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5759 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5760 | } |
5761 | ||
5762 | ALIAS_HIDDEN( | |
5763 | no_neighbor_send_community_type, | |
5764 | no_neighbor_send_community_type_hidden_cmd, | |
5765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5766 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5767 | "Send Community attribute to this neighbor\n" | |
5768 | "Send Standard and Extended Community attributes\n" | |
5769 | "Send Standard, Large and Extended Community attributes\n" | |
5770 | "Send Extended Community attributes\n" | |
5771 | "Send Standard Community attributes\n" | |
5772 | "Send Large Community attributes\n") | |
596c17ba | 5773 | |
718e3744 | 5774 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
5775 | DEFUN (neighbor_soft_reconfiguration, |
5776 | neighbor_soft_reconfiguration_cmd, | |
5777 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5778 | NEIGHBOR_STR | |
5779 | NEIGHBOR_ADDR_STR2 | |
5780 | "Per neighbor soft reconfiguration\n" | |
5781 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5782 | { |
d62a17ae | 5783 | int idx_peer = 1; |
28c6e247 IR |
5784 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5785 | bgp_node_safi(vty), | |
5786 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5787 | } |
5788 | ||
d62a17ae | 5789 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5790 | neighbor_soft_reconfiguration_hidden_cmd, | |
5791 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5792 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5793 | "Per neighbor soft reconfiguration\n" | |
5794 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5795 | |
28c6e247 IR |
5796 | DEFUN (no_neighbor_soft_reconfiguration, |
5797 | no_neighbor_soft_reconfiguration_cmd, | |
5798 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5799 | NO_STR | |
5800 | NEIGHBOR_STR | |
5801 | NEIGHBOR_ADDR_STR2 | |
5802 | "Per neighbor soft reconfiguration\n" | |
5803 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5804 | { |
d62a17ae | 5805 | int idx_peer = 2; |
28c6e247 IR |
5806 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5807 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5808 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5809 | } |
6b0655a2 | 5810 | |
d62a17ae | 5811 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5812 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5813 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5814 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5815 | "Per neighbor soft reconfiguration\n" | |
5816 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5817 | |
28c6e247 IR |
5818 | DEFUN (neighbor_route_reflector_client, |
5819 | neighbor_route_reflector_client_cmd, | |
5820 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5821 | NEIGHBOR_STR | |
5822 | NEIGHBOR_ADDR_STR2 | |
5823 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5824 | { |
d62a17ae | 5825 | int idx_peer = 1; |
28c6e247 | 5826 | struct peer *peer; |
718e3744 | 5827 | |
5828 | ||
28c6e247 IR |
5829 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5830 | if (!peer) | |
d62a17ae | 5831 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5832 | |
28c6e247 IR |
5833 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5834 | bgp_node_safi(vty), | |
5835 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5836 | } |
5837 | ||
d62a17ae | 5838 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5839 | neighbor_route_reflector_client_hidden_cmd, | |
5840 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5841 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5842 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5843 | |
28c6e247 IR |
5844 | DEFUN (no_neighbor_route_reflector_client, |
5845 | no_neighbor_route_reflector_client_cmd, | |
5846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5847 | NO_STR | |
5848 | NEIGHBOR_STR | |
5849 | NEIGHBOR_ADDR_STR2 | |
5850 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5851 | { |
d62a17ae | 5852 | int idx_peer = 2; |
28c6e247 IR |
5853 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5854 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5855 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5856 | } |
6b0655a2 | 5857 | |
d62a17ae | 5858 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5859 | no_neighbor_route_reflector_client_hidden_cmd, | |
5860 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5861 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5862 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5863 | |
718e3744 | 5864 | /* neighbor route-server-client. */ |
28c6e247 IR |
5865 | DEFUN (neighbor_route_server_client, |
5866 | neighbor_route_server_client_cmd, | |
5867 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5868 | NEIGHBOR_STR | |
5869 | NEIGHBOR_ADDR_STR2 | |
5870 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 5871 | { |
d62a17ae | 5872 | int idx_peer = 1; |
28c6e247 | 5873 | struct peer *peer; |
f4b8ec07 | 5874 | |
28c6e247 IR |
5875 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5876 | if (!peer) | |
d62a17ae | 5877 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
5878 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5879 | bgp_node_safi(vty), | |
5880 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5881 | } |
5882 | ||
d62a17ae | 5883 | ALIAS_HIDDEN(neighbor_route_server_client, |
5884 | neighbor_route_server_client_hidden_cmd, | |
5885 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5886 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5887 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5888 | |
28c6e247 IR |
5889 | DEFUN (no_neighbor_route_server_client, |
5890 | no_neighbor_route_server_client_cmd, | |
5891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5892 | NO_STR | |
5893 | NEIGHBOR_STR | |
5894 | NEIGHBOR_ADDR_STR2 | |
5895 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5896 | { |
d62a17ae | 5897 | int idx_peer = 2; |
28c6e247 IR |
5898 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5899 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5900 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5901 | } |
6b0655a2 | 5902 | |
d62a17ae | 5903 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5904 | no_neighbor_route_server_client_hidden_cmd, | |
5905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5906 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5907 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5908 | |
fee0f4c6 | 5909 | DEFUN (neighbor_nexthop_local_unchanged, |
5910 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5911 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5912 | NEIGHBOR_STR |
5913 | NEIGHBOR_ADDR_STR2 | |
5914 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5915 | "Leave link-local nexthop unchanged for this peer\n") | |
5916 | { | |
d62a17ae | 5917 | int idx_peer = 1; |
5918 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5919 | bgp_node_safi(vty), | |
5920 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5921 | } |
6b0655a2 | 5922 | |
fee0f4c6 | 5923 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5924 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5926 | NO_STR |
5927 | NEIGHBOR_STR | |
5928 | NEIGHBOR_ADDR_STR2 | |
5929 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5930 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5931 | { |
d62a17ae | 5932 | int idx_peer = 2; |
5933 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5934 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5935 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5936 | } |
6b0655a2 | 5937 | |
28c6e247 IR |
5938 | DEFUN (neighbor_attr_unchanged, |
5939 | neighbor_attr_unchanged_cmd, | |
5940 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5941 | NEIGHBOR_STR | |
5942 | NEIGHBOR_ADDR_STR2 | |
5943 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5944 | "As-path attribute\n" | |
5945 | "Nexthop attribute\n" | |
5946 | "Med attribute\n") | |
718e3744 | 5947 | { |
d62a17ae | 5948 | int idx = 0; |
8eeb0335 | 5949 | char *peer_str = argv[1]->arg; |
28c6e247 | 5950 | struct peer *peer; |
db45f64d DS |
5951 | bool aspath = false; |
5952 | bool nexthop = false; | |
5953 | bool med = false; | |
8eeb0335 DW |
5954 | afi_t afi = bgp_node_afi(vty); |
5955 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 5956 | int ret = 0; |
f4b8ec07 | 5957 | |
28c6e247 IR |
5958 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5959 | if (!peer) | |
8eeb0335 | 5960 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5961 | |
5962 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5963 | aspath = true; |
5964 | ||
d62a17ae | 5965 | idx = 0; |
5966 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5967 | nexthop = true; |
5968 | ||
d62a17ae | 5969 | idx = 0; |
5970 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5971 | med = true; |
d62a17ae | 5972 | |
8eeb0335 | 5973 | /* no flags means all of them! */ |
db45f64d | 5974 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
5975 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5976 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5977 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5978 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5979 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5980 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5981 | } else { |
28c6e247 IR |
5982 | if (!aspath) { |
5983 | if (peer_af_flag_check(peer, afi, safi, | |
5984 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5985 | ret |= peer_af_flag_unset_vty( | |
5986 | vty, peer_str, afi, safi, | |
5987 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5988 | } | |
5989 | } else | |
5990 | ret |= peer_af_flag_set_vty( | |
5991 | vty, peer_str, afi, safi, | |
5992 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5993 | ||
5994 | if (!nexthop) { | |
5995 | if (peer_af_flag_check(peer, afi, safi, | |
5996 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5997 | ret |= peer_af_flag_unset_vty( | |
5998 | vty, peer_str, afi, safi, | |
5999 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6000 | } | |
6001 | } else | |
6002 | ret |= peer_af_flag_set_vty( | |
6003 | vty, peer_str, afi, safi, | |
6004 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6005 | ||
6006 | if (!med) { | |
6007 | if (peer_af_flag_check(peer, afi, safi, | |
6008 | PEER_FLAG_MED_UNCHANGED)) { | |
6009 | ret |= peer_af_flag_unset_vty( | |
6010 | vty, peer_str, afi, safi, | |
6011 | PEER_FLAG_MED_UNCHANGED); | |
6012 | } | |
6013 | } else | |
6014 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6015 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6016 | } |
6017 | ||
28c6e247 | 6018 | return ret; |
d62a17ae | 6019 | } |
6020 | ||
6021 | ALIAS_HIDDEN( | |
6022 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6023 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6024 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6025 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6026 | "As-path attribute\n" | |
6027 | "Nexthop attribute\n" | |
6028 | "Med attribute\n") | |
596c17ba | 6029 | |
28c6e247 IR |
6030 | DEFUN (no_neighbor_attr_unchanged, |
6031 | no_neighbor_attr_unchanged_cmd, | |
6032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6033 | NO_STR | |
6034 | NEIGHBOR_STR | |
6035 | NEIGHBOR_ADDR_STR2 | |
6036 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6037 | "As-path attribute\n" | |
6038 | "Nexthop attribute\n" | |
6039 | "Med attribute\n") | |
718e3744 | 6040 | { |
d62a17ae | 6041 | int idx = 0; |
db45f64d | 6042 | char *peer_str = argv[2]->arg; |
28c6e247 | 6043 | struct peer *peer; |
db45f64d DS |
6044 | bool aspath = false; |
6045 | bool nexthop = false; | |
6046 | bool med = false; | |
6047 | afi_t afi = bgp_node_afi(vty); | |
6048 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6049 | int ret = 0; |
f4b8ec07 | 6050 | |
28c6e247 IR |
6051 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6052 | if (!peer) | |
db45f64d | 6053 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6054 | |
6055 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6056 | aspath = true; |
6057 | ||
d62a17ae | 6058 | idx = 0; |
6059 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6060 | nexthop = true; |
6061 | ||
d62a17ae | 6062 | idx = 0; |
6063 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6064 | med = true; |
d62a17ae | 6065 | |
28c6e247 IR |
6066 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6067 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6068 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6069 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6070 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6071 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6072 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6073 | |
6074 | if (aspath) | |
28c6e247 IR |
6075 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6076 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6077 | |
6078 | if (nexthop) | |
28c6e247 IR |
6079 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6080 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6081 | |
db45f64d | 6082 | if (med) |
28c6e247 IR |
6083 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6084 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6085 | |
28c6e247 | 6086 | return ret; |
d62a17ae | 6087 | } |
6088 | ||
6089 | ALIAS_HIDDEN( | |
6090 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6092 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6093 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6094 | "As-path attribute\n" | |
6095 | "Nexthop attribute\n" | |
6096 | "Med attribute\n") | |
718e3744 | 6097 | |
28c6e247 IR |
6098 | /* EBGP multihop configuration. */ |
6099 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6100 | const char *ttl_str) | |
718e3744 | 6101 | { |
28c6e247 IR |
6102 | struct peer *peer; |
6103 | unsigned int ttl; | |
718e3744 | 6104 | |
28c6e247 IR |
6105 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6106 | if (!peer) | |
d62a17ae | 6107 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6108 | |
28c6e247 IR |
6109 | if (peer->conf_if) |
6110 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6111 | ||
6112 | if (!ttl_str) | |
6113 | ttl = MAXTTL; | |
6114 | else | |
6115 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6116 | |
28c6e247 | 6117 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6118 | } |
6119 | ||
28c6e247 | 6120 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6121 | { |
28c6e247 | 6122 | struct peer *peer; |
718e3744 | 6123 | |
28c6e247 IR |
6124 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6125 | if (!peer) | |
d62a17ae | 6126 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6127 | |
28c6e247 | 6128 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6129 | } |
6130 | ||
28c6e247 IR |
6131 | /* neighbor ebgp-multihop. */ |
6132 | DEFUN (neighbor_ebgp_multihop, | |
6133 | neighbor_ebgp_multihop_cmd, | |
6134 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6135 | NEIGHBOR_STR | |
6136 | NEIGHBOR_ADDR_STR2 | |
6137 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6138 | { |
28c6e247 IR |
6139 | int idx_peer = 1; |
6140 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6141 | } | |
f4b8ec07 | 6142 | |
28c6e247 IR |
6143 | DEFUN (neighbor_ebgp_multihop_ttl, |
6144 | neighbor_ebgp_multihop_ttl_cmd, | |
6145 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6146 | NEIGHBOR_STR | |
6147 | NEIGHBOR_ADDR_STR2 | |
6148 | "Allow EBGP neighbors not on directly connected networks\n" | |
6149 | "maximum hop count\n") | |
6150 | { | |
6151 | int idx_peer = 1; | |
6152 | int idx_number = 3; | |
6153 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6154 | argv[idx_number]->arg); | |
6155 | } | |
f4b8ec07 | 6156 | |
28c6e247 IR |
6157 | DEFUN (no_neighbor_ebgp_multihop, |
6158 | no_neighbor_ebgp_multihop_cmd, | |
6159 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6160 | NO_STR | |
6161 | NEIGHBOR_STR | |
6162 | NEIGHBOR_ADDR_STR2 | |
6163 | "Allow EBGP neighbors not on directly connected networks\n" | |
6164 | "maximum hop count\n") | |
6165 | { | |
6166 | int idx_peer = 2; | |
6167 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6168 | } |
6169 | ||
6b0655a2 | 6170 | |
6ffd2079 | 6171 | /* disable-connected-check */ |
28c6e247 IR |
6172 | DEFUN (neighbor_disable_connected_check, |
6173 | neighbor_disable_connected_check_cmd, | |
6174 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6175 | NEIGHBOR_STR | |
6176 | NEIGHBOR_ADDR_STR2 | |
6177 | "one-hop away EBGP peer using loopback address\n" | |
6178 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6179 | { |
d62a17ae | 6180 | int idx_peer = 1; |
28c6e247 IR |
6181 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6182 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6183 | } |
6184 | ||
28c6e247 IR |
6185 | DEFUN (no_neighbor_disable_connected_check, |
6186 | no_neighbor_disable_connected_check_cmd, | |
6187 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6188 | NO_STR | |
6189 | NEIGHBOR_STR | |
6190 | NEIGHBOR_ADDR_STR2 | |
6191 | "one-hop away EBGP peer using loopback address\n" | |
6192 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6193 | { |
d62a17ae | 6194 | int idx_peer = 2; |
28c6e247 IR |
6195 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6196 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6197 | } |
6198 | ||
7ab294ea DA |
6199 | /* disable-link-bw-encoding-ieee */ |
6200 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6201 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6202 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6203 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6204 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6205 | { |
6206 | int idx_peer = 1; | |
6207 | ||
6208 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6209 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6210 | } | |
6211 | ||
7ab294ea DA |
6212 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6213 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6215 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6216 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6217 | { |
6218 | int idx_peer = 2; | |
6219 | ||
6220 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6221 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6222 | } | |
6223 | ||
47cbc09b PM |
6224 | |
6225 | /* enforce-first-as */ | |
28c6e247 IR |
6226 | DEFUN (neighbor_enforce_first_as, |
6227 | neighbor_enforce_first_as_cmd, | |
6228 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6229 | NEIGHBOR_STR | |
6230 | NEIGHBOR_ADDR_STR2 | |
6231 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6232 | { |
6233 | int idx_peer = 1; | |
f4b8ec07 | 6234 | |
28c6e247 IR |
6235 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6236 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6237 | } |
6238 | ||
28c6e247 IR |
6239 | DEFUN (no_neighbor_enforce_first_as, |
6240 | no_neighbor_enforce_first_as_cmd, | |
6241 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6242 | NO_STR | |
6243 | NEIGHBOR_STR | |
6244 | NEIGHBOR_ADDR_STR2 | |
6245 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6246 | { |
6247 | int idx_peer = 2; | |
f4b8ec07 | 6248 | |
28c6e247 IR |
6249 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6250 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6251 | } |
6252 | ||
6253 | ||
28c6e247 IR |
6254 | DEFUN (neighbor_description, |
6255 | neighbor_description_cmd, | |
6256 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6257 | NEIGHBOR_STR | |
6258 | NEIGHBOR_ADDR_STR2 | |
6259 | "Neighbor specific description\n" | |
6260 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6261 | { |
d62a17ae | 6262 | int idx_peer = 1; |
6263 | int idx_line = 3; | |
28c6e247 | 6264 | struct peer *peer; |
d62a17ae | 6265 | char *str; |
718e3744 | 6266 | |
28c6e247 IR |
6267 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6268 | if (!peer) | |
d62a17ae | 6269 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6270 | |
d62a17ae | 6271 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6272 | |
28c6e247 | 6273 | peer_description_set(peer, str); |
718e3744 | 6274 | |
d62a17ae | 6275 | XFREE(MTYPE_TMP, str); |
718e3744 | 6276 | |
28c6e247 | 6277 | return CMD_SUCCESS; |
718e3744 | 6278 | } |
6279 | ||
28c6e247 IR |
6280 | DEFUN (no_neighbor_description, |
6281 | no_neighbor_description_cmd, | |
6282 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6283 | NO_STR | |
6284 | NEIGHBOR_STR | |
6285 | NEIGHBOR_ADDR_STR2 | |
6286 | "Neighbor specific description\n") | |
718e3744 | 6287 | { |
d62a17ae | 6288 | int idx_peer = 2; |
28c6e247 | 6289 | struct peer *peer; |
f4b8ec07 | 6290 | |
28c6e247 IR |
6291 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6292 | if (!peer) | |
d62a17ae | 6293 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6294 | |
28c6e247 | 6295 | peer_description_unset(peer); |
718e3744 | 6296 | |
28c6e247 | 6297 | return CMD_SUCCESS; |
718e3744 | 6298 | } |
6299 | ||
1d80f243 | 6300 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6302 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6303 | "Neighbor specific description\n" | |
6304 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6305 | |
28c6e247 IR |
6306 | /* Neighbor update-source. */ |
6307 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6308 | const char *source_str) | |
6309 | { | |
6310 | struct peer *peer; | |
6311 | struct prefix p; | |
6312 | union sockunion su; | |
6313 | ||
6314 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6315 | if (!peer) | |
6316 | return CMD_WARNING_CONFIG_FAILED; | |
6317 | ||
6318 | if (peer->conf_if) | |
6319 | return CMD_WARNING; | |
6320 | ||
6321 | if (source_str) { | |
6322 | if (str2sockunion(source_str, &su) == 0) | |
6323 | peer_update_source_addr_set(peer, &su); | |
6324 | else { | |
6325 | if (str2prefix(source_str, &p)) { | |
6326 | vty_out(vty, | |
6327 | "%% Invalid update-source, remove prefix length \n"); | |
6328 | return CMD_WARNING_CONFIG_FAILED; | |
6329 | } else | |
6330 | peer_update_source_if_set(peer, source_str); | |
6331 | } | |
6332 | } else | |
6333 | peer_update_source_unset(peer); | |
6334 | ||
6335 | return CMD_SUCCESS; | |
6336 | } | |
6337 | ||
d62a17ae | 6338 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6339 | "IPv4 address\n" \ | |
6340 | "IPv6 address\n" \ | |
6341 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6342 | |
28c6e247 IR |
6343 | DEFUN (neighbor_update_source, |
6344 | neighbor_update_source_cmd, | |
6345 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6346 | NEIGHBOR_STR | |
6347 | NEIGHBOR_ADDR_STR2 | |
6348 | "Source of routing updates\n" | |
6349 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6350 | { |
d62a17ae | 6351 | int idx_peer = 1; |
6352 | int idx_peer_2 = 3; | |
28c6e247 | 6353 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6354 | argv[idx_peer_2]->arg); |
718e3744 | 6355 | } |
6356 | ||
28c6e247 IR |
6357 | DEFUN (no_neighbor_update_source, |
6358 | no_neighbor_update_source_cmd, | |
6359 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6360 | NO_STR | |
6361 | NEIGHBOR_STR | |
6362 | NEIGHBOR_ADDR_STR2 | |
6363 | "Source of routing updates\n" | |
6364 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6365 | { |
d62a17ae | 6366 | int idx_peer = 2; |
28c6e247 | 6367 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6368 | } |
6b0655a2 | 6369 | |
d62a17ae | 6370 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6371 | afi_t afi, safi_t safi, | |
6372 | const char *rmap, int set) | |
718e3744 | 6373 | { |
d62a17ae | 6374 | int ret; |
6375 | struct peer *peer; | |
80912664 | 6376 | struct route_map *route_map = NULL; |
718e3744 | 6377 | |
d62a17ae | 6378 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6379 | if (!peer) | |
6380 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6381 | |
1de27621 | 6382 | if (set) { |
80912664 DS |
6383 | if (rmap) |
6384 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6385 | ret = peer_default_originate_set(peer, afi, safi, |
6386 | rmap, route_map); | |
6387 | } else | |
d62a17ae | 6388 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6389 | |
d62a17ae | 6390 | return bgp_vty_return(vty, ret); |
718e3744 | 6391 | } |
6392 | ||
6393 | /* neighbor default-originate. */ | |
6394 | DEFUN (neighbor_default_originate, | |
6395 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6396 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6397 | NEIGHBOR_STR |
6398 | NEIGHBOR_ADDR_STR2 | |
6399 | "Originate default route to this neighbor\n") | |
6400 | { | |
d62a17ae | 6401 | int idx_peer = 1; |
6402 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6403 | bgp_node_afi(vty), | |
6404 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6405 | } |
6406 | ||
d62a17ae | 6407 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6408 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6409 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6410 | "Originate default route to this neighbor\n") | |
596c17ba | 6411 | |
718e3744 | 6412 | DEFUN (neighbor_default_originate_rmap, |
6413 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6414 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6415 | NEIGHBOR_STR |
6416 | NEIGHBOR_ADDR_STR2 | |
6417 | "Originate default route to this neighbor\n" | |
6418 | "Route-map to specify criteria to originate default\n" | |
6419 | "route-map name\n") | |
6420 | { | |
d62a17ae | 6421 | int idx_peer = 1; |
6422 | int idx_word = 4; | |
6423 | return peer_default_originate_set_vty( | |
6424 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6425 | argv[idx_word]->arg, 1); | |
718e3744 | 6426 | } |
6427 | ||
d62a17ae | 6428 | ALIAS_HIDDEN( |
6429 | neighbor_default_originate_rmap, | |
6430 | neighbor_default_originate_rmap_hidden_cmd, | |
6431 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6432 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6433 | "Originate default route to this neighbor\n" | |
6434 | "Route-map to specify criteria to originate default\n" | |
6435 | "route-map name\n") | |
596c17ba | 6436 | |
718e3744 | 6437 | DEFUN (no_neighbor_default_originate, |
6438 | no_neighbor_default_originate_cmd, | |
a636c635 | 6439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6440 | NO_STR |
6441 | NEIGHBOR_STR | |
6442 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6443 | "Originate default route to this neighbor\n" |
6444 | "Route-map to specify criteria to originate default\n" | |
6445 | "route-map name\n") | |
718e3744 | 6446 | { |
d62a17ae | 6447 | int idx_peer = 2; |
6448 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6449 | bgp_node_afi(vty), | |
6450 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6451 | } |
6452 | ||
d62a17ae | 6453 | ALIAS_HIDDEN( |
6454 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6455 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6456 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6457 | "Originate default route to this neighbor\n" | |
6458 | "Route-map to specify criteria to originate default\n" | |
6459 | "route-map name\n") | |
596c17ba | 6460 | |
6b0655a2 | 6461 | |
28c6e247 IR |
6462 | /* Set neighbor's BGP port. */ |
6463 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6464 | const char *port_str) | |
718e3744 | 6465 | { |
28c6e247 IR |
6466 | struct peer *peer; |
6467 | uint16_t port; | |
6468 | struct servent *sp; | |
6469 | ||
6470 | peer = peer_lookup_vty(vty, ip_str); | |
6471 | if (!peer) | |
6472 | return CMD_WARNING_CONFIG_FAILED; | |
6473 | ||
6474 | if (!port_str) { | |
6475 | sp = getservbyname("bgp", "tcp"); | |
6476 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6477 | } else { | |
6478 | port = strtoul(port_str, NULL, 10); | |
6479 | } | |
718e3744 | 6480 | |
28c6e247 | 6481 | peer_port_set(peer, port); |
718e3744 | 6482 | |
28c6e247 IR |
6483 | return CMD_SUCCESS; |
6484 | } | |
f4b8ec07 | 6485 | |
28c6e247 IR |
6486 | /* Set specified peer's BGP port. */ |
6487 | DEFUN (neighbor_port, | |
6488 | neighbor_port_cmd, | |
6489 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6490 | NEIGHBOR_STR | |
6491 | NEIGHBOR_ADDR_STR | |
6492 | "Neighbor's BGP port\n" | |
6493 | "TCP port number\n") | |
6494 | { | |
6495 | int idx_ip = 1; | |
6496 | int idx_number = 3; | |
6497 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6498 | argv[idx_number]->arg); | |
f4b8ec07 | 6499 | } |
6b0655a2 | 6500 | |
28c6e247 IR |
6501 | DEFUN (no_neighbor_port, |
6502 | no_neighbor_port_cmd, | |
6503 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6504 | NO_STR | |
6505 | NEIGHBOR_STR | |
6506 | NEIGHBOR_ADDR_STR | |
6507 | "Neighbor's BGP port\n" | |
6508 | "TCP port number\n") | |
718e3744 | 6509 | { |
f4b8ec07 | 6510 | int idx_ip = 2; |
28c6e247 IR |
6511 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
6512 | } | |
6513 | ||
6514 | ||
6515 | /* neighbor weight. */ | |
6516 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6517 | safi_t safi, const char *weight_str) | |
6518 | { | |
6519 | int ret; | |
6520 | struct peer *peer; | |
6521 | unsigned long weight; | |
718e3744 | 6522 | |
28c6e247 IR |
6523 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6524 | if (!peer) | |
6525 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6526 | |
28c6e247 | 6527 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6528 | |
28c6e247 IR |
6529 | ret = peer_weight_set(peer, afi, safi, weight); |
6530 | return bgp_vty_return(vty, ret); | |
718e3744 | 6531 | } |
6532 | ||
28c6e247 IR |
6533 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6534 | safi_t safi) | |
718e3744 | 6535 | { |
28c6e247 IR |
6536 | int ret; |
6537 | struct peer *peer; | |
f4b8ec07 | 6538 | |
28c6e247 IR |
6539 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6540 | if (!peer) | |
d62a17ae | 6541 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6542 | |
28c6e247 IR |
6543 | ret = peer_weight_unset(peer, afi, safi); |
6544 | return bgp_vty_return(vty, ret); | |
6545 | } | |
f4b8ec07 | 6546 | |
28c6e247 IR |
6547 | DEFUN (neighbor_weight, |
6548 | neighbor_weight_cmd, | |
6549 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6550 | NEIGHBOR_STR | |
6551 | NEIGHBOR_ADDR_STR2 | |
6552 | "Set default weight for routes from this neighbor\n" | |
6553 | "default weight\n") | |
6554 | { | |
6555 | int idx_peer = 1; | |
6556 | int idx_number = 3; | |
6557 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6558 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6559 | } |
6560 | ||
d62a17ae | 6561 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6562 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6563 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6564 | "Set default weight for routes from this neighbor\n" | |
6565 | "default weight\n") | |
596c17ba | 6566 | |
28c6e247 IR |
6567 | DEFUN (no_neighbor_weight, |
6568 | no_neighbor_weight_cmd, | |
6569 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6570 | NO_STR | |
6571 | NEIGHBOR_STR | |
6572 | NEIGHBOR_ADDR_STR2 | |
6573 | "Set default weight for routes from this neighbor\n" | |
6574 | "default weight\n") | |
718e3744 | 6575 | { |
d62a17ae | 6576 | int idx_peer = 2; |
28c6e247 IR |
6577 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
6578 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6579 | } |
6580 | ||
d62a17ae | 6581 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6582 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6583 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6584 | "Set default weight for routes from this neighbor\n" | |
6585 | "default weight\n") | |
596c17ba | 6586 | |
6b0655a2 | 6587 | |
718e3744 | 6588 | /* Override capability negotiation. */ |
c36bc05f IR |
6589 | DEFUN (neighbor_override_capability, |
6590 | neighbor_override_capability_cmd, | |
6591 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6592 | NEIGHBOR_STR | |
6593 | NEIGHBOR_ADDR_STR2 | |
6594 | "Override capability negotiation result\n") | |
718e3744 | 6595 | { |
d62a17ae | 6596 | int idx_peer = 1; |
c36bc05f IR |
6597 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6598 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6599 | } |
6600 | ||
c36bc05f IR |
6601 | DEFUN (no_neighbor_override_capability, |
6602 | no_neighbor_override_capability_cmd, | |
6603 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6604 | NO_STR | |
6605 | NEIGHBOR_STR | |
6606 | NEIGHBOR_ADDR_STR2 | |
6607 | "Override capability negotiation result\n") | |
718e3744 | 6608 | { |
d62a17ae | 6609 | int idx_peer = 2; |
c36bc05f IR |
6610 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6611 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6612 | } |
6b0655a2 | 6613 | |
c36bc05f IR |
6614 | DEFUN (neighbor_strict_capability, |
6615 | neighbor_strict_capability_cmd, | |
6616 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6617 | NEIGHBOR_STR | |
6618 | NEIGHBOR_ADDR_STR2 | |
6619 | "Strict capability negotiation match\n") | |
718e3744 | 6620 | { |
9fb964de PM |
6621 | int idx_peer = 1; |
6622 | ||
c36bc05f IR |
6623 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6624 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6625 | } |
6626 | ||
c36bc05f IR |
6627 | DEFUN (no_neighbor_strict_capability, |
6628 | no_neighbor_strict_capability_cmd, | |
6629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6630 | NO_STR | |
6631 | NEIGHBOR_STR | |
6632 | NEIGHBOR_ADDR_STR2 | |
6633 | "Strict capability negotiation match\n") | |
718e3744 | 6634 | { |
9fb964de | 6635 | int idx_peer = 2; |
8611c7f3 | 6636 | |
c36bc05f IR |
6637 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6638 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6639 | } |
6b0655a2 | 6640 | |
28c6e247 IR |
6641 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6642 | const char *keep_str, const char *hold_str) | |
718e3744 | 6643 | { |
28c6e247 IR |
6644 | int ret; |
6645 | struct peer *peer; | |
6646 | uint32_t keepalive; | |
6647 | uint32_t holdtime; | |
718e3744 | 6648 | |
28c6e247 IR |
6649 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6650 | if (!peer) | |
d62a17ae | 6651 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6652 | |
28c6e247 IR |
6653 | keepalive = strtoul(keep_str, NULL, 10); |
6654 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6655 | |
28c6e247 | 6656 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6657 | |
28c6e247 | 6658 | return bgp_vty_return(vty, ret); |
718e3744 | 6659 | } |
6b0655a2 | 6660 | |
28c6e247 | 6661 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6662 | { |
28c6e247 IR |
6663 | int ret; |
6664 | struct peer *peer; | |
718e3744 | 6665 | |
28c6e247 IR |
6666 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6667 | if (!peer) | |
d62a17ae | 6668 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6669 | |
28c6e247 | 6670 | ret = peer_timers_unset(peer); |
718e3744 | 6671 | |
28c6e247 | 6672 | return bgp_vty_return(vty, ret); |
718e3744 | 6673 | } |
6b0655a2 | 6674 | |
28c6e247 IR |
6675 | DEFUN (neighbor_timers, |
6676 | neighbor_timers_cmd, | |
6677 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6678 | NEIGHBOR_STR | |
6679 | NEIGHBOR_ADDR_STR2 | |
6680 | "BGP per neighbor timers\n" | |
6681 | "Keepalive interval\n" | |
6682 | "Holdtime\n") | |
718e3744 | 6683 | { |
f4b8ec07 | 6684 | int idx_peer = 1; |
28c6e247 IR |
6685 | int idx_number = 3; |
6686 | int idx_number_2 = 4; | |
6687 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6688 | argv[idx_number]->arg, | |
6689 | argv[idx_number_2]->arg); | |
6690 | } | |
6691 | ||
6692 | DEFUN (no_neighbor_timers, | |
6693 | no_neighbor_timers_cmd, | |
6694 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6695 | NO_STR | |
6696 | NEIGHBOR_STR | |
6697 | NEIGHBOR_ADDR_STR2 | |
6698 | "BGP per neighbor timers\n" | |
6699 | "Keepalive interval\n" | |
6700 | "Holdtime\n") | |
6701 | { | |
6702 | int idx_peer = 2; | |
6703 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6704 | } | |
6705 | ||
6706 | ||
6707 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6708 | const char *time_str) | |
6709 | { | |
6710 | int ret; | |
6711 | struct peer *peer; | |
6712 | uint32_t connect; | |
718e3744 | 6713 | |
28c6e247 IR |
6714 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6715 | if (!peer) | |
d62a17ae | 6716 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6717 | |
28c6e247 IR |
6718 | connect = strtoul(time_str, NULL, 10); |
6719 | ||
6720 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 6721 | |
28c6e247 | 6722 | return bgp_vty_return(vty, ret); |
718e3744 | 6723 | } |
6724 | ||
28c6e247 | 6725 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6726 | { |
28c6e247 IR |
6727 | int ret; |
6728 | struct peer *peer; | |
718e3744 | 6729 | |
28c6e247 IR |
6730 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6731 | if (!peer) | |
d62a17ae | 6732 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6733 | |
28c6e247 IR |
6734 | ret = peer_timers_connect_unset(peer); |
6735 | ||
6736 | return bgp_vty_return(vty, ret); | |
6737 | } | |
6738 | ||
6739 | DEFUN (neighbor_timers_connect, | |
6740 | neighbor_timers_connect_cmd, | |
6741 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
6742 | NEIGHBOR_STR | |
6743 | NEIGHBOR_ADDR_STR2 | |
6744 | "BGP per neighbor timers\n" | |
6745 | "BGP connect timer\n" | |
6746 | "Connect timer\n") | |
6747 | { | |
6748 | int idx_peer = 1; | |
6749 | int idx_number = 4; | |
6750 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6751 | argv[idx_number]->arg); | |
6752 | } | |
718e3744 | 6753 | |
28c6e247 IR |
6754 | DEFUN (no_neighbor_timers_connect, |
6755 | no_neighbor_timers_connect_cmd, | |
6756 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
6757 | NO_STR | |
6758 | NEIGHBOR_STR | |
6759 | NEIGHBOR_ADDR_STR2 | |
6760 | "BGP per neighbor timers\n" | |
6761 | "BGP connect timer\n" | |
6762 | "Connect timer\n") | |
6763 | { | |
6764 | int idx_peer = 2; | |
6765 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6766 | } |
6767 | ||
d43114f3 DS |
6768 | DEFPY (neighbor_timers_delayopen, |
6769 | neighbor_timers_delayopen_cmd, | |
6770 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
6771 | NEIGHBOR_STR | |
6772 | NEIGHBOR_ADDR_STR2 | |
6773 | "BGP per neighbor timers\n" | |
6774 | "RFC 4271 DelayOpenTimer\n" | |
6775 | "DelayOpenTime timer interval\n") | |
6776 | { | |
6777 | struct peer *peer; | |
6778 | ||
6779 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6780 | if (!peer) | |
6781 | return CMD_WARNING_CONFIG_FAILED; | |
6782 | ||
6783 | if (!interval) { | |
6784 | if (peer_timers_delayopen_unset(peer)) | |
6785 | return CMD_WARNING_CONFIG_FAILED; | |
6786 | } else { | |
6787 | if (peer_timers_delayopen_set(peer, interval)) | |
6788 | return CMD_WARNING_CONFIG_FAILED; | |
6789 | } | |
6790 | ||
6791 | return CMD_SUCCESS; | |
6792 | } | |
6793 | ||
6794 | DEFPY (no_neighbor_timers_delayopen, | |
6795 | no_neighbor_timers_delayopen_cmd, | |
6796 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
6797 | NO_STR | |
6798 | NEIGHBOR_STR | |
6799 | NEIGHBOR_ADDR_STR2 | |
6800 | "BGP per neighbor timers\n" | |
6801 | "RFC 4271 DelayOpenTimer\n" | |
6802 | "DelayOpenTime timer interval\n") | |
6803 | { | |
6804 | struct peer *peer; | |
6805 | ||
6806 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6807 | if (!peer) | |
6808 | return CMD_WARNING_CONFIG_FAILED; | |
6809 | ||
6810 | if (peer_timers_delayopen_unset(peer)) | |
6811 | return CMD_WARNING_CONFIG_FAILED; | |
6812 | ||
6813 | return CMD_SUCCESS; | |
6814 | } | |
6815 | ||
28c6e247 IR |
6816 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6817 | const char *time_str, int set) | |
718e3744 | 6818 | { |
28c6e247 IR |
6819 | int ret; |
6820 | struct peer *peer; | |
6821 | uint32_t routeadv = 0; | |
718e3744 | 6822 | |
28c6e247 IR |
6823 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6824 | if (!peer) | |
d62a17ae | 6825 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6826 | |
28c6e247 IR |
6827 | if (time_str) |
6828 | routeadv = strtoul(time_str, NULL, 10); | |
6829 | ||
6830 | if (set) | |
6831 | ret = peer_advertise_interval_set(peer, routeadv); | |
6832 | else | |
6833 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6834 | |
28c6e247 | 6835 | return bgp_vty_return(vty, ret); |
718e3744 | 6836 | } |
6837 | ||
28c6e247 IR |
6838 | DEFUN (neighbor_advertise_interval, |
6839 | neighbor_advertise_interval_cmd, | |
6840 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
6841 | NEIGHBOR_STR | |
6842 | NEIGHBOR_ADDR_STR2 | |
6843 | "Minimum interval between sending BGP routing updates\n" | |
6844 | "time in seconds\n") | |
718e3744 | 6845 | { |
28c6e247 IR |
6846 | int idx_peer = 1; |
6847 | int idx_number = 3; | |
6848 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6849 | argv[idx_number]->arg, 1); | |
6850 | } | |
f4b8ec07 | 6851 | |
28c6e247 IR |
6852 | DEFUN (no_neighbor_advertise_interval, |
6853 | no_neighbor_advertise_interval_cmd, | |
6854 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
6855 | NO_STR | |
6856 | NEIGHBOR_STR | |
6857 | NEIGHBOR_ADDR_STR2 | |
6858 | "Minimum interval between sending BGP routing updates\n" | |
6859 | "time in seconds\n") | |
6860 | { | |
6861 | int idx_peer = 2; | |
6862 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6863 | } |
6864 | ||
6b0655a2 | 6865 | |
518f0eb1 DS |
6866 | /* Time to wait before processing route-map updates */ |
6867 | DEFUN (bgp_set_route_map_delay_timer, | |
6868 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6869 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6870 | SET_STR |
6871 | "BGP route-map delay timer\n" | |
6872 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6873 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6874 | { |
d62a17ae | 6875 | int idx_number = 3; |
d7c0a89a | 6876 | uint32_t rmap_delay_timer; |
d62a17ae | 6877 | |
6878 | if (argv[idx_number]->arg) { | |
6879 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6880 | bm->rmap_update_timer = rmap_delay_timer; | |
6881 | ||
6882 | /* if the dynamic update handling is being disabled, and a timer | |
6883 | * is | |
6884 | * running, stop the timer and act as if the timer has already | |
6885 | * fired. | |
6886 | */ | |
6887 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6888 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6889 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6890 | NULL, 0); | |
6891 | } | |
6892 | return CMD_SUCCESS; | |
6893 | } else { | |
6894 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6895 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6896 | } |
518f0eb1 DS |
6897 | } |
6898 | ||
6899 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6900 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6901 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6902 | NO_STR |
3a2d747c | 6903 | BGP_STR |
518f0eb1 | 6904 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6905 | "Reset to default time to wait for processing route-map changes\n" |
6906 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6907 | { |
518f0eb1 | 6908 | |
d62a17ae | 6909 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6910 | |
d62a17ae | 6911 | return CMD_SUCCESS; |
518f0eb1 DS |
6912 | } |
6913 | ||
28c6e247 IR |
6914 | /* neighbor interface */ |
6915 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
6916 | const char *str) | |
718e3744 | 6917 | { |
28c6e247 | 6918 | struct peer *peer; |
718e3744 | 6919 | |
28c6e247 IR |
6920 | peer = peer_lookup_vty(vty, ip_str); |
6921 | if (!peer || peer->conf_if) { | |
6922 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6923 | return CMD_WARNING_CONFIG_FAILED; | |
6924 | } | |
718e3744 | 6925 | |
28c6e247 IR |
6926 | if (str) |
6927 | peer_interface_set(peer, str); | |
6928 | else | |
6929 | peer_interface_unset(peer); | |
718e3744 | 6930 | |
28c6e247 | 6931 | return CMD_SUCCESS; |
718e3744 | 6932 | } |
6933 | ||
28c6e247 IR |
6934 | DEFUN (neighbor_interface, |
6935 | neighbor_interface_cmd, | |
6936 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
6937 | NEIGHBOR_STR | |
6938 | NEIGHBOR_ADDR_STR | |
6939 | "Interface\n" | |
6940 | "Interface name\n") | |
718e3744 | 6941 | { |
28c6e247 IR |
6942 | int idx_ip = 1; |
6943 | int idx_word = 3; | |
294d8425 | 6944 | |
28c6e247 IR |
6945 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
6946 | } | |
f4b8ec07 | 6947 | |
28c6e247 IR |
6948 | DEFUN (no_neighbor_interface, |
6949 | no_neighbor_interface_cmd, | |
294d8425 | 6950 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
6951 | NO_STR |
6952 | NEIGHBOR_STR | |
294d8425 | 6953 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
6954 | "Interface\n" |
6955 | "Interface name\n") | |
6956 | { | |
6957 | int idx_peer = 2; | |
294d8425 | 6958 | |
28c6e247 | 6959 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6960 | } |
6b0655a2 | 6961 | |
718e3744 | 6962 | DEFUN (neighbor_distribute_list, |
6963 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6964 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6965 | NEIGHBOR_STR |
6966 | NEIGHBOR_ADDR_STR2 | |
6967 | "Filter updates to/from this neighbor\n" | |
6968 | "IP access-list number\n" | |
6969 | "IP access-list number (expanded range)\n" | |
6970 | "IP Access-list name\n" | |
6971 | "Filter incoming updates\n" | |
6972 | "Filter outgoing updates\n") | |
6973 | { | |
d62a17ae | 6974 | int idx_peer = 1; |
6975 | int idx_acl = 3; | |
6976 | int direct, ret; | |
6977 | struct peer *peer; | |
a8206004 | 6978 | |
d62a17ae | 6979 | const char *pstr = argv[idx_peer]->arg; |
6980 | const char *acl = argv[idx_acl]->arg; | |
6981 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6982 | |
d62a17ae | 6983 | peer = peer_and_group_lookup_vty(vty, pstr); |
6984 | if (!peer) | |
6985 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6986 | |
d62a17ae | 6987 | /* Check filter direction. */ |
6988 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6989 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6990 | direct, acl); | |
a8206004 | 6991 | |
d62a17ae | 6992 | return bgp_vty_return(vty, ret); |
718e3744 | 6993 | } |
6994 | ||
d62a17ae | 6995 | ALIAS_HIDDEN( |
6996 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6997 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6998 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6999 | "Filter updates to/from this neighbor\n" | |
7000 | "IP access-list number\n" | |
7001 | "IP access-list number (expanded range)\n" | |
7002 | "IP Access-list name\n" | |
7003 | "Filter incoming updates\n" | |
7004 | "Filter outgoing updates\n") | |
596c17ba | 7005 | |
718e3744 | 7006 | DEFUN (no_neighbor_distribute_list, |
7007 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 7008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7009 | NO_STR |
7010 | NEIGHBOR_STR | |
7011 | NEIGHBOR_ADDR_STR2 | |
7012 | "Filter updates to/from this neighbor\n" | |
7013 | "IP access-list number\n" | |
7014 | "IP access-list number (expanded range)\n" | |
7015 | "IP Access-list name\n" | |
7016 | "Filter incoming updates\n" | |
7017 | "Filter outgoing updates\n") | |
7018 | { | |
d62a17ae | 7019 | int idx_peer = 2; |
7020 | int direct, ret; | |
7021 | struct peer *peer; | |
a8206004 | 7022 | |
d62a17ae | 7023 | const char *pstr = argv[idx_peer]->arg; |
7024 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7025 | |
d62a17ae | 7026 | peer = peer_and_group_lookup_vty(vty, pstr); |
7027 | if (!peer) | |
7028 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7029 | |
d62a17ae | 7030 | /* Check filter direction. */ |
7031 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7032 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7033 | direct); | |
a8206004 | 7034 | |
d62a17ae | 7035 | return bgp_vty_return(vty, ret); |
718e3744 | 7036 | } |
6b0655a2 | 7037 | |
d62a17ae | 7038 | ALIAS_HIDDEN( |
7039 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7041 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7042 | "Filter updates to/from this neighbor\n" | |
7043 | "IP access-list number\n" | |
7044 | "IP access-list number (expanded range)\n" | |
7045 | "IP Access-list name\n" | |
7046 | "Filter incoming updates\n" | |
7047 | "Filter outgoing updates\n") | |
596c17ba | 7048 | |
718e3744 | 7049 | /* Set prefix list to the peer. */ |
642ef664 IR |
7050 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7051 | afi_t afi, safi_t safi, | |
7052 | const char *name_str, | |
7053 | const char *direct_str) | |
718e3744 | 7054 | { |
642ef664 IR |
7055 | int ret; |
7056 | int direct = FILTER_IN; | |
7057 | struct peer *peer; | |
718e3744 | 7058 | |
642ef664 IR |
7059 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7060 | if (!peer) | |
d62a17ae | 7061 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7062 | |
642ef664 IR |
7063 | /* Check filter direction. */ |
7064 | if (strncmp(direct_str, "i", 1) == 0) | |
7065 | direct = FILTER_IN; | |
7066 | else if (strncmp(direct_str, "o", 1) == 0) | |
7067 | direct = FILTER_OUT; | |
718e3744 | 7068 | |
642ef664 | 7069 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7070 | |
642ef664 IR |
7071 | return bgp_vty_return(vty, ret); |
7072 | } | |
7073 | ||
7074 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7075 | afi_t afi, safi_t safi, | |
7076 | const char *direct_str) | |
7077 | { | |
7078 | int ret; | |
7079 | struct peer *peer; | |
7080 | int direct = FILTER_IN; | |
7081 | ||
7082 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7083 | if (!peer) | |
7084 | return CMD_WARNING_CONFIG_FAILED; | |
7085 | ||
7086 | /* Check filter direction. */ | |
7087 | if (strncmp(direct_str, "i", 1) == 0) | |
7088 | direct = FILTER_IN; | |
7089 | else if (strncmp(direct_str, "o", 1) == 0) | |
7090 | direct = FILTER_OUT; | |
7091 | ||
7092 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7093 | ||
7094 | return bgp_vty_return(vty, ret); | |
7095 | } | |
7096 | ||
7097 | DEFUN (neighbor_prefix_list, | |
7098 | neighbor_prefix_list_cmd, | |
7099 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7100 | NEIGHBOR_STR | |
7101 | NEIGHBOR_ADDR_STR2 | |
7102 | "Filter updates to/from this neighbor\n" | |
7103 | "Name of a prefix list\n" | |
7104 | "Filter incoming updates\n" | |
7105 | "Filter outgoing updates\n") | |
7106 | { | |
7107 | int idx_peer = 1; | |
7108 | int idx_word = 3; | |
7109 | int idx_in_out = 4; | |
7110 | return peer_prefix_list_set_vty( | |
7111 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7112 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7113 | } |
7114 | ||
d62a17ae | 7115 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7116 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7117 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7118 | "Filter updates to/from this neighbor\n" | |
7119 | "Name of a prefix list\n" | |
7120 | "Filter incoming updates\n" | |
7121 | "Filter outgoing updates\n") | |
596c17ba | 7122 | |
642ef664 IR |
7123 | DEFUN (no_neighbor_prefix_list, |
7124 | no_neighbor_prefix_list_cmd, | |
7125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7126 | NO_STR | |
7127 | NEIGHBOR_STR | |
7128 | NEIGHBOR_ADDR_STR2 | |
7129 | "Filter updates to/from this neighbor\n" | |
7130 | "Name of a prefix list\n" | |
7131 | "Filter incoming updates\n" | |
7132 | "Filter outgoing updates\n") | |
7133 | { | |
7134 | int idx_peer = 2; | |
7135 | int idx_in_out = 5; | |
7136 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7137 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7138 | argv[idx_in_out]->arg); | |
7139 | } | |
7140 | ||
7141 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7142 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7143 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7144 | "Filter updates to/from this neighbor\n" | |
7145 | "Name of a prefix list\n" | |
7146 | "Filter incoming updates\n" | |
7147 | "Filter outgoing updates\n") | |
7148 | ||
d62a17ae | 7149 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7150 | safi_t safi, const char *name_str, | |
7151 | const char *direct_str) | |
718e3744 | 7152 | { |
d62a17ae | 7153 | int ret; |
7154 | struct peer *peer; | |
7155 | int direct = FILTER_IN; | |
718e3744 | 7156 | |
d62a17ae | 7157 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7158 | if (!peer) | |
7159 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7160 | |
d62a17ae | 7161 | /* Check filter direction. */ |
7162 | if (strncmp(direct_str, "i", 1) == 0) | |
7163 | direct = FILTER_IN; | |
7164 | else if (strncmp(direct_str, "o", 1) == 0) | |
7165 | direct = FILTER_OUT; | |
718e3744 | 7166 | |
d62a17ae | 7167 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7168 | |
d62a17ae | 7169 | return bgp_vty_return(vty, ret); |
718e3744 | 7170 | } |
7171 | ||
d62a17ae | 7172 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7173 | safi_t safi, const char *direct_str) | |
718e3744 | 7174 | { |
d62a17ae | 7175 | int ret; |
7176 | struct peer *peer; | |
7177 | int direct = FILTER_IN; | |
718e3744 | 7178 | |
d62a17ae | 7179 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7180 | if (!peer) | |
7181 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7182 | |
d62a17ae | 7183 | /* Check filter direction. */ |
7184 | if (strncmp(direct_str, "i", 1) == 0) | |
7185 | direct = FILTER_IN; | |
7186 | else if (strncmp(direct_str, "o", 1) == 0) | |
7187 | direct = FILTER_OUT; | |
718e3744 | 7188 | |
d62a17ae | 7189 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7190 | |
d62a17ae | 7191 | return bgp_vty_return(vty, ret); |
718e3744 | 7192 | } |
7193 | ||
7194 | DEFUN (neighbor_filter_list, | |
7195 | neighbor_filter_list_cmd, | |
9ccf14f7 | 7196 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7197 | NEIGHBOR_STR |
7198 | NEIGHBOR_ADDR_STR2 | |
7199 | "Establish BGP filters\n" | |
7200 | "AS path access-list name\n" | |
7201 | "Filter incoming routes\n" | |
7202 | "Filter outgoing routes\n") | |
7203 | { | |
d62a17ae | 7204 | int idx_peer = 1; |
7205 | int idx_word = 3; | |
7206 | int idx_in_out = 4; | |
7207 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7208 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7209 | argv[idx_in_out]->arg); | |
718e3744 | 7210 | } |
7211 | ||
d62a17ae | 7212 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7213 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7214 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7215 | "Establish BGP filters\n" | |
7216 | "AS path access-list name\n" | |
7217 | "Filter incoming routes\n" | |
7218 | "Filter outgoing routes\n") | |
596c17ba | 7219 | |
718e3744 | 7220 | DEFUN (no_neighbor_filter_list, |
7221 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7223 | NO_STR |
7224 | NEIGHBOR_STR | |
7225 | NEIGHBOR_ADDR_STR2 | |
7226 | "Establish BGP filters\n" | |
7227 | "AS path access-list name\n" | |
7228 | "Filter incoming routes\n" | |
7229 | "Filter outgoing routes\n") | |
7230 | { | |
d62a17ae | 7231 | int idx_peer = 2; |
7232 | int idx_in_out = 5; | |
7233 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7234 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7235 | argv[idx_in_out]->arg); | |
718e3744 | 7236 | } |
6b0655a2 | 7237 | |
d62a17ae | 7238 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7240 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7241 | "Establish BGP filters\n" | |
7242 | "AS path access-list name\n" | |
7243 | "Filter incoming routes\n" | |
7244 | "Filter outgoing routes\n") | |
596c17ba | 7245 | |
7f7940e6 MK |
7246 | /* Set advertise-map to the peer. */ |
7247 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7248 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7249 | const char *advertise_str, |
7250 | const char *condition_str, bool condition, | |
7251 | bool set) | |
7f7940e6 MK |
7252 | { |
7253 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7254 | struct peer *peer; | |
7255 | struct route_map *advertise_map; | |
7256 | struct route_map *condition_map; | |
7257 | ||
7258 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7259 | if (!peer) | |
7260 | return ret; | |
7261 | ||
7262 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7263 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7264 | ||
cf2ad4d8 MK |
7265 | if (set) |
7266 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7267 | advertise_map, condition_str, | |
7268 | condition_map, condition); | |
7269 | else | |
7270 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7271 | advertise_map, condition_str, | |
7272 | condition_map, condition); | |
7f7940e6 MK |
7273 | |
7274 | return bgp_vty_return(vty, ret); | |
7275 | } | |
7276 | ||
389e4f92 QY |
7277 | DEFPY (bgp_condadv_period, |
7278 | bgp_condadv_period_cmd, | |
7279 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7280 | NO_STR | |
7281 | BGP_STR | |
7282 | "Conditional advertisement settings\n" | |
7283 | "Set period to rescan BGP table to check if condition is met\n" | |
7284 | "Period between BGP table scans, in seconds; default 60\n") | |
7285 | { | |
7286 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7287 | ||
7288 | bgp->condition_check_period = | |
7289 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7290 | ||
7291 | return CMD_SUCCESS; | |
7292 | } | |
7293 | ||
cf2ad4d8 | 7294 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7295 | neighbor_advertise_map_cmd, |
52b84062 | 7296 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
cf2ad4d8 | 7297 | NO_STR |
7f7940e6 MK |
7298 | NEIGHBOR_STR |
7299 | NEIGHBOR_ADDR_STR2 | |
7300 | "Route-map to conditionally advertise routes\n" | |
7301 | "Name of advertise map\n" | |
7302 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7303 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7304 | "Name of the exist or non exist map\n") |
7f7940e6 | 7305 | { |
7f7940e6 MK |
7306 | bool condition = CONDITION_EXIST; |
7307 | ||
52b84062 | 7308 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7309 | condition = CONDITION_NON_EXIST; |
7310 | ||
52b84062 MK |
7311 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7312 | bgp_node_safi(vty), advertise_str, | |
7313 | condition_str, condition, !no); | |
7f7940e6 MK |
7314 | } |
7315 | ||
7316 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7317 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
7f7940e6 MK |
7318 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7319 | "Route-map to conditionally advertise routes\n" | |
7320 | "Name of advertise map\n" | |
7321 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7322 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7323 | "Name of the exist or non exist map\n") |
7f7940e6 | 7324 | |
718e3744 | 7325 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7326 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7327 | afi_t afi, safi_t safi, const char *name_str, | |
7328 | const char *direct_str) | |
718e3744 | 7329 | { |
0ea8d871 IR |
7330 | int ret; |
7331 | struct peer *peer; | |
7332 | int direct = RMAP_IN; | |
7333 | struct route_map *route_map; | |
718e3744 | 7334 | |
0ea8d871 IR |
7335 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7336 | if (!peer) | |
d62a17ae | 7337 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7338 | |
0ea8d871 IR |
7339 | /* Check filter direction. */ |
7340 | if (strncmp(direct_str, "in", 2) == 0) | |
7341 | direct = RMAP_IN; | |
7342 | else if (strncmp(direct_str, "o", 1) == 0) | |
7343 | direct = RMAP_OUT; | |
718e3744 | 7344 | |
0ea8d871 IR |
7345 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7346 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7347 | |
0ea8d871 IR |
7348 | return bgp_vty_return(vty, ret); |
7349 | } | |
7350 | ||
7351 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7352 | afi_t afi, safi_t safi, | |
7353 | const char *direct_str) | |
7354 | { | |
7355 | int ret; | |
7356 | struct peer *peer; | |
7357 | int direct = RMAP_IN; | |
7358 | ||
7359 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7360 | if (!peer) | |
7361 | return CMD_WARNING_CONFIG_FAILED; | |
7362 | ||
7363 | /* Check filter direction. */ | |
7364 | if (strncmp(direct_str, "in", 2) == 0) | |
7365 | direct = RMAP_IN; | |
7366 | else if (strncmp(direct_str, "o", 1) == 0) | |
7367 | direct = RMAP_OUT; | |
7368 | ||
7369 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7370 | ||
7371 | return bgp_vty_return(vty, ret); | |
7372 | } | |
7373 | ||
7374 | DEFUN (neighbor_route_map, | |
7375 | neighbor_route_map_cmd, | |
7376 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7377 | NEIGHBOR_STR | |
7378 | NEIGHBOR_ADDR_STR2 | |
7379 | "Apply route map to neighbor\n" | |
7380 | "Name of route map\n" | |
7381 | "Apply map to incoming routes\n" | |
7382 | "Apply map to outbound routes\n") | |
7383 | { | |
7384 | int idx_peer = 1; | |
7385 | int idx_word = 3; | |
7386 | int idx_in_out = 4; | |
7387 | return peer_route_map_set_vty( | |
7388 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7389 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7390 | } |
7391 | ||
d6d7ed37 IR |
7392 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7393 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7394 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7395 | "Apply route map to neighbor\n" | |
7396 | "Name of route map\n" | |
7397 | "Apply map to incoming routes\n" | |
7398 | "Apply map to outbound routes\n") | |
7399 | ||
0ea8d871 IR |
7400 | DEFUN (no_neighbor_route_map, |
7401 | no_neighbor_route_map_cmd, | |
7402 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7403 | NO_STR | |
7404 | NEIGHBOR_STR | |
7405 | NEIGHBOR_ADDR_STR2 | |
7406 | "Apply route map to neighbor\n" | |
7407 | "Name of route map\n" | |
7408 | "Apply map to incoming routes\n" | |
7409 | "Apply map to outbound routes\n") | |
7410 | { | |
7411 | int idx_peer = 2; | |
7412 | int idx_in_out = 5; | |
7413 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7414 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7415 | argv[idx_in_out]->arg); | |
7416 | } | |
7417 | ||
7418 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
d6d7ed37 IR |
7419 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
7420 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7421 | "Apply route map to neighbor\n" | |
7422 | "Name of route map\n" | |
7423 | "Apply map to incoming routes\n" | |
7424 | "Apply map to outbound routes\n") | |
7425 | ||
718e3744 | 7426 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7427 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7428 | afi_t afi, safi_t safi, | |
7429 | const char *name_str) | |
718e3744 | 7430 | { |
d62a17ae | 7431 | int ret; |
7432 | struct peer *peer; | |
1de27621 | 7433 | struct route_map *route_map; |
718e3744 | 7434 | |
d62a17ae | 7435 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7436 | if (!peer) | |
7437 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7438 | |
1de27621 DA |
7439 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7440 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7441 | |
d62a17ae | 7442 | return bgp_vty_return(vty, ret); |
718e3744 | 7443 | } |
7444 | ||
7445 | /* Unset route-map from the peer. */ | |
d62a17ae | 7446 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7447 | afi_t afi, safi_t safi) | |
718e3744 | 7448 | { |
d62a17ae | 7449 | int ret; |
7450 | struct peer *peer; | |
718e3744 | 7451 | |
d62a17ae | 7452 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7453 | if (!peer) | |
7454 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7455 | |
d62a17ae | 7456 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7457 | |
d62a17ae | 7458 | return bgp_vty_return(vty, ret); |
718e3744 | 7459 | } |
7460 | ||
7461 | DEFUN (neighbor_unsuppress_map, | |
7462 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7463 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7464 | NEIGHBOR_STR |
7465 | NEIGHBOR_ADDR_STR2 | |
7466 | "Route-map to selectively unsuppress suppressed routes\n" | |
7467 | "Name of route map\n") | |
7468 | { | |
d62a17ae | 7469 | int idx_peer = 1; |
7470 | int idx_word = 3; | |
7471 | return peer_unsuppress_map_set_vty( | |
7472 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7473 | argv[idx_word]->arg); | |
718e3744 | 7474 | } |
7475 | ||
d62a17ae | 7476 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7477 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7478 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7479 | "Route-map to selectively unsuppress suppressed routes\n" | |
7480 | "Name of route map\n") | |
596c17ba | 7481 | |
718e3744 | 7482 | DEFUN (no_neighbor_unsuppress_map, |
7483 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7484 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7485 | NO_STR |
7486 | NEIGHBOR_STR | |
7487 | NEIGHBOR_ADDR_STR2 | |
7488 | "Route-map to selectively unsuppress suppressed routes\n" | |
7489 | "Name of route map\n") | |
7490 | { | |
d62a17ae | 7491 | int idx_peer = 2; |
7492 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7493 | bgp_node_afi(vty), | |
7494 | bgp_node_safi(vty)); | |
718e3744 | 7495 | } |
6b0655a2 | 7496 | |
d62a17ae | 7497 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7498 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7499 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7500 | "Route-map to selectively unsuppress suppressed routes\n" | |
7501 | "Name of route map\n") | |
596c17ba | 7502 | |
7e62b792 IR |
7503 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7504 | afi_t afi, safi_t safi, | |
7505 | const char *num_str, | |
7506 | const char *threshold_str, int warning, | |
7507 | const char *restart_str, | |
7508 | const char *force_str) | |
7509 | { | |
7510 | int ret; | |
7511 | struct peer *peer; | |
7512 | uint32_t max; | |
7513 | uint8_t threshold; | |
7514 | uint16_t restart; | |
7515 | ||
7516 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7517 | if (!peer) | |
7518 | return CMD_WARNING_CONFIG_FAILED; | |
7519 | ||
7520 | max = strtoul(num_str, NULL, 10); | |
7521 | if (threshold_str) | |
7522 | threshold = atoi(threshold_str); | |
7523 | else | |
7524 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7525 | ||
7526 | if (restart_str) | |
7527 | restart = atoi(restart_str); | |
7528 | else | |
7529 | restart = 0; | |
7530 | ||
7531 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7532 | restart, force_str ? true : false); | |
7533 | ||
7534 | return bgp_vty_return(vty, ret); | |
7535 | } | |
7536 | ||
7537 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7538 | afi_t afi, safi_t safi) | |
7539 | { | |
7540 | int ret; | |
7541 | struct peer *peer; | |
7542 | ||
7543 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7544 | if (!peer) | |
7545 | return CMD_WARNING_CONFIG_FAILED; | |
7546 | ||
7547 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7548 | ||
7549 | return bgp_vty_return(vty, ret); | |
7550 | } | |
7551 | ||
fde246e8 | 7552 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
7553 | DEFUN(neighbor_maximum_prefix_out, |
7554 | neighbor_maximum_prefix_out_cmd, | |
7555 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7556 | NEIGHBOR_STR | |
7557 | NEIGHBOR_ADDR_STR2 | |
7558 | "Maximum number of prefixes to be sent to this peer\n" | |
7559 | "Maximum no. of prefix limit\n") | |
fde246e8 DA |
7560 | { |
7561 | int idx_peer = 1; | |
7562 | int idx_number = 3; | |
7e62b792 IR |
7563 | struct peer *peer; |
7564 | uint32_t max; | |
fde246e8 DA |
7565 | afi_t afi = bgp_node_afi(vty); |
7566 | safi_t safi = bgp_node_safi(vty); | |
7567 | ||
7e62b792 IR |
7568 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7569 | if (!peer) | |
fde246e8 DA |
7570 | return CMD_WARNING_CONFIG_FAILED; |
7571 | ||
7e62b792 | 7572 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 7573 | |
7e62b792 IR |
7574 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7575 | peer->pmax_out[afi][safi] = max; | |
fde246e8 | 7576 | |
7e62b792 | 7577 | return CMD_SUCCESS; |
fde246e8 DA |
7578 | } |
7579 | ||
1d80f243 IR |
7580 | DEFUN(no_neighbor_maximum_prefix_out, |
7581 | no_neighbor_maximum_prefix_out_cmd, | |
7582 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7583 | NO_STR | |
7584 | NEIGHBOR_STR | |
7585 | NEIGHBOR_ADDR_STR2 | |
7586 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 DA |
7587 | { |
7588 | int idx_peer = 2; | |
7e62b792 | 7589 | struct peer *peer; |
fde246e8 DA |
7590 | afi_t afi = bgp_node_afi(vty); |
7591 | safi_t safi = bgp_node_safi(vty); | |
7592 | ||
7e62b792 IR |
7593 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7594 | if (!peer) | |
fde246e8 DA |
7595 | return CMD_WARNING_CONFIG_FAILED; |
7596 | ||
7e62b792 IR |
7597 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7598 | peer->pmax_out[afi][safi] = 0; | |
fde246e8 | 7599 | |
7e62b792 | 7600 | return CMD_SUCCESS; |
fde246e8 DA |
7601 | } |
7602 | ||
9cbd06e0 DA |
7603 | /* Maximum number of prefix configuration. Prefix count is different |
7604 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7605 | each peer configuration. */ |
1d80f243 IR |
7606 | DEFUN (neighbor_maximum_prefix, |
7607 | neighbor_maximum_prefix_cmd, | |
7608 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7609 | NEIGHBOR_STR | |
7610 | NEIGHBOR_ADDR_STR2 | |
7611 | "Maximum number of prefix accept from this peer\n" | |
7612 | "maximum no. of prefix limit\n" | |
7613 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7614 | { |
d62a17ae | 7615 | int idx_peer = 1; |
7616 | int idx_number = 3; | |
9cbd06e0 | 7617 | int idx_force = 0; |
7e62b792 | 7618 | char *force = NULL; |
9cbd06e0 DA |
7619 | |
7620 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7621 | force = argv[idx_force]->arg; |
9cbd06e0 | 7622 | |
7e62b792 IR |
7623 | return peer_maximum_prefix_set_vty( |
7624 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7625 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 7626 | } |
7627 | ||
d62a17ae | 7628 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7629 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7630 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7631 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7632 | "maximum no. of prefix limit\n" |
7633 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7634 | |
1d80f243 IR |
7635 | DEFUN (neighbor_maximum_prefix_threshold, |
7636 | neighbor_maximum_prefix_threshold_cmd, | |
7637 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7638 | NEIGHBOR_STR | |
7639 | NEIGHBOR_ADDR_STR2 | |
7640 | "Maximum number of prefix accept from this peer\n" | |
7641 | "maximum no. of prefix limit\n" | |
7642 | "Threshold value (%) at which to generate a warning msg\n" | |
7643 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7644 | { |
d62a17ae | 7645 | int idx_peer = 1; |
7646 | int idx_number = 3; | |
7647 | int idx_number_2 = 4; | |
9cbd06e0 | 7648 | int idx_force = 0; |
7e62b792 | 7649 | char *force = NULL; |
9cbd06e0 DA |
7650 | |
7651 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7652 | force = argv[idx_force]->arg; |
9cbd06e0 | 7653 | |
7e62b792 IR |
7654 | return peer_maximum_prefix_set_vty( |
7655 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7656 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 7657 | } |
e0701b79 | 7658 | |
d62a17ae | 7659 | ALIAS_HIDDEN( |
7660 | neighbor_maximum_prefix_threshold, | |
7661 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7662 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7663 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7664 | "Maximum number of prefix accept from this peer\n" | |
7665 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7666 | "Threshold value (%) at which to generate a warning msg\n" |
7667 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7668 | |
1d80f243 IR |
7669 | DEFUN (neighbor_maximum_prefix_warning, |
7670 | neighbor_maximum_prefix_warning_cmd, | |
7671 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7672 | NEIGHBOR_STR | |
7673 | NEIGHBOR_ADDR_STR2 | |
7674 | "Maximum number of prefix accept from this peer\n" | |
7675 | "maximum no. of prefix limit\n" | |
7676 | "Only give warning message when limit is exceeded\n" | |
7677 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7678 | { |
d62a17ae | 7679 | int idx_peer = 1; |
7680 | int idx_number = 3; | |
9cbd06e0 | 7681 | int idx_force = 0; |
7e62b792 | 7682 | char *force = NULL; |
9cbd06e0 DA |
7683 | |
7684 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7685 | force = argv[idx_force]->arg; |
9cbd06e0 | 7686 | |
7e62b792 IR |
7687 | return peer_maximum_prefix_set_vty( |
7688 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7689 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 7690 | } |
7691 | ||
d62a17ae | 7692 | ALIAS_HIDDEN( |
7693 | neighbor_maximum_prefix_warning, | |
7694 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7695 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7696 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7697 | "Maximum number of prefix accept from this peer\n" | |
7698 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7699 | "Only give warning message when limit is exceeded\n" |
7700 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7701 | |
1d80f243 IR |
7702 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7703 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7704 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7705 | NEIGHBOR_STR | |
7706 | NEIGHBOR_ADDR_STR2 | |
7707 | "Maximum number of prefix accept from this peer\n" | |
7708 | "maximum no. of prefix limit\n" | |
7709 | "Threshold value (%) at which to generate a warning msg\n" | |
7710 | "Only give warning message when limit is exceeded\n" | |
7711 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7712 | { |
d62a17ae | 7713 | int idx_peer = 1; |
7714 | int idx_number = 3; | |
7715 | int idx_number_2 = 4; | |
9cbd06e0 | 7716 | int idx_force = 0; |
7e62b792 | 7717 | char *force = NULL; |
9cbd06e0 DA |
7718 | |
7719 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7720 | force = argv[idx_force]->arg; |
9cbd06e0 | 7721 | |
7e62b792 IR |
7722 | return peer_maximum_prefix_set_vty( |
7723 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7724 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 7725 | } |
7726 | ||
d62a17ae | 7727 | ALIAS_HIDDEN( |
7728 | neighbor_maximum_prefix_threshold_warning, | |
7729 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7730 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7731 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7732 | "Maximum number of prefix accept from this peer\n" | |
7733 | "maximum no. of prefix limit\n" | |
7734 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7735 | "Only give warning message when limit is exceeded\n" |
7736 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7737 | |
1d80f243 IR |
7738 | DEFUN (neighbor_maximum_prefix_restart, |
7739 | neighbor_maximum_prefix_restart_cmd, | |
7740 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7741 | NEIGHBOR_STR | |
7742 | NEIGHBOR_ADDR_STR2 | |
7743 | "Maximum number of prefix accept from this peer\n" | |
7744 | "maximum no. of prefix limit\n" | |
7745 | "Restart bgp connection after limit is exceeded\n" | |
7746 | "Restart interval in minutes\n" | |
7747 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7748 | { |
d62a17ae | 7749 | int idx_peer = 1; |
7750 | int idx_number = 3; | |
7751 | int idx_number_2 = 5; | |
9cbd06e0 | 7752 | int idx_force = 0; |
7e62b792 | 7753 | char *force = NULL; |
9cbd06e0 DA |
7754 | |
7755 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7756 | force = argv[idx_force]->arg; |
9cbd06e0 | 7757 | |
7e62b792 IR |
7758 | return peer_maximum_prefix_set_vty( |
7759 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7760 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 7761 | } |
7762 | ||
d62a17ae | 7763 | ALIAS_HIDDEN( |
7764 | neighbor_maximum_prefix_restart, | |
7765 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7766 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7767 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7768 | "Maximum number of prefix accept from this peer\n" | |
7769 | "maximum no. of prefix limit\n" | |
7770 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7771 | "Restart interval in minutes\n" |
7772 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7773 | |
1d80f243 IR |
7774 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7775 | neighbor_maximum_prefix_threshold_restart_cmd, | |
7776 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7777 | NEIGHBOR_STR | |
7778 | NEIGHBOR_ADDR_STR2 | |
7779 | "Maximum number of prefixes to accept from this peer\n" | |
7780 | "maximum no. of prefix limit\n" | |
7781 | "Threshold value (%) at which to generate a warning msg\n" | |
7782 | "Restart bgp connection after limit is exceeded\n" | |
7783 | "Restart interval in minutes\n" | |
7784 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7785 | { |
d62a17ae | 7786 | int idx_peer = 1; |
7787 | int idx_number = 3; | |
7788 | int idx_number_2 = 4; | |
7789 | int idx_number_3 = 6; | |
9cbd06e0 | 7790 | int idx_force = 0; |
7e62b792 | 7791 | char *force = NULL; |
9cbd06e0 DA |
7792 | |
7793 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7794 | force = argv[idx_force]->arg; |
9cbd06e0 | 7795 | |
7e62b792 IR |
7796 | return peer_maximum_prefix_set_vty( |
7797 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7798 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
7799 | argv[idx_number_3]->arg, force); | |
d62a17ae | 7800 | } |
7801 | ||
7802 | ALIAS_HIDDEN( | |
7803 | neighbor_maximum_prefix_threshold_restart, | |
7804 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7805 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7806 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7807 | "Maximum number of prefixes to accept from this peer\n" | |
7808 | "maximum no. of prefix limit\n" | |
7809 | "Threshold value (%) at which to generate a warning msg\n" | |
7810 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7811 | "Restart interval in minutes\n" |
7812 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7813 | |
1d80f243 IR |
7814 | DEFUN (no_neighbor_maximum_prefix, |
7815 | no_neighbor_maximum_prefix_cmd, | |
7816 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7817 | NO_STR | |
7818 | NEIGHBOR_STR | |
7819 | NEIGHBOR_ADDR_STR2 | |
7820 | "Maximum number of prefixes to accept from this peer\n" | |
7821 | "maximum no. of prefix limit\n" | |
7822 | "Threshold value (%) at which to generate a warning msg\n" | |
7823 | "Restart bgp connection after limit is exceeded\n" | |
7824 | "Restart interval in minutes\n" | |
7825 | "Only give warning message when limit is exceeded\n" | |
7826 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7827 | { |
d62a17ae | 7828 | int idx_peer = 2; |
7e62b792 IR |
7829 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
7830 | bgp_node_afi(vty), | |
7831 | bgp_node_safi(vty)); | |
718e3744 | 7832 | } |
e52702f2 | 7833 | |
d62a17ae | 7834 | ALIAS_HIDDEN( |
7835 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7837 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7838 | "Maximum number of prefixes to accept from this peer\n" | |
7839 | "maximum no. of prefix limit\n" | |
7840 | "Threshold value (%) at which to generate a warning msg\n" | |
7841 | "Restart bgp connection after limit is exceeded\n" | |
7842 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7843 | "Only give warning message when limit is exceeded\n" |
7844 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7845 | |
718e3744 | 7846 | |
718e3744 | 7847 | /* "neighbor allowas-in" */ |
7848 | DEFUN (neighbor_allowas_in, | |
7849 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7850 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7851 | NEIGHBOR_STR |
7852 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7853 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7854 | "Number of occurrences of AS number\n" |
fd8503f5 | 7855 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7856 | { |
d62a17ae | 7857 | int idx_peer = 1; |
7858 | int idx_number_origin = 3; | |
7859 | int ret; | |
7860 | int origin = 0; | |
7861 | struct peer *peer; | |
7862 | int allow_num = 0; | |
7863 | ||
7864 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7865 | if (!peer) | |
7866 | return CMD_WARNING_CONFIG_FAILED; | |
7867 | ||
7868 | if (argc <= idx_number_origin) | |
7869 | allow_num = 3; | |
7870 | else { | |
7871 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7872 | origin = 1; | |
7873 | else | |
7874 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7875 | } | |
7876 | ||
7877 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7878 | allow_num, origin); | |
7879 | ||
7880 | return bgp_vty_return(vty, ret); | |
7881 | } | |
7882 | ||
7883 | ALIAS_HIDDEN( | |
7884 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7885 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7886 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7887 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7888 | "Number of occurrences of AS number\n" |
d62a17ae | 7889 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7890 | |
718e3744 | 7891 | DEFUN (no_neighbor_allowas_in, |
7892 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7893 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7894 | NO_STR |
7895 | NEIGHBOR_STR | |
7896 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7897 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7898 | "Number of occurrences of AS number\n" |
fd8503f5 | 7899 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7900 | { |
d62a17ae | 7901 | int idx_peer = 2; |
7902 | int ret; | |
7903 | struct peer *peer; | |
718e3744 | 7904 | |
d62a17ae | 7905 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7906 | if (!peer) | |
7907 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7908 | |
d62a17ae | 7909 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7910 | bgp_node_safi(vty)); | |
718e3744 | 7911 | |
d62a17ae | 7912 | return bgp_vty_return(vty, ret); |
718e3744 | 7913 | } |
6b0655a2 | 7914 | |
d62a17ae | 7915 | ALIAS_HIDDEN( |
7916 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7917 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7918 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7919 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7920 | "Number of occurrences of AS number\n" |
d62a17ae | 7921 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7922 | |
28c6e247 IR |
7923 | DEFUN (neighbor_ttl_security, |
7924 | neighbor_ttl_security_cmd, | |
7925 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
7926 | NEIGHBOR_STR | |
7927 | NEIGHBOR_ADDR_STR2 | |
7928 | "BGP ttl-security parameters\n" | |
7929 | "Specify the maximum number of hops to the BGP peer\n" | |
7930 | "Number of hops to BGP peer\n") | |
fa411a21 | 7931 | { |
d62a17ae | 7932 | int idx_peer = 1; |
7933 | int idx_number = 4; | |
28c6e247 IR |
7934 | struct peer *peer; |
7935 | int gtsm_hops; | |
d62a17ae | 7936 | |
28c6e247 IR |
7937 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7938 | if (!peer) | |
d62a17ae | 7939 | return CMD_WARNING_CONFIG_FAILED; |
7940 | ||
28c6e247 IR |
7941 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
7942 | ||
7943 | /* | |
7944 | * If 'neighbor swpX', then this is for directly connected peers, | |
7945 | * we should not accept a ttl-security hops value greater than 1. | |
7946 | */ | |
7947 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
7948 | vty_out(vty, | |
7949 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7950 | argv[idx_peer]->arg); | |
7951 | return CMD_WARNING_CONFIG_FAILED; | |
7952 | } | |
7ebe625c | 7953 | |
28c6e247 | 7954 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7955 | } |
7956 | ||
1d80f243 IR |
7957 | DEFUN (no_neighbor_ttl_security, |
7958 | no_neighbor_ttl_security_cmd, | |
7959 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
7960 | NO_STR | |
7961 | NEIGHBOR_STR | |
7962 | NEIGHBOR_ADDR_STR2 | |
7963 | "BGP ttl-security parameters\n" | |
7964 | "Specify the maximum number of hops to the BGP peer\n" | |
7965 | "Number of hops to BGP peer\n") | |
fa411a21 | 7966 | { |
d62a17ae | 7967 | int idx_peer = 2; |
28c6e247 | 7968 | struct peer *peer; |
fa411a21 | 7969 | |
28c6e247 IR |
7970 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7971 | if (!peer) | |
d62a17ae | 7972 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 7973 | |
28c6e247 | 7974 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7975 | } |
6b0655a2 | 7976 | |
7c0e4312 DA |
7977 | /* disable-addpath-rx */ |
7978 | DEFUN(neighbor_disable_addpath_rx, | |
7979 | neighbor_disable_addpath_rx_cmd, | |
7980 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
7981 | NEIGHBOR_STR | |
7982 | NEIGHBOR_ADDR_STR2 | |
7983 | "Do not accept additional paths\n") | |
7984 | { | |
7985 | char *peer_str = argv[1]->arg; | |
7986 | struct peer *peer; | |
7987 | afi_t afi = bgp_node_afi(vty); | |
7988 | safi_t safi = bgp_node_safi(vty); | |
7989 | ||
7990 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
7991 | if (!peer) | |
7992 | return CMD_WARNING_CONFIG_FAILED; | |
7993 | ||
7994 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
7995 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
7996 | } | |
7997 | ||
7998 | DEFUN(no_neighbor_disable_addpath_rx, | |
7999 | no_neighbor_disable_addpath_rx_cmd, | |
8000 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8001 | NO_STR | |
8002 | NEIGHBOR_STR | |
8003 | NEIGHBOR_ADDR_STR2 | |
8004 | "Do not accept additional paths\n") | |
8005 | { | |
8006 | char *peer_str = argv[2]->arg; | |
8007 | struct peer *peer; | |
8008 | afi_t afi = bgp_node_afi(vty); | |
8009 | safi_t safi = bgp_node_safi(vty); | |
8010 | ||
8011 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8012 | if (!peer) | |
8013 | return CMD_WARNING_CONFIG_FAILED; | |
8014 | ||
8015 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8016 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8017 | } | |
8018 | ||
adbac85e DW |
8019 | DEFUN (neighbor_addpath_tx_all_paths, |
8020 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8021 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8022 | NEIGHBOR_STR |
8023 | NEIGHBOR_ADDR_STR2 | |
8024 | "Use addpath to advertise all paths to a neighbor\n") | |
8025 | { | |
d62a17ae | 8026 | int idx_peer = 1; |
8027 | struct peer *peer; | |
adbac85e | 8028 | |
d62a17ae | 8029 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8030 | if (!peer) | |
8031 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8032 | |
dcc68b5e MS |
8033 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8034 | BGP_ADDPATH_ALL); | |
8035 | return CMD_SUCCESS; | |
adbac85e DW |
8036 | } |
8037 | ||
d62a17ae | 8038 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8039 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8040 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8041 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8042 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8043 | |
adbac85e DW |
8044 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8045 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8046 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8047 | NO_STR |
8048 | NEIGHBOR_STR | |
8049 | NEIGHBOR_ADDR_STR2 | |
8050 | "Use addpath to advertise all paths to a neighbor\n") | |
8051 | { | |
d62a17ae | 8052 | int idx_peer = 2; |
dcc68b5e MS |
8053 | struct peer *peer; |
8054 | ||
8055 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8056 | if (!peer) | |
8057 | return CMD_WARNING_CONFIG_FAILED; | |
8058 | ||
8059 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8060 | != BGP_ADDPATH_ALL) { | |
8061 | vty_out(vty, | |
8062 | "%% Peer not currently configured to transmit all paths."); | |
8063 | return CMD_WARNING_CONFIG_FAILED; | |
8064 | } | |
8065 | ||
8066 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8067 | BGP_ADDPATH_NONE); | |
8068 | ||
8069 | return CMD_SUCCESS; | |
adbac85e DW |
8070 | } |
8071 | ||
d62a17ae | 8072 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8073 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8074 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8075 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8076 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8077 | |
06370dac DW |
8078 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8079 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8080 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8081 | NEIGHBOR_STR |
8082 | NEIGHBOR_ADDR_STR2 | |
8083 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8084 | { | |
d62a17ae | 8085 | int idx_peer = 1; |
8086 | struct peer *peer; | |
06370dac | 8087 | |
d62a17ae | 8088 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8089 | if (!peer) | |
8090 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8091 | |
dcc68b5e MS |
8092 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8093 | BGP_ADDPATH_BEST_PER_AS); | |
8094 | ||
8095 | return CMD_SUCCESS; | |
06370dac DW |
8096 | } |
8097 | ||
d62a17ae | 8098 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8099 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8100 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8101 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8102 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8103 | |
06370dac DW |
8104 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8105 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8106 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8107 | NO_STR |
8108 | NEIGHBOR_STR | |
8109 | NEIGHBOR_ADDR_STR2 | |
8110 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8111 | { | |
d62a17ae | 8112 | int idx_peer = 2; |
dcc68b5e MS |
8113 | struct peer *peer; |
8114 | ||
8115 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8116 | if (!peer) | |
8117 | return CMD_WARNING_CONFIG_FAILED; | |
8118 | ||
8119 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8120 | != BGP_ADDPATH_BEST_PER_AS) { | |
8121 | vty_out(vty, | |
8122 | "%% Peer not currently configured to transmit all best path per as."); | |
8123 | return CMD_WARNING_CONFIG_FAILED; | |
8124 | } | |
8125 | ||
8126 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8127 | BGP_ADDPATH_NONE); | |
8128 | ||
8129 | return CMD_SUCCESS; | |
06370dac DW |
8130 | } |
8131 | ||
d62a17ae | 8132 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8133 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8135 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8136 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8137 | |
2b31007c RZ |
8138 | DEFPY( |
8139 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8140 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8141 | NEIGHBOR_STR | |
8142 | NEIGHBOR_ADDR_STR2 | |
8143 | "Detect AS loops before sending to neighbor\n") | |
8144 | { | |
8145 | struct peer *peer; | |
8146 | ||
8147 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8148 | if (!peer) | |
8149 | return CMD_WARNING_CONFIG_FAILED; | |
8150 | ||
8151 | peer->as_path_loop_detection = true; | |
8152 | ||
8153 | return CMD_SUCCESS; | |
8154 | } | |
8155 | ||
8156 | DEFPY( | |
8157 | no_neighbor_aspath_loop_detection, | |
8158 | no_neighbor_aspath_loop_detection_cmd, | |
8159 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8160 | NO_STR | |
8161 | NEIGHBOR_STR | |
8162 | NEIGHBOR_ADDR_STR2 | |
8163 | "Detect AS loops before sending to neighbor\n") | |
8164 | { | |
8165 | struct peer *peer; | |
8166 | ||
8167 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8168 | if (!peer) | |
8169 | return CMD_WARNING_CONFIG_FAILED; | |
8170 | ||
8171 | peer->as_path_loop_detection = false; | |
8172 | ||
8173 | return CMD_SUCCESS; | |
8174 | } | |
8175 | ||
b9c7bc5a | 8176 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8177 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8178 | { |
b9c7bc5a PZ |
8179 | struct ecommunity *ecom = NULL; |
8180 | struct ecommunity *ecomadd; | |
ddb5b488 | 8181 | |
b9c7bc5a | 8182 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8183 | if (is_rt6) |
8184 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8185 | ECOMMUNITY_ROUTE_TARGET, | |
8186 | 0); | |
8187 | else | |
8188 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8189 | ECOMMUNITY_ROUTE_TARGET, | |
8190 | 0); | |
b9c7bc5a PZ |
8191 | if (!ecomadd) { |
8192 | vty_out(vty, "Malformed community-list value\n"); | |
8193 | if (ecom) | |
8194 | ecommunity_free(&ecom); | |
8195 | return CMD_WARNING_CONFIG_FAILED; | |
8196 | } | |
ddb5b488 | 8197 | |
b9c7bc5a PZ |
8198 | if (ecom) { |
8199 | ecommunity_merge(ecom, ecomadd); | |
8200 | ecommunity_free(&ecomadd); | |
8201 | } else { | |
8202 | ecom = ecomadd; | |
8203 | } | |
8204 | } | |
8205 | ||
8206 | if (*list) { | |
8207 | ecommunity_free(&*list); | |
ddb5b488 | 8208 | } |
b9c7bc5a PZ |
8209 | *list = ecom; |
8210 | ||
8211 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8212 | } |
8213 | ||
0ca70ba5 DS |
8214 | /* |
8215 | * v2vimport is true if we are handling a `import vrf ...` command | |
8216 | */ | |
8217 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8218 | { |
0ca70ba5 DS |
8219 | afi_t afi; |
8220 | ||
ddb5b488 | 8221 | switch (vty->node) { |
b9c7bc5a | 8222 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8223 | afi = AFI_IP; |
8224 | break; | |
b9c7bc5a | 8225 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8226 | afi = AFI_IP6; |
8227 | break; | |
ddb5b488 PZ |
8228 | default: |
8229 | vty_out(vty, | |
b9c7bc5a | 8230 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8231 | return AFI_MAX; |
ddb5b488 | 8232 | } |
69b07479 | 8233 | |
0ca70ba5 DS |
8234 | if (!v2vimport) { |
8235 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8236 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8237 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8238 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8239 | vty_out(vty, | |
8240 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8241 | return AFI_MAX; | |
8242 | } | |
8243 | } else { | |
8244 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8245 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8246 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8247 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8248 | vty_out(vty, | |
8249 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8250 | return AFI_MAX; | |
8251 | } | |
8252 | } | |
8253 | return afi; | |
ddb5b488 PZ |
8254 | } |
8255 | ||
585f1adc IR |
8256 | DEFPY (af_rd_vpn_export, |
8257 | af_rd_vpn_export_cmd, | |
8258 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8259 | NO_STR | |
8260 | "Specify route distinguisher\n" | |
8261 | "Between current address-family and vpn\n" | |
8262 | "For routes leaked from current address-family to vpn\n" | |
8263 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8264 | { |
585f1adc IR |
8265 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8266 | struct prefix_rd prd; | |
8267 | int ret; | |
ddb5b488 | 8268 | afi_t afi; |
b9c7bc5a | 8269 | int idx = 0; |
585f1adc | 8270 | bool yes = true; |
b9c7bc5a | 8271 | |
585f1adc IR |
8272 | if (argv_find(argv, argc, "no", &idx)) |
8273 | yes = false; | |
ddb5b488 | 8274 | |
585f1adc IR |
8275 | if (yes) { |
8276 | ret = str2prefix_rd(rd_str, &prd); | |
8277 | if (!ret) { | |
8278 | vty_out(vty, "%% Malformed rd\n"); | |
8279 | return CMD_WARNING_CONFIG_FAILED; | |
8280 | } | |
8281 | } | |
ddb5b488 | 8282 | |
585f1adc IR |
8283 | afi = vpn_policy_getafi(vty, bgp, false); |
8284 | if (afi == AFI_MAX) | |
8285 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8286 | |
585f1adc IR |
8287 | /* |
8288 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8289 | */ | |
8290 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8291 | bgp_get_default(), bgp); | |
ddb5b488 | 8292 | |
585f1adc IR |
8293 | if (yes) { |
8294 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8295 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8296 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8297 | } else { | |
8298 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8299 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8300 | } | |
69b07479 | 8301 | |
585f1adc IR |
8302 | /* post-change: re-export vpn routes */ |
8303 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8304 | bgp_get_default(), bgp); | |
8305 | ||
8306 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8307 | } |
8308 | ||
b9c7bc5a PZ |
8309 | ALIAS (af_rd_vpn_export, |
8310 | af_no_rd_vpn_export_cmd, | |
8311 | "no rd vpn export", | |
ddb5b488 | 8312 | NO_STR |
b9c7bc5a PZ |
8313 | "Specify route distinguisher\n" |
8314 | "Between current address-family and vpn\n" | |
8315 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8316 | |
b9c7bc5a PZ |
8317 | DEFPY (af_label_vpn_export, |
8318 | af_label_vpn_export_cmd, | |
e70e9f8e | 8319 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8320 | NO_STR |
ddb5b488 | 8321 | "label value for VRF\n" |
b9c7bc5a PZ |
8322 | "Between current address-family and vpn\n" |
8323 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8324 | "Label Value <0-1048575>\n" |
8325 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8326 | { |
8327 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8328 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8329 | afi_t afi; |
b9c7bc5a | 8330 | int idx = 0; |
c6423c31 | 8331 | bool yes = true; |
b9c7bc5a PZ |
8332 | |
8333 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8334 | yes = false; |
ddb5b488 | 8335 | |
21a16cc2 PZ |
8336 | /* If "no ...", squash trailing parameter */ |
8337 | if (!yes) | |
8338 | label_auto = NULL; | |
8339 | ||
e70e9f8e PZ |
8340 | if (yes) { |
8341 | if (!label_auto) | |
8342 | label = label_val; /* parser should force unsigned */ | |
8343 | } | |
ddb5b488 | 8344 | |
0ca70ba5 | 8345 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8346 | if (afi == AFI_MAX) |
8347 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8348 | |
e70e9f8e | 8349 | |
69b07479 DS |
8350 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8351 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8352 | /* no change */ | |
8353 | return CMD_SUCCESS; | |
e70e9f8e | 8354 | |
69b07479 DS |
8355 | /* |
8356 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8357 | */ | |
8358 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8359 | bgp_get_default(), bgp); | |
8360 | ||
8361 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8362 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8363 | ||
8364 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8365 | ||
8366 | /* | |
8367 | * label has previously been automatically | |
8368 | * assigned by labelpool: release it | |
8369 | * | |
8370 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8371 | * means the automatic assignment is in flight | |
8372 | * and therefore the labelpool callback must | |
8373 | * detect that the auto label is not needed. | |
8374 | */ | |
8375 | ||
8376 | bgp_lp_release(LP_TYPE_VRF, | |
8377 | &bgp->vpn_policy[afi], | |
8378 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8379 | } |
69b07479 DS |
8380 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8381 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8382 | } | |
ddb5b488 | 8383 | |
69b07479 DS |
8384 | bgp->vpn_policy[afi].tovpn_label = label; |
8385 | if (label_auto) { | |
8386 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8387 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8388 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8389 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8390 | } |
8391 | ||
69b07479 DS |
8392 | /* post-change: re-export vpn routes */ |
8393 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8394 | bgp_get_default(), bgp); | |
8395 | ||
0d020cd6 | 8396 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
8397 | return CMD_SUCCESS; |
8398 | } | |
8399 | ||
b72c9e14 HS |
8400 | DEFPY (af_sid_vpn_export, |
8401 | af_sid_vpn_export_cmd, | |
8402 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8403 | NO_STR | |
8404 | "sid value for VRF\n" | |
8405 | "Between current address-family and vpn\n" | |
8406 | "For routes leaked from current address-family to vpn\n" | |
8407 | "Sid allocation index\n" | |
8408 | "Automatically assign a label\n") | |
8409 | { | |
8410 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8411 | afi_t afi; | |
8412 | int debug = 0; | |
8413 | int idx = 0; | |
8414 | bool yes = true; | |
8415 | ||
8416 | if (argv_find(argv, argc, "no", &idx)) | |
8417 | yes = false; | |
8418 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8419 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8420 | ||
8421 | afi = vpn_policy_getafi(vty, bgp, false); | |
8422 | if (afi == AFI_MAX) | |
8423 | return CMD_WARNING_CONFIG_FAILED; | |
8424 | ||
8425 | if (!yes) { | |
8426 | /* implement me */ | |
8427 | vty_out(vty, "It's not implemented"); | |
8428 | return CMD_WARNING_CONFIG_FAILED; | |
8429 | } | |
8430 | ||
8431 | /* skip when it's already configured */ | |
8432 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8433 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8434 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8435 | return CMD_SUCCESS; | |
8436 | ||
7de4c885 HS |
8437 | /* |
8438 | * mode change between sid_idx and sid_auto isn't supported. | |
8439 | * user must negate sid vpn export when they want to change the mode | |
8440 | */ | |
b72c9e14 HS |
8441 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
8442 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8443 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8444 | vty_out(vty, "it's already configured as %s.\n", | |
8445 | sid_auto ? "auto-mode" : "idx-mode"); | |
8446 | return CMD_WARNING_CONFIG_FAILED; | |
8447 | } | |
8448 | ||
8449 | /* pre-change */ | |
8450 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8451 | bgp_get_default(), bgp); | |
8452 | ||
8453 | if (sid_auto) { | |
8454 | /* SID allocation auto-mode */ | |
8455 | if (debug) | |
8456 | zlog_debug("%s: auto sid alloc.", __func__); | |
8457 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8458 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8459 | } else { | |
8460 | /* SID allocation index-mode */ | |
8461 | if (debug) | |
8462 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8463 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8464 | } | |
8465 | ||
8466 | /* post-change */ | |
8467 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8468 | bgp_get_default(), bgp); | |
8469 | return CMD_SUCCESS; | |
8470 | } | |
8471 | ||
b9c7bc5a PZ |
8472 | ALIAS (af_label_vpn_export, |
8473 | af_no_label_vpn_export_cmd, | |
8474 | "no label vpn export", | |
8475 | NO_STR | |
8476 | "label value for VRF\n" | |
8477 | "Between current address-family and vpn\n" | |
8478 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8479 | |
585f1adc | 8480 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 8481 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 8482 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8483 | NO_STR |
ddb5b488 | 8484 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8485 | "Between current address-family and vpn\n" |
8486 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8487 | "IPv4 prefix\n" |
8488 | "IPv6 prefix\n") | |
8489 | { | |
585f1adc | 8490 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 8491 | afi_t afi; |
ddb5b488 PZ |
8492 | struct prefix p; |
8493 | ||
8c85ca28 QY |
8494 | if (!no) { |
8495 | if (!nexthop_su) { | |
8496 | vty_out(vty, "%% Nexthop required\n"); | |
8497 | return CMD_WARNING_CONFIG_FAILED; | |
8498 | } | |
8c85ca28 | 8499 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8500 | return CMD_WARNING_CONFIG_FAILED; |
8501 | } | |
ddb5b488 | 8502 | |
585f1adc IR |
8503 | afi = vpn_policy_getafi(vty, bgp, false); |
8504 | if (afi == AFI_MAX) | |
8505 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8506 | |
585f1adc IR |
8507 | /* |
8508 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8509 | */ | |
8510 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8511 | bgp_get_default(), bgp); | |
ddb5b488 | 8512 | |
585f1adc IR |
8513 | if (!no) { |
8514 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8515 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8516 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8517 | } else { | |
8518 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8519 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8520 | } | |
69b07479 | 8521 | |
585f1adc IR |
8522 | /* post-change: re-export vpn routes */ |
8523 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8524 | bgp_get_default(), bgp); | |
37a87b8f | 8525 | |
585f1adc | 8526 | return CMD_SUCCESS; |
ddb5b488 PZ |
8527 | } |
8528 | ||
b9c7bc5a | 8529 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8530 | { |
b9c7bc5a PZ |
8531 | if (!strcmp(dstr, "import")) { |
8532 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8533 | } else if (!strcmp(dstr, "export")) { | |
8534 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8535 | } else if (!strcmp(dstr, "both")) { | |
8536 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8537 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8538 | } else { | |
8539 | vty_out(vty, "%% direction parse error\n"); | |
8540 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8541 | } |
ddb5b488 PZ |
8542 | return CMD_SUCCESS; |
8543 | } | |
8544 | ||
b9c7bc5a PZ |
8545 | DEFPY (af_rt_vpn_imexport, |
8546 | af_rt_vpn_imexport_cmd, | |
8547 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8548 | NO_STR | |
8549 | "Specify route target list\n" | |
ddb5b488 | 8550 | "Specify route target list\n" |
b9c7bc5a PZ |
8551 | "Between current address-family and vpn\n" |
8552 | "For routes leaked from vpn to current address-family: match any\n" | |
8553 | "For routes leaked from current address-family to vpn: set\n" | |
8554 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8555 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8556 | { | |
8557 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8558 | int ret; | |
8559 | struct ecommunity *ecom = NULL; | |
8560 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8561 | vpn_policy_direction_t dir; |
8562 | afi_t afi; | |
8563 | int idx = 0; | |
c6423c31 | 8564 | bool yes = true; |
ddb5b488 | 8565 | |
b9c7bc5a | 8566 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8567 | yes = false; |
b9c7bc5a | 8568 | |
0ca70ba5 | 8569 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8570 | if (afi == AFI_MAX) |
8571 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8572 | |
b9c7bc5a | 8573 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8574 | if (ret != CMD_SUCCESS) |
8575 | return ret; | |
8576 | ||
b9c7bc5a PZ |
8577 | if (yes) { |
8578 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8579 | vty_out(vty, "%% Missing RTLIST\n"); | |
8580 | return CMD_WARNING_CONFIG_FAILED; | |
8581 | } | |
c6423c31 | 8582 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8583 | if (ret != CMD_SUCCESS) { |
8584 | return ret; | |
8585 | } | |
ddb5b488 PZ |
8586 | } |
8587 | ||
69b07479 DS |
8588 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8589 | if (!dodir[dir]) | |
ddb5b488 | 8590 | continue; |
ddb5b488 | 8591 | |
69b07479 | 8592 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8593 | |
69b07479 DS |
8594 | if (yes) { |
8595 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8596 | ecommunity_free( | |
8597 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8598 | bgp->vpn_policy[afi].rtlist[dir] = | |
8599 | ecommunity_dup(ecom); | |
8600 | } else { | |
8601 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8602 | ecommunity_free( | |
8603 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8604 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8605 | } |
69b07479 DS |
8606 | |
8607 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8608 | } |
69b07479 | 8609 | |
d555f3e9 PZ |
8610 | if (ecom) |
8611 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8612 | |
8613 | return CMD_SUCCESS; | |
8614 | } | |
8615 | ||
b9c7bc5a PZ |
8616 | ALIAS (af_rt_vpn_imexport, |
8617 | af_no_rt_vpn_imexport_cmd, | |
8618 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8619 | NO_STR |
8620 | "Specify route target list\n" | |
b9c7bc5a PZ |
8621 | "Specify route target list\n" |
8622 | "Between current address-family and vpn\n" | |
8623 | "For routes leaked from vpn to current address-family\n" | |
8624 | "For routes leaked from current address-family to vpn\n" | |
8625 | "both import and export\n") | |
8626 | ||
585f1adc | 8627 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
8628 | af_route_map_vpn_imexport_cmd, |
8629 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8630 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8631 | NO_STR | |
ddb5b488 | 8632 | "Specify route map\n" |
b9c7bc5a PZ |
8633 | "Between current address-family and vpn\n" |
8634 | "For routes leaked from vpn to current address-family\n" | |
8635 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8636 | "name of route-map\n") |
8637 | { | |
585f1adc IR |
8638 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8639 | int ret; | |
8640 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8641 | vpn_policy_direction_t dir; | |
ddb5b488 | 8642 | afi_t afi; |
ddb5b488 | 8643 | int idx = 0; |
585f1adc | 8644 | bool yes = true; |
ddb5b488 | 8645 | |
585f1adc IR |
8646 | if (argv_find(argv, argc, "no", &idx)) |
8647 | yes = false; | |
ddb5b488 | 8648 | |
585f1adc IR |
8649 | afi = vpn_policy_getafi(vty, bgp, false); |
8650 | if (afi == AFI_MAX) | |
8651 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8652 | |
585f1adc IR |
8653 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
8654 | if (ret != CMD_SUCCESS) | |
8655 | return ret; | |
ddb5b488 | 8656 | |
585f1adc IR |
8657 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8658 | if (!dodir[dir]) | |
8659 | continue; | |
69b07479 | 8660 | |
585f1adc IR |
8661 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
8662 | ||
8663 | if (yes) { | |
8664 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8665 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8666 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8667 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8668 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8669 | bgp->vpn_policy[afi].rmap[dir] = | |
8670 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8671 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8672 | return CMD_SUCCESS; | |
8673 | } else { | |
8674 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8675 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8676 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8677 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8678 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8679 | } | |
8680 | ||
8681 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8682 | } | |
ddb5b488 | 8683 | |
585f1adc | 8684 | return CMD_SUCCESS; |
ddb5b488 PZ |
8685 | } |
8686 | ||
b9c7bc5a PZ |
8687 | ALIAS (af_route_map_vpn_imexport, |
8688 | af_no_route_map_vpn_imexport_cmd, | |
8689 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8690 | NO_STR |
8691 | "Specify route map\n" | |
b9c7bc5a PZ |
8692 | "Between current address-family and vpn\n" |
8693 | "For routes leaked from vpn to current address-family\n" | |
8694 | "For routes leaked from current address-family to vpn\n") | |
8695 | ||
bb4f6190 | 8696 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8697 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8698 | "Import routes from another VRF\n" |
8699 | "Vrf routes being filtered\n" | |
8700 | "Specify route map\n" | |
8701 | "name of route-map\n") | |
8702 | { | |
8703 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8704 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8705 | afi_t afi; | |
bb4f6190 DS |
8706 | struct bgp *bgp_default; |
8707 | ||
0ca70ba5 | 8708 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8709 | if (afi == AFI_MAX) |
8710 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8711 | |
8712 | bgp_default = bgp_get_default(); | |
8713 | if (!bgp_default) { | |
8714 | int32_t ret; | |
8715 | as_t as = bgp->as; | |
8716 | ||
8717 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8718 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8719 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8720 | |
8721 | if (ret) { | |
8722 | vty_out(vty, | |
8723 | "VRF default is not configured as a bgp instance\n"); | |
8724 | return CMD_WARNING; | |
8725 | } | |
8726 | } | |
8727 | ||
69b07479 | 8728 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8729 | |
ae6a6fb4 DS |
8730 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8731 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8732 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8733 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8734 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8735 | bgp->vpn_policy[afi].rmap[dir] = | |
8736 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8737 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8738 | return CMD_SUCCESS; | |
8739 | ||
8740 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8741 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8742 | |
69b07479 DS |
8743 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8744 | ||
bb4f6190 DS |
8745 | return CMD_SUCCESS; |
8746 | } | |
8747 | ||
ae6a6fb4 DS |
8748 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8749 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8750 | NO_STR |
8751 | "Import routes from another VRF\n" | |
8752 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8753 | "Specify route map\n" |
8754 | "name of route-map\n") | |
8755 | { | |
8756 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8757 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8758 | afi_t afi; | |
8759 | ||
8760 | afi = vpn_policy_getafi(vty, bgp, true); | |
8761 | if (afi == AFI_MAX) | |
8762 | return CMD_WARNING_CONFIG_FAILED; | |
8763 | ||
8764 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8765 | ||
8766 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8767 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8768 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8769 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8770 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8771 | ||
8772 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8773 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8774 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8775 | ||
8776 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8777 | ||
8778 | return CMD_SUCCESS; | |
8779 | } | |
bb4f6190 | 8780 | |
585f1adc IR |
8781 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8782 | "[no] import vrf VIEWVRFNAME$import_name", | |
8783 | NO_STR | |
8784 | "Import routes from another VRF\n" | |
8785 | "VRF to import from\n" | |
8786 | "The name of the VRF\n") | |
12a844a5 | 8787 | { |
585f1adc IR |
8788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8789 | struct listnode *node; | |
8790 | struct bgp *vrf_bgp, *bgp_default; | |
8791 | int32_t ret = 0; | |
8792 | as_t as = bgp->as; | |
8793 | bool remove = false; | |
8794 | int32_t idx = 0; | |
8795 | char *vname; | |
8796 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
8797 | safi_t safi; |
8798 | afi_t afi; | |
8799 | ||
867f0cca | 8800 | if (import_name == NULL) { |
8801 | vty_out(vty, "%% Missing import name\n"); | |
8802 | return CMD_WARNING; | |
8803 | } | |
8804 | ||
ae6a6fb4 DS |
8805 | if (strcmp(import_name, "route-map") == 0) { |
8806 | vty_out(vty, "%% Must include route-map name\n"); | |
8807 | return CMD_WARNING; | |
8808 | } | |
8809 | ||
585f1adc IR |
8810 | if (argv_find(argv, argc, "no", &idx)) |
8811 | remove = true; | |
8812 | ||
8813 | afi = vpn_policy_getafi(vty, bgp, true); | |
8814 | if (afi == AFI_MAX) | |
8815 | return CMD_WARNING_CONFIG_FAILED; | |
8816 | ||
12a844a5 DS |
8817 | safi = bgp_node_safi(vty); |
8818 | ||
585f1adc IR |
8819 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
8820 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
8821 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
8822 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8823 | remove ? "unimport" : "import", import_name); | |
8824 | return CMD_WARNING; | |
8825 | } | |
25679caa | 8826 | |
585f1adc IR |
8827 | bgp_default = bgp_get_default(); |
8828 | if (!bgp_default) { | |
8829 | /* Auto-create assuming the same AS */ | |
8830 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8831 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 8832 | |
585f1adc IR |
8833 | if (ret) { |
8834 | vty_out(vty, | |
8835 | "VRF default is not configured as a bgp instance\n"); | |
8836 | return CMD_WARNING; | |
8837 | } | |
8838 | } | |
12a844a5 | 8839 | |
585f1adc IR |
8840 | vrf_bgp = bgp_lookup_by_name(import_name); |
8841 | if (!vrf_bgp) { | |
8842 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
8843 | vrf_bgp = bgp_default; | |
8844 | else | |
8845 | /* Auto-create assuming the same AS */ | |
8846 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
8847 | ||
8848 | if (ret) { | |
8849 | vty_out(vty, | |
8850 | "VRF %s is not configured as a bgp instance\n", | |
8851 | import_name); | |
8852 | return CMD_WARNING; | |
8853 | } | |
8854 | } | |
8855 | ||
8856 | if (remove) { | |
8857 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
8858 | } else { | |
8859 | /* Already importing from "import_vrf"? */ | |
8860 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
8861 | vname)) { | |
8862 | if (strcmp(vname, import_name) == 0) | |
8863 | return CMD_WARNING; | |
8864 | } | |
8865 | ||
8866 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
8867 | } | |
8868 | ||
8869 | return CMD_SUCCESS; | |
12a844a5 DS |
8870 | } |
8871 | ||
b9c7bc5a | 8872 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 8873 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
8874 | bgp_imexport_vpn_cmd, |
8875 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8876 | NO_STR |
8877 | "Import routes to this address-family\n" | |
8878 | "Export routes from this address-family\n" | |
8879 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 8880 | { |
585f1adc IR |
8881 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8882 | int previous_state; | |
37a87b8f | 8883 | afi_t afi; |
585f1adc IR |
8884 | safi_t safi; |
8885 | int idx = 0; | |
8886 | bool yes = true; | |
8887 | int flag; | |
8888 | vpn_policy_direction_t dir; | |
8889 | ||
8890 | if (argv_find(argv, argc, "no", &idx)) | |
8891 | yes = false; | |
8892 | ||
8893 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
8894 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
8895 | ||
8896 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
8897 | return CMD_WARNING_CONFIG_FAILED; | |
8898 | } | |
ddb5b488 | 8899 | |
b9c7bc5a PZ |
8900 | afi = bgp_node_afi(vty); |
8901 | safi = bgp_node_safi(vty); | |
585f1adc IR |
8902 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
8903 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8904 | return CMD_WARNING_CONFIG_FAILED; | |
8905 | } | |
ddb5b488 | 8906 | |
b9c7bc5a | 8907 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
8908 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
8909 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 8910 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
8911 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
8912 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
8913 | } else { |
8914 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8915 | return CMD_WARNING_CONFIG_FAILED; | |
8916 | } | |
8917 | ||
585f1adc | 8918 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 8919 | |
585f1adc IR |
8920 | if (yes) { |
8921 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8922 | if (!previous_state) { | |
8923 | /* trigger export current vrf */ | |
8924 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8925 | } | |
8926 | } else { | |
8927 | if (previous_state) { | |
8928 | /* trigger un-export current vrf */ | |
8929 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8930 | } | |
8931 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
8932 | } | |
37a87b8f | 8933 | |
1ca2fd11 IR |
8934 | hook_call(bgp_snmp_init_stats, bgp); |
8935 | ||
585f1adc | 8936 | return CMD_SUCCESS; |
ddb5b488 PZ |
8937 | } |
8938 | ||
301ad80a PG |
8939 | DEFPY (af_routetarget_import, |
8940 | af_routetarget_import_cmd, | |
9a659715 | 8941 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
8942 | NO_STR |
8943 | "Specify route target list\n" | |
8944 | "Specify route target list\n" | |
9a659715 PG |
8945 | "Specify route target list\n" |
8946 | "Specify route target list\n" | |
301ad80a PG |
8947 | "Flow-spec redirect type route target\n" |
8948 | "Import routes to this address-family\n" | |
9a659715 | 8949 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
8950 | { |
8951 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8952 | int ret; | |
8953 | struct ecommunity *ecom = NULL; | |
301ad80a | 8954 | afi_t afi; |
9a659715 | 8955 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
8956 | bool yes = true; |
8957 | bool rt6 = false; | |
301ad80a PG |
8958 | |
8959 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8960 | yes = false; |
301ad80a | 8961 | |
9a659715 PG |
8962 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
8963 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 8964 | rt6 = true; |
301ad80a | 8965 | |
0ca70ba5 | 8966 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8967 | if (afi == AFI_MAX) |
8968 | return CMD_WARNING_CONFIG_FAILED; | |
8969 | ||
9a659715 PG |
8970 | if (rt6 && afi != AFI_IP6) |
8971 | return CMD_WARNING_CONFIG_FAILED; | |
8972 | ||
301ad80a PG |
8973 | if (yes) { |
8974 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8975 | vty_out(vty, "%% Missing RTLIST\n"); | |
8976 | return CMD_WARNING_CONFIG_FAILED; | |
8977 | } | |
9a659715 | 8978 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
8979 | if (ret != CMD_SUCCESS) |
8980 | return ret; | |
8981 | } | |
69b07479 DS |
8982 | |
8983 | if (yes) { | |
8984 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8985 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8986 | .import_redirect_rtlist); |
69b07479 DS |
8987 | bgp->vpn_policy[afi].import_redirect_rtlist = |
8988 | ecommunity_dup(ecom); | |
8989 | } else { | |
8990 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8991 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8992 | .import_redirect_rtlist); |
69b07479 | 8993 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 8994 | } |
69b07479 | 8995 | |
301ad80a PG |
8996 | if (ecom) |
8997 | ecommunity_free(&ecom); | |
8998 | ||
8999 | return CMD_SUCCESS; | |
9000 | } | |
9001 | ||
505e5056 | 9002 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9003 | address_family_ipv4_safi_cmd, |
9004 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9005 | "Enter Address Family command mode\n" | |
9006 | "Address Family\n" | |
9007 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9008 | { |
f51bae9c | 9009 | |
d62a17ae | 9010 | if (argc == 3) { |
585f1adc IR |
9011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9012 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9013 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9014 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9015 | && safi != SAFI_EVPN) { |
31947174 MK |
9016 | vty_out(vty, |
9017 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9018 | return CMD_WARNING_CONFIG_FAILED; |
9019 | } | |
585f1adc IR |
9020 | vty->node = bgp_node_type(AFI_IP, safi); |
9021 | } else | |
9022 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9023 | |
d62a17ae | 9024 | return CMD_SUCCESS; |
718e3744 | 9025 | } |
9026 | ||
505e5056 | 9027 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9028 | address_family_ipv6_safi_cmd, |
9029 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9030 | "Enter Address Family command mode\n" | |
9031 | "Address Family\n" | |
9032 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9033 | { |
d62a17ae | 9034 | if (argc == 3) { |
585f1adc IR |
9035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9036 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9037 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9038 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9039 | && safi != SAFI_EVPN) { |
31947174 MK |
9040 | vty_out(vty, |
9041 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9042 | return CMD_WARNING_CONFIG_FAILED; |
9043 | } | |
585f1adc IR |
9044 | vty->node = bgp_node_type(AFI_IP6, safi); |
9045 | } else | |
9046 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9047 | |
d62a17ae | 9048 | return CMD_SUCCESS; |
25ffbdc1 | 9049 | } |
718e3744 | 9050 | |
d6902373 | 9051 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9052 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9053 | address_family_vpnv4_cmd, |
8334fd5a | 9054 | "address-family vpnv4 [unicast]", |
718e3744 | 9055 | "Enter Address Family command mode\n" |
8c3deaae | 9056 | "Address Family\n" |
3a2d747c | 9057 | "Address Family modifier\n") |
718e3744 | 9058 | { |
d62a17ae | 9059 | vty->node = BGP_VPNV4_NODE; |
9060 | return CMD_SUCCESS; | |
718e3744 | 9061 | } |
9062 | ||
505e5056 | 9063 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9064 | address_family_vpnv6_cmd, |
8334fd5a | 9065 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9066 | "Enter Address Family command mode\n" |
8c3deaae | 9067 | "Address Family\n" |
3a2d747c | 9068 | "Address Family modifier\n") |
8ecd3266 | 9069 | { |
d62a17ae | 9070 | vty->node = BGP_VPNV6_NODE; |
9071 | return CMD_SUCCESS; | |
8ecd3266 | 9072 | } |
64e4a6c5 | 9073 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9074 | |
505e5056 | 9075 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9076 | address_family_evpn_cmd, |
7111c1a0 | 9077 | "address-family l2vpn evpn", |
4e0b7b6d | 9078 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9079 | "Address Family\n" |
9080 | "Address Family modifier\n") | |
4e0b7b6d | 9081 | { |
2131d5cf | 9082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9083 | vty->node = BGP_EVPN_NODE; |
9084 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9085 | } |
9086 | ||
bfaab44d HS |
9087 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9088 | bgp_segment_routing_srv6_cmd, | |
9089 | "segment-routing srv6", | |
9090 | "Segment-Routing configuration\n" | |
9091 | "Segment-Routing SRv6 configuration\n") | |
9092 | { | |
9093 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9094 | bgp->srv6_enabled = true; |
bfaab44d HS |
9095 | vty->node = BGP_SRV6_NODE; |
9096 | return CMD_SUCCESS; | |
9097 | } | |
9098 | ||
a0281b2e HS |
9099 | DEFPY (bgp_srv6_locator, |
9100 | bgp_srv6_locator_cmd, | |
9101 | "locator NAME$name", | |
9102 | "Specify SRv6 locator\n" | |
9103 | "Specify SRv6 locator\n") | |
9104 | { | |
9105 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9106 | int ret; |
a0281b2e HS |
9107 | |
9108 | if (strlen(bgp->srv6_locator_name) > 0 | |
9109 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9110 | vty_out(vty, "srv6 locator is already configured\n"); | |
9111 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9112 | } |
9113 | ||
9114 | snprintf(bgp->srv6_locator_name, | |
9115 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9116 | |
7de4c885 | 9117 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9118 | if (ret < 0) |
9119 | return CMD_WARNING_CONFIG_FAILED; | |
9120 | ||
9121 | return CMD_SUCCESS; | |
9122 | } | |
9123 | ||
ea372e81 HS |
9124 | DEFPY (show_bgp_srv6, |
9125 | show_bgp_srv6_cmd, | |
9126 | "show bgp segment-routing srv6", | |
9127 | SHOW_STR | |
9128 | BGP_STR | |
9129 | "BGP Segment Routing\n" | |
9130 | "BGP Segment Routing SRv6\n") | |
9131 | { | |
9132 | struct bgp *bgp; | |
9133 | struct listnode *node; | |
9134 | struct prefix_ipv6 *chunk; | |
9135 | struct bgp_srv6_function *func; | |
9136 | struct in6_addr *tovpn4_sid; | |
9137 | struct in6_addr *tovpn6_sid; | |
9138 | char buf[256]; | |
9139 | char buf_tovpn4_sid[256]; | |
9140 | char buf_tovpn6_sid[256]; | |
9141 | ||
9142 | bgp = bgp_get_default(); | |
96db4340 | 9143 | if (!bgp) |
ea372e81 HS |
9144 | return CMD_SUCCESS; |
9145 | ||
9146 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9147 | vty_out(vty, "locator_chunks:\n"); | |
9148 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
9149 | prefix2str(chunk, buf, sizeof(buf)); | |
9150 | vty_out(vty, "- %s\n", buf); | |
9151 | } | |
9152 | ||
9153 | vty_out(vty, "functions:\n"); | |
9154 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9155 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9156 | vty_out(vty, "- sid: %s\n", buf); | |
9157 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9158 | } | |
9159 | ||
9160 | vty_out(vty, "bgps:\n"); | |
9161 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9162 | vty_out(vty, "- name: %s\n", | |
9163 | bgp->name ? bgp->name : "default"); | |
9164 | ||
9165 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9166 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9167 | if (tovpn4_sid) | |
9168 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9169 | sizeof(buf_tovpn4_sid)); | |
9170 | if (tovpn6_sid) | |
9171 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9172 | sizeof(buf_tovpn6_sid)); | |
9173 | ||
9174 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9175 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9176 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9177 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9178 | } | |
9179 | ||
9180 | return CMD_SUCCESS; | |
9181 | } | |
9182 | ||
505e5056 | 9183 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9184 | exit_address_family_cmd, |
9185 | "exit-address-family", | |
9186 | "Exit from Address Family configuration mode\n") | |
9187 | { | |
d62a17ae | 9188 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9189 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9190 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9191 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9192 | || vty->node == BGP_EVPN_NODE |
9193 | || vty->node == BGP_FLOWSPECV4_NODE | |
9194 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9195 | vty->node = BGP_NODE; |
9196 | return CMD_SUCCESS; | |
718e3744 | 9197 | } |
6b0655a2 | 9198 | |
8ad7271d | 9199 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9200 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9201 | const char *ip_str, afi_t afi, safi_t safi, | |
9202 | struct prefix_rd *prd) | |
9203 | { | |
9204 | int ret; | |
9205 | struct prefix match; | |
9bcb3eef DS |
9206 | struct bgp_dest *dest; |
9207 | struct bgp_dest *rm; | |
d62a17ae | 9208 | struct bgp *bgp; |
9209 | struct bgp_table *table; | |
9210 | struct bgp_table *rib; | |
9211 | ||
9212 | /* BGP structure lookup. */ | |
9213 | if (view_name) { | |
9214 | bgp = bgp_lookup_by_name(view_name); | |
9215 | if (bgp == NULL) { | |
9216 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9217 | view_name); | |
9218 | return CMD_WARNING; | |
9219 | } | |
9220 | } else { | |
9221 | bgp = bgp_get_default(); | |
9222 | if (bgp == NULL) { | |
9223 | vty_out(vty, "%% No BGP process is configured\n"); | |
9224 | return CMD_WARNING; | |
9225 | } | |
9226 | } | |
9227 | ||
9228 | /* Check IP address argument. */ | |
9229 | ret = str2prefix(ip_str, &match); | |
9230 | if (!ret) { | |
9231 | vty_out(vty, "%% address is malformed\n"); | |
9232 | return CMD_WARNING; | |
9233 | } | |
9234 | ||
9235 | match.family = afi2family(afi); | |
9236 | rib = bgp->rib[afi][safi]; | |
9237 | ||
9238 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9239 | for (dest = bgp_table_top(rib); dest; |
9240 | dest = bgp_route_next(dest)) { | |
9241 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9242 | |
9bcb3eef | 9243 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9244 | continue; |
9245 | ||
9bcb3eef | 9246 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9247 | if (table == NULL) |
9248 | continue; | |
9249 | ||
4953391b DA |
9250 | rm = bgp_node_match(table, &match); |
9251 | if (rm != NULL) { | |
b54892e0 | 9252 | const struct prefix *rm_p = |
9bcb3eef | 9253 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9254 | |
9255 | if (rm_p->prefixlen == match.prefixlen) { | |
9256 | SET_FLAG(rm->flags, | |
9257 | BGP_NODE_USER_CLEAR); | |
9258 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9259 | } |
9bcb3eef | 9260 | bgp_dest_unlock_node(rm); |
d62a17ae | 9261 | } |
9262 | } | |
9263 | } else { | |
4953391b DA |
9264 | dest = bgp_node_match(rib, &match); |
9265 | if (dest != NULL) { | |
9bcb3eef | 9266 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 9267 | |
9bcb3eef DS |
9268 | if (dest_p->prefixlen == match.prefixlen) { |
9269 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9270 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9271 | } |
9bcb3eef | 9272 | bgp_dest_unlock_node(dest); |
d62a17ae | 9273 | } |
9274 | } | |
9275 | ||
9276 | return CMD_SUCCESS; | |
8ad7271d DS |
9277 | } |
9278 | ||
b09b5ae0 | 9279 | /* one clear bgp command to rule them all */ |
718e3744 | 9280 | DEFUN (clear_ip_bgp_all, |
9281 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9282 | "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>]", |
718e3744 | 9283 | CLEAR_STR |
9284 | IP_STR | |
9285 | BGP_STR | |
838758ac | 9286 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9287 | BGP_AFI_HELP_STR |
fd5e7b70 | 9288 | "Address Family\n" |
510afcd6 | 9289 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9290 | "Address Family modifier\n" |
b09b5ae0 | 9291 | "Clear all peers\n" |
453c92f6 | 9292 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9293 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9294 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9295 | "Clear peers with the AS number\n" |
9296 | "Clear all external peers\n" | |
718e3744 | 9297 | "Clear all members of peer-group\n" |
b09b5ae0 | 9298 | "BGP peer-group name\n" |
b09b5ae0 DW |
9299 | BGP_SOFT_STR |
9300 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9301 | BGP_SOFT_OUT_STR |
9302 | BGP_SOFT_IN_STR | |
9303 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9304 | BGP_SOFT_OUT_STR) |
718e3744 | 9305 | { |
d62a17ae | 9306 | char *vrf = NULL; |
9307 | ||
dc912615 DS |
9308 | afi_t afi = AFI_UNSPEC; |
9309 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9310 | enum clear_sort clr_sort = clear_peer; |
9311 | enum bgp_clear_type clr_type; | |
9312 | char *clr_arg = NULL; | |
9313 | ||
9314 | int idx = 0; | |
9315 | ||
9316 | /* clear [ip] bgp */ | |
9317 | if (argv_find(argv, argc, "ip", &idx)) | |
9318 | afi = AFI_IP; | |
9319 | ||
9a8bdf1c PG |
9320 | /* [<vrf> VIEWVRFNAME] */ |
9321 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9322 | vrf = argv[idx + 1]->arg; | |
9323 | idx += 2; | |
9324 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9325 | vrf = NULL; | |
9326 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9327 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9328 | vrf = argv[idx + 1]->arg; |
9329 | idx += 2; | |
9330 | } | |
d62a17ae | 9331 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9332 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9333 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9334 | ||
d7b9898c | 9335 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9336 | if (argv_find(argv, argc, "*", &idx)) { |
9337 | clr_sort = clear_all; | |
9338 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9339 | clr_sort = clear_peer; | |
9340 | clr_arg = argv[idx]->arg; | |
9341 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9342 | clr_sort = clear_peer; | |
9343 | clr_arg = argv[idx]->arg; | |
9344 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9345 | clr_sort = clear_group; | |
9346 | idx++; | |
9347 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9348 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9349 | clr_sort = clear_peer; |
9350 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9351 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9352 | clr_sort = clear_peer; | |
9353 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9354 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9355 | clr_sort = clear_as; | |
9356 | clr_arg = argv[idx]->arg; | |
9357 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9358 | clr_sort = clear_external; | |
9359 | } | |
9360 | ||
9361 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9362 | if (argv_find(argv, argc, "soft", &idx)) { | |
9363 | if (argv_find(argv, argc, "in", &idx) | |
9364 | || argv_find(argv, argc, "out", &idx)) | |
9365 | clr_type = strmatch(argv[idx]->text, "in") | |
9366 | ? BGP_CLEAR_SOFT_IN | |
9367 | : BGP_CLEAR_SOFT_OUT; | |
9368 | else | |
9369 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9370 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9371 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9372 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9373 | : BGP_CLEAR_SOFT_IN; | |
9374 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9375 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9376 | } else | |
9377 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9378 | ||
1ca2fd11 | 9379 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 9380 | } |
01080f7c | 9381 | |
8ad7271d DS |
9382 | DEFUN (clear_ip_bgp_prefix, |
9383 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9384 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9385 | CLEAR_STR |
9386 | IP_STR | |
9387 | BGP_STR | |
838758ac | 9388 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9389 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9390 | "IPv4 prefix\n") |
8ad7271d | 9391 | { |
d62a17ae | 9392 | char *vrf = NULL; |
9393 | char *prefix = NULL; | |
8ad7271d | 9394 | |
d62a17ae | 9395 | int idx = 0; |
01080f7c | 9396 | |
d62a17ae | 9397 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9398 | if (argv_find(argv, argc, "vrf", &idx)) { |
9399 | vrf = argv[idx + 1]->arg; | |
9400 | idx += 2; | |
9401 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9402 | vrf = NULL; | |
9403 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9404 | /* [<view> VIEWVRFNAME] */ | |
9405 | vrf = argv[idx + 1]->arg; | |
9406 | idx += 2; | |
9407 | } | |
0c7b1b01 | 9408 | |
d62a17ae | 9409 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9410 | |
d62a17ae | 9411 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9412 | } |
8ad7271d | 9413 | |
b09b5ae0 DW |
9414 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9415 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9416 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9417 | CLEAR_STR |
3a2d747c | 9418 | IP_STR |
718e3744 | 9419 | BGP_STR |
8c3deaae | 9420 | "Address Family\n" |
46f296b4 | 9421 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9422 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9423 | "IPv6 prefix\n") |
718e3744 | 9424 | { |
9b475e76 PG |
9425 | int idx_safi = 0; |
9426 | int idx_ipv6_prefix = 0; | |
9427 | safi_t safi = SAFI_UNICAST; | |
9428 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9429 | argv[idx_ipv6_prefix]->arg : NULL; | |
9430 | ||
9431 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9432 | return bgp_clear_prefix( |
9b475e76 PG |
9433 | vty, NULL, prefix, AFI_IP6, |
9434 | safi, NULL); | |
838758ac | 9435 | } |
01080f7c | 9436 | |
b09b5ae0 DW |
9437 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9438 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9439 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9440 | CLEAR_STR |
3a2d747c | 9441 | IP_STR |
718e3744 | 9442 | BGP_STR |
838758ac | 9443 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9444 | "Address Family\n" |
46f296b4 | 9445 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9446 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9447 | "IPv6 prefix\n") |
718e3744 | 9448 | { |
9b475e76 | 9449 | int idx_safi = 0; |
9a8bdf1c | 9450 | int idx_vrfview = 0; |
9b475e76 PG |
9451 | int idx_ipv6_prefix = 0; |
9452 | safi_t safi = SAFI_UNICAST; | |
9453 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9454 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9455 | char *vrfview = NULL; |
9b475e76 | 9456 | |
9a8bdf1c PG |
9457 | /* [<view|vrf> VIEWVRFNAME] */ |
9458 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9459 | vrfview = argv[idx_vrfview + 1]->arg; | |
9460 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9461 | vrfview = NULL; | |
9462 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9463 | /* [<view> VIEWVRFNAME] */ | |
9464 | vrfview = argv[idx_vrfview + 1]->arg; | |
9465 | } | |
9b475e76 PG |
9466 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9467 | ||
d62a17ae | 9468 | return bgp_clear_prefix( |
9b475e76 PG |
9469 | vty, vrfview, prefix, |
9470 | AFI_IP6, safi, NULL); | |
718e3744 | 9471 | } |
9472 | ||
b09b5ae0 DW |
9473 | DEFUN (show_bgp_views, |
9474 | show_bgp_views_cmd, | |
d6e3c605 | 9475 | "show [ip] bgp views", |
b09b5ae0 | 9476 | SHOW_STR |
d6e3c605 | 9477 | IP_STR |
01080f7c | 9478 | BGP_STR |
b09b5ae0 | 9479 | "Show the defined BGP views\n") |
01080f7c | 9480 | { |
d62a17ae | 9481 | struct list *inst = bm->bgp; |
9482 | struct listnode *node; | |
9483 | struct bgp *bgp; | |
01080f7c | 9484 | |
d62a17ae | 9485 | vty_out(vty, "Defined BGP views:\n"); |
9486 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9487 | /* Skip VRFs. */ | |
9488 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9489 | continue; | |
9490 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9491 | bgp->as); | |
9492 | } | |
e52702f2 | 9493 | |
d62a17ae | 9494 | return CMD_SUCCESS; |
e0081f70 ML |
9495 | } |
9496 | ||
8386ac43 | 9497 | DEFUN (show_bgp_vrfs, |
9498 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9499 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9500 | SHOW_STR |
d6e3c605 | 9501 | IP_STR |
8386ac43 | 9502 | BGP_STR |
9503 | "Show BGP VRFs\n" | |
9973d184 | 9504 | JSON_STR) |
8386ac43 | 9505 | { |
fe1dc5a3 | 9506 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9507 | struct list *inst = bm->bgp; |
9508 | struct listnode *node; | |
9509 | struct bgp *bgp; | |
9f049418 | 9510 | bool uj = use_json(argc, argv); |
d62a17ae | 9511 | json_object *json = NULL; |
9512 | json_object *json_vrfs = NULL; | |
9513 | int count = 0; | |
d62a17ae | 9514 | |
d62a17ae | 9515 | if (uj) { |
9516 | json = json_object_new_object(); | |
9517 | json_vrfs = json_object_new_object(); | |
9518 | } | |
9519 | ||
9520 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9521 | const char *name, *type; | |
9522 | struct peer *peer; | |
7fe96307 | 9523 | struct listnode *node2, *nnode2; |
d62a17ae | 9524 | int peers_cfg, peers_estb; |
9525 | json_object *json_vrf = NULL; | |
d62a17ae | 9526 | |
9527 | /* Skip Views. */ | |
9528 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9529 | continue; | |
9530 | ||
9531 | count++; | |
efb4077a | 9532 | if (!uj && count == 1) { |
fe1dc5a3 | 9533 | vty_out(vty, |
efb4077a | 9534 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9535 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9536 | "#PeersEstb", "Name"); |
9537 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9538 | "L3-VNI", "RouterMAC", "Interface"); | |
9539 | } | |
d62a17ae | 9540 | |
9541 | peers_cfg = peers_estb = 0; | |
9542 | if (uj) | |
9543 | json_vrf = json_object_new_object(); | |
9544 | ||
9545 | ||
7fe96307 | 9546 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9547 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9548 | continue; | |
9549 | peers_cfg++; | |
feb17238 | 9550 | if (peer_established(peer)) |
d62a17ae | 9551 | peers_estb++; |
9552 | } | |
9553 | ||
9554 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9555 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9556 | type = "DFLT"; |
9557 | } else { | |
9558 | name = bgp->name; | |
9559 | type = "VRF"; | |
9560 | } | |
9561 | ||
a8bf7d9c | 9562 | |
d62a17ae | 9563 | if (uj) { |
a4d82a8a PZ |
9564 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9565 | ? -1 | |
9566 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9567 | char buf[BUFSIZ] = {0}; |
9568 | ||
d62a17ae | 9569 | json_object_string_add(json_vrf, "type", type); |
9570 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9571 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
9572 | inet_ntop(AF_INET, |
9573 | &bgp->router_id, buf, | |
9574 | sizeof(buf))); | |
d62a17ae | 9575 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9576 | peers_cfg); | |
9577 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9578 | peers_estb); | |
9579 | ||
fe1dc5a3 | 9580 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9581 | json_object_string_add( |
9582 | json_vrf, "rmac", | |
9583 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9584 | json_object_string_add(json_vrf, "interface", |
9585 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9586 | bgp->vrf_id)); | |
d62a17ae | 9587 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9588 | } else { |
23d0a753 | 9589 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9590 | type, |
9591 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9592 | : (int)bgp->vrf_id, | |
23d0a753 | 9593 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9594 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9595 | bgp->l3vni, | |
9596 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9597 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9598 | bgp->vrf_id)); | |
9599 | } | |
d62a17ae | 9600 | } |
9601 | ||
9602 | if (uj) { | |
9603 | json_object_object_add(json, "vrfs", json_vrfs); | |
9604 | ||
9605 | json_object_int_add(json, "totalVrfs", count); | |
9606 | ||
996c9314 LB |
9607 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9608 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9609 | json_object_free(json); |
9610 | } else { | |
9611 | if (count) | |
9612 | vty_out(vty, | |
9613 | "\nTotal number of VRFs (including default): %d\n", | |
9614 | count); | |
9615 | } | |
9616 | ||
9617 | return CMD_SUCCESS; | |
8386ac43 | 9618 | } |
9619 | ||
48ecf8f5 DS |
9620 | DEFUN (show_bgp_mac_hash, |
9621 | show_bgp_mac_hash_cmd, | |
9622 | "show bgp mac hash", | |
9623 | SHOW_STR | |
9624 | BGP_STR | |
9625 | "Mac Address\n" | |
9626 | "Mac Address database\n") | |
9627 | { | |
9628 | bgp_mac_dump_table(vty); | |
9629 | ||
9630 | return CMD_SUCCESS; | |
9631 | } | |
acf71666 | 9632 | |
e3b78da8 | 9633 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9634 | { |
0291c246 | 9635 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9636 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9637 | |
23d0a753 | 9638 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9639 | } |
9640 | ||
9641 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9642 | { | |
9643 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9644 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9645 | |
9646 | vty_out(vty, "Tunnel-ip database:\n"); | |
9647 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9648 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9649 | vty); |
9650 | } | |
9651 | ||
15c81ca4 DS |
9652 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9653 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9654 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9655 | "martian next-hops\n" |
9656 | "martian next-hop database\n") | |
acf71666 | 9657 | { |
0291c246 | 9658 | struct bgp *bgp = NULL; |
15c81ca4 | 9659 | int idx = 0; |
9a8bdf1c PG |
9660 | char *name = NULL; |
9661 | ||
9662 | /* [<vrf> VIEWVRFNAME] */ | |
9663 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9664 | name = argv[idx + 1]->arg; | |
9665 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9666 | name = NULL; | |
9667 | } else if (argv_find(argv, argc, "view", &idx)) | |
9668 | /* [<view> VIEWVRFNAME] */ | |
9669 | name = argv[idx + 1]->arg; | |
9670 | if (name) | |
9671 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9672 | else |
9673 | bgp = bgp_get_default(); | |
acf71666 | 9674 | |
acf71666 MK |
9675 | if (!bgp) { |
9676 | vty_out(vty, "%% No BGP process is configured\n"); | |
9677 | return CMD_WARNING; | |
9678 | } | |
9679 | bgp_show_martian_nexthops(vty, bgp); | |
9680 | ||
9681 | return CMD_SUCCESS; | |
9682 | } | |
9683 | ||
f412b39a | 9684 | DEFUN (show_bgp_memory, |
4bf6a362 | 9685 | show_bgp_memory_cmd, |
7fa12b13 | 9686 | "show [ip] bgp memory", |
4bf6a362 | 9687 | SHOW_STR |
3a2d747c | 9688 | IP_STR |
4bf6a362 PJ |
9689 | BGP_STR |
9690 | "Global BGP memory statistics\n") | |
9691 | { | |
d62a17ae | 9692 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9693 | unsigned long count; | |
9694 | ||
9695 | /* RIB related usage stats */ | |
9696 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9697 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9698 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9699 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9700 | |
9701 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9702 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9703 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9704 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9705 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9706 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9707 | count, | |
4b7e6066 DS |
9708 | mtype_memstr( |
9709 | memstrbuf, sizeof(memstrbuf), | |
9710 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9711 | |
9712 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9713 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9714 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9715 | count * sizeof(struct bgp_static))); | |
9716 | ||
9717 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9718 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9719 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9720 | count * sizeof(struct bpacket))); | |
9721 | ||
9722 | /* Adj-In/Out */ | |
9723 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9724 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9725 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9726 | count * sizeof(struct bgp_adj_in))); | |
9727 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9728 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9729 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9730 | count * sizeof(struct bgp_adj_out))); | |
9731 | ||
9732 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9733 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9734 | count, | |
9735 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9736 | count * sizeof(struct bgp_nexthop_cache))); | |
9737 | ||
9738 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9739 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9740 | count, | |
9741 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9742 | count * sizeof(struct bgp_damp_info))); | |
9743 | ||
9744 | /* Attributes */ | |
9745 | count = attr_count(); | |
9746 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9747 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9748 | count * sizeof(struct attr))); | |
9749 | ||
9750 | if ((count = attr_unknown_count())) | |
9751 | vty_out(vty, "%ld unknown attributes\n", count); | |
9752 | ||
9753 | /* AS_PATH attributes */ | |
9754 | count = aspath_count(); | |
9755 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9756 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9757 | count * sizeof(struct aspath))); | |
9758 | ||
9759 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9760 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9761 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9762 | count * sizeof(struct assegment))); | |
9763 | ||
9764 | /* Other attributes */ | |
9765 | if ((count = community_count())) | |
9766 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9767 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9768 | count * sizeof(struct community))); | |
d62a17ae | 9769 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9770 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9771 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9772 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9773 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9774 | vty_out(vty, | |
9775 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9776 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9777 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9778 | |
9779 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9780 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9781 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9782 | count * sizeof(struct cluster_list))); | |
9783 | ||
9784 | /* Peer related usage */ | |
9785 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9786 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9787 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9788 | count * sizeof(struct peer))); | |
9789 | ||
9790 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9791 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9792 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9793 | count * sizeof(struct peer_group))); | |
9794 | ||
9795 | /* Other */ | |
d62a17ae | 9796 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9797 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9798 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9799 | count * sizeof(regex_t))); | |
d62a17ae | 9800 | return CMD_SUCCESS; |
4bf6a362 | 9801 | } |
fee0f4c6 | 9802 | |
57a9c8a8 DS |
9803 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9804 | { | |
9805 | json_object *bestpath = json_object_new_object(); | |
9806 | ||
892fedb6 | 9807 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9808 | json_object_string_add(bestpath, "asPath", "ignore"); |
9809 | ||
892fedb6 | 9810 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9811 | json_object_string_add(bestpath, "asPath", "confed"); |
9812 | ||
892fedb6 DA |
9813 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9814 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9815 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9816 | "as-set"); |
9817 | else | |
a4d82a8a | 9818 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9819 | "true"); |
9820 | } else | |
a4d82a8a | 9821 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9822 | |
ee88563a JM |
9823 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
9824 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
9825 | ||
892fedb6 | 9826 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9827 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9828 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9829 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9830 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9831 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9832 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9833 | json_object_string_add(bestpath, "med", |
9834 | "missing-as-worst"); | |
9835 | else | |
9836 | json_object_string_add(bestpath, "med", "true"); | |
9837 | } | |
9838 | ||
9839 | json_object_object_add(json, "bestPath", bestpath); | |
9840 | } | |
9841 | ||
3577f1c5 DD |
9842 | /* Print the error code/subcode for why the peer is down */ |
9843 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9844 | json_object *json_peer, bool use_json) | |
9845 | { | |
9846 | const char *code_str; | |
9847 | const char *subcode_str; | |
9848 | ||
9849 | if (use_json) { | |
9850 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9851 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9852 | char errorcodesubcode_hexstr[5]; | |
9853 | char errorcodesubcode_str[256]; | |
9854 | ||
9855 | code_str = bgp_notify_code_str(peer->notify.code); | |
9856 | subcode_str = bgp_notify_subcode_str( | |
9857 | peer->notify.code, | |
9858 | peer->notify.subcode); | |
9859 | ||
772270f3 QY |
9860 | snprintf(errorcodesubcode_hexstr, |
9861 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
9862 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
9863 | json_object_string_add(json_peer, |
9864 | "lastErrorCodeSubcode", | |
9865 | errorcodesubcode_hexstr); | |
9866 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9867 | code_str, subcode_str); | |
9868 | json_object_string_add(json_peer, | |
9869 | "lastNotificationReason", | |
9870 | errorcodesubcode_str); | |
9871 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9872 | && peer->notify.code == BGP_NOTIFY_CEASE | |
9873 | && (peer->notify.subcode | |
9874 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9875 | || peer->notify.subcode | |
9876 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9877 | && peer->notify.length) { | |
9878 | char msgbuf[1024]; | |
9879 | const char *msg_str; | |
9880 | ||
9881 | msg_str = bgp_notify_admin_message( | |
9882 | msgbuf, sizeof(msgbuf), | |
9883 | (uint8_t *)peer->notify.data, | |
9884 | peer->notify.length); | |
9885 | if (msg_str) | |
9886 | json_object_string_add( | |
9887 | json_peer, | |
9888 | "lastShutdownDescription", | |
9889 | msg_str); | |
9890 | } | |
9891 | ||
c258527b | 9892 | } |
3577f1c5 DD |
9893 | json_object_string_add(json_peer, "lastResetDueTo", |
9894 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
9895 | json_object_int_add(json_peer, "lastResetCode", |
9896 | peer->last_reset); | |
3577f1c5 DD |
9897 | } else { |
9898 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9899 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9900 | code_str = bgp_notify_code_str(peer->notify.code); | |
9901 | subcode_str = | |
9902 | bgp_notify_subcode_str(peer->notify.code, | |
9903 | peer->notify.subcode); | |
9904 | vty_out(vty, " Notification %s (%s%s)\n", | |
9905 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9906 | ? "sent" | |
9907 | : "received", | |
9908 | code_str, subcode_str); | |
9909 | } else { | |
e91c24c8 | 9910 | vty_out(vty, " %s\n", |
3577f1c5 DD |
9911 | peer_down_str[(int)peer->last_reset]); |
9912 | } | |
9913 | } | |
9914 | } | |
9915 | ||
9916 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
9917 | safi_t safi) | |
9918 | { | |
feb17238 | 9919 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
9920 | } |
9921 | ||
9922 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
9923 | struct peer *peer, json_object *json_peer, | |
9924 | int max_neighbor_width, bool use_json) | |
9925 | { | |
9926 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
9927 | int len; | |
9928 | ||
9929 | if (use_json) { | |
9930 | if (peer_dynamic_neighbor(peer)) | |
9931 | json_object_boolean_true_add(json_peer, | |
9932 | "dynamicPeer"); | |
9933 | if (peer->hostname) | |
9934 | json_object_string_add(json_peer, "hostname", | |
9935 | peer->hostname); | |
9936 | ||
9937 | if (peer->domainname) | |
9938 | json_object_string_add(json_peer, "domainname", | |
9939 | peer->domainname); | |
9940 | json_object_int_add(json_peer, "connectionsEstablished", | |
9941 | peer->established); | |
9942 | json_object_int_add(json_peer, "connectionsDropped", | |
9943 | peer->dropped); | |
9944 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9945 | use_json, json_peer); | |
feb17238 | 9946 | if (peer_established(peer)) |
3577f1c5 DD |
9947 | json_object_string_add(json_peer, "lastResetDueTo", |
9948 | "AFI/SAFI Not Negotiated"); | |
9949 | else | |
9950 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
9951 | } else { | |
9952 | dn_flag[1] = '\0'; | |
9953 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
9954 | if (peer->hostname | |
892fedb6 | 9955 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
9956 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
9957 | peer->hostname, peer->host); | |
9958 | else | |
9959 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
9960 | ||
9961 | /* pad the neighbor column with spaces */ | |
9962 | if (len < max_neighbor_width) | |
9963 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9964 | " "); | |
e91c24c8 | 9965 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
9966 | peer->dropped, |
9967 | peer_uptime(peer->uptime, timebuf, | |
9968 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 9969 | if (peer_established(peer)) |
3577f1c5 DD |
9970 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
9971 | else | |
9972 | bgp_show_peer_reset(vty, peer, NULL, | |
9973 | false); | |
9974 | } | |
9975 | } | |
c258527b | 9976 | |
cb75bb31 DA |
9977 | /* If the peer's description includes whitespaces |
9978 | * then return the first occurrence. Also strip description | |
9979 | * to the given size if needed. | |
9980 | */ | |
9981 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) | |
9982 | { | |
9983 | static char stripped[BUFSIZ]; | |
9984 | char *pnt; | |
9985 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; | |
9986 | ||
9987 | pnt = strchr(desc, ' '); | |
9988 | if (pnt) | |
9989 | len = size > (uint32_t)(pnt - desc) ? (uint32_t)(pnt - desc) | |
9990 | : size; | |
9991 | ||
9992 | strlcpy(stripped, desc, len + 1); | |
9993 | ||
9994 | return stripped; | |
9995 | } | |
3577f1c5 | 9996 | |
8c1d4cd5 LS |
9997 | /* Determine whether var peer should be filtered out of the summary. */ |
9998 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
9999 | struct peer *fpeer, int as_type, | |
10000 | as_t as) | |
10001 | { | |
10002 | ||
10003 | /* filter neighbor XXXX */ | |
10004 | if (fpeer && fpeer != peer) | |
10005 | return true; | |
10006 | ||
10007 | /* filter remote-as (internal|external) */ | |
10008 | if (as_type != AS_UNSPECIFIED) { | |
10009 | if (peer->as_type == AS_SPECIFIED) { | |
10010 | if (as_type == AS_INTERNAL) { | |
10011 | if (peer->as != peer->local_as) | |
10012 | return true; | |
10013 | } else if (peer->as == peer->local_as) | |
10014 | return true; | |
10015 | } else if (as_type != peer->as_type) | |
10016 | return true; | |
10017 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10018 | return true; | |
10019 | ||
10020 | return false; | |
10021 | } | |
10022 | ||
718e3744 | 10023 | /* Show BGP peer's summary information. */ |
d62a17ae | 10024 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10025 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10026 | uint16_t show_flags) |
d62a17ae | 10027 | { |
10028 | struct peer *peer; | |
10029 | struct listnode *node, *nnode; | |
10030 | unsigned int count = 0, dn_count = 0; | |
10031 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10032 | char neighbor_buf[VTY_BUFSIZ]; | |
10033 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10034 | int len, failed_count = 0; |
ce1944f0 | 10035 | unsigned int filtered_count = 0; |
d62a17ae | 10036 | int max_neighbor_width = 0; |
10037 | int pfx_rcd_safi; | |
3c13337d | 10038 | json_object *json = NULL; |
d62a17ae | 10039 | json_object *json_peer = NULL; |
10040 | json_object *json_peers = NULL; | |
50e05855 | 10041 | struct peer_af *paf; |
d3ada366 | 10042 | struct bgp_filter *filter; |
85eeb029 DA |
10043 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10044 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10045 | bool show_established = | |
10046 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10047 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10048 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10049 | |
10050 | /* labeled-unicast routes are installed in the unicast table so in order | |
10051 | * to | |
10052 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10053 | */ | |
3577f1c5 | 10054 | |
d62a17ae | 10055 | if (safi == SAFI_LABELED_UNICAST) |
10056 | pfx_rcd_safi = SAFI_UNICAST; | |
10057 | else | |
10058 | pfx_rcd_safi = safi; | |
10059 | ||
10060 | if (use_json) { | |
3c13337d | 10061 | json = json_object_new_object(); |
d62a17ae | 10062 | json_peers = json_object_new_object(); |
3577f1c5 | 10063 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10064 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10065 | as_type, as)) { | |
ce1944f0 | 10066 | filtered_count++; |
8c1d4cd5 LS |
10067 | count++; |
10068 | continue; | |
10069 | } | |
10070 | ||
3577f1c5 DD |
10071 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10072 | continue; | |
10073 | ||
10074 | if (peer->afc[afi][safi]) { | |
10075 | /* See if we have at least a single failed peer */ | |
10076 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10077 | failed_count++; | |
10078 | count++; | |
10079 | } | |
10080 | if (peer_dynamic_neighbor(peer)) | |
10081 | dn_count++; | |
10082 | } | |
c258527b | 10083 | |
d62a17ae | 10084 | } else { |
10085 | /* Loop over all neighbors that will be displayed to determine | |
10086 | * how many | |
10087 | * characters are needed for the Neighbor column | |
10088 | */ | |
10089 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10090 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10091 | as_type, as)) { | |
ce1944f0 | 10092 | filtered_count++; |
8c1d4cd5 LS |
10093 | count++; |
10094 | continue; | |
10095 | } | |
10096 | ||
d62a17ae | 10097 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10098 | continue; | |
10099 | ||
10100 | if (peer->afc[afi][safi]) { | |
10101 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10102 | if (peer_dynamic_neighbor(peer)) | |
10103 | dn_flag[0] = '*'; | |
10104 | ||
10105 | if (peer->hostname | |
892fedb6 DA |
10106 | && CHECK_FLAG(bgp->flags, |
10107 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10108 | snprintf(neighbor_buf, |
10109 | sizeof(neighbor_buf), | |
10110 | "%s%s(%s) ", dn_flag, | |
10111 | peer->hostname, peer->host); | |
d62a17ae | 10112 | else |
772270f3 QY |
10113 | snprintf(neighbor_buf, |
10114 | sizeof(neighbor_buf), "%s%s ", | |
10115 | dn_flag, peer->host); | |
d62a17ae | 10116 | |
10117 | len = strlen(neighbor_buf); | |
10118 | ||
10119 | if (len > max_neighbor_width) | |
10120 | max_neighbor_width = len; | |
c258527b | 10121 | |
3577f1c5 DD |
10122 | /* See if we have at least a single failed peer */ |
10123 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10124 | failed_count++; | |
10125 | count++; | |
d62a17ae | 10126 | } |
10127 | } | |
f933309e | 10128 | |
d62a17ae | 10129 | /* Originally we displayed the Neighbor column as 16 |
10130 | * characters wide so make that the default | |
10131 | */ | |
10132 | if (max_neighbor_width < neighbor_col_default_width) | |
10133 | max_neighbor_width = neighbor_col_default_width; | |
10134 | } | |
f933309e | 10135 | |
3577f1c5 DD |
10136 | if (show_failed && !failed_count) { |
10137 | if (use_json) { | |
10138 | json_object_int_add(json, "failedPeersCount", 0); | |
10139 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10140 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10141 | |
10142 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10143 | json, JSON_C_TO_STRING_PRETTY)); | |
10144 | json_object_free(json); | |
10145 | } else { | |
10146 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10147 | } |
10148 | return CMD_SUCCESS; | |
10149 | } | |
c258527b | 10150 | |
3577f1c5 | 10151 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10152 | filtered_count = 0; |
d62a17ae | 10153 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10154 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10155 | continue; | |
10156 | ||
ea47320b DL |
10157 | if (!peer->afc[afi][safi]) |
10158 | continue; | |
d62a17ae | 10159 | |
ea47320b DL |
10160 | if (!count) { |
10161 | unsigned long ents; | |
10162 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10163 | int64_t vrf_id_ui; |
d62a17ae | 10164 | |
a4d82a8a PZ |
10165 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10166 | ? -1 | |
10167 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10168 | |
10169 | /* Usage summary and header */ | |
10170 | if (use_json) { | |
23d0a753 DA |
10171 | char buf[BUFSIZ] = {0}; |
10172 | ||
ea47320b DL |
10173 | json_object_string_add( |
10174 | json, "routerId", | |
23d0a753 DA |
10175 | inet_ntop(AF_INET, &bgp->router_id, buf, |
10176 | sizeof(buf))); | |
60466a63 QY |
10177 | json_object_int_add(json, "as", bgp->as); |
10178 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10179 | json_object_string_add( |
10180 | json, "vrfName", | |
10181 | (bgp->inst_type | |
10182 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10183 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10184 | : bgp->name); |
10185 | } else { | |
10186 | vty_out(vty, | |
23d0a753 DA |
10187 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10188 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10189 | bgp->vrf_id == VRF_UNKNOWN |
10190 | ? -1 | |
10191 | : (int)bgp->vrf_id); | |
ea47320b DL |
10192 | vty_out(vty, "\n"); |
10193 | } | |
d62a17ae | 10194 | |
ea47320b | 10195 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10196 | if (use_json) { |
ea47320b | 10197 | json_object_int_add( |
60466a63 | 10198 | json, "updateDelayLimit", |
ea47320b | 10199 | bgp->v_update_delay); |
d62a17ae | 10200 | |
ea47320b DL |
10201 | if (bgp->v_update_delay |
10202 | != bgp->v_establish_wait) | |
d62a17ae | 10203 | json_object_int_add( |
10204 | json, | |
ea47320b DL |
10205 | "updateDelayEstablishWait", |
10206 | bgp->v_establish_wait); | |
d62a17ae | 10207 | |
60466a63 | 10208 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10209 | json_object_string_add( |
10210 | json, | |
10211 | "updateDelayFirstNeighbor", | |
10212 | bgp->update_delay_begin_time); | |
10213 | json_object_boolean_true_add( | |
10214 | json, | |
10215 | "updateDelayInProgress"); | |
10216 | } else { | |
10217 | if (bgp->update_delay_over) { | |
d62a17ae | 10218 | json_object_string_add( |
10219 | json, | |
10220 | "updateDelayFirstNeighbor", | |
10221 | bgp->update_delay_begin_time); | |
ea47320b | 10222 | json_object_string_add( |
d62a17ae | 10223 | json, |
ea47320b DL |
10224 | "updateDelayBestpathResumed", |
10225 | bgp->update_delay_end_time); | |
10226 | json_object_string_add( | |
d62a17ae | 10227 | json, |
ea47320b DL |
10228 | "updateDelayZebraUpdateResume", |
10229 | bgp->update_delay_zebra_resume_time); | |
10230 | json_object_string_add( | |
10231 | json, | |
10232 | "updateDelayPeerUpdateResume", | |
10233 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10234 | } |
ea47320b DL |
10235 | } |
10236 | } else { | |
10237 | vty_out(vty, | |
10238 | "Read-only mode update-delay limit: %d seconds\n", | |
10239 | bgp->v_update_delay); | |
10240 | if (bgp->v_update_delay | |
10241 | != bgp->v_establish_wait) | |
d62a17ae | 10242 | vty_out(vty, |
ea47320b DL |
10243 | " Establish wait: %d seconds\n", |
10244 | bgp->v_establish_wait); | |
d62a17ae | 10245 | |
60466a63 | 10246 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10247 | vty_out(vty, |
10248 | " First neighbor established: %s\n", | |
10249 | bgp->update_delay_begin_time); | |
10250 | vty_out(vty, | |
10251 | " Delay in progress\n"); | |
10252 | } else { | |
10253 | if (bgp->update_delay_over) { | |
d62a17ae | 10254 | vty_out(vty, |
10255 | " First neighbor established: %s\n", | |
10256 | bgp->update_delay_begin_time); | |
10257 | vty_out(vty, | |
ea47320b DL |
10258 | " Best-paths resumed: %s\n", |
10259 | bgp->update_delay_end_time); | |
10260 | vty_out(vty, | |
10261 | " zebra update resumed: %s\n", | |
10262 | bgp->update_delay_zebra_resume_time); | |
10263 | vty_out(vty, | |
10264 | " peers update resumed: %s\n", | |
10265 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10266 | } |
10267 | } | |
10268 | } | |
ea47320b | 10269 | } |
d62a17ae | 10270 | |
ea47320b DL |
10271 | if (use_json) { |
10272 | if (bgp_maxmed_onstartup_configured(bgp) | |
10273 | && bgp->maxmed_active) | |
10274 | json_object_boolean_true_add( | |
60466a63 | 10275 | json, "maxMedOnStartup"); |
ea47320b DL |
10276 | if (bgp->v_maxmed_admin) |
10277 | json_object_boolean_true_add( | |
60466a63 | 10278 | json, "maxMedAdministrative"); |
d62a17ae | 10279 | |
ea47320b DL |
10280 | json_object_int_add( |
10281 | json, "tableVersion", | |
60466a63 | 10282 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10283 | |
60466a63 QY |
10284 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10285 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10286 | json_object_int_add( |
10287 | json, "ribMemory", | |
9bcb3eef | 10288 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10289 | |
210ec2a0 | 10290 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10291 | json_object_int_add(json, "peerCount", ents); |
10292 | json_object_int_add(json, "peerMemory", | |
10293 | ents * sizeof(struct peer)); | |
d62a17ae | 10294 | |
ea47320b DL |
10295 | if ((ents = listcount(bgp->group))) { |
10296 | json_object_int_add( | |
60466a63 | 10297 | json, "peerGroupCount", ents); |
ea47320b DL |
10298 | json_object_int_add( |
10299 | json, "peerGroupMemory", | |
996c9314 LB |
10300 | ents * sizeof(struct |
10301 | peer_group)); | |
ea47320b | 10302 | } |
d62a17ae | 10303 | |
ea47320b DL |
10304 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10305 | BGP_CONFIG_DAMPENING)) | |
10306 | json_object_boolean_true_add( | |
60466a63 | 10307 | json, "dampeningEnabled"); |
ea47320b | 10308 | } else { |
96c81f66 LS |
10309 | if (!show_terse) { |
10310 | if (bgp_maxmed_onstartup_configured(bgp) | |
10311 | && bgp->maxmed_active) | |
10312 | vty_out(vty, | |
10313 | "Max-med on-startup active\n"); | |
10314 | if (bgp->v_maxmed_admin) | |
10315 | vty_out(vty, | |
10316 | "Max-med administrative active\n"); | |
d62a17ae | 10317 | |
96c81f66 LS |
10318 | vty_out(vty, |
10319 | "BGP table version %" PRIu64 | |
10320 | "\n", | |
10321 | bgp_table_version( | |
10322 | bgp->rib[afi][safi])); | |
ea47320b | 10323 | |
96c81f66 LS |
10324 | ents = bgp_table_count( |
10325 | bgp->rib[afi][safi]); | |
d62a17ae | 10326 | vty_out(vty, |
96c81f66 | 10327 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 10328 | ents, |
10329 | mtype_memstr( | |
10330 | memstrbuf, | |
10331 | sizeof(memstrbuf), | |
96c81f66 LS |
10332 | ents |
10333 | * sizeof( | |
10334 | struct | |
10335 | bgp_dest))); | |
d62a17ae | 10336 | |
96c81f66 LS |
10337 | /* Peer related usage */ |
10338 | ents = bgp->af_peer_count[afi][safi]; | |
10339 | vty_out(vty, | |
10340 | "Peers %ld, using %s of memory\n", | |
10341 | ents, | |
10342 | mtype_memstr( | |
10343 | memstrbuf, | |
10344 | sizeof(memstrbuf), | |
10345 | ents | |
10346 | * sizeof( | |
10347 | struct | |
10348 | peer))); | |
d62a17ae | 10349 | |
96c81f66 LS |
10350 | if ((ents = listcount(bgp->group))) |
10351 | vty_out(vty, | |
10352 | "Peer groups %ld, using %s of memory\n", | |
10353 | ents, | |
10354 | mtype_memstr( | |
10355 | memstrbuf, | |
10356 | sizeof(memstrbuf), | |
10357 | ents | |
10358 | * sizeof( | |
10359 | struct | |
10360 | peer_group))); | |
10361 | ||
10362 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10363 | BGP_CONFIG_DAMPENING)) | |
10364 | vty_out(vty, | |
10365 | "Dampening enabled.\n"); | |
10366 | } | |
10367 | if (show_failed) { | |
10368 | vty_out(vty, "\n"); | |
10369 | ||
10370 | /* Subtract 8 here because 'Neighbor' is | |
10371 | * 8 characters */ | |
10372 | vty_out(vty, "Neighbor"); | |
10373 | vty_out(vty, "%*s", | |
10374 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
10375 | vty_out(vty, |
10376 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 10377 | } |
d62a17ae | 10378 | } |
ea47320b | 10379 | } |
d62a17ae | 10380 | |
d55811cc | 10381 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10382 | filter = &peer->filter[afi][safi]; |
db92d226 | 10383 | |
ea47320b | 10384 | count++; |
3577f1c5 DD |
10385 | /* Works for both failed & successful cases */ |
10386 | if (peer_dynamic_neighbor(peer)) | |
10387 | dn_count++; | |
d62a17ae | 10388 | |
ea47320b | 10389 | if (use_json) { |
3577f1c5 | 10390 | json_peer = NULL; |
8c1d4cd5 | 10391 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10392 | as_type, as)) { |
10393 | filtered_count++; | |
8c1d4cd5 | 10394 | continue; |
ce1944f0 | 10395 | } |
3577f1c5 DD |
10396 | if (show_failed && |
10397 | bgp_has_peer_failed(peer, afi, safi)) { | |
10398 | json_peer = json_object_new_object(); | |
10399 | bgp_show_failed_summary(vty, bgp, peer, | |
10400 | json_peer, 0, use_json); | |
10401 | } else if (!show_failed) { | |
10b49f14 | 10402 | if (show_established |
ce1944f0 LS |
10403 | && bgp_has_peer_failed(peer, afi, safi)) { |
10404 | filtered_count++; | |
10b49f14 | 10405 | continue; |
ce1944f0 | 10406 | } |
10b49f14 | 10407 | |
3577f1c5 DD |
10408 | json_peer = json_object_new_object(); |
10409 | if (peer_dynamic_neighbor(peer)) { | |
10410 | json_object_boolean_true_add(json_peer, | |
10411 | "dynamicPeer"); | |
10412 | } | |
d62a17ae | 10413 | |
3577f1c5 DD |
10414 | if (peer->hostname) |
10415 | json_object_string_add(json_peer, "hostname", | |
10416 | peer->hostname); | |
10417 | ||
10418 | if (peer->domainname) | |
10419 | json_object_string_add(json_peer, "domainname", | |
10420 | peer->domainname); | |
10421 | ||
10422 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10423 | json_object_int_add( |
10424 | json_peer, "localAs", | |
10425 | peer->change_local_as | |
10426 | ? peer->change_local_as | |
10427 | : peer->local_as); | |
3577f1c5 DD |
10428 | json_object_int_add(json_peer, "version", 4); |
10429 | json_object_int_add(json_peer, "msgRcvd", | |
10430 | PEER_TOTAL_RX(peer)); | |
10431 | json_object_int_add(json_peer, "msgSent", | |
10432 | PEER_TOTAL_TX(peer)); | |
10433 | ||
43aa5965 QY |
10434 | atomic_size_t outq_count, inq_count; |
10435 | outq_count = atomic_load_explicit( | |
10436 | &peer->obuf->count, | |
10437 | memory_order_relaxed); | |
10438 | inq_count = atomic_load_explicit( | |
10439 | &peer->ibuf->count, | |
10440 | memory_order_relaxed); | |
10441 | ||
3577f1c5 DD |
10442 | json_object_int_add(json_peer, "tableVersion", |
10443 | peer->version[afi][safi]); | |
10444 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10445 | outq_count); |
10446 | json_object_int_add(json_peer, "inq", | |
10447 | inq_count); | |
3577f1c5 DD |
10448 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10449 | use_json, json_peer); | |
10450 | ||
3577f1c5 DD |
10451 | json_object_int_add(json_peer, "pfxRcd", |
10452 | peer->pcount[afi][pfx_rcd_safi]); | |
10453 | ||
3577f1c5 | 10454 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10455 | json_object_int_add( |
10456 | json_peer, "pfxSnt", | |
10457 | (PAF_SUBGRP(paf))->scount); | |
10458 | else | |
10459 | json_object_int_add(json_peer, "pfxSnt", | |
10460 | 0); | |
0e1f8ab5 DA |
10461 | |
10462 | /* BGP FSM state */ | |
cb9196e7 | 10463 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10464 | || CHECK_FLAG(peer->bgp->flags, |
10465 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10466 | json_object_string_add(json_peer, |
10467 | "state", | |
3577f1c5 DD |
10468 | "Idle (Admin)"); |
10469 | else if (peer->afc_recv[afi][safi]) | |
10470 | json_object_string_add( | |
0e1f8ab5 DA |
10471 | json_peer, "state", |
10472 | lookup_msg(bgp_status_msg, | |
10473 | peer->status, NULL)); | |
10474 | else if (CHECK_FLAG( | |
10475 | peer->sflags, | |
10476 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10477 | json_object_string_add(json_peer, | |
10478 | "state", | |
3577f1c5 DD |
10479 | "Idle (PfxCt)"); |
10480 | else | |
10481 | json_object_string_add( | |
0e1f8ab5 DA |
10482 | json_peer, "state", |
10483 | lookup_msg(bgp_status_msg, | |
10484 | peer->status, NULL)); | |
10485 | ||
10486 | /* BGP peer state */ | |
10487 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10488 | || CHECK_FLAG(peer->bgp->flags, | |
10489 | BGP_FLAG_SHUTDOWN)) | |
10490 | json_object_string_add(json_peer, | |
10491 | "peerState", | |
10492 | "Admin"); | |
10493 | else if (CHECK_FLAG( | |
10494 | peer->sflags, | |
10495 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10496 | json_object_string_add(json_peer, | |
10497 | "peerState", | |
10498 | "PfxCt"); | |
10499 | else if (CHECK_FLAG(peer->flags, | |
10500 | PEER_FLAG_PASSIVE)) | |
10501 | json_object_string_add(json_peer, | |
10502 | "peerState", | |
10503 | "Passive"); | |
10504 | else if (CHECK_FLAG(peer->sflags, | |
10505 | PEER_STATUS_NSF_WAIT)) | |
10506 | json_object_string_add(json_peer, | |
10507 | "peerState", | |
10508 | "NSF passive"); | |
10509 | else if (CHECK_FLAG( | |
10510 | peer->bgp->flags, | |
10511 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10512 | && (!bgp_inbound_policy_exists(peer, | |
10513 | filter) | |
10514 | || !bgp_outbound_policy_exists( | |
10515 | peer, filter))) | |
10516 | json_object_string_add(json_peer, | |
10517 | "peerState", | |
10518 | "Policy"); | |
10519 | else | |
10520 | json_object_string_add( | |
10521 | json_peer, "peerState", "OK"); | |
10522 | ||
200116db DD |
10523 | json_object_int_add(json_peer, "connectionsEstablished", |
10524 | peer->established); | |
10525 | json_object_int_add(json_peer, "connectionsDropped", | |
10526 | peer->dropped); | |
aa72bd7e PG |
10527 | if (peer->desc) |
10528 | json_object_string_add( | |
10529 | json_peer, "desc", peer->desc); | |
b4e9dcba | 10530 | } |
3577f1c5 DD |
10531 | /* Avoid creating empty peer dicts in JSON */ |
10532 | if (json_peer == NULL) | |
10533 | continue; | |
ea47320b DL |
10534 | |
10535 | if (peer->conf_if) | |
60466a63 | 10536 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10537 | "interface"); |
10538 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10539 | json_object_string_add(json_peer, "idType", |
10540 | "ipv4"); | |
ea47320b | 10541 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10542 | json_object_string_add(json_peer, "idType", |
10543 | "ipv6"); | |
ea47320b DL |
10544 | json_object_object_add(json_peers, peer->host, |
10545 | json_peer); | |
10546 | } else { | |
8c1d4cd5 | 10547 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10548 | as_type, as)) { |
10549 | filtered_count++; | |
8c1d4cd5 | 10550 | continue; |
ce1944f0 | 10551 | } |
3577f1c5 DD |
10552 | if (show_failed && |
10553 | bgp_has_peer_failed(peer, afi, safi)) { | |
10554 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10555 | max_neighbor_width, | |
10556 | use_json); | |
10557 | } else if (!show_failed) { | |
10b49f14 | 10558 | if (show_established |
ce1944f0 LS |
10559 | && bgp_has_peer_failed(peer, afi, safi)) { |
10560 | filtered_count++; | |
10b49f14 | 10561 | continue; |
ce1944f0 | 10562 | } |
96c81f66 LS |
10563 | |
10564 | if ((count - filtered_count) == 1) { | |
10565 | /* display headline before the first | |
10566 | * neighbor line */ | |
10567 | vty_out(vty, "\n"); | |
10568 | ||
10569 | /* Subtract 8 here because 'Neighbor' is | |
10570 | * 8 characters */ | |
10571 | vty_out(vty, "Neighbor"); | |
10572 | vty_out(vty, "%*s", | |
10573 | max_neighbor_width - 8, " "); | |
10574 | vty_out(vty, | |
10575 | show_wide | |
10576 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10577 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10578 | } | |
10579 | ||
3577f1c5 DD |
10580 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10581 | if (peer_dynamic_neighbor(peer)) { | |
10582 | dn_flag[0] = '*'; | |
10583 | } | |
d62a17ae | 10584 | |
3577f1c5 | 10585 | if (peer->hostname |
892fedb6 DA |
10586 | && CHECK_FLAG(bgp->flags, |
10587 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10588 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10589 | peer->hostname, |
10590 | peer->host); | |
d62a17ae | 10591 | else |
3577f1c5 DD |
10592 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10593 | ||
10594 | /* pad the neighbor column with spaces */ | |
10595 | if (len < max_neighbor_width) | |
10596 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10597 | " "); | |
10598 | ||
43aa5965 QY |
10599 | atomic_size_t outq_count, inq_count; |
10600 | outq_count = atomic_load_explicit( | |
10601 | &peer->obuf->count, | |
10602 | memory_order_relaxed); | |
10603 | inq_count = atomic_load_explicit( | |
10604 | &peer->ibuf->count, | |
10605 | memory_order_relaxed); | |
10606 | ||
85eeb029 DA |
10607 | if (show_wide) |
10608 | vty_out(vty, | |
10609 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10610 | " %4zu %4zu %8s", | |
10611 | peer->as, | |
10612 | peer->change_local_as | |
10613 | ? peer->change_local_as | |
10614 | : peer->local_as, | |
10615 | PEER_TOTAL_RX(peer), | |
10616 | PEER_TOTAL_TX(peer), | |
10617 | peer->version[afi][safi], | |
10618 | inq_count, outq_count, | |
10619 | peer_uptime(peer->uptime, | |
10620 | timebuf, | |
10621 | BGP_UPTIME_LEN, 0, | |
10622 | NULL)); | |
10623 | else | |
10624 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10625 | " %4zu %4zu %8s", | |
10626 | peer->as, PEER_TOTAL_RX(peer), | |
10627 | PEER_TOTAL_TX(peer), | |
10628 | peer->version[afi][safi], | |
10629 | inq_count, outq_count, | |
10630 | peer_uptime(peer->uptime, | |
10631 | timebuf, | |
10632 | BGP_UPTIME_LEN, 0, | |
10633 | NULL)); | |
3577f1c5 | 10634 | |
feb17238 | 10635 | if (peer_established(peer)) { |
d3ada366 DA |
10636 | if (peer->afc_recv[afi][safi]) { |
10637 | if (CHECK_FLAG( | |
10638 | bgp->flags, | |
10639 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10640 | && !bgp_inbound_policy_exists( | |
10641 | peer, filter)) | |
10642 | vty_out(vty, " %12s", | |
10643 | "(Policy)"); | |
10644 | else | |
10645 | vty_out(vty, | |
6cde4b45 | 10646 | " %12u", |
d3ada366 DA |
10647 | peer->pcount |
10648 | [afi] | |
10649 | [pfx_rcd_safi]); | |
10650 | } else { | |
749d0f27 | 10651 | vty_out(vty, " NoNeg"); |
d3ada366 | 10652 | } |
db92d226 | 10653 | |
d3ada366 DA |
10654 | if (paf && PAF_SUBGRP(paf)) { |
10655 | if (CHECK_FLAG( | |
10656 | bgp->flags, | |
10657 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10658 | && !bgp_outbound_policy_exists( | |
10659 | peer, filter)) | |
10660 | vty_out(vty, " %8s", | |
10661 | "(Policy)"); | |
10662 | else | |
10663 | vty_out(vty, | |
6cde4b45 | 10664 | " %8u", |
d3ada366 DA |
10665 | (PAF_SUBGRP( |
10666 | paf)) | |
10667 | ->scount); | |
749d0f27 DA |
10668 | } else { |
10669 | vty_out(vty, " NoNeg"); | |
d3ada366 | 10670 | } |
db92d226 | 10671 | } else { |
736b68f3 DS |
10672 | if (CHECK_FLAG(peer->flags, |
10673 | PEER_FLAG_SHUTDOWN) | |
10674 | || CHECK_FLAG(peer->bgp->flags, | |
10675 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10676 | vty_out(vty, " Idle (Admin)"); |
10677 | else if (CHECK_FLAG( | |
10678 | peer->sflags, | |
10679 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10680 | vty_out(vty, " Idle (PfxCt)"); | |
10681 | else | |
10682 | vty_out(vty, " %12s", | |
10683 | lookup_msg(bgp_status_msg, | |
10684 | peer->status, NULL)); | |
db92d226 | 10685 | |
6cde4b45 | 10686 | vty_out(vty, " %8u", 0); |
3577f1c5 | 10687 | } |
aa72bd7e | 10688 | if (peer->desc) |
cb75bb31 DA |
10689 | vty_out(vty, " %s", |
10690 | bgp_peer_description_stripped( | |
85eeb029 DA |
10691 | peer->desc, |
10692 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
10693 | else |
10694 | vty_out(vty, " N/A"); | |
3577f1c5 | 10695 | vty_out(vty, "\n"); |
d62a17ae | 10696 | } |
3577f1c5 | 10697 | |
d62a17ae | 10698 | } |
10699 | } | |
f933309e | 10700 | |
d62a17ae | 10701 | if (use_json) { |
10702 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10703 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
10704 | json_object_int_add(json, "displayedPeers", |
10705 | count - filtered_count); | |
d62a17ae | 10706 | json_object_int_add(json, "totalPeers", count); |
10707 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10708 | ||
3577f1c5 DD |
10709 | if (!show_failed) |
10710 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10711 | |
996c9314 LB |
10712 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10713 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10714 | json_object_free(json); |
10715 | } else { | |
ce1944f0 | 10716 | if (count) { |
96c81f66 LS |
10717 | if (filtered_count == count) |
10718 | vty_out(vty, "\n%% No matching neighbor\n"); | |
10719 | else { | |
10720 | if (show_failed) | |
10721 | vty_out(vty, "\nDisplayed neighbors %d", | |
10722 | failed_count); | |
10723 | else if (as_type != AS_UNSPECIFIED || as | |
10724 | || fpeer || show_established) | |
ce1944f0 LS |
10725 | vty_out(vty, "\nDisplayed neighbors %d", |
10726 | count - filtered_count); | |
96c81f66 LS |
10727 | |
10728 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
10729 | count); | |
ce1944f0 | 10730 | } |
ce1944f0 | 10731 | } else { |
d6ceaca3 | 10732 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10733 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10734 | } |
b05a1c8b | 10735 | |
d6ceaca3 | 10736 | if (dn_count) { |
d62a17ae | 10737 | vty_out(vty, "* - dynamic neighbor\n"); |
10738 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10739 | dn_count, bgp->dynamic_neighbors_limit); | |
10740 | } | |
10741 | } | |
1ff9a340 | 10742 | |
d62a17ae | 10743 | return CMD_SUCCESS; |
718e3744 | 10744 | } |
10745 | ||
d62a17ae | 10746 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 10747 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 10748 | as_t as, uint16_t show_flags) |
d62a17ae | 10749 | { |
10750 | int is_first = 1; | |
10751 | int afi_wildcard = (afi == AFI_MAX); | |
10752 | int safi_wildcard = (safi == SAFI_MAX); | |
10753 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10754 | bool nbr_output = false; |
85eeb029 | 10755 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10756 | |
10757 | if (use_json && is_wildcard) | |
10758 | vty_out(vty, "{\n"); | |
10759 | if (afi_wildcard) | |
10760 | afi = 1; /* AFI_IP */ | |
10761 | while (afi < AFI_MAX) { | |
10762 | if (safi_wildcard) | |
10763 | safi = 1; /* SAFI_UNICAST */ | |
10764 | while (safi < SAFI_MAX) { | |
318cac96 | 10765 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10766 | nbr_output = true; |
f86897b9 | 10767 | |
d62a17ae | 10768 | if (is_wildcard) { |
10769 | /* | |
10770 | * So limit output to those afi/safi | |
10771 | * pairs that | |
10772 | * actualy have something interesting in | |
10773 | * them | |
10774 | */ | |
10775 | if (use_json) { | |
d62a17ae | 10776 | if (!is_first) |
10777 | vty_out(vty, ",\n"); | |
10778 | else | |
10779 | is_first = 0; | |
10780 | ||
10781 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10782 | get_afi_safi_str(afi, |
10783 | safi, | |
10784 | true)); | |
d62a17ae | 10785 | } else { |
6cac2fcc LS |
10786 | vty_out(vty, |
10787 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
10788 | get_afi_safi_str(afi, |
10789 | safi, | |
6cac2fcc LS |
10790 | false), |
10791 | bgp->name_pretty); | |
d62a17ae | 10792 | } |
10793 | } | |
8c1d4cd5 LS |
10794 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
10795 | as_type, as, show_flags); | |
d62a17ae | 10796 | } |
10797 | safi++; | |
d62a17ae | 10798 | if (!safi_wildcard) |
10799 | safi = SAFI_MAX; | |
10800 | } | |
10801 | afi++; | |
ee851c8c | 10802 | if (!afi_wildcard) |
d62a17ae | 10803 | afi = AFI_MAX; |
10804 | } | |
10805 | ||
10806 | if (use_json && is_wildcard) | |
10807 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10808 | else if (!nbr_output) { |
10809 | if (use_json) | |
10810 | vty_out(vty, "{}\n"); | |
10811 | else | |
6cac2fcc LS |
10812 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
10813 | bgp->name_pretty); | |
ca61fd25 | 10814 | } |
d62a17ae | 10815 | } |
10816 | ||
10817 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
10818 | safi_t safi, |
10819 | const char *neighbor, | |
10820 | int as_type, as_t as, | |
96c81f66 | 10821 | uint16_t show_flags) |
d62a17ae | 10822 | { |
10823 | struct listnode *node, *nnode; | |
10824 | struct bgp *bgp; | |
8c1d4cd5 | 10825 | struct peer *fpeer = NULL; |
d62a17ae | 10826 | int is_first = 1; |
9f049418 | 10827 | bool nbr_output = false; |
85eeb029 | 10828 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10829 | |
10830 | if (use_json) | |
10831 | vty_out(vty, "{\n"); | |
10832 | ||
10833 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10834 | nbr_output = true; |
d62a17ae | 10835 | if (use_json) { |
d62a17ae | 10836 | if (!is_first) |
10837 | vty_out(vty, ",\n"); | |
10838 | else | |
10839 | is_first = 0; | |
10840 | ||
10841 | vty_out(vty, "\"%s\":", | |
10842 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10843 | ? VRF_DEFAULT_NAME |
d62a17ae | 10844 | : bgp->name); |
d62a17ae | 10845 | } |
8c1d4cd5 LS |
10846 | if (neighbor) { |
10847 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10848 | use_json); | |
10849 | if (!fpeer) | |
10850 | continue; | |
10851 | } | |
10852 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
10853 | as, show_flags); | |
d62a17ae | 10854 | } |
10855 | ||
10856 | if (use_json) | |
10857 | vty_out(vty, "}\n"); | |
9f049418 DS |
10858 | else if (!nbr_output) |
10859 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10860 | } |
10861 | ||
10862 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 10863 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 10864 | as_t as, uint16_t show_flags) |
d62a17ae | 10865 | { |
10866 | struct bgp *bgp; | |
85eeb029 | 10867 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 10868 | struct peer *fpeer = NULL; |
d62a17ae | 10869 | |
10870 | if (name) { | |
10871 | if (strmatch(name, "all")) { | |
85eeb029 | 10872 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
10873 | neighbor, as_type, |
10874 | as, show_flags); | |
d62a17ae | 10875 | return CMD_SUCCESS; |
10876 | } else { | |
10877 | bgp = bgp_lookup_by_name(name); | |
10878 | ||
10879 | if (!bgp) { | |
10880 | if (use_json) | |
10881 | vty_out(vty, "{}\n"); | |
10882 | else | |
10883 | vty_out(vty, | |
ca61fd25 | 10884 | "%% BGP instance not found\n"); |
d62a17ae | 10885 | return CMD_WARNING; |
10886 | } | |
10887 | ||
8c1d4cd5 LS |
10888 | if (neighbor) { |
10889 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10890 | use_json); | |
10891 | if (!fpeer) | |
10892 | return CMD_WARNING; | |
10893 | } | |
10894 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
10895 | as_type, as, show_flags); | |
d62a17ae | 10896 | return CMD_SUCCESS; |
10897 | } | |
10898 | } | |
10899 | ||
10900 | bgp = bgp_get_default(); | |
10901 | ||
8c1d4cd5 LS |
10902 | if (bgp) { |
10903 | if (neighbor) { | |
10904 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10905 | use_json); | |
10906 | if (!fpeer) | |
10907 | return CMD_WARNING; | |
10908 | } | |
10909 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
10910 | as, show_flags); | |
10911 | } else { | |
ca61fd25 DS |
10912 | if (use_json) |
10913 | vty_out(vty, "{}\n"); | |
10914 | else | |
10915 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
10916 | return CMD_WARNING; |
10917 | } | |
d62a17ae | 10918 | |
10919 | return CMD_SUCCESS; | |
4fb25c53 DW |
10920 | } |
10921 | ||
716b2d8a | 10922 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
10923 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
10924 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
10925 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 10926 | "]] [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 |
10927 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
10928 | BGP_SAFI_WITH_LABEL_HELP_STR | |
10929 | "Display the entries for all address families\n" | |
10930 | "Summary of BGP neighbor status\n" | |
10931 | "Show only sessions in Established state\n" | |
10932 | "Show only sessions not in Established state\n" | |
10933 | "Show only the specified neighbor session\n" | |
10934 | "Neighbor to display information about\n" | |
10935 | "Neighbor to display information about\n" | |
10936 | "Neighbor on BGP configured interface\n" | |
10937 | "Show only the specified remote AS sessions\n" | |
10938 | "AS number\n" | |
10939 | "Internal (iBGP) AS sessions\n" | |
10940 | "External (eBGP) AS sessions\n" | |
96c81f66 | 10941 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 10942 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 10943 | { |
d62a17ae | 10944 | char *vrf = NULL; |
10945 | afi_t afi = AFI_MAX; | |
10946 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
10947 | as_t as = 0; /* 0 means AS filter not set */ |
10948 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 10949 | uint16_t show_flags = 0; |
d62a17ae | 10950 | |
10951 | int idx = 0; | |
10952 | ||
10953 | /* show [ip] bgp */ | |
96f3485c | 10954 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 10955 | afi = AFI_IP; |
9a8bdf1c PG |
10956 | /* [<vrf> VIEWVRFNAME] */ |
10957 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10958 | vrf = argv[idx + 1]->arg; | |
10959 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10960 | vrf = NULL; | |
10961 | } else if (argv_find(argv, argc, "view", &idx)) | |
10962 | /* [<view> VIEWVRFNAME] */ | |
10963 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 10964 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10965 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10966 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10967 | } | |
10968 | ||
3577f1c5 | 10969 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
10970 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
10971 | ||
10b49f14 | 10972 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
10973 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
10974 | ||
8c1d4cd5 LS |
10975 | if (argv_find(argv, argc, "remote-as", &idx)) { |
10976 | if (argv[idx + 1]->arg[0] == 'i') | |
10977 | as_type = AS_INTERNAL; | |
10978 | else if (argv[idx + 1]->arg[0] == 'e') | |
10979 | as_type = AS_EXTERNAL; | |
10980 | else | |
10981 | as = (as_t)atoi(argv[idx + 1]->arg); | |
10982 | } | |
10983 | ||
96c81f66 LS |
10984 | if (argv_find(argv, argc, "terse", &idx)) |
10985 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
10986 | ||
85eeb029 DA |
10987 | if (argv_find(argv, argc, "wide", &idx)) |
10988 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
10989 | ||
10990 | if (argv_find(argv, argc, "json", &idx)) | |
10991 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 10992 | |
8c1d4cd5 LS |
10993 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
10994 | show_flags); | |
d62a17ae | 10995 | } |
10996 | ||
5cb5f4d0 | 10997 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 10998 | { |
5cb5f4d0 DD |
10999 | if (for_json) |
11000 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11001 | else |
5cb5f4d0 | 11002 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11003 | } |
11004 | ||
d62a17ae | 11005 | |
11006 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11007 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11008 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11009 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11010 | bool use_json, json_object *json_pref) |
d62a17ae | 11011 | { |
11012 | /* Send-Mode */ | |
11013 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11014 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11015 | if (use_json) { | |
11016 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11017 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11018 | json_object_string_add(json_pref, "sendMode", | |
11019 | "advertisedAndReceived"); | |
11020 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11021 | json_object_string_add(json_pref, "sendMode", | |
11022 | "advertised"); | |
11023 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11024 | json_object_string_add(json_pref, "sendMode", | |
11025 | "received"); | |
11026 | } else { | |
11027 | vty_out(vty, " Send-mode: "); | |
11028 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11029 | vty_out(vty, "advertised"); | |
11030 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11031 | vty_out(vty, "%sreceived", | |
11032 | CHECK_FLAG(p->af_cap[afi][safi], | |
11033 | adv_smcap) | |
11034 | ? ", " | |
11035 | : ""); | |
11036 | vty_out(vty, "\n"); | |
11037 | } | |
11038 | } | |
11039 | ||
11040 | /* Receive-Mode */ | |
11041 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11042 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11043 | if (use_json) { | |
11044 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11045 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11046 | json_object_string_add(json_pref, "recvMode", | |
11047 | "advertisedAndReceived"); | |
11048 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11049 | json_object_string_add(json_pref, "recvMode", | |
11050 | "advertised"); | |
11051 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11052 | json_object_string_add(json_pref, "recvMode", | |
11053 | "received"); | |
11054 | } else { | |
11055 | vty_out(vty, " Receive-mode: "); | |
11056 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11057 | vty_out(vty, "advertised"); | |
11058 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11059 | vty_out(vty, "%sreceived", | |
11060 | CHECK_FLAG(p->af_cap[afi][safi], | |
11061 | adv_rmcap) | |
11062 | ? ", " | |
11063 | : ""); | |
11064 | vty_out(vty, "\n"); | |
11065 | } | |
11066 | } | |
11067 | } | |
11068 | ||
13909c4f DS |
11069 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11070 | struct peer *p, | |
11071 | bool use_json, | |
11072 | json_object *json) | |
2986cac2 | 11073 | { |
08c2d52a | 11074 | bool rbit_status = false; |
2986cac2 | 11075 | |
11076 | if (!use_json) | |
a53ca37b | 11077 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11078 | |
13909c4f DS |
11079 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11080 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11081 | && (peer_established(p))) { |
2986cac2 | 11082 | |
11083 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11084 | rbit_status = true; |
2986cac2 | 11085 | else |
08c2d52a | 11086 | rbit_status = false; |
2986cac2 | 11087 | } |
11088 | ||
11089 | if (rbit_status) { | |
11090 | if (use_json) | |
13909c4f | 11091 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11092 | else |
11093 | vty_out(vty, "True\n"); | |
11094 | } else { | |
11095 | if (use_json) | |
13909c4f | 11096 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11097 | else |
11098 | vty_out(vty, "False\n"); | |
11099 | } | |
11100 | } | |
11101 | ||
13909c4f DS |
11102 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11103 | struct peer *peer, | |
11104 | bool use_json, | |
11105 | json_object *json) | |
2986cac2 | 11106 | { |
2bb5d39b | 11107 | const char *mode = "NotApplicable"; |
2986cac2 | 11108 | |
11109 | if (!use_json) | |
a53ca37b | 11110 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11111 | |
13909c4f | 11112 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11113 | && (peer_established(peer))) { |
2986cac2 | 11114 | |
13909c4f DS |
11115 | if ((peer->nsf_af_count == 0) |
11116 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11117 | |
2986cac2 | 11118 | mode = "Disable"; |
11119 | ||
13909c4f DS |
11120 | } else if (peer->nsf_af_count == 0 |
11121 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11122 | |
2986cac2 | 11123 | mode = "Helper"; |
11124 | ||
13909c4f DS |
11125 | } else if (peer->nsf_af_count != 0 |
11126 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11127 | |
2986cac2 | 11128 | mode = "Restart"; |
2986cac2 | 11129 | } |
11130 | } | |
11131 | ||
11132 | if (use_json) { | |
13909c4f | 11133 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11134 | } else |
11135 | vty_out(vty, mode, "\n"); | |
11136 | } | |
11137 | ||
13909c4f DS |
11138 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11139 | struct peer *p, | |
11140 | bool use_json, | |
11141 | json_object *json) | |
2986cac2 | 11142 | { |
11143 | const char *mode = "Invalid"; | |
11144 | ||
11145 | if (!use_json) | |
a53ca37b | 11146 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11147 | |
11148 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11149 | mode = "Helper"; | |
11150 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11151 | mode = "Restart"; | |
11152 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11153 | mode = "Disable"; | |
2ba1fe69 | 11154 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11155 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11156 | mode = "Helper*"; | |
11157 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11158 | mode = "Restart*"; | |
11159 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11160 | mode = "Disable*"; | |
11161 | else | |
11162 | mode = "Invalid*"; | |
2ba1fe69 | 11163 | } |
2986cac2 | 11164 | |
11165 | if (use_json) { | |
13909c4f | 11166 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11167 | } else { |
11168 | vty_out(vty, mode, "\n"); | |
11169 | } | |
11170 | } | |
11171 | ||
13909c4f DS |
11172 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11173 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11174 | { |
2ba1fe69 | 11175 | afi_t afi; |
11176 | safi_t safi; | |
2986cac2 | 11177 | json_object *json_afi_safi = NULL; |
11178 | json_object *json_timer = NULL; | |
11179 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11180 | bool eor_flag = false; |
2986cac2 | 11181 | |
11182 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11183 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11184 | if (!peer->afc[afi][safi]) |
11185 | continue; | |
2986cac2 | 11186 | |
13909c4f DS |
11187 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11188 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11189 | continue; | |
9e3b51a7 | 11190 | |
13909c4f DS |
11191 | if (use_json) { |
11192 | json_afi_safi = json_object_new_object(); | |
11193 | json_endofrib_status = json_object_new_object(); | |
11194 | json_timer = json_object_new_object(); | |
11195 | } | |
2986cac2 | 11196 | |
13909c4f DS |
11197 | if (peer->eor_stime[afi][safi] |
11198 | >= peer->pkt_stime[afi][safi]) | |
11199 | eor_flag = true; | |
11200 | else | |
11201 | eor_flag = false; | |
2986cac2 | 11202 | |
13909c4f | 11203 | if (!use_json) { |
a53ca37b | 11204 | vty_out(vty, " %s:\n", |
13909c4f | 11205 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11206 | |
a53ca37b | 11207 | vty_out(vty, " F bit: "); |
698ba8d0 | 11208 | } |
2986cac2 | 11209 | |
13909c4f DS |
11210 | if (peer->nsf[afi][safi] |
11211 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11212 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11213 | |
13909c4f DS |
11214 | if (use_json) { |
11215 | json_object_boolean_true_add( | |
2986cac2 | 11216 | json_afi_safi, "fBit"); |
13909c4f DS |
11217 | } else |
11218 | vty_out(vty, "True\n"); | |
11219 | } else { | |
11220 | if (use_json) | |
11221 | json_object_boolean_false_add( | |
11222 | json_afi_safi, "fBit"); | |
11223 | else | |
11224 | vty_out(vty, "False\n"); | |
11225 | } | |
2986cac2 | 11226 | |
13909c4f | 11227 | if (!use_json) |
a53ca37b | 11228 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11229 | |
13909c4f DS |
11230 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11231 | PEER_STATUS_EOR_SEND)) { | |
11232 | if (use_json) { | |
11233 | json_object_boolean_true_add( | |
2986cac2 | 11234 | json_endofrib_status, |
13909c4f | 11235 | "endOfRibSend"); |
9e3b51a7 | 11236 | |
13909c4f DS |
11237 | PRINT_EOR_JSON(eor_flag); |
11238 | } else { | |
11239 | vty_out(vty, "Yes\n"); | |
11240 | vty_out(vty, | |
a53ca37b | 11241 | " End-of-RIB sent after update: "); |
2986cac2 | 11242 | |
13909c4f DS |
11243 | PRINT_EOR(eor_flag); |
11244 | } | |
11245 | } else { | |
11246 | if (use_json) { | |
11247 | json_object_boolean_false_add( | |
2986cac2 | 11248 | json_endofrib_status, |
13909c4f DS |
11249 | "endOfRibSend"); |
11250 | json_object_boolean_false_add( | |
9e3b51a7 | 11251 | json_endofrib_status, |
13909c4f DS |
11252 | "endOfRibSentAfterUpdate"); |
11253 | } else { | |
11254 | vty_out(vty, "No\n"); | |
11255 | vty_out(vty, | |
a53ca37b | 11256 | " End-of-RIB sent after update: "); |
13909c4f | 11257 | vty_out(vty, "No\n"); |
2986cac2 | 11258 | } |
13909c4f | 11259 | } |
2986cac2 | 11260 | |
a53ca37b DA |
11261 | if (!use_json) |
11262 | vty_out(vty, " End-of-RIB received: "); | |
11263 | ||
11264 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11265 | PEER_STATUS_EOR_RECEIVED)) { | |
11266 | if (use_json) | |
11267 | json_object_boolean_true_add( | |
11268 | json_endofrib_status, | |
11269 | "endOfRibRecv"); | |
11270 | else | |
11271 | vty_out(vty, "Yes\n"); | |
11272 | } else { | |
11273 | if (use_json) | |
11274 | json_object_boolean_false_add( | |
11275 | json_endofrib_status, | |
11276 | "endOfRibRecv"); | |
11277 | else | |
11278 | vty_out(vty, "No\n"); | |
11279 | } | |
11280 | ||
13909c4f DS |
11281 | if (use_json) { |
11282 | json_object_int_add(json_timer, | |
11283 | "stalePathTimer", | |
11284 | peer->bgp->stalepath_time); | |
2986cac2 | 11285 | |
13909c4f DS |
11286 | if (peer->t_gr_stale != NULL) { |
11287 | json_object_int_add( | |
2986cac2 | 11288 | json_timer, |
11289 | "stalePathTimerRemaining", | |
11290 | thread_timer_remain_second( | |
13909c4f DS |
11291 | peer->t_gr_stale)); |
11292 | } | |
3a75afa4 | 11293 | |
13909c4f DS |
11294 | /* Display Configured Selection |
11295 | * Deferral only when when | |
11296 | * Gr mode is enabled. | |
11297 | */ | |
11298 | if (CHECK_FLAG(peer->flags, | |
11299 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11300 | json_object_int_add( | |
3a75afa4 | 11301 | json_timer, |
2986cac2 | 11302 | "selectionDeferralTimer", |
11303 | peer->bgp->stalepath_time); | |
13909c4f | 11304 | } |
2986cac2 | 11305 | |
13909c4f DS |
11306 | if (peer->bgp->gr_info[afi][safi] |
11307 | .t_select_deferral | |
11308 | != NULL) { | |
2986cac2 | 11309 | |
13909c4f | 11310 | json_object_int_add( |
2986cac2 | 11311 | json_timer, |
11312 | "selectionDeferralTimerRemaining", | |
11313 | thread_timer_remain_second( | |
13909c4f DS |
11314 | peer->bgp |
11315 | ->gr_info[afi] | |
11316 | [safi] | |
11317 | .t_select_deferral)); | |
11318 | } | |
11319 | } else { | |
a53ca37b | 11320 | vty_out(vty, " Timers:\n"); |
13909c4f | 11321 | vty_out(vty, |
a53ca37b DA |
11322 | " Configured Stale Path Time(sec): %u\n", |
11323 | peer->bgp->stalepath_time); | |
2986cac2 | 11324 | |
a53ca37b | 11325 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11326 | vty_out(vty, |
a53ca37b | 11327 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11328 | thread_timer_remain_second( |
13909c4f | 11329 | peer->t_gr_stale)); |
13909c4f DS |
11330 | /* Display Configured Selection |
11331 | * Deferral only when when | |
11332 | * Gr mode is enabled. | |
11333 | */ | |
11334 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11335 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11336 | vty_out(vty, |
a53ca37b | 11337 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11338 | peer->bgp->select_defer_time); |
2986cac2 | 11339 | |
13909c4f DS |
11340 | if (peer->bgp->gr_info[afi][safi] |
11341 | .t_select_deferral | |
a53ca37b | 11342 | != NULL) |
13909c4f | 11343 | vty_out(vty, |
a53ca37b | 11344 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11345 | thread_timer_remain_second( |
13909c4f DS |
11346 | peer->bgp |
11347 | ->gr_info[afi] | |
11348 | [safi] | |
11349 | .t_select_deferral)); | |
2986cac2 | 11350 | } |
13909c4f DS |
11351 | if (use_json) { |
11352 | json_object_object_add(json_afi_safi, | |
11353 | "endOfRibStatus", | |
11354 | json_endofrib_status); | |
11355 | json_object_object_add(json_afi_safi, "timers", | |
11356 | json_timer); | |
11357 | json_object_object_add( | |
11358 | json, get_afi_safi_str(afi, safi, true), | |
11359 | json_afi_safi); | |
11360 | } | |
2986cac2 | 11361 | } |
11362 | } | |
11363 | } | |
11364 | ||
36235319 QY |
11365 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11366 | struct peer *p, | |
11367 | bool use_json, | |
11368 | json_object *json) | |
2986cac2 | 11369 | { |
11370 | if (use_json) { | |
11371 | json_object *json_timer = NULL; | |
11372 | ||
11373 | json_timer = json_object_new_object(); | |
11374 | ||
13909c4f DS |
11375 | json_object_int_add(json_timer, "configuredRestartTimer", |
11376 | p->bgp->restart_time); | |
2986cac2 | 11377 | |
13909c4f DS |
11378 | json_object_int_add(json_timer, "receivedRestartTimer", |
11379 | p->v_gr_restart); | |
2986cac2 | 11380 | |
13909c4f DS |
11381 | if (p->t_gr_restart != NULL) |
11382 | json_object_int_add( | |
11383 | json_timer, "restartTimerRemaining", | |
11384 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11385 | |
11386 | json_object_object_add(json, "timers", json_timer); | |
11387 | } else { | |
11388 | ||
a53ca37b DA |
11389 | vty_out(vty, " Timers:\n"); |
11390 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11391 | p->bgp->restart_time); |
2986cac2 | 11392 | |
a53ca37b | 11393 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11394 | p->v_gr_restart); |
11395 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11396 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11397 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11398 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11399 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11400 | thread_timer_remain_second(p->t_gr_restart)); |
11401 | } | |
2986cac2 | 11402 | } |
11403 | } | |
11404 | ||
11405 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11406 | bool use_json, json_object *json) |
2986cac2 | 11407 | { |
11408 | char buf[SU_ADDRSTRLEN] = {0}; | |
11409 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11410 | /* '*' + v6 address of neighbor */ |
11411 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11412 | |
2986cac2 | 11413 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11414 | dn_flag[0] = '*'; | |
11415 | ||
11416 | if (p->conf_if) { | |
11417 | if (use_json) | |
13909c4f DS |
11418 | json_object_string_add( |
11419 | json, "neighborAddr", | |
2986cac2 | 11420 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11421 | ? "none" |
11422 | : sockunion2str(&p->su, buf, | |
11423 | SU_ADDRSTRLEN)); | |
2986cac2 | 11424 | else |
13909c4f | 11425 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11426 | BGP_PEER_SU_UNSPEC(p) |
11427 | ? "none" | |
11428 | : sockunion2str(&p->su, buf, | |
11429 | SU_ADDRSTRLEN)); | |
11430 | } else { | |
772270f3 QY |
11431 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11432 | p->host); | |
2986cac2 | 11433 | |
11434 | if (use_json) | |
36235319 QY |
11435 | json_object_string_add(json, "neighborAddr", |
11436 | neighborAddr); | |
2986cac2 | 11437 | else |
36235319 | 11438 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11439 | } |
11440 | ||
11441 | /* more gr info in new format */ | |
11442 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11443 | } | |
11444 | ||
d62a17ae | 11445 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11446 | safi_t safi, bool use_json, |
d62a17ae | 11447 | json_object *json_neigh) |
11448 | { | |
0291c246 MK |
11449 | struct bgp_filter *filter; |
11450 | struct peer_af *paf; | |
11451 | char orf_pfx_name[BUFSIZ]; | |
11452 | int orf_pfx_count; | |
11453 | json_object *json_af = NULL; | |
11454 | json_object *json_prefA = NULL; | |
11455 | json_object *json_prefB = NULL; | |
11456 | json_object *json_addr = NULL; | |
fa36596c | 11457 | json_object *json_advmap = NULL; |
d62a17ae | 11458 | |
11459 | if (use_json) { | |
11460 | json_addr = json_object_new_object(); | |
11461 | json_af = json_object_new_object(); | |
11462 | filter = &p->filter[afi][safi]; | |
11463 | ||
11464 | if (peer_group_active(p)) | |
11465 | json_object_string_add(json_addr, "peerGroupMember", | |
11466 | p->group->name); | |
11467 | ||
11468 | paf = peer_af_find(p, afi, safi); | |
11469 | if (paf && PAF_SUBGRP(paf)) { | |
11470 | json_object_int_add(json_addr, "updateGroupId", | |
11471 | PAF_UPDGRP(paf)->id); | |
11472 | json_object_int_add(json_addr, "subGroupId", | |
11473 | PAF_SUBGRP(paf)->id); | |
11474 | json_object_int_add(json_addr, "packetQueueLength", | |
11475 | bpacket_queue_virtual_length(paf)); | |
11476 | } | |
11477 | ||
11478 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11479 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11480 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11481 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11482 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11483 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11484 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11485 | json_object_int_add(json_af, "orfType", | |
11486 | ORF_TYPE_PREFIX); | |
11487 | json_prefA = json_object_new_object(); | |
11488 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11489 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11490 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11491 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11492 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11493 | use_json, json_prefA); | |
11494 | json_object_object_add(json_af, "orfPrefixList", | |
11495 | json_prefA); | |
11496 | } | |
11497 | ||
11498 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11499 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11500 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11501 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11502 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11503 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11504 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11505 | json_object_int_add(json_af, "orfOldType", | |
11506 | ORF_TYPE_PREFIX_OLD); | |
11507 | json_prefB = json_object_new_object(); | |
11508 | bgp_show_peer_afi_orf_cap( | |
11509 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11510 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11511 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11512 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11513 | json_prefB); | |
11514 | json_object_object_add(json_af, "orfOldPrefixList", | |
11515 | json_prefB); | |
11516 | } | |
11517 | ||
11518 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11519 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11520 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11521 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11522 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11523 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11524 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11525 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11526 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11527 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11528 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11529 | json_object_object_add(json_addr, "afDependentCap", | |
11530 | json_af); | |
11531 | else | |
11532 | json_object_free(json_af); | |
11533 | ||
772270f3 QY |
11534 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11535 | p->host, afi, safi); | |
d62a17ae | 11536 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11537 | NULL, afi, orf_pfx_name, use_json); | |
11538 | ||
11539 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11540 | PEER_STATUS_ORF_PREFIX_SEND) | |
11541 | || orf_pfx_count) { | |
11542 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11543 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11544 | json_object_boolean_true_add(json_neigh, | |
11545 | "orfSent"); | |
11546 | if (orf_pfx_count) | |
11547 | json_object_int_add(json_addr, "orfRecvCounter", | |
11548 | orf_pfx_count); | |
11549 | } | |
11550 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11551 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11552 | json_object_string_add( | |
11553 | json_addr, "orfFirstUpdate", | |
11554 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11555 | ||
11556 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11557 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11558 | json_object_boolean_true_add(json_addr, | |
11559 | "routeReflectorClient"); | |
11560 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11561 | PEER_FLAG_RSERVER_CLIENT)) | |
11562 | json_object_boolean_true_add(json_addr, | |
11563 | "routeServerClient"); | |
11564 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11565 | json_object_boolean_true_add(json_addr, | |
11566 | "inboundSoftConfigPermit"); | |
11567 | ||
11568 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11569 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11570 | json_object_boolean_true_add( | |
11571 | json_addr, | |
11572 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11573 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11574 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11575 | json_object_boolean_true_add( | |
11576 | json_addr, | |
11577 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11578 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11579 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11580 | json_object_boolean_true_add( | |
11581 | json_addr, | |
11582 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11583 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11584 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11585 | json_object_boolean_true_add( | |
11586 | json_addr, | |
11587 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11588 | ||
dcc68b5e MS |
11589 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11590 | json_object_boolean_true_add( | |
11591 | json_addr, | |
11592 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11593 | ->type_json_name); | |
d62a17ae | 11594 | |
11595 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11596 | json_object_string_add(json_addr, | |
11597 | "overrideASNsInOutboundUpdates", | |
11598 | "ifAspathEqualRemoteAs"); | |
11599 | ||
11600 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11601 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11602 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11603 | json_object_boolean_true_add(json_addr, | |
11604 | "routerAlwaysNextHop"); | |
11605 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11606 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11607 | json_object_boolean_true_add( | |
11608 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11609 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11610 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11611 | json_object_boolean_true_add( | |
11612 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11613 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11614 | json_object_boolean_true_add( | |
11615 | json_addr, "unchangedMedPropogatedToNbr"); | |
11616 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11617 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11618 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11619 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11620 | PEER_FLAG_SEND_COMMUNITY) | |
11621 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11622 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11623 | json_object_string_add(json_addr, | |
11624 | "commAttriSentToNbr", | |
11625 | "extendedAndStandard"); | |
11626 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11627 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11628 | json_object_string_add(json_addr, | |
11629 | "commAttriSentToNbr", | |
11630 | "extended"); | |
11631 | else | |
11632 | json_object_string_add(json_addr, | |
11633 | "commAttriSentToNbr", | |
11634 | "standard"); | |
11635 | } | |
11636 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11637 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11638 | if (p->default_rmap[afi][safi].name) | |
11639 | json_object_string_add( | |
11640 | json_addr, "defaultRouteMap", | |
11641 | p->default_rmap[afi][safi].name); | |
11642 | ||
11643 | if (paf && PAF_SUBGRP(paf) | |
11644 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11645 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11646 | json_object_boolean_true_add(json_addr, | |
11647 | "defaultSent"); | |
11648 | else | |
11649 | json_object_boolean_true_add(json_addr, | |
11650 | "defaultNotSent"); | |
11651 | } | |
11652 | ||
dff8f48d | 11653 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11654 | if (is_evpn_enabled()) |
60466a63 QY |
11655 | json_object_boolean_true_add( |
11656 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11657 | } |
11658 | ||
d62a17ae | 11659 | if (filter->plist[FILTER_IN].name |
11660 | || filter->dlist[FILTER_IN].name | |
11661 | || filter->aslist[FILTER_IN].name | |
11662 | || filter->map[RMAP_IN].name) | |
11663 | json_object_boolean_true_add(json_addr, | |
11664 | "inboundPathPolicyConfig"); | |
11665 | if (filter->plist[FILTER_OUT].name | |
11666 | || filter->dlist[FILTER_OUT].name | |
11667 | || filter->aslist[FILTER_OUT].name | |
11668 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11669 | json_object_boolean_true_add( | |
11670 | json_addr, "outboundPathPolicyConfig"); | |
11671 | ||
11672 | /* prefix-list */ | |
11673 | if (filter->plist[FILTER_IN].name) | |
11674 | json_object_string_add(json_addr, | |
11675 | "incomingUpdatePrefixFilterList", | |
11676 | filter->plist[FILTER_IN].name); | |
11677 | if (filter->plist[FILTER_OUT].name) | |
11678 | json_object_string_add(json_addr, | |
11679 | "outgoingUpdatePrefixFilterList", | |
11680 | filter->plist[FILTER_OUT].name); | |
11681 | ||
11682 | /* distribute-list */ | |
11683 | if (filter->dlist[FILTER_IN].name) | |
11684 | json_object_string_add( | |
11685 | json_addr, "incomingUpdateNetworkFilterList", | |
11686 | filter->dlist[FILTER_IN].name); | |
11687 | if (filter->dlist[FILTER_OUT].name) | |
11688 | json_object_string_add( | |
11689 | json_addr, "outgoingUpdateNetworkFilterList", | |
11690 | filter->dlist[FILTER_OUT].name); | |
11691 | ||
11692 | /* filter-list. */ | |
11693 | if (filter->aslist[FILTER_IN].name) | |
11694 | json_object_string_add(json_addr, | |
11695 | "incomingUpdateAsPathFilterList", | |
11696 | filter->aslist[FILTER_IN].name); | |
11697 | if (filter->aslist[FILTER_OUT].name) | |
11698 | json_object_string_add(json_addr, | |
11699 | "outgoingUpdateAsPathFilterList", | |
11700 | filter->aslist[FILTER_OUT].name); | |
11701 | ||
11702 | /* route-map. */ | |
11703 | if (filter->map[RMAP_IN].name) | |
11704 | json_object_string_add( | |
11705 | json_addr, "routeMapForIncomingAdvertisements", | |
11706 | filter->map[RMAP_IN].name); | |
11707 | if (filter->map[RMAP_OUT].name) | |
11708 | json_object_string_add( | |
11709 | json_addr, "routeMapForOutgoingAdvertisements", | |
11710 | filter->map[RMAP_OUT].name); | |
11711 | ||
9dac9fc8 | 11712 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11713 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11714 | && !bgp_inbound_policy_exists(p, filter)) |
11715 | json_object_string_add( | |
11716 | json_addr, "inboundEbgpRequiresPolicy", | |
11717 | "Inbound updates discarded due to missing policy"); | |
11718 | ||
11719 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11720 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11721 | && (!bgp_outbound_policy_exists(p, filter))) |
11722 | json_object_string_add( | |
11723 | json_addr, "outboundEbgpRequiresPolicy", | |
11724 | "Outbound updates discarded due to missing policy"); | |
11725 | ||
d62a17ae | 11726 | /* unsuppress-map */ |
11727 | if (filter->usmap.name) | |
11728 | json_object_string_add(json_addr, | |
11729 | "selectiveUnsuppressRouteMap", | |
11730 | filter->usmap.name); | |
11731 | ||
fa36596c MK |
11732 | /* advertise-map */ |
11733 | if (filter->advmap.aname) { | |
11734 | json_advmap = json_object_new_object(); | |
11735 | json_object_string_add(json_advmap, "condition", | |
11736 | filter->advmap.condition | |
11737 | ? "EXIST" | |
11738 | : "NON_EXIST"); | |
11739 | json_object_string_add(json_advmap, "conditionMap", | |
11740 | filter->advmap.cname); | |
11741 | json_object_string_add(json_advmap, "advertiseMap", | |
11742 | filter->advmap.aname); | |
11743 | json_object_string_add(json_advmap, "advertiseStatus", | |
11744 | filter->advmap.update_type | |
11745 | == ADVERTISE | |
11746 | ? "Advertise" | |
11747 | : "Withdraw"); | |
11748 | json_object_object_add(json_addr, "advertiseMap", | |
11749 | json_advmap); | |
11750 | } | |
11751 | ||
d62a17ae | 11752 | /* Receive prefix count */ |
11753 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11754 | p->pcount[afi][safi]); | |
50e05855 AD |
11755 | if (paf && PAF_SUBGRP(paf)) |
11756 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11757 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11758 | |
fde246e8 DA |
11759 | /* Maximum prefix */ |
11760 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11761 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11762 | p->pmax_out[afi][safi]); | |
11763 | ||
d62a17ae | 11764 | /* Maximum prefix */ |
11765 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11766 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11767 | p->pmax[afi][safi]); | |
11768 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11769 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11770 | json_object_boolean_true_add( | |
11771 | json_addr, "prefixAllowedMaxWarning"); | |
11772 | json_object_int_add(json_addr, | |
11773 | "prefixAllowedWarningThresh", | |
11774 | p->pmax_threshold[afi][safi]); | |
11775 | if (p->pmax_restart[afi][safi]) | |
11776 | json_object_int_add( | |
11777 | json_addr, | |
11778 | "prefixAllowedRestartIntervalMsecs", | |
11779 | p->pmax_restart[afi][safi] * 60000); | |
11780 | } | |
2986cac2 | 11781 | json_object_object_add(json_neigh, |
36235319 | 11782 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11783 | json_addr); |
11784 | ||
11785 | } else { | |
11786 | filter = &p->filter[afi][safi]; | |
11787 | ||
11788 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11789 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11790 | |
11791 | if (peer_group_active(p)) | |
11792 | vty_out(vty, " %s peer-group member\n", | |
11793 | p->group->name); | |
11794 | ||
11795 | paf = peer_af_find(p, afi, safi); | |
11796 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11797 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11798 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11799 | vty_out(vty, " Packet Queue length %d\n", | |
11800 | bpacket_queue_virtual_length(paf)); | |
11801 | } else { | |
11802 | vty_out(vty, " Not part of any update group\n"); | |
11803 | } | |
11804 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11805 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11806 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11807 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11808 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11809 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11810 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11811 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11812 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11813 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11814 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11815 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11816 | ||
11817 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11818 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11819 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11820 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11821 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11822 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11823 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11824 | vty_out(vty, | |
11825 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11826 | ORF_TYPE_PREFIX); | |
11827 | bgp_show_peer_afi_orf_cap( | |
11828 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11829 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11830 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11831 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11832 | } | |
11833 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11834 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11835 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11836 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11837 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11838 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11839 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11840 | vty_out(vty, | |
11841 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11842 | ORF_TYPE_PREFIX_OLD); | |
11843 | bgp_show_peer_afi_orf_cap( | |
11844 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11845 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11846 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11847 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11848 | } | |
11849 | ||
772270f3 QY |
11850 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11851 | p->host, afi, safi); | |
d62a17ae | 11852 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11853 | NULL, afi, orf_pfx_name, use_json); | |
11854 | ||
11855 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11856 | PEER_STATUS_ORF_PREFIX_SEND) | |
11857 | || orf_pfx_count) { | |
11858 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11859 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11860 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11861 | vty_out(vty, " sent;"); | |
11862 | if (orf_pfx_count) | |
11863 | vty_out(vty, " received (%d entries)", | |
11864 | orf_pfx_count); | |
11865 | vty_out(vty, "\n"); | |
11866 | } | |
11867 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11868 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11869 | vty_out(vty, | |
11870 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11871 | ||
11872 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11873 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11874 | vty_out(vty, " Route-Reflector Client\n"); | |
11875 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11876 | PEER_FLAG_RSERVER_CLIENT)) | |
11877 | vty_out(vty, " Route-Server Client\n"); | |
11878 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11879 | vty_out(vty, | |
11880 | " Inbound soft reconfiguration allowed\n"); | |
11881 | ||
11882 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11883 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11884 | vty_out(vty, | |
11885 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
11886 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11887 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11888 | vty_out(vty, | |
11889 | " Private AS numbers replaced in updates to this neighbor\n"); | |
11890 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11891 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11892 | vty_out(vty, | |
11893 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
11894 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11895 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11896 | vty_out(vty, | |
11897 | " Private AS numbers removed in updates to this neighbor\n"); | |
11898 | ||
dcc68b5e MS |
11899 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11900 | vty_out(vty, " %s\n", | |
11901 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11902 | ->human_description); | |
d62a17ae | 11903 | |
11904 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11905 | vty_out(vty, | |
11906 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
11907 | ||
11908 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11909 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11910 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11911 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
11912 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11913 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11914 | vty_out(vty, | |
11915 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
11916 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11917 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11918 | vty_out(vty, | |
11919 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
11920 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11921 | vty_out(vty, | |
11922 | " MED is propagated unchanged to this neighbor\n"); | |
11923 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11924 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11925 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11926 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11927 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
11928 | vty_out(vty, | |
11929 | " Community attribute sent to this neighbor"); | |
11930 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11931 | PEER_FLAG_SEND_COMMUNITY) | |
11932 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11933 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11934 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11935 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11936 | vty_out(vty, "(all)\n"); | |
11937 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11938 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11939 | vty_out(vty, "(large)\n"); | |
11940 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11941 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11942 | vty_out(vty, "(extended)\n"); | |
11943 | else | |
11944 | vty_out(vty, "(standard)\n"); | |
11945 | } | |
11946 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11947 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11948 | vty_out(vty, " Default information originate,"); | |
11949 | ||
11950 | if (p->default_rmap[afi][safi].name) | |
11951 | vty_out(vty, " default route-map %s%s,", | |
11952 | p->default_rmap[afi][safi].map ? "*" | |
11953 | : "", | |
11954 | p->default_rmap[afi][safi].name); | |
11955 | if (paf && PAF_SUBGRP(paf) | |
11956 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11957 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11958 | vty_out(vty, " default sent\n"); | |
11959 | else | |
11960 | vty_out(vty, " default not sent\n"); | |
11961 | } | |
11962 | ||
dff8f48d MK |
11963 | /* advertise-vni-all */ |
11964 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 11965 | if (is_evpn_enabled()) |
dff8f48d MK |
11966 | vty_out(vty, " advertise-all-vni\n"); |
11967 | } | |
11968 | ||
d62a17ae | 11969 | if (filter->plist[FILTER_IN].name |
11970 | || filter->dlist[FILTER_IN].name | |
11971 | || filter->aslist[FILTER_IN].name | |
11972 | || filter->map[RMAP_IN].name) | |
11973 | vty_out(vty, " Inbound path policy configured\n"); | |
11974 | if (filter->plist[FILTER_OUT].name | |
11975 | || filter->dlist[FILTER_OUT].name | |
11976 | || filter->aslist[FILTER_OUT].name | |
11977 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11978 | vty_out(vty, " Outbound path policy configured\n"); | |
11979 | ||
11980 | /* prefix-list */ | |
11981 | if (filter->plist[FILTER_IN].name) | |
11982 | vty_out(vty, | |
11983 | " Incoming update prefix filter list is %s%s\n", | |
11984 | filter->plist[FILTER_IN].plist ? "*" : "", | |
11985 | filter->plist[FILTER_IN].name); | |
11986 | if (filter->plist[FILTER_OUT].name) | |
11987 | vty_out(vty, | |
11988 | " Outgoing update prefix filter list is %s%s\n", | |
11989 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
11990 | filter->plist[FILTER_OUT].name); | |
11991 | ||
11992 | /* distribute-list */ | |
11993 | if (filter->dlist[FILTER_IN].name) | |
11994 | vty_out(vty, | |
11995 | " Incoming update network filter list is %s%s\n", | |
11996 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
11997 | filter->dlist[FILTER_IN].name); | |
11998 | if (filter->dlist[FILTER_OUT].name) | |
11999 | vty_out(vty, | |
12000 | " Outgoing update network filter list is %s%s\n", | |
12001 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12002 | filter->dlist[FILTER_OUT].name); | |
12003 | ||
12004 | /* filter-list. */ | |
12005 | if (filter->aslist[FILTER_IN].name) | |
12006 | vty_out(vty, | |
12007 | " Incoming update AS path filter list is %s%s\n", | |
12008 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12009 | filter->aslist[FILTER_IN].name); | |
12010 | if (filter->aslist[FILTER_OUT].name) | |
12011 | vty_out(vty, | |
12012 | " Outgoing update AS path filter list is %s%s\n", | |
12013 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12014 | filter->aslist[FILTER_OUT].name); | |
12015 | ||
12016 | /* route-map. */ | |
12017 | if (filter->map[RMAP_IN].name) | |
12018 | vty_out(vty, | |
12019 | " Route map for incoming advertisements is %s%s\n", | |
12020 | filter->map[RMAP_IN].map ? "*" : "", | |
12021 | filter->map[RMAP_IN].name); | |
12022 | if (filter->map[RMAP_OUT].name) | |
12023 | vty_out(vty, | |
12024 | " Route map for outgoing advertisements is %s%s\n", | |
12025 | filter->map[RMAP_OUT].map ? "*" : "", | |
12026 | filter->map[RMAP_OUT].name); | |
12027 | ||
9dac9fc8 | 12028 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12029 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12030 | && !bgp_inbound_policy_exists(p, filter)) |
12031 | vty_out(vty, | |
12032 | " Inbound updates discarded due to missing policy\n"); | |
12033 | ||
12034 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12035 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12036 | && !bgp_outbound_policy_exists(p, filter)) |
12037 | vty_out(vty, | |
12038 | " Outbound updates discarded due to missing policy\n"); | |
12039 | ||
d62a17ae | 12040 | /* unsuppress-map */ |
12041 | if (filter->usmap.name) | |
12042 | vty_out(vty, | |
12043 | " Route map for selective unsuppress is %s%s\n", | |
12044 | filter->usmap.map ? "*" : "", | |
12045 | filter->usmap.name); | |
12046 | ||
7f7940e6 MK |
12047 | /* advertise-map */ |
12048 | if (filter->advmap.aname && filter->advmap.cname) | |
12049 | vty_out(vty, | |
12050 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12051 | filter->advmap.condition ? "EXIST" | |
12052 | : "NON_EXIST", | |
12053 | filter->advmap.cmap ? "*" : "", | |
12054 | filter->advmap.cname, | |
12055 | filter->advmap.amap ? "*" : "", | |
12056 | filter->advmap.aname, | |
fa36596c | 12057 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12058 | ? "Advertise" |
12059 | : "Withdraw"); | |
7f7940e6 | 12060 | |
d62a17ae | 12061 | /* Receive prefix count */ |
6cde4b45 | 12062 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12063 | p->pcount[afi][safi]); |
d62a17ae | 12064 | |
fde246e8 DA |
12065 | /* maximum-prefix-out */ |
12066 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12067 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12068 | vty_out(vty, | |
6cde4b45 | 12069 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12070 | p->pmax_out[afi][safi]); |
12071 | ||
d62a17ae | 12072 | /* Maximum prefix */ |
12073 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12074 | vty_out(vty, |
6cde4b45 | 12075 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12076 | p->pmax[afi][safi], |
12077 | CHECK_FLAG(p->af_flags[afi][safi], | |
12078 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12079 | ? " (warning-only)" | |
12080 | : ""); | |
12081 | vty_out(vty, " Threshold for warning message %d%%", | |
12082 | p->pmax_threshold[afi][safi]); | |
12083 | if (p->pmax_restart[afi][safi]) | |
12084 | vty_out(vty, ", restart interval %d min", | |
12085 | p->pmax_restart[afi][safi]); | |
12086 | vty_out(vty, "\n"); | |
12087 | } | |
12088 | ||
12089 | vty_out(vty, "\n"); | |
12090 | } | |
12091 | } | |
12092 | ||
9f049418 | 12093 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12094 | json_object *json) |
718e3744 | 12095 | { |
d62a17ae | 12096 | struct bgp *bgp; |
12097 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12098 | char timebuf[BGP_UPTIME_LEN]; | |
12099 | char dn_flag[2]; | |
d62a17ae | 12100 | afi_t afi; |
12101 | safi_t safi; | |
d7c0a89a QY |
12102 | uint16_t i; |
12103 | uint8_t *msg; | |
d62a17ae | 12104 | json_object *json_neigh = NULL; |
12105 | time_t epoch_tbuf; | |
4ab46701 | 12106 | uint32_t sync_tcp_mss; |
718e3744 | 12107 | |
d62a17ae | 12108 | bgp = p->bgp; |
12109 | ||
12110 | if (use_json) | |
12111 | json_neigh = json_object_new_object(); | |
12112 | ||
12113 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12114 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12115 | dn_flag[0] = '*'; | |
12116 | ||
12117 | if (!use_json) { | |
12118 | if (p->conf_if) /* Configured interface name. */ | |
12119 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12120 | BGP_PEER_SU_UNSPEC(p) | |
12121 | ? "None" | |
12122 | : sockunion2str(&p->su, buf, | |
12123 | SU_ADDRSTRLEN)); | |
12124 | else /* Configured IP address. */ | |
12125 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12126 | p->host); | |
12127 | } | |
12128 | ||
12129 | if (use_json) { | |
12130 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12131 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12132 | "none"); | |
12133 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12134 | json_object_string_add( | |
12135 | json_neigh, "bgpNeighborAddr", | |
12136 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12137 | ||
12138 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12139 | ||
12140 | if (p->change_local_as) | |
12141 | json_object_int_add(json_neigh, "localAs", | |
12142 | p->change_local_as); | |
12143 | else | |
12144 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12145 | ||
12146 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12147 | json_object_boolean_true_add(json_neigh, | |
12148 | "localAsNoPrepend"); | |
12149 | ||
12150 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12151 | json_object_boolean_true_add(json_neigh, | |
12152 | "localAsReplaceAs"); | |
12153 | } else { | |
12154 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12155 | || (p->as_type == AS_INTERNAL)) | |
12156 | vty_out(vty, "remote AS %u, ", p->as); | |
12157 | else | |
12158 | vty_out(vty, "remote AS Unspecified, "); | |
12159 | vty_out(vty, "local AS %u%s%s, ", | |
12160 | p->change_local_as ? p->change_local_as : p->local_as, | |
12161 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12162 | ? " no-prepend" | |
12163 | : "", | |
12164 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12165 | ? " replace-as" | |
12166 | : ""); | |
12167 | } | |
faa16034 DS |
12168 | /* peer type internal or confed-internal */ |
12169 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12170 | if (use_json) { |
12171 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12172 | json_object_boolean_true_add( | |
12173 | json_neigh, "nbrConfedInternalLink"); | |
12174 | else | |
12175 | json_object_boolean_true_add(json_neigh, | |
12176 | "nbrInternalLink"); | |
12177 | } else { | |
12178 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12179 | vty_out(vty, "confed-internal link\n"); | |
12180 | else | |
12181 | vty_out(vty, "internal link\n"); | |
12182 | } | |
faa16034 DS |
12183 | /* peer type external or confed-external */ |
12184 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12185 | if (use_json) { |
12186 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12187 | json_object_boolean_true_add( | |
12188 | json_neigh, "nbrConfedExternalLink"); | |
12189 | else | |
12190 | json_object_boolean_true_add(json_neigh, | |
12191 | "nbrExternalLink"); | |
12192 | } else { | |
12193 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12194 | vty_out(vty, "confed-external link\n"); | |
12195 | else | |
12196 | vty_out(vty, "external link\n"); | |
12197 | } | |
faa16034 DS |
12198 | } else { |
12199 | if (use_json) | |
12200 | json_object_boolean_true_add(json_neigh, | |
12201 | "nbrUnspecifiedLink"); | |
12202 | else | |
12203 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12204 | } |
12205 | ||
12206 | /* Description. */ | |
12207 | if (p->desc) { | |
12208 | if (use_json) | |
12209 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12210 | else | |
12211 | vty_out(vty, " Description: %s\n", p->desc); | |
12212 | } | |
12213 | ||
12214 | if (p->hostname) { | |
12215 | if (use_json) { | |
12216 | if (p->hostname) | |
12217 | json_object_string_add(json_neigh, "hostname", | |
12218 | p->hostname); | |
12219 | ||
12220 | if (p->domainname) | |
12221 | json_object_string_add(json_neigh, "domainname", | |
12222 | p->domainname); | |
12223 | } else { | |
12224 | if (p->domainname && (p->domainname[0] != '\0')) | |
12225 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12226 | p->domainname); | |
12227 | else | |
12228 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12229 | } | |
12230 | } | |
12231 | ||
12232 | /* Peer-group */ | |
12233 | if (p->group) { | |
12234 | if (use_json) { | |
12235 | json_object_string_add(json_neigh, "peerGroup", | |
12236 | p->group->name); | |
12237 | ||
12238 | if (dn_flag[0]) { | |
12239 | struct prefix prefix, *range = NULL; | |
12240 | ||
0154d8ce DS |
12241 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12242 | range = peer_group_lookup_dynamic_neighbor_range( | |
12243 | p->group, &prefix); | |
d62a17ae | 12244 | |
12245 | if (range) { | |
12246 | prefix2str(range, buf1, sizeof(buf1)); | |
12247 | json_object_string_add( | |
12248 | json_neigh, | |
12249 | "peerSubnetRangeGroup", buf1); | |
12250 | } | |
12251 | } | |
12252 | } else { | |
12253 | vty_out(vty, | |
12254 | " Member of peer-group %s for session parameters\n", | |
12255 | p->group->name); | |
12256 | ||
12257 | if (dn_flag[0]) { | |
12258 | struct prefix prefix, *range = NULL; | |
12259 | ||
0154d8ce DS |
12260 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12261 | range = peer_group_lookup_dynamic_neighbor_range( | |
12262 | p->group, &prefix); | |
d62a17ae | 12263 | |
12264 | if (range) { | |
d62a17ae | 12265 | vty_out(vty, |
1b78780b DL |
12266 | " Belongs to the subnet range group: %pFX\n", |
12267 | range); | |
d62a17ae | 12268 | } |
12269 | } | |
12270 | } | |
12271 | } | |
12272 | ||
12273 | if (use_json) { | |
12274 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12275 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12276 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12277 | json_object_boolean_true_add(json_neigh, |
12278 | "adminShutDown"); | |
12279 | ||
12280 | /* BGP Version. */ | |
12281 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12282 | json_object_string_add( | |
12283 | json_neigh, "remoteRouterId", | |
12284 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12285 | json_object_string_add( |
12286 | json_neigh, "localRouterId", | |
12287 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12288 | sizeof(buf1))); | |
d62a17ae | 12289 | |
12290 | /* Confederation */ | |
12291 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12292 | && bgp_confederation_peers_check(bgp, p->as)) | |
12293 | json_object_boolean_true_add(json_neigh, | |
12294 | "nbrCommonAdmin"); | |
12295 | ||
12296 | /* Status. */ | |
12297 | json_object_string_add( | |
12298 | json_neigh, "bgpState", | |
12299 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12300 | ||
feb17238 | 12301 | if (peer_established(p)) { |
d62a17ae | 12302 | time_t uptime; |
d62a17ae | 12303 | |
12304 | uptime = bgp_clock(); | |
12305 | uptime -= p->uptime; | |
d62a17ae | 12306 | epoch_tbuf = time(NULL) - uptime; |
12307 | ||
d3c7efed DS |
12308 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12309 | uptime * 1000); | |
d62a17ae | 12310 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12311 | peer_uptime(p->uptime, timebuf, | |
12312 | BGP_UPTIME_LEN, 0, | |
12313 | NULL)); | |
12314 | json_object_int_add(json_neigh, | |
12315 | "bgpTimerUpEstablishedEpoch", | |
12316 | epoch_tbuf); | |
12317 | } | |
12318 | ||
12319 | else if (p->status == Active) { | |
12320 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12321 | json_object_string_add(json_neigh, "bgpStateIs", | |
12322 | "passive"); | |
12323 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12324 | json_object_string_add(json_neigh, "bgpStateIs", | |
12325 | "passiveNSF"); | |
12326 | } | |
12327 | ||
12328 | /* read timer */ | |
12329 | time_t uptime; | |
a2700b50 | 12330 | struct tm tm; |
d62a17ae | 12331 | |
12332 | uptime = bgp_clock(); | |
12333 | uptime -= p->readtime; | |
a2700b50 MS |
12334 | gmtime_r(&uptime, &tm); |
12335 | ||
d62a17ae | 12336 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12337 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12338 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12339 | |
12340 | uptime = bgp_clock(); | |
12341 | uptime -= p->last_write; | |
a2700b50 MS |
12342 | gmtime_r(&uptime, &tm); |
12343 | ||
d62a17ae | 12344 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12345 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12346 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12347 | |
12348 | uptime = bgp_clock(); | |
12349 | uptime -= p->update_time; | |
a2700b50 MS |
12350 | gmtime_r(&uptime, &tm); |
12351 | ||
d62a17ae | 12352 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12353 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12354 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12355 | |
12356 | /* Configured timer values. */ | |
12357 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12358 | p->v_holdtime * 1000); | |
12359 | json_object_int_add(json_neigh, | |
12360 | "bgpTimerKeepAliveIntervalMsecs", | |
12361 | p->v_keepalive * 1000); | |
d43114f3 DS |
12362 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12363 | json_object_int_add(json_neigh, | |
12364 | "bgpTimerDelayOpenTimeMsecs", | |
12365 | p->v_delayopen * 1000); | |
12366 | } | |
12367 | ||
4ab46701 AR |
12368 | /* Configured and Synced tcp-mss value for peer */ |
12369 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12370 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12371 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12372 | p->tcp_mss); | |
12373 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12374 | sync_tcp_mss); | |
12375 | } | |
12376 | ||
b90a8e13 | 12377 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12378 | json_object_int_add(json_neigh, |
12379 | "bgpTimerConfiguredHoldTimeMsecs", | |
12380 | p->holdtime * 1000); | |
12381 | json_object_int_add( | |
12382 | json_neigh, | |
12383 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12384 | p->keepalive * 1000); | |
5d5393b9 DL |
12385 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12386 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12387 | json_object_int_add(json_neigh, |
12388 | "bgpTimerConfiguredHoldTimeMsecs", | |
12389 | bgp->default_holdtime); | |
12390 | json_object_int_add( | |
12391 | json_neigh, | |
12392 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12393 | bgp->default_keepalive); | |
d62a17ae | 12394 | } |
12395 | } else { | |
12396 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12397 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12398 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12399 | vty_out(vty, " Administratively shut down\n"); |
12400 | ||
12401 | /* BGP Version. */ | |
12402 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12403 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12404 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12405 | vty_out(vty, ", local router ID %s\n", |
12406 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12407 | sizeof(buf1))); | |
d62a17ae | 12408 | |
12409 | /* Confederation */ | |
12410 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12411 | && bgp_confederation_peers_check(bgp, p->as)) | |
12412 | vty_out(vty, | |
12413 | " Neighbor under common administration\n"); | |
12414 | ||
12415 | /* Status. */ | |
12416 | vty_out(vty, " BGP state = %s", | |
12417 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12418 | ||
feb17238 | 12419 | if (peer_established(p)) |
d62a17ae | 12420 | vty_out(vty, ", up for %8s", |
12421 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12422 | 0, NULL)); | |
12423 | ||
12424 | else if (p->status == Active) { | |
12425 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12426 | vty_out(vty, " (passive)"); | |
12427 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12428 | vty_out(vty, " (NSF passive)"); | |
12429 | } | |
12430 | vty_out(vty, "\n"); | |
12431 | ||
12432 | /* read timer */ | |
12433 | vty_out(vty, " Last read %s", | |
12434 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12435 | NULL)); | |
12436 | vty_out(vty, ", Last write %s\n", | |
12437 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12438 | NULL)); | |
12439 | ||
12440 | /* Configured timer values. */ | |
12441 | vty_out(vty, | |
12442 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12443 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12444 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12445 | vty_out(vty, " Configured hold time is %d", |
12446 | p->holdtime); | |
12447 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12448 | p->keepalive); | |
5d5393b9 DL |
12449 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12450 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12451 | vty_out(vty, " Configured hold time is %d", |
12452 | bgp->default_holdtime); | |
12453 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12454 | bgp->default_keepalive); | |
d62a17ae | 12455 | } |
d43114f3 DS |
12456 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12457 | vty_out(vty, | |
12458 | " Configured DelayOpenTime is %d seconds\n", | |
12459 | p->delayopen); | |
4ab46701 AR |
12460 | |
12461 | /* Configured and synced tcp-mss value for peer */ | |
12462 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12463 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12464 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12465 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12466 | } | |
d62a17ae | 12467 | } |
12468 | /* Capability. */ | |
feb17238 | 12469 | if (peer_established(p)) { |
d62a17ae | 12470 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] |
12471 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12472 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12473 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12474 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12475 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12476 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12477 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12478 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12479 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12480 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12481 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12482 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12483 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12484 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12485 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12486 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12487 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12488 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12489 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12490 | if (use_json) { | |
12491 | json_object *json_cap = NULL; | |
12492 | ||
12493 | json_cap = json_object_new_object(); | |
12494 | ||
12495 | /* AS4 */ | |
12496 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12497 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12498 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12499 | && CHECK_FLAG(p->cap, | |
12500 | PEER_CAP_AS4_RCV)) | |
12501 | json_object_string_add( | |
12502 | json_cap, "4byteAs", | |
12503 | "advertisedAndReceived"); | |
12504 | else if (CHECK_FLAG(p->cap, | |
12505 | PEER_CAP_AS4_ADV)) | |
12506 | json_object_string_add( | |
12507 | json_cap, "4byteAs", | |
12508 | "advertised"); | |
12509 | else if (CHECK_FLAG(p->cap, | |
12510 | PEER_CAP_AS4_RCV)) | |
12511 | json_object_string_add( | |
12512 | json_cap, "4byteAs", | |
12513 | "received"); | |
12514 | } | |
12515 | ||
ef56aee4 DA |
12516 | /* Extended Message Support */ |
12517 | if (CHECK_FLAG(p->cap, | |
12518 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
12519 | && CHECK_FLAG( | |
12520 | p->cap, | |
12521 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12522 | json_object_string_add( | |
12523 | json_cap, "extendedMessage", | |
12524 | "advertisedAndReceived"); | |
12525 | else if (CHECK_FLAG( | |
12526 | p->cap, | |
12527 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12528 | json_object_string_add( | |
12529 | json_cap, "extendedMessage", | |
12530 | "advertised"); | |
12531 | else if (CHECK_FLAG( | |
12532 | p->cap, | |
12533 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12534 | json_object_string_add( | |
12535 | json_cap, "extendedMessage", | |
12536 | "received"); | |
12537 | ||
d62a17ae | 12538 | /* AddPath */ |
12539 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12540 | || CHECK_FLAG(p->cap, | |
12541 | PEER_CAP_ADDPATH_ADV)) { | |
12542 | json_object *json_add = NULL; | |
12543 | const char *print_store; | |
12544 | ||
12545 | json_add = json_object_new_object(); | |
12546 | ||
05c7a1cc QY |
12547 | FOREACH_AFI_SAFI (afi, safi) { |
12548 | json_object *json_sub = NULL; | |
12549 | json_sub = | |
12550 | json_object_new_object(); | |
5cb5f4d0 DD |
12551 | print_store = get_afi_safi_str( |
12552 | afi, safi, true); | |
d62a17ae | 12553 | |
05c7a1cc QY |
12554 | if (CHECK_FLAG( |
12555 | p->af_cap[afi] | |
12556 | [safi], | |
12557 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12558 | || CHECK_FLAG( | |
12559 | p->af_cap[afi] | |
12560 | [safi], | |
12561 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12562 | if (CHECK_FLAG( |
12563 | p->af_cap | |
12564 | [afi] | |
12565 | [safi], | |
12566 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12567 | && CHECK_FLAG( |
d62a17ae | 12568 | p->af_cap |
12569 | [afi] | |
12570 | [safi], | |
05c7a1cc QY |
12571 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12572 | json_object_boolean_true_add( | |
12573 | json_sub, | |
12574 | "txAdvertisedAndReceived"); | |
12575 | else if ( | |
12576 | CHECK_FLAG( | |
12577 | p->af_cap | |
12578 | [afi] | |
12579 | [safi], | |
12580 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12581 | json_object_boolean_true_add( | |
12582 | json_sub, | |
12583 | "txAdvertised"); | |
12584 | else if ( | |
12585 | CHECK_FLAG( | |
12586 | p->af_cap | |
12587 | [afi] | |
12588 | [safi], | |
12589 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12590 | json_object_boolean_true_add( | |
12591 | json_sub, | |
12592 | "txReceived"); | |
12593 | } | |
d62a17ae | 12594 | |
05c7a1cc QY |
12595 | if (CHECK_FLAG( |
12596 | p->af_cap[afi] | |
12597 | [safi], | |
12598 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12599 | || CHECK_FLAG( | |
12600 | p->af_cap[afi] | |
12601 | [safi], | |
12602 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12603 | if (CHECK_FLAG( |
12604 | p->af_cap | |
12605 | [afi] | |
12606 | [safi], | |
12607 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12608 | && CHECK_FLAG( |
d62a17ae | 12609 | p->af_cap |
12610 | [afi] | |
12611 | [safi], | |
12612 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12613 | json_object_boolean_true_add( |
12614 | json_sub, | |
12615 | "rxAdvertisedAndReceived"); | |
12616 | else if ( | |
12617 | CHECK_FLAG( | |
12618 | p->af_cap | |
12619 | [afi] | |
12620 | [safi], | |
12621 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12622 | json_object_boolean_true_add( | |
12623 | json_sub, | |
12624 | "rxAdvertised"); | |
12625 | else if ( | |
12626 | CHECK_FLAG( | |
12627 | p->af_cap | |
12628 | [afi] | |
12629 | [safi], | |
12630 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12631 | json_object_boolean_true_add( | |
12632 | json_sub, | |
12633 | "rxReceived"); | |
d62a17ae | 12634 | } |
12635 | ||
05c7a1cc QY |
12636 | if (CHECK_FLAG( |
12637 | p->af_cap[afi] | |
12638 | [safi], | |
12639 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12640 | || CHECK_FLAG( | |
12641 | p->af_cap[afi] | |
12642 | [safi], | |
12643 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12644 | || CHECK_FLAG( | |
12645 | p->af_cap[afi] | |
12646 | [safi], | |
12647 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12648 | || CHECK_FLAG( | |
12649 | p->af_cap[afi] | |
12650 | [safi], | |
12651 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12652 | json_object_object_add( | |
12653 | json_add, | |
12654 | print_store, | |
12655 | json_sub); | |
12656 | else | |
12657 | json_object_free( | |
12658 | json_sub); | |
12659 | } | |
12660 | ||
d62a17ae | 12661 | json_object_object_add( |
12662 | json_cap, "addPath", json_add); | |
12663 | } | |
12664 | ||
12665 | /* Dynamic */ | |
12666 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12667 | || CHECK_FLAG(p->cap, | |
12668 | PEER_CAP_DYNAMIC_ADV)) { | |
12669 | if (CHECK_FLAG(p->cap, | |
12670 | PEER_CAP_DYNAMIC_ADV) | |
12671 | && CHECK_FLAG(p->cap, | |
12672 | PEER_CAP_DYNAMIC_RCV)) | |
12673 | json_object_string_add( | |
12674 | json_cap, "dynamic", | |
12675 | "advertisedAndReceived"); | |
12676 | else if (CHECK_FLAG( | |
12677 | p->cap, | |
12678 | PEER_CAP_DYNAMIC_ADV)) | |
12679 | json_object_string_add( | |
12680 | json_cap, "dynamic", | |
12681 | "advertised"); | |
12682 | else if (CHECK_FLAG( | |
12683 | p->cap, | |
12684 | PEER_CAP_DYNAMIC_RCV)) | |
12685 | json_object_string_add( | |
12686 | json_cap, "dynamic", | |
12687 | "received"); | |
12688 | } | |
12689 | ||
12690 | /* Extended nexthop */ | |
12691 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12692 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12693 | json_object *json_nxt = NULL; | |
12694 | const char *print_store; | |
12695 | ||
12696 | ||
12697 | if (CHECK_FLAG(p->cap, | |
12698 | PEER_CAP_ENHE_ADV) | |
12699 | && CHECK_FLAG(p->cap, | |
12700 | PEER_CAP_ENHE_RCV)) | |
12701 | json_object_string_add( | |
12702 | json_cap, | |
12703 | "extendedNexthop", | |
12704 | "advertisedAndReceived"); | |
12705 | else if (CHECK_FLAG(p->cap, | |
12706 | PEER_CAP_ENHE_ADV)) | |
12707 | json_object_string_add( | |
12708 | json_cap, | |
12709 | "extendedNexthop", | |
12710 | "advertised"); | |
12711 | else if (CHECK_FLAG(p->cap, | |
12712 | PEER_CAP_ENHE_RCV)) | |
12713 | json_object_string_add( | |
12714 | json_cap, | |
12715 | "extendedNexthop", | |
12716 | "received"); | |
12717 | ||
12718 | if (CHECK_FLAG(p->cap, | |
12719 | PEER_CAP_ENHE_RCV)) { | |
12720 | json_nxt = | |
12721 | json_object_new_object(); | |
12722 | ||
12723 | for (safi = SAFI_UNICAST; | |
12724 | safi < SAFI_MAX; safi++) { | |
12725 | if (CHECK_FLAG( | |
12726 | p->af_cap | |
12727 | [AFI_IP] | |
12728 | [safi], | |
12729 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12730 | print_store = get_afi_safi_str( |
d62a17ae | 12731 | AFI_IP, |
5cb5f4d0 | 12732 | safi, true); |
d62a17ae | 12733 | json_object_string_add( |
12734 | json_nxt, | |
12735 | print_store, | |
54f29523 | 12736 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12737 | } |
12738 | } | |
12739 | json_object_object_add( | |
12740 | json_cap, | |
12741 | "extendedNexthopFamililesByPeer", | |
12742 | json_nxt); | |
12743 | } | |
12744 | } | |
12745 | ||
12746 | /* Route Refresh */ | |
12747 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12748 | || CHECK_FLAG(p->cap, | |
12749 | PEER_CAP_REFRESH_NEW_RCV) | |
12750 | || CHECK_FLAG(p->cap, | |
12751 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12752 | if (CHECK_FLAG(p->cap, | |
12753 | PEER_CAP_REFRESH_ADV) | |
12754 | && (CHECK_FLAG( | |
12755 | p->cap, | |
12756 | PEER_CAP_REFRESH_NEW_RCV) | |
12757 | || CHECK_FLAG( | |
12758 | p->cap, | |
12759 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12760 | if (CHECK_FLAG( | |
12761 | p->cap, | |
12762 | PEER_CAP_REFRESH_OLD_RCV) | |
12763 | && CHECK_FLAG( | |
12764 | p->cap, | |
12765 | PEER_CAP_REFRESH_NEW_RCV)) | |
12766 | json_object_string_add( | |
12767 | json_cap, | |
12768 | "routeRefresh", | |
12769 | "advertisedAndReceivedOldNew"); | |
12770 | else { | |
12771 | if (CHECK_FLAG( | |
12772 | p->cap, | |
12773 | PEER_CAP_REFRESH_OLD_RCV)) | |
12774 | json_object_string_add( | |
12775 | json_cap, | |
12776 | "routeRefresh", | |
12777 | "advertisedAndReceivedOld"); | |
12778 | else | |
12779 | json_object_string_add( | |
12780 | json_cap, | |
12781 | "routeRefresh", | |
12782 | "advertisedAndReceivedNew"); | |
12783 | } | |
12784 | } else if ( | |
12785 | CHECK_FLAG( | |
12786 | p->cap, | |
12787 | PEER_CAP_REFRESH_ADV)) | |
12788 | json_object_string_add( | |
12789 | json_cap, | |
12790 | "routeRefresh", | |
12791 | "advertised"); | |
12792 | else if ( | |
12793 | CHECK_FLAG( | |
12794 | p->cap, | |
12795 | PEER_CAP_REFRESH_NEW_RCV) | |
12796 | || CHECK_FLAG( | |
12797 | p->cap, | |
12798 | PEER_CAP_REFRESH_OLD_RCV)) | |
12799 | json_object_string_add( | |
12800 | json_cap, | |
12801 | "routeRefresh", | |
12802 | "received"); | |
12803 | } | |
12804 | ||
9af52ccf DA |
12805 | /* Enhanced Route Refresh */ |
12806 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
12807 | || CHECK_FLAG(p->cap, | |
12808 | PEER_CAP_ENHANCED_RR_RCV)) { | |
12809 | if (CHECK_FLAG(p->cap, | |
12810 | PEER_CAP_ENHANCED_RR_ADV) | |
12811 | && CHECK_FLAG( | |
12812 | p->cap, | |
12813 | PEER_CAP_ENHANCED_RR_RCV)) | |
12814 | json_object_string_add( | |
12815 | json_cap, | |
12816 | "enhancedRouteRefresh", | |
12817 | "advertisedAndReceived"); | |
12818 | else if ( | |
12819 | CHECK_FLAG( | |
12820 | p->cap, | |
12821 | PEER_CAP_ENHANCED_RR_ADV)) | |
12822 | json_object_string_add( | |
12823 | json_cap, | |
12824 | "enhancedRouteRefresh", | |
12825 | "advertised"); | |
12826 | else if ( | |
12827 | CHECK_FLAG( | |
12828 | p->cap, | |
12829 | PEER_CAP_ENHANCED_RR_RCV)) | |
12830 | json_object_string_add( | |
12831 | json_cap, | |
12832 | "enhancedRouteRefresh", | |
12833 | "received"); | |
12834 | } | |
12835 | ||
d62a17ae | 12836 | /* Multiprotocol Extensions */ |
12837 | json_object *json_multi = NULL; | |
12838 | json_multi = json_object_new_object(); | |
12839 | ||
05c7a1cc QY |
12840 | FOREACH_AFI_SAFI (afi, safi) { |
12841 | if (p->afc_adv[afi][safi] | |
12842 | || p->afc_recv[afi][safi]) { | |
12843 | json_object *json_exten = NULL; | |
12844 | json_exten = | |
12845 | json_object_new_object(); | |
12846 | ||
d62a17ae | 12847 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
12848 | && p->afc_recv[afi][safi]) |
12849 | json_object_boolean_true_add( | |
12850 | json_exten, | |
12851 | "advertisedAndReceived"); | |
12852 | else if (p->afc_adv[afi][safi]) | |
12853 | json_object_boolean_true_add( | |
12854 | json_exten, | |
12855 | "advertised"); | |
12856 | else if (p->afc_recv[afi][safi]) | |
12857 | json_object_boolean_true_add( | |
12858 | json_exten, | |
12859 | "received"); | |
d62a17ae | 12860 | |
05c7a1cc QY |
12861 | json_object_object_add( |
12862 | json_multi, | |
5cb5f4d0 DD |
12863 | get_afi_safi_str(afi, |
12864 | safi, | |
12865 | true), | |
05c7a1cc | 12866 | json_exten); |
d62a17ae | 12867 | } |
12868 | } | |
12869 | json_object_object_add( | |
12870 | json_cap, "multiprotocolExtensions", | |
12871 | json_multi); | |
12872 | ||
d77114b7 | 12873 | /* Hostname capabilities */ |
60466a63 | 12874 | json_object *json_hname = NULL; |
d77114b7 MK |
12875 | |
12876 | json_hname = json_object_new_object(); | |
12877 | ||
12878 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
12879 | json_object_string_add( | |
60466a63 QY |
12880 | json_hname, "advHostName", |
12881 | bgp->peer_self->hostname | |
12882 | ? bgp->peer_self | |
12883 | ->hostname | |
d77114b7 MK |
12884 | : "n/a"); |
12885 | json_object_string_add( | |
60466a63 QY |
12886 | json_hname, "advDomainName", |
12887 | bgp->peer_self->domainname | |
12888 | ? bgp->peer_self | |
12889 | ->domainname | |
d77114b7 MK |
12890 | : "n/a"); |
12891 | } | |
12892 | ||
12893 | ||
12894 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
12895 | json_object_string_add( | |
60466a63 QY |
12896 | json_hname, "rcvHostName", |
12897 | p->hostname ? p->hostname | |
12898 | : "n/a"); | |
d77114b7 | 12899 | json_object_string_add( |
60466a63 QY |
12900 | json_hname, "rcvDomainName", |
12901 | p->domainname ? p->domainname | |
12902 | : "n/a"); | |
d77114b7 MK |
12903 | } |
12904 | ||
60466a63 | 12905 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
12906 | json_hname); |
12907 | ||
d62a17ae | 12908 | /* Gracefull Restart */ |
12909 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
12910 | || CHECK_FLAG(p->cap, | |
12911 | PEER_CAP_RESTART_ADV)) { | |
12912 | if (CHECK_FLAG(p->cap, | |
12913 | PEER_CAP_RESTART_ADV) | |
12914 | && CHECK_FLAG(p->cap, | |
12915 | PEER_CAP_RESTART_RCV)) | |
12916 | json_object_string_add( | |
12917 | json_cap, | |
12918 | "gracefulRestart", | |
12919 | "advertisedAndReceived"); | |
12920 | else if (CHECK_FLAG( | |
12921 | p->cap, | |
12922 | PEER_CAP_RESTART_ADV)) | |
12923 | json_object_string_add( | |
12924 | json_cap, | |
12925 | "gracefulRestartCapability", | |
12926 | "advertised"); | |
12927 | else if (CHECK_FLAG( | |
12928 | p->cap, | |
12929 | PEER_CAP_RESTART_RCV)) | |
12930 | json_object_string_add( | |
12931 | json_cap, | |
12932 | "gracefulRestartCapability", | |
12933 | "received"); | |
12934 | ||
12935 | if (CHECK_FLAG(p->cap, | |
12936 | PEER_CAP_RESTART_RCV)) { | |
12937 | int restart_af_count = 0; | |
12938 | json_object *json_restart = | |
12939 | NULL; | |
12940 | json_restart = | |
12941 | json_object_new_object(); | |
12942 | ||
12943 | json_object_int_add( | |
12944 | json_cap, | |
12945 | "gracefulRestartRemoteTimerMsecs", | |
12946 | p->v_gr_restart * 1000); | |
12947 | ||
05c7a1cc QY |
12948 | FOREACH_AFI_SAFI (afi, safi) { |
12949 | if (CHECK_FLAG( | |
12950 | p->af_cap | |
12951 | [afi] | |
12952 | [safi], | |
12953 | PEER_CAP_RESTART_AF_RCV)) { | |
12954 | json_object * | |
12955 | json_sub = | |
12956 | NULL; | |
12957 | json_sub = | |
12958 | json_object_new_object(); | |
12959 | ||
d62a17ae | 12960 | if (CHECK_FLAG( |
12961 | p->af_cap | |
12962 | [afi] | |
12963 | [safi], | |
05c7a1cc QY |
12964 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
12965 | json_object_boolean_true_add( | |
12966 | json_sub, | |
12967 | "preserved"); | |
12968 | restart_af_count++; | |
12969 | json_object_object_add( | |
12970 | json_restart, | |
5cb5f4d0 | 12971 | get_afi_safi_str( |
05c7a1cc | 12972 | afi, |
5cb5f4d0 DD |
12973 | safi, |
12974 | true), | |
05c7a1cc | 12975 | json_sub); |
d62a17ae | 12976 | } |
12977 | } | |
12978 | if (!restart_af_count) { | |
12979 | json_object_string_add( | |
12980 | json_cap, | |
12981 | "addressFamiliesByPeer", | |
12982 | "none"); | |
12983 | json_object_free( | |
12984 | json_restart); | |
12985 | } else | |
12986 | json_object_object_add( | |
12987 | json_cap, | |
12988 | "addressFamiliesByPeer", | |
12989 | json_restart); | |
12990 | } | |
12991 | } | |
12992 | json_object_object_add(json_neigh, | |
12993 | "neighborCapabilities", | |
12994 | json_cap); | |
12995 | } else { | |
12996 | vty_out(vty, " Neighbor capabilities:\n"); | |
12997 | ||
12998 | /* AS4 */ | |
12999 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13000 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13001 | vty_out(vty, " 4 Byte AS:"); | |
13002 | if (CHECK_FLAG(p->cap, | |
13003 | PEER_CAP_AS4_ADV)) | |
13004 | vty_out(vty, " advertised"); | |
13005 | if (CHECK_FLAG(p->cap, | |
13006 | PEER_CAP_AS4_RCV)) | |
13007 | vty_out(vty, " %sreceived", | |
13008 | CHECK_FLAG( | |
13009 | p->cap, | |
13010 | PEER_CAP_AS4_ADV) | |
13011 | ? "and " | |
13012 | : ""); | |
13013 | vty_out(vty, "\n"); | |
13014 | } | |
13015 | ||
ef56aee4 DA |
13016 | /* Extended Message Support */ |
13017 | if (CHECK_FLAG(p->cap, | |
13018 | PEER_CAP_EXTENDED_MESSAGE_RCV) | |
13019 | || CHECK_FLAG( | |
13020 | p->cap, | |
13021 | PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13022 | vty_out(vty, " Extended Message:"); | |
13023 | if (CHECK_FLAG( | |
13024 | p->cap, | |
13025 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13026 | vty_out(vty, " advertised"); | |
13027 | if (CHECK_FLAG( | |
13028 | p->cap, | |
13029 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13030 | vty_out(vty, " %sreceived", | |
13031 | CHECK_FLAG( | |
13032 | p->cap, | |
13033 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13034 | ? "and " | |
13035 | : ""); | |
13036 | vty_out(vty, "\n"); | |
13037 | } | |
13038 | ||
d62a17ae | 13039 | /* AddPath */ |
13040 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13041 | || CHECK_FLAG(p->cap, | |
13042 | PEER_CAP_ADDPATH_ADV)) { | |
13043 | vty_out(vty, " AddPath:\n"); | |
13044 | ||
05c7a1cc QY |
13045 | FOREACH_AFI_SAFI (afi, safi) { |
13046 | if (CHECK_FLAG( | |
13047 | p->af_cap[afi] | |
13048 | [safi], | |
13049 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13050 | || CHECK_FLAG( | |
13051 | p->af_cap[afi] | |
13052 | [safi], | |
13053 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13054 | vty_out(vty, | |
13055 | " %s: TX ", | |
5cb5f4d0 | 13056 | get_afi_safi_str( |
05c7a1cc | 13057 | afi, |
5cb5f4d0 DD |
13058 | safi, |
13059 | false)); | |
05c7a1cc | 13060 | |
d62a17ae | 13061 | if (CHECK_FLAG( |
13062 | p->af_cap | |
13063 | [afi] | |
13064 | [safi], | |
05c7a1cc | 13065 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13066 | vty_out(vty, |
34c71a4d | 13067 | "advertised"); |
d62a17ae | 13068 | |
05c7a1cc QY |
13069 | if (CHECK_FLAG( |
13070 | p->af_cap | |
13071 | [afi] | |
13072 | [safi], | |
13073 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13074 | vty_out(vty, | |
13075 | "%sreceived", | |
13076 | CHECK_FLAG( | |
13077 | p->af_cap | |
13078 | [afi] | |
13079 | [safi], | |
13080 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13081 | ? " and " | |
13082 | : ""); | |
d62a17ae | 13083 | |
05c7a1cc QY |
13084 | vty_out(vty, "\n"); |
13085 | } | |
d62a17ae | 13086 | |
05c7a1cc QY |
13087 | if (CHECK_FLAG( |
13088 | p->af_cap[afi] | |
13089 | [safi], | |
13090 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13091 | || CHECK_FLAG( | |
13092 | p->af_cap[afi] | |
13093 | [safi], | |
13094 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13095 | vty_out(vty, | |
13096 | " %s: RX ", | |
5cb5f4d0 | 13097 | get_afi_safi_str( |
05c7a1cc | 13098 | afi, |
5cb5f4d0 DD |
13099 | safi, |
13100 | false)); | |
d62a17ae | 13101 | |
13102 | if (CHECK_FLAG( | |
13103 | p->af_cap | |
13104 | [afi] | |
13105 | [safi], | |
05c7a1cc | 13106 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13107 | vty_out(vty, |
34c71a4d | 13108 | "advertised"); |
d62a17ae | 13109 | |
05c7a1cc QY |
13110 | if (CHECK_FLAG( |
13111 | p->af_cap | |
13112 | [afi] | |
13113 | [safi], | |
13114 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13115 | vty_out(vty, |
05c7a1cc QY |
13116 | "%sreceived", |
13117 | CHECK_FLAG( | |
13118 | p->af_cap | |
13119 | [afi] | |
13120 | [safi], | |
13121 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13122 | ? " and " | |
13123 | : ""); | |
13124 | ||
13125 | vty_out(vty, "\n"); | |
d62a17ae | 13126 | } |
05c7a1cc | 13127 | } |
d62a17ae | 13128 | } |
13129 | ||
13130 | /* Dynamic */ | |
13131 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13132 | || CHECK_FLAG(p->cap, | |
13133 | PEER_CAP_DYNAMIC_ADV)) { | |
13134 | vty_out(vty, " Dynamic:"); | |
13135 | if (CHECK_FLAG(p->cap, | |
13136 | PEER_CAP_DYNAMIC_ADV)) | |
13137 | vty_out(vty, " advertised"); | |
13138 | if (CHECK_FLAG(p->cap, | |
13139 | PEER_CAP_DYNAMIC_RCV)) | |
13140 | vty_out(vty, " %sreceived", | |
13141 | CHECK_FLAG( | |
13142 | p->cap, | |
13143 | PEER_CAP_DYNAMIC_ADV) | |
13144 | ? "and " | |
13145 | : ""); | |
13146 | vty_out(vty, "\n"); | |
13147 | } | |
13148 | ||
13149 | /* Extended nexthop */ | |
13150 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13151 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13152 | vty_out(vty, " Extended nexthop:"); | |
13153 | if (CHECK_FLAG(p->cap, | |
13154 | PEER_CAP_ENHE_ADV)) | |
13155 | vty_out(vty, " advertised"); | |
13156 | if (CHECK_FLAG(p->cap, | |
13157 | PEER_CAP_ENHE_RCV)) | |
13158 | vty_out(vty, " %sreceived", | |
13159 | CHECK_FLAG( | |
13160 | p->cap, | |
13161 | PEER_CAP_ENHE_ADV) | |
13162 | ? "and " | |
13163 | : ""); | |
13164 | vty_out(vty, "\n"); | |
13165 | ||
13166 | if (CHECK_FLAG(p->cap, | |
13167 | PEER_CAP_ENHE_RCV)) { | |
13168 | vty_out(vty, | |
13169 | " Address families by peer:\n "); | |
13170 | for (safi = SAFI_UNICAST; | |
13171 | safi < SAFI_MAX; safi++) | |
13172 | if (CHECK_FLAG( | |
13173 | p->af_cap | |
13174 | [AFI_IP] | |
13175 | [safi], | |
13176 | PEER_CAP_ENHE_AF_RCV)) | |
13177 | vty_out(vty, | |
13178 | " %s\n", | |
5cb5f4d0 | 13179 | get_afi_safi_str( |
d62a17ae | 13180 | AFI_IP, |
5cb5f4d0 DD |
13181 | safi, |
13182 | false)); | |
d62a17ae | 13183 | } |
13184 | } | |
13185 | ||
13186 | /* Route Refresh */ | |
13187 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13188 | || CHECK_FLAG(p->cap, | |
13189 | PEER_CAP_REFRESH_NEW_RCV) | |
13190 | || CHECK_FLAG(p->cap, | |
13191 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13192 | vty_out(vty, " Route refresh:"); | |
13193 | if (CHECK_FLAG(p->cap, | |
13194 | PEER_CAP_REFRESH_ADV)) | |
13195 | vty_out(vty, " advertised"); | |
13196 | if (CHECK_FLAG(p->cap, | |
13197 | PEER_CAP_REFRESH_NEW_RCV) | |
13198 | || CHECK_FLAG( | |
13199 | p->cap, | |
13200 | PEER_CAP_REFRESH_OLD_RCV)) | |
13201 | vty_out(vty, " %sreceived(%s)", | |
13202 | CHECK_FLAG( | |
13203 | p->cap, | |
13204 | PEER_CAP_REFRESH_ADV) | |
13205 | ? "and " | |
13206 | : "", | |
13207 | (CHECK_FLAG( | |
13208 | p->cap, | |
13209 | PEER_CAP_REFRESH_OLD_RCV) | |
13210 | && CHECK_FLAG( | |
13211 | p->cap, | |
13212 | PEER_CAP_REFRESH_NEW_RCV)) | |
13213 | ? "old & new" | |
13214 | : CHECK_FLAG( | |
13215 | p->cap, | |
13216 | PEER_CAP_REFRESH_OLD_RCV) | |
13217 | ? "old" | |
13218 | : "new"); | |
13219 | ||
13220 | vty_out(vty, "\n"); | |
13221 | } | |
13222 | ||
9af52ccf DA |
13223 | /* Enhanced Route Refresh */ |
13224 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13225 | || CHECK_FLAG(p->cap, | |
13226 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13227 | vty_out(vty, | |
13228 | " Enhanced Route Refresh:"); | |
13229 | if (CHECK_FLAG( | |
13230 | p->cap, | |
13231 | PEER_CAP_ENHANCED_RR_ADV)) | |
13232 | vty_out(vty, " advertised"); | |
13233 | if (CHECK_FLAG( | |
13234 | p->cap, | |
13235 | PEER_CAP_ENHANCED_RR_RCV)) | |
13236 | vty_out(vty, " %sreceived", | |
13237 | CHECK_FLAG( | |
13238 | p->cap, | |
13239 | PEER_CAP_REFRESH_ADV) | |
13240 | ? "and " | |
13241 | : ""); | |
13242 | vty_out(vty, "\n"); | |
13243 | } | |
13244 | ||
d62a17ae | 13245 | /* Multiprotocol Extensions */ |
05c7a1cc QY |
13246 | FOREACH_AFI_SAFI (afi, safi) |
13247 | if (p->afc_adv[afi][safi] | |
13248 | || p->afc_recv[afi][safi]) { | |
13249 | vty_out(vty, | |
13250 | " Address Family %s:", | |
5cb5f4d0 DD |
13251 | get_afi_safi_str( |
13252 | afi, | |
13253 | safi, | |
13254 | false)); | |
05c7a1cc | 13255 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13256 | vty_out(vty, |
05c7a1cc QY |
13257 | " advertised"); |
13258 | if (p->afc_recv[afi][safi]) | |
13259 | vty_out(vty, | |
13260 | " %sreceived", | |
13261 | p->afc_adv[afi] | |
13262 | [safi] | |
13263 | ? "and " | |
13264 | : ""); | |
13265 | vty_out(vty, "\n"); | |
13266 | } | |
d62a17ae | 13267 | |
13268 | /* Hostname capability */ | |
60466a63 | 13269 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13270 | |
13271 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13272 | vty_out(vty, |
13273 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13274 | bgp->peer_self->hostname |
13275 | ? bgp->peer_self | |
13276 | ->hostname | |
d77114b7 | 13277 | : "n/a", |
60466a63 QY |
13278 | bgp->peer_self->domainname |
13279 | ? bgp->peer_self | |
13280 | ->domainname | |
d77114b7 MK |
13281 | : "n/a"); |
13282 | } else { | |
13283 | vty_out(vty, " not advertised"); | |
d62a17ae | 13284 | } |
13285 | ||
d77114b7 | 13286 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13287 | vty_out(vty, |
13288 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13289 | p->hostname ? p->hostname |
13290 | : "n/a", | |
13291 | p->domainname ? p->domainname | |
13292 | : "n/a"); | |
d77114b7 MK |
13293 | } else { |
13294 | vty_out(vty, " not received"); | |
13295 | } | |
13296 | ||
13297 | vty_out(vty, "\n"); | |
13298 | ||
61bfbd51 | 13299 | /* Graceful Restart */ |
d62a17ae | 13300 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13301 | || CHECK_FLAG(p->cap, | |
13302 | PEER_CAP_RESTART_ADV)) { | |
13303 | vty_out(vty, | |
61bfbd51 | 13304 | " Graceful Restart Capability:"); |
d62a17ae | 13305 | if (CHECK_FLAG(p->cap, |
13306 | PEER_CAP_RESTART_ADV)) | |
13307 | vty_out(vty, " advertised"); | |
13308 | if (CHECK_FLAG(p->cap, | |
13309 | PEER_CAP_RESTART_RCV)) | |
13310 | vty_out(vty, " %sreceived", | |
13311 | CHECK_FLAG( | |
13312 | p->cap, | |
13313 | PEER_CAP_RESTART_ADV) | |
13314 | ? "and " | |
13315 | : ""); | |
13316 | vty_out(vty, "\n"); | |
13317 | ||
13318 | if (CHECK_FLAG(p->cap, | |
13319 | PEER_CAP_RESTART_RCV)) { | |
13320 | int restart_af_count = 0; | |
13321 | ||
13322 | vty_out(vty, | |
13323 | " Remote Restart timer is %d seconds\n", | |
13324 | p->v_gr_restart); | |
13325 | vty_out(vty, | |
13326 | " Address families by peer:\n "); | |
13327 | ||
05c7a1cc QY |
13328 | FOREACH_AFI_SAFI (afi, safi) |
13329 | if (CHECK_FLAG( | |
13330 | p->af_cap | |
13331 | [afi] | |
13332 | [safi], | |
13333 | PEER_CAP_RESTART_AF_RCV)) { | |
13334 | vty_out(vty, | |
13335 | "%s%s(%s)", | |
13336 | restart_af_count | |
13337 | ? ", " | |
13338 | : "", | |
5cb5f4d0 | 13339 | get_afi_safi_str( |
05c7a1cc | 13340 | afi, |
5cb5f4d0 DD |
13341 | safi, |
13342 | false), | |
05c7a1cc QY |
13343 | CHECK_FLAG( |
13344 | p->af_cap | |
13345 | [afi] | |
13346 | [safi], | |
13347 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13348 | ? "preserved" | |
13349 | : "not preserved"); | |
13350 | restart_af_count++; | |
13351 | } | |
d62a17ae | 13352 | if (!restart_af_count) |
13353 | vty_out(vty, "none"); | |
13354 | vty_out(vty, "\n"); | |
13355 | } | |
2986cac2 | 13356 | } /* Gracefull Restart */ |
d62a17ae | 13357 | } |
13358 | } | |
13359 | } | |
13360 | ||
13361 | /* graceful restart information */ | |
d62a17ae | 13362 | json_object *json_grace = NULL; |
13363 | json_object *json_grace_send = NULL; | |
13364 | json_object *json_grace_recv = NULL; | |
13365 | int eor_send_af_count = 0; | |
13366 | int eor_receive_af_count = 0; | |
13367 | ||
13368 | if (use_json) { | |
13369 | json_grace = json_object_new_object(); | |
13370 | json_grace_send = json_object_new_object(); | |
13371 | json_grace_recv = json_object_new_object(); | |
13372 | ||
feb17238 | 13373 | if ((peer_established(p)) |
36235319 | 13374 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
05c7a1cc QY |
13375 | FOREACH_AFI_SAFI (afi, safi) { |
13376 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13377 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13378 | json_object_boolean_true_add( |
13379 | json_grace_send, | |
5cb5f4d0 DD |
13380 | get_afi_safi_str(afi, |
13381 | safi, | |
13382 | true)); | |
05c7a1cc | 13383 | eor_send_af_count++; |
d62a17ae | 13384 | } |
13385 | } | |
05c7a1cc QY |
13386 | FOREACH_AFI_SAFI (afi, safi) { |
13387 | if (CHECK_FLAG( | |
36235319 QY |
13388 | p->af_sflags[afi][safi], |
13389 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13390 | json_object_boolean_true_add( |
13391 | json_grace_recv, | |
5cb5f4d0 DD |
13392 | get_afi_safi_str(afi, |
13393 | safi, | |
13394 | true)); | |
05c7a1cc | 13395 | eor_receive_af_count++; |
d62a17ae | 13396 | } |
13397 | } | |
13398 | } | |
36235319 QY |
13399 | json_object_object_add(json_grace, "endOfRibSend", |
13400 | json_grace_send); | |
13401 | json_object_object_add(json_grace, "endOfRibRecv", | |
13402 | json_grace_recv); | |
d62a17ae | 13403 | |
d62a17ae | 13404 | |
13405 | if (p->t_gr_restart) | |
13406 | json_object_int_add(json_grace, | |
13407 | "gracefulRestartTimerMsecs", | |
13408 | thread_timer_remain_second( | |
13409 | p->t_gr_restart) | |
13410 | * 1000); | |
13411 | ||
13412 | if (p->t_gr_stale) | |
13413 | json_object_int_add( | |
13414 | json_grace, | |
13415 | "gracefulStalepathTimerMsecs", | |
13416 | thread_timer_remain_second( | |
13417 | p->t_gr_stale) | |
13418 | * 1000); | |
2986cac2 | 13419 | /* more gr info in new format */ |
13420 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13421 | json_grace); |
d62a17ae | 13422 | json_object_object_add( |
13423 | json_neigh, "gracefulRestartInfo", json_grace); | |
13424 | } else { | |
2089dd80 | 13425 | vty_out(vty, " Graceful restart information:\n"); |
feb17238 | 13426 | if ((peer_established(p)) |
36235319 | 13427 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
2986cac2 | 13428 | |
d62a17ae | 13429 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13430 | FOREACH_AFI_SAFI (afi, safi) { |
13431 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13432 | PEER_STATUS_EOR_SEND)) { | |
13433 | vty_out(vty, "%s%s", | |
13434 | eor_send_af_count ? ", " | |
13435 | : "", | |
36235319 QY |
13436 | get_afi_safi_str( |
13437 | afi, safi, | |
13438 | false)); | |
05c7a1cc | 13439 | eor_send_af_count++; |
d62a17ae | 13440 | } |
13441 | } | |
13442 | vty_out(vty, "\n"); | |
13443 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13444 | FOREACH_AFI_SAFI (afi, safi) { |
13445 | if (CHECK_FLAG( | |
13446 | p->af_sflags[afi][safi], | |
13447 | PEER_STATUS_EOR_RECEIVED)) { | |
13448 | vty_out(vty, "%s%s", | |
13449 | eor_receive_af_count | |
13450 | ? ", " | |
13451 | : "", | |
5cb5f4d0 DD |
13452 | get_afi_safi_str(afi, |
13453 | safi, | |
13454 | false)); | |
05c7a1cc | 13455 | eor_receive_af_count++; |
d62a17ae | 13456 | } |
13457 | } | |
13458 | vty_out(vty, "\n"); | |
13459 | } | |
13460 | ||
13461 | if (p->t_gr_restart) | |
13462 | vty_out(vty, | |
13463 | " The remaining time of restart timer is %ld\n", | |
13464 | thread_timer_remain_second( | |
13465 | p->t_gr_restart)); | |
13466 | ||
13467 | if (p->t_gr_stale) | |
13468 | vty_out(vty, | |
13469 | " The remaining time of stalepath timer is %ld\n", | |
13470 | thread_timer_remain_second( | |
13471 | p->t_gr_stale)); | |
2986cac2 | 13472 | |
13473 | /* more gr info in new format */ | |
13474 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13475 | } |
2986cac2 | 13476 | |
d62a17ae | 13477 | if (use_json) { |
13478 | json_object *json_stat = NULL; | |
13479 | json_stat = json_object_new_object(); | |
13480 | /* Packet counts. */ | |
43aa5965 QY |
13481 | |
13482 | atomic_size_t outq_count, inq_count; | |
13483 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13484 | memory_order_relaxed); | |
13485 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13486 | memory_order_relaxed); | |
13487 | ||
13488 | json_object_int_add(json_stat, "depthInq", | |
13489 | (unsigned long)inq_count); | |
d62a17ae | 13490 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13491 | (unsigned long)outq_count); |
0112e9e0 QY |
13492 | json_object_int_add(json_stat, "opensSent", |
13493 | atomic_load_explicit(&p->open_out, | |
13494 | memory_order_relaxed)); | |
13495 | json_object_int_add(json_stat, "opensRecv", | |
13496 | atomic_load_explicit(&p->open_in, | |
13497 | memory_order_relaxed)); | |
d62a17ae | 13498 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13499 | atomic_load_explicit(&p->notify_out, |
13500 | memory_order_relaxed)); | |
d62a17ae | 13501 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13502 | atomic_load_explicit(&p->notify_in, |
13503 | memory_order_relaxed)); | |
13504 | json_object_int_add(json_stat, "updatesSent", | |
13505 | atomic_load_explicit(&p->update_out, | |
13506 | memory_order_relaxed)); | |
13507 | json_object_int_add(json_stat, "updatesRecv", | |
13508 | atomic_load_explicit(&p->update_in, | |
13509 | memory_order_relaxed)); | |
d62a17ae | 13510 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13511 | atomic_load_explicit(&p->keepalive_out, |
13512 | memory_order_relaxed)); | |
d62a17ae | 13513 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13514 | atomic_load_explicit(&p->keepalive_in, |
13515 | memory_order_relaxed)); | |
d62a17ae | 13516 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13517 | atomic_load_explicit(&p->refresh_out, |
13518 | memory_order_relaxed)); | |
d62a17ae | 13519 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13520 | atomic_load_explicit(&p->refresh_in, |
13521 | memory_order_relaxed)); | |
d62a17ae | 13522 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13523 | atomic_load_explicit(&p->dynamic_cap_out, |
13524 | memory_order_relaxed)); | |
d62a17ae | 13525 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13526 | atomic_load_explicit(&p->dynamic_cap_in, |
13527 | memory_order_relaxed)); | |
13528 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13529 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13530 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13531 | } else { | |
43aa5965 QY |
13532 | atomic_size_t outq_count, inq_count; |
13533 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13534 | memory_order_relaxed); | |
13535 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13536 | memory_order_relaxed); | |
13537 | ||
d62a17ae | 13538 | /* Packet counts. */ |
13539 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13540 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13541 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13542 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13543 | vty_out(vty, " Opens: %10d %10d\n", |
13544 | atomic_load_explicit(&p->open_out, | |
13545 | memory_order_relaxed), | |
13546 | atomic_load_explicit(&p->open_in, | |
13547 | memory_order_relaxed)); | |
13548 | vty_out(vty, " Notifications: %10d %10d\n", | |
13549 | atomic_load_explicit(&p->notify_out, | |
13550 | memory_order_relaxed), | |
13551 | atomic_load_explicit(&p->notify_in, | |
13552 | memory_order_relaxed)); | |
13553 | vty_out(vty, " Updates: %10d %10d\n", | |
13554 | atomic_load_explicit(&p->update_out, | |
13555 | memory_order_relaxed), | |
13556 | atomic_load_explicit(&p->update_in, | |
13557 | memory_order_relaxed)); | |
13558 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13559 | atomic_load_explicit(&p->keepalive_out, | |
13560 | memory_order_relaxed), | |
13561 | atomic_load_explicit(&p->keepalive_in, | |
13562 | memory_order_relaxed)); | |
13563 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13564 | atomic_load_explicit(&p->refresh_out, | |
13565 | memory_order_relaxed), | |
13566 | atomic_load_explicit(&p->refresh_in, | |
13567 | memory_order_relaxed)); | |
d62a17ae | 13568 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13569 | atomic_load_explicit(&p->dynamic_cap_out, |
13570 | memory_order_relaxed), | |
13571 | atomic_load_explicit(&p->dynamic_cap_in, | |
13572 | memory_order_relaxed)); | |
13573 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13574 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13575 | } |
13576 | ||
13577 | if (use_json) { | |
13578 | /* advertisement-interval */ | |
13579 | json_object_int_add(json_neigh, | |
13580 | "minBtwnAdvertisementRunsTimerMsecs", | |
13581 | p->v_routeadv * 1000); | |
13582 | ||
13583 | /* Update-source. */ | |
13584 | if (p->update_if || p->update_source) { | |
13585 | if (p->update_if) | |
13586 | json_object_string_add(json_neigh, | |
13587 | "updateSource", | |
13588 | p->update_if); | |
13589 | else if (p->update_source) | |
13590 | json_object_string_add( | |
13591 | json_neigh, "updateSource", | |
13592 | sockunion2str(p->update_source, buf1, | |
13593 | SU_ADDRSTRLEN)); | |
13594 | } | |
13595 | } else { | |
13596 | /* advertisement-interval */ | |
13597 | vty_out(vty, | |
13598 | " Minimum time between advertisement runs is %d seconds\n", | |
13599 | p->v_routeadv); | |
13600 | ||
13601 | /* Update-source. */ | |
13602 | if (p->update_if || p->update_source) { | |
13603 | vty_out(vty, " Update source is "); | |
13604 | if (p->update_if) | |
13605 | vty_out(vty, "%s", p->update_if); | |
13606 | else if (p->update_source) | |
13607 | vty_out(vty, "%s", | |
13608 | sockunion2str(p->update_source, buf1, | |
13609 | SU_ADDRSTRLEN)); | |
13610 | vty_out(vty, "\n"); | |
13611 | } | |
13612 | ||
13613 | vty_out(vty, "\n"); | |
13614 | } | |
13615 | ||
13616 | /* Address Family Information */ | |
13617 | json_object *json_hold = NULL; | |
13618 | ||
13619 | if (use_json) | |
13620 | json_hold = json_object_new_object(); | |
13621 | ||
05c7a1cc QY |
13622 | FOREACH_AFI_SAFI (afi, safi) |
13623 | if (p->afc[afi][safi]) | |
13624 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13625 | json_hold); | |
d62a17ae | 13626 | |
13627 | if (use_json) { | |
13628 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13629 | json_hold); | |
13630 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13631 | p->established); | |
13632 | json_object_int_add(json_neigh, "connectionsDropped", | |
13633 | p->dropped); | |
13634 | } else | |
13635 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13636 | p->established, p->dropped); | |
13637 | ||
13638 | if (!p->last_reset) { | |
13639 | if (use_json) | |
13640 | json_object_string_add(json_neigh, "lastReset", | |
13641 | "never"); | |
13642 | else | |
13643 | vty_out(vty, " Last reset never\n"); | |
13644 | } else { | |
13645 | if (use_json) { | |
13646 | time_t uptime; | |
a2700b50 | 13647 | struct tm tm; |
d62a17ae | 13648 | |
13649 | uptime = bgp_clock(); | |
13650 | uptime -= p->resettime; | |
a2700b50 MS |
13651 | gmtime_r(&uptime, &tm); |
13652 | ||
d62a17ae | 13653 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13654 | (tm.tm_sec * 1000) |
13655 | + (tm.tm_min * 60000) | |
13656 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13657 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13658 | } else { |
13659 | vty_out(vty, " Last reset %s, ", | |
13660 | peer_uptime(p->resettime, timebuf, | |
13661 | BGP_UPTIME_LEN, 0, NULL)); | |
13662 | ||
3577f1c5 | 13663 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13664 | if (p->last_reset_cause_size) { |
13665 | msg = p->last_reset_cause; | |
13666 | vty_out(vty, | |
13667 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13668 | for (i = 1; i <= p->last_reset_cause_size; | |
13669 | i++) { | |
13670 | vty_out(vty, "%02X", *msg++); | |
13671 | ||
13672 | if (i != p->last_reset_cause_size) { | |
13673 | if (i % 16 == 0) { | |
13674 | vty_out(vty, "\n "); | |
13675 | } else if (i % 4 == 0) { | |
13676 | vty_out(vty, " "); | |
13677 | } | |
13678 | } | |
13679 | } | |
13680 | vty_out(vty, "\n"); | |
13681 | } | |
13682 | } | |
13683 | } | |
13684 | ||
13685 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13686 | if (use_json) | |
13687 | json_object_boolean_true_add(json_neigh, | |
13688 | "prefixesConfigExceedMax"); | |
13689 | else | |
13690 | vty_out(vty, | |
13691 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13692 | ||
13693 | if (p->t_pmax_restart) { | |
13694 | if (use_json) { | |
13695 | json_object_boolean_true_add( | |
13696 | json_neigh, "reducePrefixNumFrom"); | |
13697 | json_object_int_add(json_neigh, | |
13698 | "restartInTimerMsec", | |
13699 | thread_timer_remain_second( | |
13700 | p->t_pmax_restart) | |
13701 | * 1000); | |
13702 | } else | |
13703 | vty_out(vty, | |
13704 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13705 | p->host, thread_timer_remain_second( |
13706 | p->t_pmax_restart)); | |
d62a17ae | 13707 | } else { |
13708 | if (use_json) | |
13709 | json_object_boolean_true_add( | |
13710 | json_neigh, | |
13711 | "reducePrefixNumAndClearIpBgp"); | |
13712 | else | |
13713 | vty_out(vty, | |
13714 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13715 | p->host); | |
13716 | } | |
13717 | } | |
13718 | ||
13719 | /* EBGP Multihop and GTSM */ | |
13720 | if (p->sort != BGP_PEER_IBGP) { | |
13721 | if (use_json) { | |
e2521429 | 13722 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13723 | json_object_int_add(json_neigh, |
13724 | "externalBgpNbrMaxHopsAway", | |
13725 | p->gtsm_hops); | |
c8d6f0d6 | 13726 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13727 | json_object_int_add(json_neigh, |
13728 | "externalBgpNbrMaxHopsAway", | |
13729 | p->ttl); | |
13730 | } else { | |
e2521429 | 13731 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13732 | vty_out(vty, |
13733 | " External BGP neighbor may be up to %d hops away.\n", | |
13734 | p->gtsm_hops); | |
c8d6f0d6 | 13735 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13736 | vty_out(vty, |
13737 | " External BGP neighbor may be up to %d hops away.\n", | |
13738 | p->ttl); | |
13739 | } | |
13740 | } else { | |
e2521429 | 13741 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13742 | if (use_json) |
13743 | json_object_int_add(json_neigh, | |
13744 | "internalBgpNbrMaxHopsAway", | |
13745 | p->gtsm_hops); | |
13746 | else | |
13747 | vty_out(vty, | |
13748 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13749 | p->gtsm_hops); | |
13750 | } | |
13751 | } | |
13752 | ||
13753 | /* Local address. */ | |
13754 | if (p->su_local) { | |
13755 | if (use_json) { | |
13756 | json_object_string_add(json_neigh, "hostLocal", | |
13757 | sockunion2str(p->su_local, buf1, | |
13758 | SU_ADDRSTRLEN)); | |
13759 | json_object_int_add(json_neigh, "portLocal", | |
13760 | ntohs(p->su_local->sin.sin_port)); | |
13761 | } else | |
13762 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13763 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13764 | ntohs(p->su_local->sin.sin_port)); | |
13765 | } | |
13766 | ||
13767 | /* Remote address. */ | |
13768 | if (p->su_remote) { | |
13769 | if (use_json) { | |
13770 | json_object_string_add(json_neigh, "hostForeign", | |
13771 | sockunion2str(p->su_remote, buf1, | |
13772 | SU_ADDRSTRLEN)); | |
13773 | json_object_int_add(json_neigh, "portForeign", | |
13774 | ntohs(p->su_remote->sin.sin_port)); | |
13775 | } else | |
13776 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13777 | sockunion2str(p->su_remote, buf1, | |
13778 | SU_ADDRSTRLEN), | |
13779 | ntohs(p->su_remote->sin.sin_port)); | |
13780 | } | |
13781 | ||
13782 | /* Nexthop display. */ | |
13783 | if (p->su_local) { | |
13784 | if (use_json) { | |
13785 | json_object_string_add(json_neigh, "nexthop", | |
13786 | inet_ntop(AF_INET, | |
13787 | &p->nexthop.v4, buf1, | |
13788 | sizeof(buf1))); | |
13789 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13790 | inet_ntop(AF_INET6, | |
13791 | &p->nexthop.v6_global, | |
13792 | buf1, sizeof(buf1))); | |
13793 | json_object_string_add(json_neigh, "nexthopLocal", | |
13794 | inet_ntop(AF_INET6, | |
13795 | &p->nexthop.v6_local, | |
13796 | buf1, sizeof(buf1))); | |
13797 | if (p->shared_network) | |
13798 | json_object_string_add(json_neigh, | |
13799 | "bgpConnection", | |
13800 | "sharedNetwork"); | |
13801 | else | |
13802 | json_object_string_add(json_neigh, | |
13803 | "bgpConnection", | |
13804 | "nonSharedNetwork"); | |
13805 | } else { | |
13806 | vty_out(vty, "Nexthop: %s\n", | |
13807 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13808 | sizeof(buf1))); | |
13809 | vty_out(vty, "Nexthop global: %s\n", | |
13810 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13811 | sizeof(buf1))); | |
13812 | vty_out(vty, "Nexthop local: %s\n", | |
13813 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13814 | sizeof(buf1))); | |
13815 | vty_out(vty, "BGP connection: %s\n", | |
13816 | p->shared_network ? "shared network" | |
13817 | : "non shared network"); | |
13818 | } | |
13819 | } | |
13820 | ||
13821 | /* Timer information. */ | |
13822 | if (use_json) { | |
13823 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13824 | p->v_connect); | |
feb17238 | 13825 | if (peer_established(p) && p->rtt) |
d62a17ae | 13826 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
13827 | p->rtt); | |
13828 | if (p->t_start) | |
13829 | json_object_int_add( | |
13830 | json_neigh, "nextStartTimerDueInMsecs", | |
13831 | thread_timer_remain_second(p->t_start) * 1000); | |
13832 | if (p->t_connect) | |
13833 | json_object_int_add( | |
13834 | json_neigh, "nextConnectTimerDueInMsecs", | |
13835 | thread_timer_remain_second(p->t_connect) | |
13836 | * 1000); | |
13837 | if (p->t_routeadv) { | |
13838 | json_object_int_add(json_neigh, "mraiInterval", | |
13839 | p->v_routeadv); | |
13840 | json_object_int_add( | |
13841 | json_neigh, "mraiTimerExpireInMsecs", | |
13842 | thread_timer_remain_second(p->t_routeadv) | |
13843 | * 1000); | |
13844 | } | |
13845 | if (p->password) | |
13846 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13847 | 1); | |
13848 | ||
13849 | if (p->t_read) | |
13850 | json_object_string_add(json_neigh, "readThread", "on"); | |
13851 | else | |
13852 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13853 | |
13854 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13855 | json_object_string_add(json_neigh, "writeThread", "on"); |
13856 | else | |
13857 | json_object_string_add(json_neigh, "writeThread", | |
13858 | "off"); | |
13859 | } else { | |
13860 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13861 | p->v_connect); | |
feb17238 | 13862 | if (peer_established(p) && p->rtt) |
d62a17ae | 13863 | vty_out(vty, "Estimated round trip time: %d ms\n", |
13864 | p->rtt); | |
13865 | if (p->t_start) | |
13866 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13867 | thread_timer_remain_second(p->t_start)); | |
13868 | if (p->t_connect) | |
13869 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13870 | thread_timer_remain_second(p->t_connect)); | |
13871 | if (p->t_routeadv) | |
13872 | vty_out(vty, | |
13873 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13874 | p->v_routeadv, | |
13875 | thread_timer_remain_second(p->t_routeadv)); | |
13876 | if (p->password) | |
13877 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13878 | ||
cac9e917 | 13879 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13880 | p->t_read ? "on" : "off", |
13881 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13882 | ? "on" | |
cac9e917 | 13883 | : "off", p->fd); |
d62a17ae | 13884 | } |
13885 | ||
13886 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13887 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13888 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13889 | ||
13890 | if (!use_json) | |
13891 | vty_out(vty, "\n"); | |
13892 | ||
13893 | /* BFD information. */ | |
21bfce98 RZ |
13894 | if (p->bfd_config) |
13895 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 13896 | |
13897 | if (use_json) { | |
13898 | if (p->conf_if) /* Configured interface name. */ | |
13899 | json_object_object_add(json, p->conf_if, json_neigh); | |
13900 | else /* Configured IP address. */ | |
13901 | json_object_object_add(json, p->host, json_neigh); | |
13902 | } | |
13903 | } | |
13904 | ||
36235319 QY |
13905 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
13906 | enum show_type type, | |
13907 | union sockunion *su, | |
13908 | const char *conf_if, afi_t afi, | |
74a630b6 | 13909 | bool use_json) |
2986cac2 | 13910 | { |
13911 | struct listnode *node, *nnode; | |
13912 | struct peer *peer; | |
13913 | int find = 0; | |
13914 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 13915 | json_object *json = NULL; |
2986cac2 | 13916 | json_object *json_neighbor = NULL; |
13917 | ||
74a630b6 NT |
13918 | if (use_json) { |
13919 | json = json_object_new_object(); | |
13920 | json_neighbor = json_object_new_object(); | |
13921 | } | |
13922 | ||
2986cac2 | 13923 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
13924 | ||
13925 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13926 | continue; | |
13927 | ||
13928 | if ((peer->afc[afi][safi]) == 0) | |
13929 | continue; | |
13930 | ||
2ba1fe69 | 13931 | if (type == show_all) { |
2986cac2 | 13932 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 13933 | json_neighbor); |
2986cac2 | 13934 | |
74a630b6 | 13935 | if (use_json) { |
13909c4f DS |
13936 | json_object_object_add(json, peer->host, |
13937 | json_neighbor); | |
74a630b6 NT |
13938 | json_neighbor = NULL; |
13939 | } | |
2986cac2 | 13940 | |
2ba1fe69 | 13941 | } else if (type == show_peer) { |
2986cac2 | 13942 | if (conf_if) { |
13943 | if ((peer->conf_if | |
13909c4f DS |
13944 | && !strcmp(peer->conf_if, conf_if)) |
13945 | || (peer->hostname | |
2986cac2 | 13946 | && !strcmp(peer->hostname, conf_if))) { |
13947 | find = 1; | |
13909c4f DS |
13948 | bgp_show_peer_gr_status(vty, peer, |
13949 | use_json, | |
13950 | json_neighbor); | |
2986cac2 | 13951 | } |
13952 | } else { | |
13953 | if (sockunion_same(&peer->su, su)) { | |
13954 | find = 1; | |
13909c4f DS |
13955 | bgp_show_peer_gr_status(vty, peer, |
13956 | use_json, | |
13957 | json_neighbor); | |
2986cac2 | 13958 | } |
13959 | } | |
13909c4f DS |
13960 | if (use_json && find) |
13961 | json_object_object_add(json, peer->host, | |
13962 | json_neighbor); | |
2986cac2 | 13963 | } |
13964 | ||
74a630b6 NT |
13965 | if (find) { |
13966 | json_neighbor = NULL; | |
2986cac2 | 13967 | break; |
74a630b6 | 13968 | } |
2986cac2 | 13969 | } |
13970 | ||
13971 | if (type == show_peer && !find) { | |
13972 | if (use_json) | |
13909c4f | 13973 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 13974 | else |
13975 | vty_out(vty, "%% No such neighbor\n"); | |
13976 | } | |
13977 | if (use_json) { | |
13909c4f DS |
13978 | vty_out(vty, "%s\n", |
13979 | json_object_to_json_string_ext( | |
13980 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
13981 | |
13982 | if (json_neighbor) | |
13983 | json_object_free(json_neighbor); | |
13984 | json_object_free(json); | |
2986cac2 | 13985 | } else { |
13986 | vty_out(vty, "\n"); | |
13987 | } | |
13988 | ||
13989 | return CMD_SUCCESS; | |
13990 | } | |
13991 | ||
d62a17ae | 13992 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
13993 | enum show_type type, union sockunion *su, | |
9f049418 | 13994 | const char *conf_if, bool use_json, |
d62a17ae | 13995 | json_object *json) |
13996 | { | |
13997 | struct listnode *node, *nnode; | |
13998 | struct peer *peer; | |
13999 | int find = 0; | |
9f049418 | 14000 | bool nbr_output = false; |
d1927ebe AS |
14001 | afi_t afi = AFI_MAX; |
14002 | safi_t safi = SAFI_MAX; | |
14003 | ||
14004 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14005 | afi = AFI_IP; | |
14006 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14007 | afi = AFI_IP6; | |
14008 | } | |
d62a17ae | 14009 | |
14010 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14011 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14012 | continue; | |
14013 | ||
14014 | switch (type) { | |
14015 | case show_all: | |
14016 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14017 | nbr_output = true; |
d62a17ae | 14018 | break; |
14019 | case show_peer: | |
14020 | if (conf_if) { | |
14021 | if ((peer->conf_if | |
14022 | && !strcmp(peer->conf_if, conf_if)) | |
14023 | || (peer->hostname | |
14024 | && !strcmp(peer->hostname, conf_if))) { | |
14025 | find = 1; | |
14026 | bgp_show_peer(vty, peer, use_json, | |
14027 | json); | |
14028 | } | |
14029 | } else { | |
14030 | if (sockunion_same(&peer->su, su)) { | |
14031 | find = 1; | |
14032 | bgp_show_peer(vty, peer, use_json, | |
14033 | json); | |
14034 | } | |
14035 | } | |
14036 | break; | |
d1927ebe AS |
14037 | case show_ipv4_peer: |
14038 | case show_ipv6_peer: | |
14039 | FOREACH_SAFI (safi) { | |
14040 | if (peer->afc[afi][safi]) { | |
14041 | if (conf_if) { | |
14042 | if ((peer->conf_if | |
14043 | && !strcmp(peer->conf_if, conf_if)) | |
14044 | || (peer->hostname | |
14045 | && !strcmp(peer->hostname, conf_if))) { | |
14046 | find = 1; | |
14047 | bgp_show_peer(vty, peer, use_json, | |
14048 | json); | |
14049 | break; | |
14050 | } | |
14051 | } else { | |
14052 | if (sockunion_same(&peer->su, su)) { | |
14053 | find = 1; | |
14054 | bgp_show_peer(vty, peer, use_json, | |
14055 | json); | |
14056 | break; | |
14057 | } | |
14058 | } | |
14059 | } | |
14060 | } | |
14061 | break; | |
14062 | case show_ipv4_all: | |
14063 | case show_ipv6_all: | |
14064 | FOREACH_SAFI (safi) { | |
14065 | if (peer->afc[afi][safi]) { | |
14066 | bgp_show_peer(vty, peer, use_json, json); | |
14067 | nbr_output = true; | |
14068 | break; | |
14069 | } | |
14070 | } | |
14071 | break; | |
d62a17ae | 14072 | } |
14073 | } | |
14074 | ||
d1927ebe AS |
14075 | if ((type == show_peer || type == show_ipv4_peer || |
14076 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14077 | if (use_json) |
14078 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14079 | else | |
88b7d255 | 14080 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14081 | } |
14082 | ||
d1927ebe AS |
14083 | if (type != show_peer && type != show_ipv4_peer && |
14084 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14085 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14086 | |
d62a17ae | 14087 | if (use_json) { |
996c9314 LB |
14088 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14089 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14090 | } else { |
14091 | vty_out(vty, "\n"); | |
14092 | } | |
14093 | ||
14094 | return CMD_SUCCESS; | |
14095 | } | |
14096 | ||
36235319 QY |
14097 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14098 | enum show_type type, | |
14099 | const char *ip_str, | |
14100 | afi_t afi, bool use_json) | |
2986cac2 | 14101 | { |
14102 | ||
14103 | int ret; | |
14104 | struct bgp *bgp; | |
14105 | union sockunion su; | |
2986cac2 | 14106 | |
14107 | bgp = bgp_get_default(); | |
14108 | ||
13909c4f DS |
14109 | if (!bgp) |
14110 | return; | |
2986cac2 | 14111 | |
13909c4f DS |
14112 | if (!use_json) |
14113 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14114 | NULL); | |
2986cac2 | 14115 | |
13909c4f DS |
14116 | if (ip_str) { |
14117 | ret = str2sockunion(ip_str, &su); | |
14118 | if (ret < 0) | |
13909c4f | 14119 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14120 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14121 | else | |
14122 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14123 | NULL, afi, use_json); | |
13909c4f DS |
14124 | } else |
14125 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14126 | afi, use_json); |
2986cac2 | 14127 | } |
14128 | ||
d62a17ae | 14129 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14130 | enum show_type type, |
14131 | const char *ip_str, | |
9f049418 | 14132 | bool use_json) |
d62a17ae | 14133 | { |
0291c246 MK |
14134 | struct listnode *node, *nnode; |
14135 | struct bgp *bgp; | |
71aedaa3 | 14136 | union sockunion su; |
0291c246 | 14137 | json_object *json = NULL; |
71aedaa3 | 14138 | int ret, is_first = 1; |
9f049418 | 14139 | bool nbr_output = false; |
d62a17ae | 14140 | |
14141 | if (use_json) | |
14142 | vty_out(vty, "{\n"); | |
14143 | ||
14144 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14145 | nbr_output = true; |
d62a17ae | 14146 | if (use_json) { |
14147 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14148 | flog_err( |
e50f7cfd | 14149 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14150 | "Unable to allocate memory for JSON object"); |
14151 | vty_out(vty, | |
14152 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14153 | return; | |
14154 | } | |
14155 | ||
14156 | json_object_int_add(json, "vrfId", | |
14157 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14158 | ? -1 |
14159 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14160 | json_object_string_add( |
14161 | json, "vrfName", | |
14162 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14163 | ? VRF_DEFAULT_NAME |
d62a17ae | 14164 | : bgp->name); |
14165 | ||
14166 | if (!is_first) | |
14167 | vty_out(vty, ",\n"); | |
14168 | else | |
14169 | is_first = 0; | |
14170 | ||
14171 | vty_out(vty, "\"%s\":", | |
14172 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14173 | ? VRF_DEFAULT_NAME |
d62a17ae | 14174 | : bgp->name); |
14175 | } else { | |
14176 | vty_out(vty, "\nInstance %s:\n", | |
14177 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14178 | ? VRF_DEFAULT_NAME |
d62a17ae | 14179 | : bgp->name); |
14180 | } | |
71aedaa3 | 14181 | |
d1927ebe AS |
14182 | if (type == show_peer || type == show_ipv4_peer || |
14183 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14184 | ret = str2sockunion(ip_str, &su); |
14185 | if (ret < 0) | |
14186 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14187 | use_json, json); | |
14188 | else | |
14189 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14190 | use_json, json); | |
14191 | } else { | |
d1927ebe | 14192 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14193 | use_json, json); |
14194 | } | |
b77004d6 | 14195 | json_object_free(json); |
121067e9 | 14196 | json = NULL; |
d62a17ae | 14197 | } |
14198 | ||
3e78a6ce | 14199 | if (use_json) |
d62a17ae | 14200 | vty_out(vty, "}\n"); |
9f049418 DS |
14201 | else if (!nbr_output) |
14202 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14203 | } |
14204 | ||
14205 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14206 | enum show_type type, const char *ip_str, | |
9f049418 | 14207 | bool use_json) |
d62a17ae | 14208 | { |
14209 | int ret; | |
14210 | struct bgp *bgp; | |
14211 | union sockunion su; | |
14212 | json_object *json = NULL; | |
14213 | ||
14214 | if (name) { | |
14215 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14216 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14217 | use_json); | |
d62a17ae | 14218 | return CMD_SUCCESS; |
14219 | } else { | |
14220 | bgp = bgp_lookup_by_name(name); | |
14221 | if (!bgp) { | |
14222 | if (use_json) { | |
14223 | json = json_object_new_object(); | |
d62a17ae | 14224 | vty_out(vty, "%s\n", |
14225 | json_object_to_json_string_ext( | |
14226 | json, | |
14227 | JSON_C_TO_STRING_PRETTY)); | |
14228 | json_object_free(json); | |
14229 | } else | |
14230 | vty_out(vty, | |
9f049418 | 14231 | "%% BGP instance not found\n"); |
d62a17ae | 14232 | |
14233 | return CMD_WARNING; | |
14234 | } | |
14235 | } | |
14236 | } else { | |
14237 | bgp = bgp_get_default(); | |
14238 | } | |
14239 | ||
14240 | if (bgp) { | |
14241 | json = json_object_new_object(); | |
14242 | if (ip_str) { | |
14243 | ret = str2sockunion(ip_str, &su); | |
14244 | if (ret < 0) | |
14245 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14246 | use_json, json); | |
14247 | else | |
14248 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14249 | use_json, json); | |
14250 | } else { | |
14251 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14252 | json); | |
14253 | } | |
14254 | json_object_free(json); | |
ca61fd25 DS |
14255 | } else { |
14256 | if (use_json) | |
14257 | vty_out(vty, "{}\n"); | |
14258 | else | |
14259 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14260 | } |
14261 | ||
14262 | return CMD_SUCCESS; | |
4fb25c53 DW |
14263 | } |
14264 | ||
2986cac2 | 14265 | |
14266 | ||
14267 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14268 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14269 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14270 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14271 | SHOW_STR | |
14272 | BGP_STR | |
14273 | IP_STR | |
14274 | IPV6_STR | |
14275 | NEIGHBOR_STR | |
14276 | "Neighbor to display information about\n" | |
14277 | "Neighbor to display information about\n" | |
14278 | "Neighbor on BGP configured interface\n" | |
14279 | GR_SHOW | |
14280 | JSON_STR) | |
14281 | { | |
14282 | char *sh_arg = NULL; | |
14283 | enum show_type sh_type; | |
14284 | int idx = 0; | |
14285 | afi_t afi = AFI_MAX; | |
2986cac2 | 14286 | bool uj = use_json(argc, argv); |
14287 | ||
36235319 | 14288 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14289 | afi = AFI_MAX; |
14290 | ||
14291 | idx++; | |
14292 | ||
14293 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14294 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14295 | || argv_find(argv, argc, "WORD", &idx)) { | |
14296 | sh_type = show_peer; | |
14297 | sh_arg = argv[idx]->arg; | |
14298 | } else | |
14299 | sh_type = show_all; | |
14300 | ||
14301 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14302 | return CMD_SUCCESS; | |
14303 | ||
14304 | ||
36235319 QY |
14305 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14306 | afi, uj); | |
2986cac2 | 14307 | } |
14308 | ||
716b2d8a | 14309 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14310 | DEFUN (show_ip_bgp_neighbors, |
14311 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14312 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14313 | SHOW_STR |
14314 | IP_STR | |
14315 | BGP_STR | |
f2a8972b | 14316 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14317 | "Address Family\n" |
14318 | "Address Family\n" | |
718e3744 | 14319 | "Detailed information on TCP and BGP neighbor connections\n" |
14320 | "Neighbor to display information about\n" | |
a80beece | 14321 | "Neighbor to display information about\n" |
91d37724 | 14322 | "Neighbor on BGP configured interface\n" |
9973d184 | 14323 | JSON_STR) |
718e3744 | 14324 | { |
d62a17ae | 14325 | char *vrf = NULL; |
14326 | char *sh_arg = NULL; | |
14327 | enum show_type sh_type; | |
d1927ebe | 14328 | afi_t afi = AFI_MAX; |
718e3744 | 14329 | |
9f049418 | 14330 | bool uj = use_json(argc, argv); |
718e3744 | 14331 | |
d62a17ae | 14332 | int idx = 0; |
718e3744 | 14333 | |
9a8bdf1c PG |
14334 | /* [<vrf> VIEWVRFNAME] */ |
14335 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14336 | vrf = argv[idx + 1]->arg; | |
14337 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14338 | vrf = NULL; | |
14339 | } else if (argv_find(argv, argc, "view", &idx)) | |
14340 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14341 | vrf = argv[idx + 1]->arg; |
718e3744 | 14342 | |
d62a17ae | 14343 | idx++; |
d1927ebe AS |
14344 | |
14345 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14346 | sh_type = show_ipv4_all; | |
14347 | afi = AFI_IP; | |
14348 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14349 | sh_type = show_ipv6_all; | |
14350 | afi = AFI_IP6; | |
14351 | } else { | |
14352 | sh_type = show_all; | |
14353 | } | |
14354 | ||
d62a17ae | 14355 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14356 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14357 | || argv_find(argv, argc, "WORD", &idx)) { | |
14358 | sh_type = show_peer; | |
14359 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14360 | } |
14361 | ||
14362 | if (sh_type == show_peer && afi == AFI_IP) { | |
14363 | sh_type = show_ipv4_peer; | |
14364 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14365 | sh_type = show_ipv6_peer; | |
14366 | } | |
856ca177 | 14367 | |
d62a17ae | 14368 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14369 | } |
14370 | ||
716b2d8a | 14371 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14372 | paths' and `show ip mbgp paths'. Those functions results are the |
14373 | same.*/ | |
f412b39a | 14374 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14375 | show_ip_bgp_paths_cmd, |
46f296b4 | 14376 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14377 | SHOW_STR |
14378 | IP_STR | |
14379 | BGP_STR | |
46f296b4 | 14380 | BGP_SAFI_HELP_STR |
718e3744 | 14381 | "Path information\n") |
14382 | { | |
d62a17ae | 14383 | vty_out(vty, "Address Refcnt Path\n"); |
14384 | aspath_print_all_vty(vty); | |
14385 | return CMD_SUCCESS; | |
718e3744 | 14386 | } |
14387 | ||
718e3744 | 14388 | #include "hash.h" |
14389 | ||
e3b78da8 | 14390 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14391 | struct vty *vty) |
718e3744 | 14392 | { |
d62a17ae | 14393 | struct community *com; |
718e3744 | 14394 | |
e3b78da8 | 14395 | com = (struct community *)bucket->data; |
3f65c5b1 | 14396 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14397 | community_str(com, false)); |
718e3744 | 14398 | } |
14399 | ||
14400 | /* Show BGP's community internal data. */ | |
f412b39a | 14401 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14402 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14403 | "show [ip] bgp community-info", |
718e3744 | 14404 | SHOW_STR |
14405 | IP_STR | |
14406 | BGP_STR | |
14407 | "List all bgp community information\n") | |
14408 | { | |
d62a17ae | 14409 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14410 | |
d62a17ae | 14411 | hash_iterate(community_hash(), |
e3b78da8 | 14412 | (void (*)(struct hash_bucket *, |
d62a17ae | 14413 | void *))community_show_all_iterator, |
14414 | vty); | |
718e3744 | 14415 | |
d62a17ae | 14416 | return CMD_SUCCESS; |
718e3744 | 14417 | } |
14418 | ||
e3b78da8 | 14419 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14420 | struct vty *vty) |
57d187bc | 14421 | { |
d62a17ae | 14422 | struct lcommunity *lcom; |
57d187bc | 14423 | |
e3b78da8 | 14424 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14425 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14426 | lcommunity_str(lcom, false)); |
57d187bc JS |
14427 | } |
14428 | ||
14429 | /* Show BGP's community internal data. */ | |
14430 | DEFUN (show_ip_bgp_lcommunity_info, | |
14431 | show_ip_bgp_lcommunity_info_cmd, | |
14432 | "show ip bgp large-community-info", | |
14433 | SHOW_STR | |
14434 | IP_STR | |
14435 | BGP_STR | |
14436 | "List all bgp large-community information\n") | |
14437 | { | |
d62a17ae | 14438 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14439 | |
d62a17ae | 14440 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14441 | (void (*)(struct hash_bucket *, |
d62a17ae | 14442 | void *))lcommunity_show_all_iterator, |
14443 | vty); | |
57d187bc | 14444 | |
d62a17ae | 14445 | return CMD_SUCCESS; |
57d187bc | 14446 | } |
2986cac2 | 14447 | /* Graceful Restart */ |
14448 | ||
14449 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14450 | struct bgp *bgp, |
14451 | bool use_json, | |
14452 | json_object *json) | |
2986cac2 | 14453 | { |
57d187bc JS |
14454 | |
14455 | ||
2986cac2 | 14456 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14457 | ||
7318ae88 | 14458 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14459 | |
14460 | switch (bgp_global_gr_mode) { | |
14461 | ||
14462 | case GLOBAL_HELPER: | |
13909c4f | 14463 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14464 | break; |
14465 | ||
14466 | case GLOBAL_GR: | |
13909c4f | 14467 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14468 | break; |
14469 | ||
14470 | case GLOBAL_DISABLE: | |
13909c4f | 14471 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14472 | break; |
14473 | ||
14474 | case GLOBAL_INVALID: | |
2986cac2 | 14475 | vty_out(vty, |
2ba1fe69 | 14476 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14477 | break; |
14478 | } | |
14479 | vty_out(vty, "\n"); | |
14480 | } | |
14481 | ||
36235319 QY |
14482 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14483 | enum show_type type, | |
14484 | const char *ip_str, | |
14485 | afi_t afi, bool use_json) | |
2986cac2 | 14486 | { |
14487 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14488 | afi = AFI_IP; | |
14489 | ||
14490 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14491 | ||
36235319 QY |
14492 | bgp_show_neighbor_graceful_restart_vty( |
14493 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14494 | afi++; |
14495 | } | |
14496 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14497 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14498 | use_json); | |
2986cac2 | 14499 | } else { |
14500 | return CMD_ERR_INCOMPLETE; | |
14501 | } | |
14502 | ||
14503 | return CMD_SUCCESS; | |
14504 | } | |
14505 | /* Graceful Restart */ | |
14506 | ||
f412b39a | 14507 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14508 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14509 | "show [ip] bgp attribute-info", |
718e3744 | 14510 | SHOW_STR |
14511 | IP_STR | |
14512 | BGP_STR | |
14513 | "List all bgp attribute information\n") | |
14514 | { | |
d62a17ae | 14515 | attr_show_all(vty); |
14516 | return CMD_SUCCESS; | |
718e3744 | 14517 | } |
6b0655a2 | 14518 | |
03915806 CS |
14519 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14520 | afi_t afi, safi_t safi, | |
14521 | bool use_json, json_object *json) | |
53089bec | 14522 | { |
14523 | struct bgp *bgp; | |
14524 | struct listnode *node; | |
14525 | char *vname; | |
14526 | char buf1[INET6_ADDRSTRLEN]; | |
14527 | char *ecom_str; | |
14528 | vpn_policy_direction_t dir; | |
14529 | ||
03915806 | 14530 | if (json) { |
b46dfd20 DS |
14531 | json_object *json_import_vrfs = NULL; |
14532 | json_object *json_export_vrfs = NULL; | |
14533 | ||
b46dfd20 DS |
14534 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14535 | ||
53089bec | 14536 | if (!bgp) { |
b46dfd20 DS |
14537 | vty_out(vty, "%s\n", |
14538 | json_object_to_json_string_ext( | |
14539 | json, | |
14540 | JSON_C_TO_STRING_PRETTY)); | |
14541 | json_object_free(json); | |
14542 | ||
53089bec | 14543 | return CMD_WARNING; |
14544 | } | |
b46dfd20 | 14545 | |
94d4c685 DS |
14546 | /* Provide context for the block */ |
14547 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14548 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14549 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14550 | |
b46dfd20 DS |
14551 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14552 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14553 | json_object_string_add(json, "importFromVrfs", "none"); | |
14554 | json_object_string_add(json, "importRts", "none"); | |
14555 | } else { | |
6ce24e52 DS |
14556 | json_import_vrfs = json_object_new_array(); |
14557 | ||
b46dfd20 DS |
14558 | for (ALL_LIST_ELEMENTS_RO( |
14559 | bgp->vpn_policy[afi].import_vrf, | |
14560 | node, vname)) | |
14561 | json_object_array_add(json_import_vrfs, | |
14562 | json_object_new_string(vname)); | |
14563 | ||
b20875ea CS |
14564 | json_object_object_add(json, "importFromVrfs", |
14565 | json_import_vrfs); | |
b46dfd20 | 14566 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14567 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14568 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14569 | bgp->vpn_policy[afi].rtlist[dir], |
14570 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14571 | json_object_string_add(json, "importRts", |
14572 | ecom_str); | |
14573 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14574 | } else | |
14575 | json_object_string_add(json, "importRts", | |
14576 | "none"); | |
b46dfd20 DS |
14577 | } |
14578 | ||
14579 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14580 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14581 | json_object_string_add(json, "exportToVrfs", "none"); | |
14582 | json_object_string_add(json, "routeDistinguisher", | |
14583 | "none"); | |
14584 | json_object_string_add(json, "exportRts", "none"); | |
14585 | } else { | |
6ce24e52 DS |
14586 | json_export_vrfs = json_object_new_array(); |
14587 | ||
b46dfd20 DS |
14588 | for (ALL_LIST_ELEMENTS_RO( |
14589 | bgp->vpn_policy[afi].export_vrf, | |
14590 | node, vname)) | |
14591 | json_object_array_add(json_export_vrfs, | |
14592 | json_object_new_string(vname)); | |
14593 | json_object_object_add(json, "exportToVrfs", | |
14594 | json_export_vrfs); | |
14595 | json_object_string_add(json, "routeDistinguisher", | |
14596 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14597 | buf1, RD_ADDRSTRLEN)); | |
14598 | ||
14599 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14600 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14601 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14602 | bgp->vpn_policy[afi].rtlist[dir], |
14603 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14604 | json_object_string_add(json, "exportRts", |
14605 | ecom_str); | |
14606 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14607 | } else | |
14608 | json_object_string_add(json, "exportRts", | |
14609 | "none"); | |
b46dfd20 DS |
14610 | } |
14611 | ||
03915806 CS |
14612 | if (use_json) { |
14613 | vty_out(vty, "%s\n", | |
14614 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14615 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14616 | json_object_free(json); |
14617 | } | |
53089bec | 14618 | } else { |
b46dfd20 DS |
14619 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14620 | ||
53089bec | 14621 | if (!bgp) { |
b46dfd20 | 14622 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14623 | return CMD_WARNING; |
14624 | } | |
53089bec | 14625 | |
b46dfd20 DS |
14626 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14627 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14628 | vty_out(vty, | |
14629 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14630 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14631 | else { |
14632 | vty_out(vty, | |
14633 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14634 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14635 | |
14636 | for (ALL_LIST_ELEMENTS_RO( | |
14637 | bgp->vpn_policy[afi].import_vrf, | |
14638 | node, vname)) | |
14639 | vty_out(vty, " %s\n", vname); | |
14640 | ||
14641 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14642 | ecom_str = NULL; |
14643 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14644 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14645 | bgp->vpn_policy[afi].rtlist[dir], |
14646 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14647 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14648 | |
b20875ea CS |
14649 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14650 | } else | |
14651 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14652 | } |
53089bec | 14653 | |
b46dfd20 DS |
14654 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14655 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14656 | vty_out(vty, | |
14657 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14658 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14659 | else { |
14660 | vty_out(vty, | |
04c9077f | 14661 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14662 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14663 | |
14664 | for (ALL_LIST_ELEMENTS_RO( | |
14665 | bgp->vpn_policy[afi].export_vrf, | |
14666 | node, vname)) | |
14667 | vty_out(vty, " %s\n", vname); | |
14668 | ||
14669 | vty_out(vty, "RD: %s\n", | |
14670 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14671 | buf1, RD_ADDRSTRLEN)); | |
14672 | ||
14673 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14674 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14675 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14676 | bgp->vpn_policy[afi].rtlist[dir], |
14677 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14678 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14679 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14680 | } else | |
14681 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14682 | } |
53089bec | 14683 | } |
14684 | ||
14685 | return CMD_SUCCESS; | |
14686 | } | |
14687 | ||
03915806 CS |
14688 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14689 | safi_t safi, bool use_json) | |
14690 | { | |
14691 | struct listnode *node, *nnode; | |
14692 | struct bgp *bgp; | |
14693 | char *vrf_name = NULL; | |
14694 | json_object *json = NULL; | |
14695 | json_object *json_vrf = NULL; | |
14696 | json_object *json_vrfs = NULL; | |
14697 | ||
14698 | if (use_json) { | |
14699 | json = json_object_new_object(); | |
14700 | json_vrfs = json_object_new_object(); | |
14701 | } | |
14702 | ||
14703 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14704 | ||
14705 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14706 | vrf_name = bgp->name; | |
14707 | ||
14708 | if (use_json) { | |
14709 | json_vrf = json_object_new_object(); | |
14710 | } else { | |
14711 | vty_out(vty, "\nInstance %s:\n", | |
14712 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14713 | ? VRF_DEFAULT_NAME : bgp->name); | |
14714 | } | |
14715 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14716 | if (use_json) { | |
14717 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14718 | json_object_object_add(json_vrfs, | |
14719 | VRF_DEFAULT_NAME, json_vrf); | |
14720 | else | |
14721 | json_object_object_add(json_vrfs, vrf_name, | |
14722 | json_vrf); | |
14723 | } | |
14724 | } | |
14725 | ||
14726 | if (use_json) { | |
14727 | json_object_object_add(json, "vrfs", json_vrfs); | |
14728 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14729 | JSON_C_TO_STRING_PRETTY)); | |
14730 | json_object_free(json); | |
14731 | } | |
14732 | ||
14733 | return CMD_SUCCESS; | |
14734 | } | |
14735 | ||
53089bec | 14736 | /* "show [ip] bgp route-leak" command. */ |
14737 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14738 | show_ip_bgp_route_leak_cmd, |
14739 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14740 | SHOW_STR |
14741 | IP_STR | |
14742 | BGP_STR | |
14743 | BGP_INSTANCE_HELP_STR | |
14744 | BGP_AFI_HELP_STR | |
14745 | BGP_SAFI_HELP_STR | |
14746 | "Route leaking information\n" | |
14747 | JSON_STR) | |
53089bec | 14748 | { |
14749 | char *vrf = NULL; | |
14750 | afi_t afi = AFI_MAX; | |
14751 | safi_t safi = SAFI_MAX; | |
14752 | ||
9f049418 | 14753 | bool uj = use_json(argc, argv); |
53089bec | 14754 | int idx = 0; |
03915806 | 14755 | json_object *json = NULL; |
53089bec | 14756 | |
14757 | /* show [ip] bgp */ | |
14758 | if (argv_find(argv, argc, "ip", &idx)) { | |
14759 | afi = AFI_IP; | |
14760 | safi = SAFI_UNICAST; | |
14761 | } | |
14762 | /* [vrf VIEWVRFNAME] */ | |
14763 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14764 | vty_out(vty, |
14765 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14766 | return CMD_WARNING; |
14767 | } | |
14768 | ||
9a8bdf1c PG |
14769 | if (argv_find(argv, argc, "vrf", &idx)) { |
14770 | vrf = argv[idx + 1]->arg; | |
14771 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14772 | vrf = NULL; | |
14773 | } | |
53089bec | 14774 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14775 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14776 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14777 | } | |
14778 | ||
14779 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14780 | vty_out(vty, |
14781 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14782 | return CMD_WARNING; |
14783 | } | |
14784 | ||
03915806 CS |
14785 | if (vrf && strmatch(vrf, "all")) |
14786 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14787 | ||
14788 | if (uj) | |
14789 | json = json_object_new_object(); | |
14790 | ||
14791 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14792 | } |
14793 | ||
d62a17ae | 14794 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14795 | safi_t safi) | |
f186de26 | 14796 | { |
d62a17ae | 14797 | struct listnode *node, *nnode; |
14798 | struct bgp *bgp; | |
f186de26 | 14799 | |
d62a17ae | 14800 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14801 | vty_out(vty, "\nInstance %s:\n", | |
14802 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14803 | ? VRF_DEFAULT_NAME |
d62a17ae | 14804 | : bgp->name); |
14805 | update_group_show(bgp, afi, safi, vty, 0); | |
14806 | } | |
f186de26 | 14807 | } |
14808 | ||
d62a17ae | 14809 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14810 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14811 | { |
d62a17ae | 14812 | struct bgp *bgp; |
4fb25c53 | 14813 | |
d62a17ae | 14814 | if (name) { |
14815 | if (strmatch(name, "all")) { | |
14816 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14817 | return CMD_SUCCESS; | |
14818 | } else { | |
14819 | bgp = bgp_lookup_by_name(name); | |
14820 | } | |
14821 | } else { | |
14822 | bgp = bgp_get_default(); | |
14823 | } | |
4fb25c53 | 14824 | |
d62a17ae | 14825 | if (bgp) |
14826 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14827 | return CMD_SUCCESS; | |
4fb25c53 DW |
14828 | } |
14829 | ||
8fe8a7f6 DS |
14830 | DEFUN (show_ip_bgp_updgrps, |
14831 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14832 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14833 | SHOW_STR |
14834 | IP_STR | |
14835 | BGP_STR | |
14836 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14837 | BGP_AFI_HELP_STR |
9bedbb1e | 14838 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14839 | "Detailed info about dynamic update groups\n" |
14840 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14841 | { |
d62a17ae | 14842 | char *vrf = NULL; |
14843 | afi_t afi = AFI_IP6; | |
14844 | safi_t safi = SAFI_UNICAST; | |
14845 | uint64_t subgrp_id = 0; | |
14846 | ||
14847 | int idx = 0; | |
14848 | ||
14849 | /* show [ip] bgp */ | |
14850 | if (argv_find(argv, argc, "ip", &idx)) | |
14851 | afi = AFI_IP; | |
9a8bdf1c PG |
14852 | /* [<vrf> VIEWVRFNAME] */ |
14853 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14854 | vrf = argv[idx + 1]->arg; | |
14855 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14856 | vrf = NULL; | |
14857 | } else if (argv_find(argv, argc, "view", &idx)) | |
14858 | /* [<view> VIEWVRFNAME] */ | |
14859 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14860 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14861 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14862 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14863 | } | |
5bf15956 | 14864 | |
d62a17ae | 14865 | /* get subgroup id, if provided */ |
14866 | idx = argc - 1; | |
14867 | if (argv[idx]->type == VARIABLE_TKN) | |
14868 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14869 | |
d62a17ae | 14870 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14871 | } |
14872 | ||
f186de26 | 14873 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14874 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14875 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14876 | SHOW_STR |
716b2d8a | 14877 | IP_STR |
f186de26 | 14878 | BGP_STR |
14879 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14880 | "Detailed info about dynamic update groups\n") |
f186de26 | 14881 | { |
d62a17ae | 14882 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14883 | return CMD_SUCCESS; | |
f186de26 | 14884 | } |
14885 | ||
43d3f4fc DS |
14886 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14887 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14888 | "show [ip] bgp l2vpn evpn update-groups", | |
14889 | SHOW_STR | |
14890 | IP_STR | |
14891 | BGP_STR | |
14892 | "l2vpn address family\n" | |
14893 | "evpn sub-address family\n" | |
14894 | "Detailed info about dynamic update groups\n") | |
14895 | { | |
14896 | char *vrf = NULL; | |
14897 | uint64_t subgrp_id = 0; | |
14898 | ||
14899 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14900 | return CMD_SUCCESS; | |
14901 | } | |
14902 | ||
5bf15956 DW |
14903 | DEFUN (show_bgp_updgrps_stats, |
14904 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14905 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 14906 | SHOW_STR |
716b2d8a | 14907 | IP_STR |
3f9c7369 | 14908 | BGP_STR |
0c7b1b01 | 14909 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
14910 | "Statistics\n") |
14911 | { | |
d62a17ae | 14912 | struct bgp *bgp; |
3f9c7369 | 14913 | |
d62a17ae | 14914 | bgp = bgp_get_default(); |
14915 | if (bgp) | |
14916 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 14917 | |
d62a17ae | 14918 | return CMD_SUCCESS; |
3f9c7369 DS |
14919 | } |
14920 | ||
8386ac43 | 14921 | DEFUN (show_bgp_instance_updgrps_stats, |
14922 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 14923 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 14924 | SHOW_STR |
716b2d8a | 14925 | IP_STR |
8386ac43 | 14926 | BGP_STR |
14927 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 14928 | "Detailed info about dynamic update groups\n" |
8386ac43 | 14929 | "Statistics\n") |
14930 | { | |
d62a17ae | 14931 | int idx_word = 3; |
14932 | struct bgp *bgp; | |
8386ac43 | 14933 | |
d62a17ae | 14934 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
14935 | if (bgp) | |
14936 | update_group_show_stats(bgp, vty); | |
8386ac43 | 14937 | |
d62a17ae | 14938 | return CMD_SUCCESS; |
8386ac43 | 14939 | } |
14940 | ||
d62a17ae | 14941 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
14942 | afi_t afi, safi_t safi, | |
14943 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 14944 | { |
d62a17ae | 14945 | struct bgp *bgp; |
8386ac43 | 14946 | |
d62a17ae | 14947 | if (name) |
14948 | bgp = bgp_lookup_by_name(name); | |
14949 | else | |
14950 | bgp = bgp_get_default(); | |
8386ac43 | 14951 | |
d62a17ae | 14952 | if (bgp) { |
14953 | if (!strcmp(what, "advertise-queue")) | |
14954 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
14955 | subgrp_id); | |
14956 | else if (!strcmp(what, "advertised-routes")) | |
14957 | update_group_show_advertised(bgp, afi, safi, vty, | |
14958 | subgrp_id); | |
14959 | else if (!strcmp(what, "packet-queue")) | |
14960 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
14961 | subgrp_id); | |
14962 | } | |
3f9c7369 DS |
14963 | } |
14964 | ||
dc64bdec QY |
14965 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
14966 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
14967 | "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", | |
14968 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
14969 | BGP_SAFI_HELP_STR | |
14970 | "Detailed info about dynamic update groups\n" | |
14971 | "Specific subgroup to display info for\n" | |
14972 | "Advertisement queue\n" | |
14973 | "Announced routes\n" | |
14974 | "Packet queue\n") | |
3f9c7369 | 14975 | { |
dc64bdec QY |
14976 | uint64_t subgrp_id = 0; |
14977 | afi_t afiz; | |
14978 | safi_t safiz; | |
14979 | if (sgid) | |
14980 | subgrp_id = strtoull(sgid, NULL, 10); | |
14981 | ||
14982 | if (!ip && !afi) | |
14983 | afiz = AFI_IP6; | |
14984 | if (!ip && afi) | |
14985 | afiz = bgp_vty_afi_from_str(afi); | |
14986 | if (ip && !afi) | |
14987 | afiz = AFI_IP; | |
14988 | if (ip && afi) { | |
14989 | afiz = bgp_vty_afi_from_str(afi); | |
14990 | if (afiz != AFI_IP) | |
14991 | vty_out(vty, | |
14992 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
14993 | return CMD_WARNING; | |
14994 | } | |
d62a17ae | 14995 | |
dc64bdec | 14996 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 14997 | |
dc64bdec | 14998 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 14999 | return CMD_SUCCESS; |
15000 | } | |
15001 | ||
6f4eacf3 DA |
15002 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15003 | json_object *json) | |
d62a17ae | 15004 | { |
15005 | struct listnode *node, *nnode; | |
15006 | struct prefix *range; | |
15007 | struct peer *conf; | |
15008 | struct peer *peer; | |
d62a17ae | 15009 | afi_t afi; |
15010 | safi_t safi; | |
15011 | const char *peer_status; | |
d62a17ae | 15012 | int lr_count; |
15013 | int dynamic; | |
6f4eacf3 DA |
15014 | bool af_cfgd; |
15015 | json_object *json_peer_group = NULL; | |
15016 | json_object *json_peer_group_afc = NULL; | |
15017 | json_object *json_peer_group_members = NULL; | |
15018 | json_object *json_peer_group_dynamic = NULL; | |
15019 | json_object *json_peer_group_dynamic_af = NULL; | |
15020 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15021 | |
15022 | conf = group->conf; | |
15023 | ||
6f4eacf3 DA |
15024 | if (json) { |
15025 | json_peer_group = json_object_new_object(); | |
15026 | json_peer_group_afc = json_object_new_array(); | |
15027 | } | |
15028 | ||
d62a17ae | 15029 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15030 | if (json) |
15031 | json_object_int_add(json_peer_group, "remoteAs", | |
15032 | conf->as); | |
15033 | else | |
15034 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15035 | group->name, conf->as); | |
d62a17ae | 15036 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15037 | if (json) |
15038 | json_object_int_add(json_peer_group, "remoteAs", | |
15039 | group->bgp->as); | |
15040 | else | |
15041 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15042 | group->name, group->bgp->as); | |
d62a17ae | 15043 | } else { |
6f4eacf3 DA |
15044 | if (!json) |
15045 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15046 | } |
f14e6fdb | 15047 | |
6f4eacf3 DA |
15048 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15049 | if (json) | |
15050 | json_object_string_add(json_peer_group, "type", | |
15051 | "internal"); | |
15052 | else | |
15053 | vty_out(vty, " Peer-group type is internal\n"); | |
15054 | } else { | |
15055 | if (json) | |
15056 | json_object_string_add(json_peer_group, "type", | |
15057 | "external"); | |
15058 | else | |
15059 | vty_out(vty, " Peer-group type is external\n"); | |
15060 | } | |
d62a17ae | 15061 | |
15062 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15063 | if (!json) |
15064 | vty_out(vty, " Configured address-families:"); | |
15065 | ||
05c7a1cc QY |
15066 | FOREACH_AFI_SAFI (afi, safi) { |
15067 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15068 | af_cfgd = true; |
15069 | if (json) | |
15070 | json_object_array_add( | |
15071 | json_peer_group_afc, | |
15072 | json_object_new_string(get_afi_safi_str( | |
15073 | afi, safi, false))); | |
15074 | else | |
15075 | vty_out(vty, " %s;", | |
15076 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15077 | } |
05c7a1cc | 15078 | } |
6f4eacf3 DA |
15079 | |
15080 | if (json) { | |
15081 | json_object_object_add(json_peer_group, | |
15082 | "addressFamiliesConfigured", | |
15083 | json_peer_group_afc); | |
15084 | } else { | |
15085 | if (!af_cfgd) | |
15086 | vty_out(vty, " none\n"); | |
15087 | else | |
15088 | vty_out(vty, "\n"); | |
15089 | } | |
d62a17ae | 15090 | |
15091 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15092 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15093 | lr_count = listcount(group->listen_range[afi]); |
15094 | if (lr_count) { | |
6f4eacf3 DA |
15095 | if (json) { |
15096 | if (!json_peer_group_dynamic) | |
15097 | json_peer_group_dynamic = | |
15098 | json_object_new_object(); | |
15099 | ||
15100 | json_peer_group_dynamic_af = | |
15101 | json_object_new_object(); | |
15102 | json_peer_group_ranges = | |
15103 | json_object_new_array(); | |
15104 | json_object_int_add(json_peer_group_dynamic_af, | |
15105 | "count", lr_count); | |
15106 | } else { | |
15107 | vty_out(vty, " %d %s listen range(s)\n", | |
15108 | lr_count, afi2str(afi)); | |
15109 | } | |
d62a17ae | 15110 | |
15111 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15112 | nnode, range)) { |
15113 | if (json) { | |
15114 | char buf[BUFSIZ]; | |
15115 | ||
15116 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15117 | range); | |
15118 | ||
15119 | json_object_array_add( | |
15120 | json_peer_group_ranges, | |
15121 | json_object_new_string(buf)); | |
15122 | } else { | |
15123 | vty_out(vty, " %pFX\n", range); | |
15124 | } | |
15125 | } | |
15126 | ||
15127 | if (json) { | |
15128 | json_object_object_add( | |
15129 | json_peer_group_dynamic_af, "ranges", | |
15130 | json_peer_group_ranges); | |
15131 | ||
15132 | json_object_object_add( | |
15133 | json_peer_group_dynamic, afi2str(afi), | |
15134 | json_peer_group_dynamic_af); | |
15135 | } | |
d62a17ae | 15136 | } |
15137 | } | |
f14e6fdb | 15138 | |
6f4eacf3 DA |
15139 | if (json_peer_group_dynamic) |
15140 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15141 | json_peer_group_dynamic); | |
15142 | ||
d62a17ae | 15143 | /* Display group members and their status */ |
15144 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15145 | if (json) |
15146 | json_peer_group_members = json_object_new_object(); | |
15147 | else | |
15148 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15149 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15150 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15151 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15152 | peer_status = "Idle (Admin)"; |
15153 | else if (CHECK_FLAG(peer->sflags, | |
15154 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15155 | peer_status = "Idle (PfxCt)"; | |
15156 | else | |
15157 | peer_status = lookup_msg(bgp_status_msg, | |
15158 | peer->status, NULL); | |
15159 | ||
15160 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15161 | |
15162 | if (json) { | |
15163 | json_object *json_peer_group_member = | |
15164 | json_object_new_object(); | |
15165 | ||
15166 | json_object_string_add(json_peer_group_member, | |
15167 | "status", peer_status); | |
15168 | ||
15169 | if (dynamic) | |
15170 | json_object_boolean_true_add( | |
15171 | json_peer_group_member, | |
15172 | "dynamic"); | |
15173 | ||
15174 | json_object_object_add(json_peer_group_members, | |
15175 | peer->host, | |
15176 | json_peer_group_member); | |
15177 | } else { | |
15178 | vty_out(vty, " %s %s %s \n", peer->host, | |
15179 | dynamic ? "(dynamic)" : "", | |
15180 | peer_status); | |
15181 | } | |
d62a17ae | 15182 | } |
6f4eacf3 DA |
15183 | if (json) |
15184 | json_object_object_add(json_peer_group, "members", | |
15185 | json_peer_group_members); | |
d62a17ae | 15186 | } |
f14e6fdb | 15187 | |
6f4eacf3 DA |
15188 | if (json) |
15189 | json_object_object_add(json, group->name, json_peer_group); | |
15190 | ||
d62a17ae | 15191 | return CMD_SUCCESS; |
15192 | } | |
15193 | ||
ff9959b0 | 15194 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15195 | const char *group_name, bool uj) |
d62a17ae | 15196 | { |
ff9959b0 | 15197 | struct bgp *bgp; |
d62a17ae | 15198 | struct listnode *node, *nnode; |
15199 | struct peer_group *group; | |
ff9959b0 | 15200 | bool found = false; |
6f4eacf3 DA |
15201 | json_object *json = NULL; |
15202 | ||
15203 | if (uj) | |
15204 | json = json_object_new_object(); | |
ff9959b0 QY |
15205 | |
15206 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15207 | ||
15208 | if (!bgp) { | |
6f4eacf3 DA |
15209 | if (uj) { |
15210 | vty_out(vty, "%s\n", | |
15211 | json_object_to_json_string_ext( | |
15212 | json, JSON_C_TO_STRING_PRETTY)); | |
15213 | json_object_free(json); | |
15214 | } else { | |
15215 | vty_out(vty, "%% BGP instance not found\n"); | |
15216 | } | |
15217 | ||
ff9959b0 QY |
15218 | return CMD_WARNING; |
15219 | } | |
d62a17ae | 15220 | |
15221 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15222 | if (group_name) { |
15223 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15224 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15225 | found = true; |
15226 | break; | |
d62a17ae | 15227 | } |
ff9959b0 | 15228 | } else { |
6f4eacf3 | 15229 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15230 | } |
f14e6fdb | 15231 | } |
f14e6fdb | 15232 | |
6f4eacf3 | 15233 | if (group_name && !found && !uj) |
d62a17ae | 15234 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15235 | |
6f4eacf3 DA |
15236 | if (uj) { |
15237 | vty_out(vty, "%s\n", | |
15238 | json_object_to_json_string_ext( | |
15239 | json, JSON_C_TO_STRING_PRETTY)); | |
15240 | json_object_free(json); | |
15241 | } | |
15242 | ||
d62a17ae | 15243 | return CMD_SUCCESS; |
f14e6fdb DS |
15244 | } |
15245 | ||
6f4eacf3 DA |
15246 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15247 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15248 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15249 | "Detailed information on BGP peer groups\n" | |
15250 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15251 | { |
d62a17ae | 15252 | char *vrf, *pg; |
d62a17ae | 15253 | int idx = 0; |
6f4eacf3 | 15254 | bool uj = use_json(argc, argv); |
f14e6fdb | 15255 | |
a4d82a8a PZ |
15256 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15257 | : NULL; | |
d62a17ae | 15258 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15259 | |
6f4eacf3 | 15260 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15261 | } |
3f9c7369 | 15262 | |
d6e3c605 | 15263 | |
718e3744 | 15264 | /* Redistribute VTY commands. */ |
15265 | ||
585f1adc IR |
15266 | DEFUN (bgp_redistribute_ipv4, |
15267 | bgp_redistribute_ipv4_cmd, | |
15268 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15269 | "Redistribute information from another routing protocol\n" | |
15270 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15271 | { |
585f1adc | 15272 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15273 | int idx_protocol = 1; |
585f1adc | 15274 | int type; |
37a87b8f | 15275 | |
585f1adc IR |
15276 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15277 | if (type < 0) { | |
15278 | vty_out(vty, "%% Invalid route type\n"); | |
15279 | return CMD_WARNING_CONFIG_FAILED; | |
15280 | } | |
7f323236 | 15281 | |
585f1adc IR |
15282 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15283 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15284 | } |
15285 | ||
d62a17ae | 15286 | ALIAS_HIDDEN( |
15287 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15288 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15289 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15290 | |
585f1adc IR |
15291 | DEFUN (bgp_redistribute_ipv4_rmap, |
15292 | bgp_redistribute_ipv4_rmap_cmd, | |
15293 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15294 | "Redistribute information from another routing protocol\n" | |
15295 | FRR_IP_REDIST_HELP_STR_BGPD | |
15296 | "Route map reference\n" | |
15297 | "Pointer to route-map entries\n") | |
718e3744 | 15298 | { |
585f1adc | 15299 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15300 | int idx_protocol = 1; |
15301 | int idx_word = 3; | |
585f1adc IR |
15302 | int type; |
15303 | struct bgp_redist *red; | |
15304 | bool changed; | |
15305 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15306 | vty, argv[idx_word]->arg); | |
15307 | ||
15308 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15309 | if (type < 0) { | |
15310 | vty_out(vty, "%% Invalid route type\n"); | |
15311 | return CMD_WARNING_CONFIG_FAILED; | |
15312 | } | |
37a87b8f | 15313 | |
585f1adc IR |
15314 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15315 | changed = | |
15316 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15317 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 15318 | } |
15319 | ||
d62a17ae | 15320 | ALIAS_HIDDEN( |
15321 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15322 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15323 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15324 | "Route map reference\n" | |
15325 | "Pointer to route-map entries\n") | |
596c17ba | 15326 | |
585f1adc IR |
15327 | DEFUN (bgp_redistribute_ipv4_metric, |
15328 | bgp_redistribute_ipv4_metric_cmd, | |
15329 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15330 | "Redistribute information from another routing protocol\n" | |
15331 | FRR_IP_REDIST_HELP_STR_BGPD | |
15332 | "Metric for redistributed routes\n" | |
15333 | "Default metric\n") | |
718e3744 | 15334 | { |
585f1adc | 15335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15336 | int idx_protocol = 1; |
15337 | int idx_number = 3; | |
585f1adc IR |
15338 | int type; |
15339 | uint32_t metric; | |
15340 | struct bgp_redist *red; | |
15341 | bool changed; | |
15342 | ||
15343 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15344 | if (type < 0) { | |
15345 | vty_out(vty, "%% Invalid route type\n"); | |
15346 | return CMD_WARNING_CONFIG_FAILED; | |
15347 | } | |
15348 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15349 | |
585f1adc IR |
15350 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15351 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15352 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15353 | } |
15354 | ||
15355 | ALIAS_HIDDEN( | |
15356 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15357 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15358 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15359 | "Metric for redistributed routes\n" | |
15360 | "Default metric\n") | |
596c17ba | 15361 | |
585f1adc IR |
15362 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
15363 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15364 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15365 | "Redistribute information from another routing protocol\n" | |
15366 | FRR_IP_REDIST_HELP_STR_BGPD | |
15367 | "Route map reference\n" | |
15368 | "Pointer to route-map entries\n" | |
15369 | "Metric for redistributed routes\n" | |
15370 | "Default metric\n") | |
718e3744 | 15371 | { |
585f1adc | 15372 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15373 | int idx_protocol = 1; |
15374 | int idx_word = 3; | |
15375 | int idx_number = 5; | |
585f1adc IR |
15376 | int type; |
15377 | uint32_t metric; | |
15378 | struct bgp_redist *red; | |
15379 | bool changed; | |
15380 | struct route_map *route_map = | |
15381 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15382 | ||
15383 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15384 | if (type < 0) { | |
15385 | vty_out(vty, "%% Invalid route type\n"); | |
15386 | return CMD_WARNING_CONFIG_FAILED; | |
15387 | } | |
15388 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15389 | |
585f1adc IR |
15390 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15391 | changed = | |
15392 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15393 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15394 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15395 | } |
15396 | ||
15397 | ALIAS_HIDDEN( | |
15398 | bgp_redistribute_ipv4_rmap_metric, | |
15399 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15400 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15401 | " route-map WORD metric (0-4294967295)", | |
15402 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15403 | "Route map reference\n" | |
15404 | "Pointer to route-map entries\n" | |
15405 | "Metric for redistributed routes\n" | |
15406 | "Default metric\n") | |
596c17ba | 15407 | |
585f1adc IR |
15408 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
15409 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15410 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15411 | "Redistribute information from another routing protocol\n" | |
15412 | FRR_IP_REDIST_HELP_STR_BGPD | |
15413 | "Metric for redistributed routes\n" | |
15414 | "Default metric\n" | |
15415 | "Route map reference\n" | |
15416 | "Pointer to route-map entries\n") | |
718e3744 | 15417 | { |
585f1adc | 15418 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15419 | int idx_protocol = 1; |
37a87b8f | 15420 | int idx_number = 3; |
585f1adc IR |
15421 | int idx_word = 5; |
15422 | int type; | |
15423 | uint32_t metric; | |
15424 | struct bgp_redist *red; | |
15425 | bool changed; | |
15426 | struct route_map *route_map = | |
15427 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15428 | ||
15429 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15430 | if (type < 0) { | |
15431 | vty_out(vty, "%% Invalid route type\n"); | |
15432 | return CMD_WARNING_CONFIG_FAILED; | |
15433 | } | |
15434 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15435 | |
585f1adc IR |
15436 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15437 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15438 | changed |= | |
15439 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15440 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15441 | } |
15442 | ||
15443 | ALIAS_HIDDEN( | |
15444 | bgp_redistribute_ipv4_metric_rmap, | |
15445 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15446 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15447 | " metric (0-4294967295) route-map WORD", | |
15448 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15449 | "Metric for redistributed routes\n" | |
15450 | "Default metric\n" | |
15451 | "Route map reference\n" | |
15452 | "Pointer to route-map entries\n") | |
596c17ba | 15453 | |
585f1adc IR |
15454 | DEFUN (bgp_redistribute_ipv4_ospf, |
15455 | bgp_redistribute_ipv4_ospf_cmd, | |
15456 | "redistribute <ospf|table> (1-65535)", | |
15457 | "Redistribute information from another routing protocol\n" | |
15458 | "Open Shortest Path First (OSPFv2)\n" | |
15459 | "Non-main Kernel Routing Table\n" | |
15460 | "Instance ID/Table ID\n") | |
7c8ff89e | 15461 | { |
585f1adc IR |
15462 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15463 | int idx_ospf_table = 1; | |
d62a17ae | 15464 | int idx_number = 2; |
585f1adc IR |
15465 | unsigned short instance; |
15466 | unsigned short protocol; | |
7c8ff89e | 15467 | |
585f1adc | 15468 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 15469 | |
585f1adc IR |
15470 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15471 | protocol = ZEBRA_ROUTE_OSPF; | |
15472 | else | |
15473 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 15474 | |
585f1adc IR |
15475 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15476 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
15477 | } |
15478 | ||
d62a17ae | 15479 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15480 | "redistribute <ospf|table> (1-65535)", | |
15481 | "Redistribute information from another routing protocol\n" | |
15482 | "Open Shortest Path First (OSPFv2)\n" | |
15483 | "Non-main Kernel Routing Table\n" | |
15484 | "Instance ID/Table ID\n") | |
596c17ba | 15485 | |
585f1adc IR |
15486 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
15487 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15488 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15489 | "Redistribute information from another routing protocol\n" | |
15490 | "Open Shortest Path First (OSPFv2)\n" | |
15491 | "Non-main Kernel Routing Table\n" | |
15492 | "Instance ID/Table ID\n" | |
15493 | "Route map reference\n" | |
15494 | "Pointer to route-map entries\n") | |
7c8ff89e | 15495 | { |
585f1adc IR |
15496 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15497 | int idx_ospf_table = 1; | |
d62a17ae | 15498 | int idx_number = 2; |
15499 | int idx_word = 4; | |
585f1adc IR |
15500 | struct bgp_redist *red; |
15501 | unsigned short instance; | |
15502 | int protocol; | |
15503 | bool changed; | |
15504 | struct route_map *route_map = | |
15505 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15506 | ||
15507 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15508 | protocol = ZEBRA_ROUTE_OSPF; | |
15509 | else | |
15510 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15511 | |
585f1adc IR |
15512 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15513 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15514 | changed = | |
15515 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15516 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15517 | } |
15518 | ||
15519 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15520 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15521 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15522 | "Redistribute information from another routing protocol\n" | |
15523 | "Open Shortest Path First (OSPFv2)\n" | |
15524 | "Non-main Kernel Routing Table\n" | |
15525 | "Instance ID/Table ID\n" | |
15526 | "Route map reference\n" | |
15527 | "Pointer to route-map entries\n") | |
596c17ba | 15528 | |
585f1adc IR |
15529 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
15530 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15531 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15532 | "Redistribute information from another routing protocol\n" | |
15533 | "Open Shortest Path First (OSPFv2)\n" | |
15534 | "Non-main Kernel Routing Table\n" | |
15535 | "Instance ID/Table ID\n" | |
15536 | "Metric for redistributed routes\n" | |
15537 | "Default metric\n") | |
7c8ff89e | 15538 | { |
585f1adc IR |
15539 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15540 | int idx_ospf_table = 1; | |
d62a17ae | 15541 | int idx_number = 2; |
15542 | int idx_number_2 = 4; | |
585f1adc IR |
15543 | uint32_t metric; |
15544 | struct bgp_redist *red; | |
15545 | unsigned short instance; | |
15546 | int protocol; | |
15547 | bool changed; | |
15548 | ||
15549 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15550 | protocol = ZEBRA_ROUTE_OSPF; | |
15551 | else | |
15552 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15553 | |
585f1adc IR |
15554 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15555 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15556 | |
585f1adc IR |
15557 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15558 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15559 | metric); | |
15560 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15561 | } |
15562 | ||
15563 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15564 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15565 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15566 | "Redistribute information from another routing protocol\n" | |
15567 | "Open Shortest Path First (OSPFv2)\n" | |
15568 | "Non-main Kernel Routing Table\n" | |
15569 | "Instance ID/Table ID\n" | |
15570 | "Metric for redistributed routes\n" | |
15571 | "Default metric\n") | |
596c17ba | 15572 | |
585f1adc IR |
15573 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
15574 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15575 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15576 | "Redistribute information from another routing protocol\n" | |
15577 | "Open Shortest Path First (OSPFv2)\n" | |
15578 | "Non-main Kernel Routing Table\n" | |
15579 | "Instance ID/Table ID\n" | |
15580 | "Route map reference\n" | |
15581 | "Pointer to route-map entries\n" | |
15582 | "Metric for redistributed routes\n" | |
15583 | "Default metric\n") | |
7c8ff89e | 15584 | { |
585f1adc IR |
15585 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15586 | int idx_ospf_table = 1; | |
d62a17ae | 15587 | int idx_number = 2; |
15588 | int idx_word = 4; | |
15589 | int idx_number_2 = 6; | |
585f1adc IR |
15590 | uint32_t metric; |
15591 | struct bgp_redist *red; | |
15592 | unsigned short instance; | |
15593 | int protocol; | |
15594 | bool changed; | |
15595 | struct route_map *route_map = | |
15596 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15597 | ||
15598 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15599 | protocol = ZEBRA_ROUTE_OSPF; | |
15600 | else | |
15601 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15602 | |
585f1adc IR |
15603 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15604 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15605 | |
585f1adc IR |
15606 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15607 | changed = | |
15608 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15609 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15610 | metric); | |
15611 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15612 | } |
15613 | ||
15614 | ALIAS_HIDDEN( | |
15615 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15616 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15617 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15618 | "Redistribute information from another routing protocol\n" | |
15619 | "Open Shortest Path First (OSPFv2)\n" | |
15620 | "Non-main Kernel Routing Table\n" | |
15621 | "Instance ID/Table ID\n" | |
15622 | "Route map reference\n" | |
15623 | "Pointer to route-map entries\n" | |
15624 | "Metric for redistributed routes\n" | |
15625 | "Default metric\n") | |
596c17ba | 15626 | |
585f1adc IR |
15627 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
15628 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15629 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15630 | "Redistribute information from another routing protocol\n" | |
15631 | "Open Shortest Path First (OSPFv2)\n" | |
15632 | "Non-main Kernel Routing Table\n" | |
15633 | "Instance ID/Table ID\n" | |
15634 | "Metric for redistributed routes\n" | |
15635 | "Default metric\n" | |
15636 | "Route map reference\n" | |
15637 | "Pointer to route-map entries\n") | |
7c8ff89e | 15638 | { |
585f1adc IR |
15639 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15640 | int idx_ospf_table = 1; | |
d62a17ae | 15641 | int idx_number = 2; |
15642 | int idx_number_2 = 4; | |
15643 | int idx_word = 6; | |
585f1adc IR |
15644 | uint32_t metric; |
15645 | struct bgp_redist *red; | |
15646 | unsigned short instance; | |
15647 | int protocol; | |
15648 | bool changed; | |
15649 | struct route_map *route_map = | |
15650 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15651 | ||
15652 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15653 | protocol = ZEBRA_ROUTE_OSPF; | |
15654 | else | |
15655 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15656 | |
585f1adc IR |
15657 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15658 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15659 | |
585f1adc IR |
15660 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15661 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15662 | metric); | |
15663 | changed |= | |
15664 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15665 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15666 | } |
15667 | ||
15668 | ALIAS_HIDDEN( | |
15669 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15670 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15671 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15672 | "Redistribute information from another routing protocol\n" | |
15673 | "Open Shortest Path First (OSPFv2)\n" | |
15674 | "Non-main Kernel Routing Table\n" | |
15675 | "Instance ID/Table ID\n" | |
15676 | "Metric for redistributed routes\n" | |
15677 | "Default metric\n" | |
15678 | "Route map reference\n" | |
15679 | "Pointer to route-map entries\n") | |
596c17ba | 15680 | |
585f1adc IR |
15681 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
15682 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15683 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15684 | NO_STR | |
15685 | "Redistribute information from another routing protocol\n" | |
15686 | "Open Shortest Path First (OSPFv2)\n" | |
15687 | "Non-main Kernel Routing Table\n" | |
15688 | "Instance ID/Table ID\n" | |
15689 | "Metric for redistributed routes\n" | |
15690 | "Default metric\n" | |
15691 | "Route map reference\n" | |
15692 | "Pointer to route-map entries\n") | |
7c8ff89e | 15693 | { |
585f1adc IR |
15694 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15695 | int idx_ospf_table = 2; | |
d62a17ae | 15696 | int idx_number = 3; |
585f1adc IR |
15697 | unsigned short instance; |
15698 | int protocol; | |
37a87b8f | 15699 | |
585f1adc IR |
15700 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15701 | protocol = ZEBRA_ROUTE_OSPF; | |
15702 | else | |
15703 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15704 | |
585f1adc IR |
15705 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15706 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 15707 | } |
15708 | ||
15709 | ALIAS_HIDDEN( | |
15710 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15711 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15712 | NO_STR |
15713 | "Redistribute information from another routing protocol\n" | |
15714 | "Open Shortest Path First (OSPFv2)\n" | |
15715 | "Non-main Kernel Routing Table\n" | |
15716 | "Instance ID/Table ID\n" | |
15717 | "Metric for redistributed routes\n" | |
15718 | "Default metric\n" | |
15719 | "Route map reference\n" | |
15720 | "Pointer to route-map entries\n") | |
596c17ba | 15721 | |
585f1adc IR |
15722 | DEFUN (no_bgp_redistribute_ipv4, |
15723 | no_bgp_redistribute_ipv4_cmd, | |
15724 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15725 | NO_STR | |
15726 | "Redistribute information from another routing protocol\n" | |
15727 | FRR_IP_REDIST_HELP_STR_BGPD | |
15728 | "Metric for redistributed routes\n" | |
15729 | "Default metric\n" | |
15730 | "Route map reference\n" | |
15731 | "Pointer to route-map entries\n") | |
718e3744 | 15732 | { |
585f1adc | 15733 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15734 | int idx_protocol = 2; |
585f1adc | 15735 | int type; |
d62a17ae | 15736 | |
585f1adc IR |
15737 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15738 | if (type < 0) { | |
15739 | vty_out(vty, "%% Invalid route type\n"); | |
15740 | return CMD_WARNING_CONFIG_FAILED; | |
15741 | } | |
15742 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 15743 | } |
15744 | ||
15745 | ALIAS_HIDDEN( | |
15746 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15747 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15748 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15749 | NO_STR |
15750 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15751 | "Metric for redistributed routes\n" | |
15752 | "Default metric\n" | |
15753 | "Route map reference\n" | |
15754 | "Pointer to route-map entries\n") | |
596c17ba | 15755 | |
585f1adc IR |
15756 | DEFUN (bgp_redistribute_ipv6, |
15757 | bgp_redistribute_ipv6_cmd, | |
15758 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15759 | "Redistribute information from another routing protocol\n" | |
15760 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15761 | { |
585f1adc | 15762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15763 | int idx_protocol = 1; |
585f1adc | 15764 | int type; |
718e3744 | 15765 | |
585f1adc IR |
15766 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15767 | if (type < 0) { | |
15768 | vty_out(vty, "%% Invalid route type\n"); | |
15769 | return CMD_WARNING_CONFIG_FAILED; | |
15770 | } | |
718e3744 | 15771 | |
585f1adc IR |
15772 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
15773 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 15774 | } |
15775 | ||
585f1adc IR |
15776 | DEFUN (bgp_redistribute_ipv6_rmap, |
15777 | bgp_redistribute_ipv6_rmap_cmd, | |
15778 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15779 | "Redistribute information from another routing protocol\n" | |
15780 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15781 | "Route map reference\n" | |
15782 | "Pointer to route-map entries\n") | |
718e3744 | 15783 | { |
585f1adc | 15784 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15785 | int idx_protocol = 1; |
15786 | int idx_word = 3; | |
585f1adc IR |
15787 | int type; |
15788 | struct bgp_redist *red; | |
15789 | bool changed; | |
15790 | struct route_map *route_map = | |
15791 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15792 | ||
15793 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15794 | if (type < 0) { | |
15795 | vty_out(vty, "%% Invalid route type\n"); | |
15796 | return CMD_WARNING_CONFIG_FAILED; | |
15797 | } | |
37a87b8f | 15798 | |
585f1adc IR |
15799 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15800 | changed = | |
15801 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15802 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15803 | } |
15804 | ||
585f1adc | 15805 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 15806 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15807 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15808 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15809 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15810 | "Metric for redistributed routes\n" |
15811 | "Default metric\n") | |
15812 | { | |
585f1adc | 15813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15814 | int idx_protocol = 1; |
15815 | int idx_number = 3; | |
585f1adc IR |
15816 | int type; |
15817 | uint32_t metric; | |
15818 | struct bgp_redist *red; | |
15819 | bool changed; | |
15820 | ||
15821 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15822 | if (type < 0) { | |
15823 | vty_out(vty, "%% Invalid route type\n"); | |
15824 | return CMD_WARNING_CONFIG_FAILED; | |
15825 | } | |
15826 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15827 | |
585f1adc IR |
15828 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15829 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
15830 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15831 | } |
15832 | ||
585f1adc IR |
15833 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
15834 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15835 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15836 | "Redistribute information from another routing protocol\n" | |
15837 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15838 | "Route map reference\n" | |
15839 | "Pointer to route-map entries\n" | |
15840 | "Metric for redistributed routes\n" | |
15841 | "Default metric\n") | |
718e3744 | 15842 | { |
585f1adc | 15843 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15844 | int idx_protocol = 1; |
15845 | int idx_word = 3; | |
15846 | int idx_number = 5; | |
585f1adc IR |
15847 | int type; |
15848 | uint32_t metric; | |
15849 | struct bgp_redist *red; | |
15850 | bool changed; | |
15851 | struct route_map *route_map = | |
15852 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15853 | ||
15854 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15855 | if (type < 0) { | |
15856 | vty_out(vty, "%% Invalid route type\n"); | |
15857 | return CMD_WARNING_CONFIG_FAILED; | |
15858 | } | |
15859 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15860 | |
585f1adc IR |
15861 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15862 | changed = | |
15863 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15864 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
15865 | metric); | |
15866 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15867 | } |
15868 | ||
585f1adc IR |
15869 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
15870 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15871 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15872 | "Redistribute information from another routing protocol\n" | |
15873 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15874 | "Metric for redistributed routes\n" | |
15875 | "Default metric\n" | |
15876 | "Route map reference\n" | |
15877 | "Pointer to route-map entries\n") | |
718e3744 | 15878 | { |
585f1adc | 15879 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15880 | int idx_protocol = 1; |
37a87b8f | 15881 | int idx_number = 3; |
585f1adc IR |
15882 | int idx_word = 5; |
15883 | int type; | |
15884 | uint32_t metric; | |
15885 | struct bgp_redist *red; | |
15886 | bool changed; | |
15887 | struct route_map *route_map = | |
15888 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15889 | ||
15890 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15891 | if (type < 0) { | |
15892 | vty_out(vty, "%% Invalid route type\n"); | |
15893 | return CMD_WARNING_CONFIG_FAILED; | |
15894 | } | |
15895 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15896 | |
585f1adc IR |
15897 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15898 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
15899 | metric); | |
15900 | changed |= | |
15901 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15902 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15903 | } |
15904 | ||
585f1adc IR |
15905 | DEFUN (no_bgp_redistribute_ipv6, |
15906 | no_bgp_redistribute_ipv6_cmd, | |
15907 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15908 | NO_STR | |
15909 | "Redistribute information from another routing protocol\n" | |
15910 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15911 | "Metric for redistributed routes\n" | |
15912 | "Default metric\n" | |
15913 | "Route map reference\n" | |
15914 | "Pointer to route-map entries\n") | |
718e3744 | 15915 | { |
585f1adc | 15916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15917 | int idx_protocol = 2; |
585f1adc | 15918 | int type; |
37a87b8f | 15919 | |
585f1adc IR |
15920 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15921 | if (type < 0) { | |
15922 | vty_out(vty, "%% Invalid route type\n"); | |
15923 | return CMD_WARNING_CONFIG_FAILED; | |
15924 | } | |
718e3744 | 15925 | |
585f1adc | 15926 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 15927 | } |
15928 | ||
4ab46701 AR |
15929 | /* Neighbor update tcp-mss. */ |
15930 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
15931 | const char *tcp_mss_str) | |
15932 | { | |
15933 | struct peer *peer; | |
15934 | uint32_t tcp_mss_val = 0; | |
15935 | ||
15936 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
15937 | if (!peer) | |
15938 | return CMD_WARNING_CONFIG_FAILED; | |
15939 | ||
15940 | if (tcp_mss_str) { | |
15941 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
15942 | peer_tcp_mss_set(peer, tcp_mss_val); | |
15943 | } else { | |
15944 | peer_tcp_mss_unset(peer); | |
15945 | } | |
15946 | ||
15947 | return CMD_SUCCESS; | |
15948 | } | |
15949 | ||
15950 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
15951 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
15952 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
15953 | "TCP max segment size\n" | |
15954 | "TCP MSS value\n") | |
15955 | { | |
15956 | int peer_index = 1; | |
15957 | int mss_index = 3; | |
15958 | ||
15959 | vty_out(vty, | |
15960 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
15961 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
15962 | argv[mss_index]->arg); | |
15963 | } | |
15964 | ||
15965 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
15966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
15967 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
15968 | "TCP max segment size\n" | |
15969 | "TCP MSS value\n") | |
15970 | { | |
15971 | int peer_index = 2; | |
15972 | ||
15973 | vty_out(vty, | |
15974 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
15975 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
15976 | } | |
15977 | ||
dd65f45e DL |
15978 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15979 | afi_t afi, safi_t safi) | |
d62a17ae | 15980 | { |
15981 | int i; | |
15982 | ||
15983 | /* Unicast redistribution only. */ | |
15984 | if (safi != SAFI_UNICAST) | |
2b791107 | 15985 | return; |
d62a17ae | 15986 | |
15987 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15988 | /* Redistribute BGP does not make sense. */ | |
15989 | if (i != ZEBRA_ROUTE_BGP) { | |
15990 | struct list *red_list; | |
15991 | struct listnode *node; | |
15992 | struct bgp_redist *red; | |
15993 | ||
15994 | red_list = bgp->redist[afi][i]; | |
15995 | if (!red_list) | |
15996 | continue; | |
15997 | ||
15998 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15999 | /* "redistribute" configuration. */ |
16000 | vty_out(vty, " redistribute %s", | |
16001 | zebra_route_string(i)); | |
16002 | if (red->instance) | |
16003 | vty_out(vty, " %d", red->instance); | |
16004 | if (red->redist_metric_flag) | |
16005 | vty_out(vty, " metric %u", | |
16006 | red->redist_metric); | |
16007 | if (red->rmap.name) | |
16008 | vty_out(vty, " route-map %s", | |
16009 | red->rmap.name); | |
16010 | vty_out(vty, "\n"); | |
16011 | } | |
16012 | } | |
16013 | } | |
718e3744 | 16014 | } |
6b0655a2 | 16015 | |
dd65f45e DL |
16016 | /* peer-group helpers for config-write */ |
16017 | ||
16018 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16019 | { | |
16020 | if (!peer_group_active(peer)) { | |
16021 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16022 | return !CHECK_FLAG(peer->flags, flag); | |
16023 | else | |
16024 | return !!CHECK_FLAG(peer->flags, flag); | |
16025 | } | |
16026 | ||
16027 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16028 | } | |
16029 | ||
16030 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16031 | uint32_t flag) | |
16032 | { | |
16033 | if (!peer_group_active(peer)) { | |
16034 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16035 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16036 | else | |
16037 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16038 | } | |
16039 | ||
16040 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16041 | } | |
16042 | ||
16043 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16044 | uint8_t type, int direct) | |
16045 | { | |
16046 | struct bgp_filter *filter; | |
16047 | ||
16048 | if (peer_group_active(peer)) | |
16049 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16050 | type); | |
16051 | ||
16052 | filter = &peer->filter[afi][safi]; | |
16053 | switch (type) { | |
16054 | case PEER_FT_DISTRIBUTE_LIST: | |
16055 | return !!(filter->dlist[direct].name); | |
16056 | case PEER_FT_FILTER_LIST: | |
16057 | return !!(filter->aslist[direct].name); | |
16058 | case PEER_FT_PREFIX_LIST: | |
16059 | return !!(filter->plist[direct].name); | |
16060 | case PEER_FT_ROUTE_MAP: | |
16061 | return !!(filter->map[direct].name); | |
16062 | case PEER_FT_UNSUPPRESS_MAP: | |
16063 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16064 | case PEER_FT_ADVERTISE_MAP: |
16065 | return !!(filter->advmap.aname | |
16066 | && ((filter->advmap.condition == direct) | |
16067 | && filter->advmap.cname)); | |
dd65f45e DL |
16068 | default: |
16069 | return false; | |
16070 | } | |
16071 | } | |
16072 | ||
16073 | /* Return true if the addpath type is set for peer and different from | |
16074 | * peer-group. | |
16075 | */ | |
3dc339cd DA |
16076 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16077 | safi_t safi) | |
dd65f45e DL |
16078 | { |
16079 | enum bgp_addpath_strat type, g_type; | |
16080 | ||
16081 | type = peer->addpath_type[afi][safi]; | |
16082 | ||
16083 | if (type != BGP_ADDPATH_NONE) { | |
16084 | if (peer_group_active(peer)) { | |
16085 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16086 | ||
16087 | if (type != g_type) | |
3dc339cd | 16088 | return true; |
dd65f45e | 16089 | else |
3dc339cd | 16090 | return false; |
dd65f45e DL |
16091 | } |
16092 | ||
3dc339cd | 16093 | return true; |
dd65f45e DL |
16094 | } |
16095 | ||
3dc339cd | 16096 | return false; |
dd65f45e DL |
16097 | } |
16098 | ||
b9c7bc5a | 16099 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16100 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16101 | afi_t afi) |
16102 | { | |
b9c7bc5a | 16103 | int indent = 2; |
53970de3 | 16104 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16105 | |
8a066a70 | 16106 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16107 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16108 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16109 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16110 | bgp->vpn_policy[afi] | |
bb4f6190 | 16111 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16112 | else |
16113 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16114 | bgp->vpn_policy[afi] | |
16115 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16116 | } | |
12a844a5 DS |
16117 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16118 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16119 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16120 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16121 | return; | |
16122 | ||
e70e9f8e PZ |
16123 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16124 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16125 | ||
16126 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16127 | ||
16128 | } else { | |
16129 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16130 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16131 | bgp->vpn_policy[afi].tovpn_label); | |
16132 | } | |
ddb5b488 | 16133 | } |
53970de3 RS |
16134 | |
16135 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16136 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16137 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16138 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16139 | } else if (tovpn_sid_index != 0) { | |
16140 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16141 | tovpn_sid_index); | |
16142 | } | |
16143 | ||
ddb5b488 PZ |
16144 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16145 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16146 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16147 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16148 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16149 | sizeof(buf))); | |
16150 | } | |
16151 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16152 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16153 | ||
16154 | char buf[PREFIX_STRLEN]; | |
16155 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16156 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16157 | sizeof(buf))) { | |
16158 | ||
b9c7bc5a PZ |
16159 | vty_out(vty, "%*snexthop vpn export %s\n", |
16160 | indent, "", buf); | |
ddb5b488 PZ |
16161 | } |
16162 | } | |
16163 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16164 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16165 | && ecommunity_cmp( | |
16166 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16167 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16168 | ||
16169 | char *b = ecommunity_ecom2str( | |
16170 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16171 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16172 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16173 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16174 | } else { | |
16175 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16176 | char *b = ecommunity_ecom2str( | |
16177 | bgp->vpn_policy[afi] | |
16178 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16179 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16180 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16181 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16182 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16183 | } | |
16184 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16185 | char *b = ecommunity_ecom2str( | |
16186 | bgp->vpn_policy[afi] | |
16187 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16188 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16189 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16190 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16191 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16192 | } | |
16193 | } | |
bb4f6190 DS |
16194 | |
16195 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16196 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16197 | bgp->vpn_policy[afi] |
16198 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16199 | |
301ad80a PG |
16200 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16201 | char *b = ecommunity_ecom2str( | |
16202 | bgp->vpn_policy[afi] | |
16203 | .import_redirect_rtlist, | |
16204 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16205 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16206 | |
9a659715 PG |
16207 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16208 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16209 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16210 | indent, "", b); |
16211 | else | |
16212 | vty_out(vty, "%*srt redirect import %s\n", | |
16213 | indent, "", b); | |
301ad80a PG |
16214 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16215 | } | |
ddb5b488 PZ |
16216 | } |
16217 | ||
dd65f45e DL |
16218 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16219 | afi_t afi, safi_t safi) | |
16220 | { | |
16221 | struct bgp_filter *filter; | |
16222 | char *addr; | |
16223 | ||
16224 | addr = peer->host; | |
16225 | filter = &peer->filter[afi][safi]; | |
16226 | ||
16227 | /* distribute-list. */ | |
16228 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16229 | FILTER_IN)) | |
16230 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16231 | filter->dlist[FILTER_IN].name); | |
16232 | ||
16233 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16234 | FILTER_OUT)) | |
16235 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16236 | filter->dlist[FILTER_OUT].name); | |
16237 | ||
16238 | /* prefix-list. */ | |
16239 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16240 | FILTER_IN)) | |
16241 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16242 | filter->plist[FILTER_IN].name); | |
16243 | ||
16244 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16245 | FILTER_OUT)) | |
16246 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16247 | filter->plist[FILTER_OUT].name); | |
16248 | ||
16249 | /* route-map. */ | |
16250 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16251 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16252 | filter->map[RMAP_IN].name); | |
16253 | ||
16254 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16255 | RMAP_OUT)) | |
16256 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16257 | filter->map[RMAP_OUT].name); | |
16258 | ||
16259 | /* unsuppress-map */ | |
16260 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16261 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16262 | filter->usmap.name); | |
16263 | ||
7f7940e6 MK |
16264 | /* advertise-map : always applied in OUT direction*/ |
16265 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16266 | CONDITION_NON_EXIST)) | |
16267 | vty_out(vty, | |
16268 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16269 | addr, filter->advmap.aname, filter->advmap.cname); | |
16270 | ||
16271 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16272 | CONDITION_EXIST)) | |
16273 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16274 | addr, filter->advmap.aname, filter->advmap.cname); | |
16275 | ||
dd65f45e DL |
16276 | /* filter-list. */ |
16277 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16278 | FILTER_IN)) | |
16279 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16280 | filter->aslist[FILTER_IN].name); | |
16281 | ||
16282 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16283 | FILTER_OUT)) | |
16284 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16285 | filter->aslist[FILTER_OUT].name); | |
16286 | } | |
16287 | ||
16288 | /* BGP peer configuration display function. */ | |
16289 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16290 | struct peer *peer) | |
16291 | { | |
16292 | struct peer *g_peer = NULL; | |
16293 | char buf[SU_ADDRSTRLEN]; | |
16294 | char *addr; | |
16295 | int if_pg_printed = false; | |
16296 | int if_ras_printed = false; | |
16297 | ||
16298 | /* Skip dynamic neighbors. */ | |
16299 | if (peer_dynamic_neighbor(peer)) | |
16300 | return; | |
16301 | ||
16302 | if (peer->conf_if) | |
16303 | addr = peer->conf_if; | |
16304 | else | |
16305 | addr = peer->host; | |
16306 | ||
16307 | /************************************ | |
16308 | ****** Global to the neighbor ****** | |
16309 | ************************************/ | |
16310 | if (peer->conf_if) { | |
16311 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16312 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16313 | else | |
16314 | vty_out(vty, " neighbor %s interface", addr); | |
16315 | ||
16316 | if (peer_group_active(peer)) { | |
16317 | vty_out(vty, " peer-group %s", peer->group->name); | |
16318 | if_pg_printed = true; | |
16319 | } else if (peer->as_type == AS_SPECIFIED) { | |
16320 | vty_out(vty, " remote-as %u", peer->as); | |
16321 | if_ras_printed = true; | |
16322 | } else if (peer->as_type == AS_INTERNAL) { | |
16323 | vty_out(vty, " remote-as internal"); | |
16324 | if_ras_printed = true; | |
16325 | } else if (peer->as_type == AS_EXTERNAL) { | |
16326 | vty_out(vty, " remote-as external"); | |
16327 | if_ras_printed = true; | |
16328 | } | |
16329 | ||
16330 | vty_out(vty, "\n"); | |
16331 | } | |
16332 | ||
16333 | /* remote-as and peer-group */ | |
16334 | /* peer is a member of a peer-group */ | |
16335 | if (peer_group_active(peer)) { | |
16336 | g_peer = peer->group->conf; | |
16337 | ||
16338 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16339 | if (peer->as_type == AS_SPECIFIED) { | |
16340 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16341 | addr, peer->as); | |
16342 | } else if (peer->as_type == AS_INTERNAL) { | |
16343 | vty_out(vty, | |
16344 | " neighbor %s remote-as internal\n", | |
16345 | addr); | |
16346 | } else if (peer->as_type == AS_EXTERNAL) { | |
16347 | vty_out(vty, | |
16348 | " neighbor %s remote-as external\n", | |
16349 | addr); | |
16350 | } | |
16351 | } | |
16352 | ||
16353 | /* For swpX peers we displayed the peer-group | |
16354 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16355 | if (!if_pg_printed) | |
16356 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16357 | peer->group->name); | |
16358 | } | |
16359 | ||
16360 | /* peer is NOT a member of a peer-group */ | |
16361 | else { | |
16362 | /* peer is a peer-group, declare the peer-group */ | |
16363 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16364 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16365 | } | |
16366 | ||
16367 | if (!if_ras_printed) { | |
16368 | if (peer->as_type == AS_SPECIFIED) { | |
16369 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16370 | addr, peer->as); | |
16371 | } else if (peer->as_type == AS_INTERNAL) { | |
16372 | vty_out(vty, | |
16373 | " neighbor %s remote-as internal\n", | |
16374 | addr); | |
16375 | } else if (peer->as_type == AS_EXTERNAL) { | |
16376 | vty_out(vty, | |
16377 | " neighbor %s remote-as external\n", | |
16378 | addr); | |
16379 | } | |
16380 | } | |
16381 | } | |
16382 | ||
16383 | /* local-as */ | |
16384 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16385 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16386 | peer->change_local_as); | |
16387 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16388 | vty_out(vty, " no-prepend"); | |
16389 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16390 | vty_out(vty, " replace-as"); | |
16391 | vty_out(vty, "\n"); | |
16392 | } | |
16393 | ||
16394 | /* description */ | |
16395 | if (peer->desc) { | |
16396 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16397 | } | |
16398 | ||
16399 | /* shutdown */ | |
16400 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16401 | if (peer->tx_shutdown_message) | |
16402 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16403 | peer->tx_shutdown_message); | |
16404 | else | |
16405 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16406 | } | |
16407 | ||
8336c896 DA |
16408 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16409 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16410 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16411 | ||
dd65f45e | 16412 | /* bfd */ |
21bfce98 RZ |
16413 | if (peer->bfd_config) |
16414 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
16415 | |
16416 | /* password */ | |
16417 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16418 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16419 | peer->password); | |
16420 | ||
16421 | /* neighbor solo */ | |
16422 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16423 | if (!peer_group_active(peer)) { | |
16424 | vty_out(vty, " neighbor %s solo\n", addr); | |
16425 | } | |
16426 | } | |
16427 | ||
16428 | /* BGP port */ | |
16429 | if (peer->port != BGP_PORT_DEFAULT) { | |
16430 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16431 | } | |
16432 | ||
16433 | /* Local interface name */ | |
16434 | if (peer->ifname) { | |
16435 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16436 | } | |
16437 | ||
4ab46701 AR |
16438 | /* TCP max segment size */ |
16439 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16440 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16441 | ||
dd65f45e DL |
16442 | /* passive */ |
16443 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16444 | vty_out(vty, " neighbor %s passive\n", addr); | |
16445 | ||
16446 | /* ebgp-multihop */ | |
16447 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16448 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16449 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16450 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16451 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16452 | peer->ttl); | |
16453 | } | |
16454 | } | |
16455 | ||
16456 | /* ttl-security hops */ | |
e2521429 | 16457 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16458 | if (!peer_group_active(peer) |
16459 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16460 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16461 | addr, peer->gtsm_hops); | |
16462 | } | |
16463 | } | |
16464 | ||
16465 | /* disable-connected-check */ | |
16466 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16467 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16468 | ||
27aa23a4 DA |
16469 | /* link-bw-encoding-ieee */ |
16470 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16471 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16472 | addr); | |
16473 | ||
dd65f45e DL |
16474 | /* enforce-first-as */ |
16475 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16476 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16477 | ||
16478 | /* update-source */ | |
16479 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16480 | if (peer->update_source) | |
16481 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16482 | sockunion2str(peer->update_source, buf, | |
16483 | SU_ADDRSTRLEN)); | |
16484 | else if (peer->update_if) | |
16485 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16486 | peer->update_if); | |
16487 | } | |
16488 | ||
16489 | /* advertisement-interval */ | |
16490 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16491 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16492 | peer->routeadv); | |
16493 | ||
16494 | /* timers */ | |
16495 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16496 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16497 | peer->keepalive, peer->holdtime); | |
16498 | ||
16499 | /* timers connect */ | |
16500 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16501 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16502 | peer->connect); | |
5d5393b9 DL |
16503 | /* need special-case handling for changed default values due to |
16504 | * config profile / version (because there is no "timers bgp connect" | |
16505 | * command, we need to save this per-peer :/) | |
16506 | */ | |
16507 | else if (!peer_group_active(peer) && !peer->connect && | |
16508 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16509 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16510 | peer->bgp->default_connect_retry); | |
dd65f45e | 16511 | |
d43114f3 DS |
16512 | /* timers delayopen */ |
16513 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16514 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16515 | peer->delayopen); | |
16516 | /* Save config even though flag is not set if default values have been | |
16517 | * changed | |
16518 | */ | |
16519 | else if (!peer_group_active(peer) && !peer->delayopen | |
16520 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16521 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16522 | peer->bgp->default_delayopen); | |
16523 | ||
dd65f45e DL |
16524 | /* capability dynamic */ |
16525 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16526 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16527 | ||
16528 | /* capability extended-nexthop */ | |
16529 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16530 | if (!peer->conf_if) { | |
16531 | if (CHECK_FLAG(peer->flags_invert, | |
16532 | PEER_FLAG_CAPABILITY_ENHE)) | |
16533 | vty_out(vty, | |
16534 | " no neighbor %s capability extended-nexthop\n", | |
16535 | addr); | |
16536 | else | |
16537 | vty_out(vty, | |
16538 | " neighbor %s capability extended-nexthop\n", | |
16539 | addr); | |
16540 | } | |
16541 | } | |
16542 | ||
16543 | /* dont-capability-negotiation */ | |
16544 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16545 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16546 | ||
16547 | /* override-capability */ | |
16548 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16549 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16550 | ||
16551 | /* strict-capability-match */ | |
16552 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16553 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16554 | ||
16555 | /* Sender side AS path loop detection. */ | |
16556 | if (peer->as_path_loop_detection) | |
16557 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16558 | addr); | |
cfd47646 | 16559 | |
16560 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16561 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16562 | |
16563 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16564 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16565 | vty_out(vty, |
16566 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16567 | } else if (CHECK_FLAG( |
16568 | peer->peer_gr_new_status_flag, | |
16569 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16570 | vty_out(vty, |
16571 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16572 | } else if ( |
16573 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16574 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16575 | && !(CHECK_FLAG( | |
16576 | peer->peer_gr_new_status_flag, | |
16577 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16578 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16579 | addr); | |
cfd47646 | 16580 | } |
16581 | } | |
dd65f45e DL |
16582 | } |
16583 | ||
16584 | /* BGP peer configuration display function. */ | |
16585 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16586 | struct peer *peer, afi_t afi, safi_t safi) | |
16587 | { | |
16588 | struct peer *g_peer = NULL; | |
16589 | char *addr; | |
16590 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16591 | ||
16592 | /* Skip dynamic neighbors. */ | |
16593 | if (peer_dynamic_neighbor(peer)) | |
16594 | return; | |
16595 | ||
16596 | if (peer->conf_if) | |
16597 | addr = peer->conf_if; | |
16598 | else | |
16599 | addr = peer->host; | |
16600 | ||
16601 | /************************************ | |
16602 | ****** Per AF to the neighbor ****** | |
16603 | ************************************/ | |
16604 | if (peer_group_active(peer)) { | |
16605 | g_peer = peer->group->conf; | |
16606 | ||
16607 | /* If the peer-group is active but peer is not, print a 'no | |
16608 | * activate' */ | |
16609 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16610 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16611 | } | |
16612 | ||
16613 | /* If the peer-group is not active but peer is, print an | |
16614 | 'activate' */ | |
16615 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16616 | vty_out(vty, " neighbor %s activate\n", addr); | |
16617 | } | |
16618 | } else { | |
16619 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
16620 | if (safi == SAFI_ENCAP) |
16621 | vty_out(vty, " neighbor %s activate\n", addr); | |
16622 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
16623 | vty_out(vty, " neighbor %s activate\n", addr); |
16624 | } else { | |
38d11af5 TA |
16625 | if (bgp->default_af[afi][safi]) |
16626 | vty_out(vty, " no neighbor %s activate\n", | |
16627 | addr); | |
dd65f45e DL |
16628 | } |
16629 | } | |
16630 | ||
16631 | /* addpath TX knobs */ | |
16632 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16633 | switch (peer->addpath_type[afi][safi]) { | |
16634 | case BGP_ADDPATH_ALL: | |
16635 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16636 | addr); | |
16637 | break; | |
16638 | case BGP_ADDPATH_BEST_PER_AS: | |
16639 | vty_out(vty, | |
16640 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16641 | addr); | |
16642 | break; | |
16643 | case BGP_ADDPATH_MAX: | |
16644 | case BGP_ADDPATH_NONE: | |
16645 | break; | |
16646 | } | |
16647 | } | |
16648 | ||
7c0e4312 DA |
16649 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
16650 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16651 | ||
dd65f45e DL |
16652 | /* ORF capability. */ |
16653 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16654 | || peergroup_af_flag_check(peer, afi, safi, | |
16655 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16656 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16657 | ||
16658 | if (peergroup_af_flag_check(peer, afi, safi, | |
16659 | PEER_FLAG_ORF_PREFIX_SM) | |
16660 | && peergroup_af_flag_check(peer, afi, safi, | |
16661 | PEER_FLAG_ORF_PREFIX_RM)) | |
16662 | vty_out(vty, " both"); | |
16663 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16664 | PEER_FLAG_ORF_PREFIX_SM)) | |
16665 | vty_out(vty, " send"); | |
16666 | else | |
16667 | vty_out(vty, " receive"); | |
16668 | vty_out(vty, "\n"); | |
16669 | } | |
16670 | ||
dd65f45e DL |
16671 | /* Route reflector client. */ |
16672 | if (peergroup_af_flag_check(peer, afi, safi, | |
16673 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16674 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16675 | } | |
16676 | ||
16677 | /* next-hop-self force */ | |
16678 | if (peergroup_af_flag_check(peer, afi, safi, | |
16679 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16680 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16681 | } | |
16682 | ||
16683 | /* next-hop-self */ | |
16684 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16685 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16686 | } | |
16687 | ||
16688 | /* remove-private-AS */ | |
16689 | if (peergroup_af_flag_check(peer, afi, safi, | |
16690 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16691 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16692 | addr); | |
16693 | } | |
16694 | ||
16695 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16696 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16697 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16698 | addr); | |
16699 | } | |
16700 | ||
16701 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16702 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16703 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16704 | } | |
16705 | ||
16706 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16707 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16708 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16709 | } | |
16710 | ||
16711 | /* as-override */ | |
16712 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16713 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16714 | } | |
16715 | ||
16716 | /* send-community print. */ | |
16717 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16718 | PEER_FLAG_SEND_COMMUNITY); | |
16719 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16720 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16721 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16722 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16723 | ||
16724 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16725 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16726 | } else { | |
16727 | if (flag_scomm) | |
16728 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16729 | if (flag_secomm) | |
16730 | vty_out(vty, | |
16731 | " no neighbor %s send-community extended\n", | |
16732 | addr); | |
16733 | ||
16734 | if (flag_slcomm) | |
16735 | vty_out(vty, " no neighbor %s send-community large\n", | |
16736 | addr); | |
16737 | } | |
16738 | ||
16739 | /* Default information */ | |
16740 | if (peergroup_af_flag_check(peer, afi, safi, | |
16741 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16742 | vty_out(vty, " neighbor %s default-originate", addr); | |
16743 | ||
16744 | if (peer->default_rmap[afi][safi].name) | |
16745 | vty_out(vty, " route-map %s", | |
16746 | peer->default_rmap[afi][safi].name); | |
16747 | ||
16748 | vty_out(vty, "\n"); | |
16749 | } | |
16750 | ||
16751 | /* Soft reconfiguration inbound. */ | |
16752 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16753 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16754 | addr); | |
16755 | } | |
16756 | ||
16757 | /* maximum-prefix. */ | |
16758 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16759 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16760 | peer->pmax[afi][safi]); |
16761 | ||
16762 | if (peer->pmax_threshold[afi][safi] | |
16763 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16764 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16765 | if (peer_af_flag_check(peer, afi, safi, | |
16766 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16767 | vty_out(vty, " warning-only"); | |
16768 | if (peer->pmax_restart[afi][safi]) | |
16769 | vty_out(vty, " restart %u", | |
16770 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16771 | if (peer_af_flag_check(peer, afi, safi, |
16772 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16773 | vty_out(vty, " force"); | |
dd65f45e DL |
16774 | |
16775 | vty_out(vty, "\n"); | |
16776 | } | |
16777 | ||
fde246e8 DA |
16778 | /* maximum-prefix-out */ |
16779 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16780 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16781 | addr, peer->pmax_out[afi][safi]); |
16782 | ||
dd65f45e DL |
16783 | /* Route server client. */ |
16784 | if (peergroup_af_flag_check(peer, afi, safi, | |
16785 | PEER_FLAG_RSERVER_CLIENT)) { | |
16786 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16787 | } | |
16788 | ||
16789 | /* Nexthop-local unchanged. */ | |
16790 | if (peergroup_af_flag_check(peer, afi, safi, | |
16791 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16792 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16793 | } | |
16794 | ||
16795 | /* allowas-in <1-10> */ | |
16796 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16797 | if (peer_af_flag_check(peer, afi, safi, | |
16798 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16799 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16800 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16801 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16802 | } else { | |
16803 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16804 | peer->allowas_in[afi][safi]); | |
16805 | } | |
16806 | } | |
16807 | ||
16808 | /* weight */ | |
16809 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16810 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16811 | peer->weight[afi][safi]); | |
16812 | ||
16813 | /* Filter. */ | |
16814 | bgp_config_write_filter(vty, peer, afi, safi); | |
16815 | ||
16816 | /* atribute-unchanged. */ | |
16817 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16818 | || (safi != SAFI_EVPN | |
16819 | && peer_af_flag_check(peer, afi, safi, | |
16820 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16821 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16822 | ||
16823 | if (!peer_group_active(peer) | |
16824 | || peergroup_af_flag_check(peer, afi, safi, | |
16825 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16826 | || peergroup_af_flag_check(peer, afi, safi, | |
16827 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16828 | || peergroup_af_flag_check(peer, afi, safi, | |
16829 | PEER_FLAG_MED_UNCHANGED)) { | |
16830 | ||
16831 | vty_out(vty, | |
16832 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16833 | addr, | |
16834 | peer_af_flag_check(peer, afi, safi, | |
16835 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16836 | ? " as-path" | |
16837 | : "", | |
16838 | peer_af_flag_check(peer, afi, safi, | |
16839 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16840 | ? " next-hop" | |
16841 | : "", | |
16842 | peer_af_flag_check(peer, afi, safi, | |
16843 | PEER_FLAG_MED_UNCHANGED) | |
16844 | ? " med" | |
16845 | : ""); | |
16846 | } | |
16847 | } | |
16848 | } | |
16849 | ||
16850 | /* Address family based peer configuration display. */ | |
16851 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16852 | safi_t safi) | |
16853 | { | |
16854 | struct peer *peer; | |
16855 | struct peer_group *group; | |
16856 | struct listnode *node, *nnode; | |
16857 | ||
16858 | ||
16859 | vty_frame(vty, " !\n address-family "); | |
16860 | if (afi == AFI_IP) { | |
16861 | if (safi == SAFI_UNICAST) | |
16862 | vty_frame(vty, "ipv4 unicast"); | |
16863 | else if (safi == SAFI_LABELED_UNICAST) | |
16864 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16865 | else if (safi == SAFI_MULTICAST) | |
16866 | vty_frame(vty, "ipv4 multicast"); | |
16867 | else if (safi == SAFI_MPLS_VPN) | |
16868 | vty_frame(vty, "ipv4 vpn"); | |
16869 | else if (safi == SAFI_ENCAP) | |
16870 | vty_frame(vty, "ipv4 encap"); | |
16871 | else if (safi == SAFI_FLOWSPEC) | |
16872 | vty_frame(vty, "ipv4 flowspec"); | |
16873 | } else if (afi == AFI_IP6) { | |
16874 | if (safi == SAFI_UNICAST) | |
16875 | vty_frame(vty, "ipv6 unicast"); | |
16876 | else if (safi == SAFI_LABELED_UNICAST) | |
16877 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16878 | else if (safi == SAFI_MULTICAST) | |
16879 | vty_frame(vty, "ipv6 multicast"); | |
16880 | else if (safi == SAFI_MPLS_VPN) | |
16881 | vty_frame(vty, "ipv6 vpn"); | |
16882 | else if (safi == SAFI_ENCAP) | |
16883 | vty_frame(vty, "ipv6 encap"); | |
16884 | else if (safi == SAFI_FLOWSPEC) | |
16885 | vty_frame(vty, "ipv6 flowspec"); | |
16886 | } else if (afi == AFI_L2VPN) { | |
16887 | if (safi == SAFI_EVPN) | |
16888 | vty_frame(vty, "l2vpn evpn"); | |
16889 | } | |
16890 | vty_frame(vty, "\n"); | |
16891 | ||
16892 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16893 | ||
16894 | bgp_config_write_network(vty, bgp, afi, safi); | |
16895 | ||
16896 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16897 | ||
8a4e7fe6 DA |
16898 | /* BGP flag dampening. */ |
16899 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 16900 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 16901 | |
dd65f45e DL |
16902 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16903 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16904 | ||
16905 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
16906 | /* Do not display doppelganger peers */ |
16907 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16908 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16909 | } | |
16910 | ||
16911 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16912 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16913 | ||
16914 | if (safi == SAFI_EVPN) | |
16915 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16916 | ||
16917 | if (safi == SAFI_FLOWSPEC) | |
16918 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16919 | ||
16920 | if (safi == SAFI_UNICAST) { | |
16921 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16922 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16923 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16924 | ||
16925 | vty_out(vty, " export vpn\n"); | |
16926 | } | |
16927 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16928 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16929 | ||
16930 | vty_out(vty, " import vpn\n"); | |
16931 | } | |
16932 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16933 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16934 | char *name; | |
16935 | ||
16936 | for (ALL_LIST_ELEMENTS_RO( | |
16937 | bgp->vpn_policy[afi].import_vrf, node, | |
16938 | name)) | |
16939 | vty_out(vty, " import vrf %s\n", name); | |
16940 | } | |
16941 | } | |
16942 | ||
16943 | vty_endframe(vty, " exit-address-family\n"); | |
16944 | } | |
16945 | ||
16946 | int bgp_config_write(struct vty *vty) | |
16947 | { | |
16948 | struct bgp *bgp; | |
16949 | struct peer_group *group; | |
16950 | struct peer *peer; | |
16951 | struct listnode *node, *nnode; | |
16952 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
16953 | afi_t afi; |
16954 | safi_t safi; | |
dd65f45e DL |
16955 | |
16956 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16957 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16958 | bm->rmap_update_timer); | |
16959 | ||
d70583f7 D |
16960 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16961 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16962 | if (bm->v_update_delay != bm->v_establish_wait) | |
16963 | vty_out(vty, " %d", bm->v_establish_wait); | |
16964 | vty_out(vty, "\n"); | |
16965 | } | |
16966 | ||
9acb67cb DS |
16967 | if (bm->wait_for_fib) |
16968 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
16969 | ||
05bd726c | 16970 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16971 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16972 | ||
c163f297 DS |
16973 | /* No-RIB (Zebra) option flag configuration */ |
16974 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16975 | vty_out(vty, "bgp no-rib\n"); | |
16976 | ||
ec0acb80 | 16977 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
16978 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
16979 | ||
dd65f45e DL |
16980 | /* BGP configuration. */ |
16981 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
16982 | ||
16983 | /* skip all auto created vrf as they dont have user config */ | |
16984 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
16985 | continue; | |
16986 | ||
16987 | /* Router bgp ASN */ | |
16988 | vty_out(vty, "router bgp %u", bgp->as); | |
16989 | ||
16990 | if (bgp->name) | |
16991 | vty_out(vty, " %s %s", | |
16992 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
16993 | ? "view" : "vrf", bgp->name); | |
16994 | vty_out(vty, "\n"); | |
16995 | ||
16996 | /* BGP fast-external-failover. */ | |
16997 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
16998 | vty_out(vty, " no bgp fast-external-failover\n"); | |
16999 | ||
17000 | /* BGP router ID. */ | |
3a6290bd | 17001 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17002 | vty_out(vty, " bgp router-id %pI4\n", |
17003 | &bgp->router_id_static); | |
dd65f45e | 17004 | |
c208c586 S |
17005 | /* Suppress fib pending */ |
17006 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17007 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17008 | ||
dd65f45e | 17009 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17010 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17011 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17012 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17013 | CHECK_FLAG(bgp->flags, |
17014 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17015 | ? "" |
17016 | : "no "); | |
17017 | ||
17018 | /* BGP configuration. */ | |
892fedb6 | 17019 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17020 | vty_out(vty, " bgp always-compare-med\n"); |
17021 | ||
17022 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17023 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17024 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17025 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17026 | CHECK_FLAG(bgp->flags, | |
17027 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17028 | ? "" | |
17029 | : "no "); | |
dd65f45e DL |
17030 | |
17031 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17032 | if (bgp->reject_as_sets) |
dd65f45e DL |
17033 | vty_out(vty, " bgp reject-as-sets\n"); |
17034 | ||
2adac256 DA |
17035 | /* Suppress duplicate updates if the route actually not changed |
17036 | */ | |
17037 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17038 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17039 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17040 | CHECK_FLAG(bgp->flags, | |
17041 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17042 | ? "" | |
17043 | : "no "); | |
17044 | ||
b16bcbba TA |
17045 | /* BGP default <afi>-<safi> */ |
17046 | FOREACH_AFI_SAFI (afi, safi) { | |
17047 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17048 | if (!bgp->default_af[afi][safi]) | |
17049 | vty_out(vty, " no bgp default %s\n", | |
17050 | get_bgp_default_af_flag(afi, | |
17051 | safi)); | |
17052 | } else if (bgp->default_af[afi][safi]) | |
17053 | vty_out(vty, " bgp default %s\n", | |
17054 | get_bgp_default_af_flag(afi, safi)); | |
17055 | } | |
e84c59af | 17056 | |
dd65f45e DL |
17057 | /* BGP default local-preference. */ |
17058 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17059 | vty_out(vty, " bgp default local-preference %u\n", | |
17060 | bgp->default_local_pref); | |
17061 | ||
17062 | /* BGP default show-hostname */ | |
892fedb6 | 17063 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17064 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17065 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17066 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17067 | ? "" |
17068 | : "no "); | |
17069 | ||
aef999a2 DA |
17070 | /* BGP default show-nexthop-hostname */ |
17071 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17072 | != SAVE_BGP_SHOW_HOSTNAME) | |
17073 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17074 | CHECK_FLAG(bgp->flags, | |
17075 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17076 | ? "" | |
17077 | : "no "); | |
17078 | ||
dd65f45e DL |
17079 | /* BGP default subgroup-pkt-queue-max. */ |
17080 | if (bgp->default_subgroup_pkt_queue_max | |
17081 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17082 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17083 | bgp->default_subgroup_pkt_queue_max); | |
17084 | ||
17085 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17086 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17087 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17088 | ||
17089 | /* BGP cluster ID. */ | |
17090 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17091 | vty_out(vty, " bgp cluster-id %pI4\n", |
17092 | &bgp->cluster_id); | |
dd65f45e DL |
17093 | |
17094 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17095 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17096 | vty_out(vty, |
17097 | " bgp disable-ebgp-connected-route-check\n"); | |
17098 | ||
17099 | /* Confederation identifier*/ | |
17100 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17101 | vty_out(vty, " bgp confederation identifier %u\n", | |
17102 | bgp->confed_id); | |
17103 | ||
17104 | /* Confederation peer */ | |
17105 | if (bgp->confed_peers_cnt > 0) { | |
17106 | int i; | |
17107 | ||
17108 | vty_out(vty, " bgp confederation peers"); | |
17109 | ||
17110 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17111 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17112 | ||
17113 | vty_out(vty, "\n"); | |
17114 | } | |
17115 | ||
17116 | /* BGP deterministic-med. */ | |
892fedb6 | 17117 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17118 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17119 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17120 | CHECK_FLAG(bgp->flags, |
17121 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17122 | ? "" |
17123 | : "no "); | |
17124 | ||
17125 | /* BGP update-delay. */ | |
17126 | bgp_config_write_update_delay(vty, bgp); | |
17127 | ||
17128 | if (bgp->v_maxmed_onstartup | |
17129 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17130 | vty_out(vty, " bgp max-med on-startup %u", | |
17131 | bgp->v_maxmed_onstartup); | |
17132 | if (bgp->maxmed_onstartup_value | |
17133 | != BGP_MAXMED_VALUE_DEFAULT) | |
17134 | vty_out(vty, " %u", | |
17135 | bgp->maxmed_onstartup_value); | |
17136 | vty_out(vty, "\n"); | |
17137 | } | |
17138 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17139 | vty_out(vty, " bgp max-med administrative"); | |
17140 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17141 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17142 | vty_out(vty, "\n"); | |
17143 | } | |
17144 | ||
17145 | /* write quanta */ | |
17146 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17147 | /* read quanta */ | |
17148 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17149 | ||
17150 | /* coalesce time */ | |
17151 | bgp_config_write_coalesce_time(vty, bgp); | |
17152 | ||
05bd726c | 17153 | /* BGP per-instance graceful-shutdown */ |
17154 | /* BGP-wide settings and per-instance settings are mutually | |
17155 | * exclusive. | |
17156 | */ | |
17157 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17158 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17159 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17160 | ||
dd65f45e DL |
17161 | /* BGP graceful-restart. */ |
17162 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17163 | vty_out(vty, | |
17164 | " bgp graceful-restart stalepath-time %u\n", | |
17165 | bgp->stalepath_time); | |
cfd47646 | 17166 | |
dd65f45e DL |
17167 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17168 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17169 | bgp->restart_time); | |
cfd47646 | 17170 | |
17171 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17172 | vty_out(vty, | |
17173 | " bgp graceful-restart select-defer-time %u\n", | |
17174 | bgp->select_defer_time); | |
17175 | ||
17176 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17177 | vty_out(vty, " bgp graceful-restart\n"); |
17178 | ||
cfd47646 | 17179 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17180 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17181 | ||
dd65f45e | 17182 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17183 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17184 | vty_out(vty, |
17185 | " bgp graceful-restart preserve-fw-state\n"); | |
17186 | ||
dc95985f | 17187 | /* Stale timer for RIB */ |
17188 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17189 | vty_out(vty, | |
17190 | " bgp graceful-restart rib-stale-time %u\n", | |
17191 | bgp->rib_stale_time); | |
17192 | ||
dd65f45e | 17193 | /* BGP bestpath method. */ |
892fedb6 | 17194 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17195 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17196 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17197 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17198 | ||
892fedb6 DA |
17199 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17200 | if (CHECK_FLAG(bgp->flags, | |
17201 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17202 | vty_out(vty, |
17203 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17204 | } else { | |
17205 | vty_out(vty, | |
17206 | " bgp bestpath as-path multipath-relax\n"); | |
17207 | } | |
17208 | } | |
17209 | ||
892fedb6 | 17210 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17211 | vty_out(vty, |
17212 | " bgp route-reflector allow-outbound-policy\n"); | |
17213 | } | |
892fedb6 | 17214 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17215 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17216 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17217 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17218 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17219 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17220 | vty_out(vty, " confed"); |
892fedb6 DA |
17221 | if (CHECK_FLAG(bgp->flags, |
17222 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17223 | vty_out(vty, " missing-as-worst"); |
17224 | vty_out(vty, "\n"); | |
17225 | } | |
17226 | ||
ee88563a JM |
17227 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
17228 | vty_out(vty, | |
17229 | " bgp bestpath peer-type multipath-relax\n"); | |
17230 | ||
f7e1c681 | 17231 | /* Link bandwidth handling. */ |
17232 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17233 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17234 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17235 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17236 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17237 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17238 | ||
dd65f45e | 17239 | /* BGP network import check. */ |
892fedb6 | 17240 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17241 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17242 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17243 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17244 | ? "" |
17245 | : "no "); | |
17246 | ||
17247 | /* BGP timers configuration. */ | |
5d5393b9 | 17248 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 17249 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
17250 | vty_out(vty, " timers bgp %u %u\n", |
17251 | bgp->default_keepalive, bgp->default_holdtime); | |
17252 | ||
b042667a TI |
17253 | /* BGP minimum holdtime configuration. */ |
17254 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17255 | && bgp->default_min_holdtime != 0) | |
17256 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17257 | bgp->default_min_holdtime); | |
17258 | ||
389e4f92 QY |
17259 | /* Conditional advertisement timer configuration */ |
17260 | if (bgp->condition_check_period | |
17261 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17262 | vty_out(vty, | |
17263 | " bgp conditional-advertisement timer %u\n", | |
17264 | bgp->condition_check_period); | |
17265 | ||
dd65f45e DL |
17266 | /* peer-group */ |
17267 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17268 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17269 | } | |
17270 | ||
17271 | /* Normal neighbor configuration. */ | |
17272 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17273 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17274 | bgp_config_write_peer_global(vty, bgp, peer); | |
17275 | } | |
17276 | ||
17277 | /* listen range and limit for dynamic BGP neighbors */ | |
17278 | bgp_config_write_listen(vty, bgp); | |
17279 | ||
17280 | /* | |
17281 | * BGP default autoshutdown neighbors | |
17282 | * | |
17283 | * This must be placed after any peer and peer-group | |
17284 | * configuration, to avoid setting all peers to shutdown after | |
17285 | * a daemon restart, which is undesired behavior. (see #2286) | |
17286 | */ | |
17287 | if (bgp->autoshutdown) | |
17288 | vty_out(vty, " bgp default shutdown\n"); | |
17289 | ||
9cf59432 DS |
17290 | /* BGP instance administrative shutdown */ |
17291 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17292 | vty_out(vty, " bgp shutdown\n"); | |
17293 | ||
f852eb98 PG |
17294 | if (bgp->fast_convergence) |
17295 | vty_out(vty, " bgp fast-convergence\n"); | |
17296 | ||
a0281b2e HS |
17297 | if (bgp->srv6_enabled) { |
17298 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 17299 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
17300 | vty_out(vty, " locator %s\n", |
17301 | bgp->srv6_locator_name); | |
ff7c3ee1 | 17302 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
17303 | } |
17304 | ||
17305 | ||
dd65f45e DL |
17306 | /* IPv4 unicast configuration. */ |
17307 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17308 | ||
17309 | /* IPv4 multicast configuration. */ | |
17310 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17311 | ||
17312 | /* IPv4 labeled-unicast configuration. */ | |
17313 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17314 | ||
17315 | /* IPv4 VPN configuration. */ | |
17316 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17317 | ||
17318 | /* ENCAPv4 configuration. */ | |
17319 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17320 | ||
17321 | /* FLOWSPEC v4 configuration. */ | |
17322 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17323 | ||
17324 | /* IPv6 unicast configuration. */ | |
17325 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17326 | ||
17327 | /* IPv6 multicast configuration. */ | |
17328 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17329 | ||
17330 | /* IPv6 labeled-unicast configuration. */ | |
17331 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17332 | SAFI_LABELED_UNICAST); | |
17333 | ||
17334 | /* IPv6 VPN configuration. */ | |
17335 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17336 | ||
17337 | /* ENCAPv6 configuration. */ | |
17338 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17339 | ||
17340 | /* FLOWSPEC v6 configuration. */ | |
17341 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17342 | ||
17343 | /* EVPN configuration. */ | |
17344 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17345 | ||
17346 | hook_call(bgp_inst_config_write, bgp, vty); | |
17347 | ||
49e5a4a0 | 17348 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17349 | bgp_rfapi_cfg_write(vty, bgp); |
17350 | #endif | |
17351 | ||
07679ad9 | 17352 | vty_out(vty, "exit\n"); |
dd65f45e DL |
17353 | vty_out(vty, "!\n"); |
17354 | } | |
17355 | return 0; | |
17356 | } | |
17357 | ||
ddb5b488 | 17358 | |
718e3744 | 17359 | /* BGP node structure. */ |
d62a17ae | 17360 | static struct cmd_node bgp_node = { |
f4b8291f | 17361 | .name = "bgp", |
62b346ee | 17362 | .node = BGP_NODE, |
24389580 | 17363 | .parent_node = CONFIG_NODE, |
62b346ee | 17364 | .prompt = "%s(config-router)# ", |
612c2c15 | 17365 | .config_write = bgp_config_write, |
718e3744 | 17366 | }; |
17367 | ||
d62a17ae | 17368 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17369 | .name = "bgp ipv4 unicast", |
62b346ee | 17370 | .node = BGP_IPV4_NODE, |
24389580 | 17371 | .parent_node = BGP_NODE, |
62b346ee | 17372 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17373 | }; |
17374 | ||
d62a17ae | 17375 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17376 | .name = "bgp ipv4 multicast", |
62b346ee | 17377 | .node = BGP_IPV4M_NODE, |
24389580 | 17378 | .parent_node = BGP_NODE, |
62b346ee | 17379 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17380 | }; |
17381 | ||
d62a17ae | 17382 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17383 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17384 | .node = BGP_IPV4L_NODE, |
24389580 | 17385 | .parent_node = BGP_NODE, |
62b346ee | 17386 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17387 | }; |
17388 | ||
d62a17ae | 17389 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 17390 | .name = "bgp ipv6 unicast", |
62b346ee | 17391 | .node = BGP_IPV6_NODE, |
24389580 | 17392 | .parent_node = BGP_NODE, |
62b346ee | 17393 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17394 | }; |
17395 | ||
d62a17ae | 17396 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17397 | .name = "bgp ipv6 multicast", |
62b346ee | 17398 | .node = BGP_IPV6M_NODE, |
24389580 | 17399 | .parent_node = BGP_NODE, |
62b346ee | 17400 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17401 | }; |
17402 | ||
d62a17ae | 17403 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17404 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17405 | .node = BGP_IPV6L_NODE, |
24389580 | 17406 | .parent_node = BGP_NODE, |
62b346ee | 17407 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17408 | }; |
17409 | ||
62b346ee | 17410 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17411 | .name = "bgp vpnv4", |
62b346ee | 17412 | .node = BGP_VPNV4_NODE, |
24389580 | 17413 | .parent_node = BGP_NODE, |
62b346ee | 17414 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17415 | }; |
6b0655a2 | 17416 | |
62b346ee | 17417 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17418 | .name = "bgp vpnv6", |
62b346ee | 17419 | .node = BGP_VPNV6_NODE, |
24389580 | 17420 | .parent_node = BGP_NODE, |
62b346ee | 17421 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17422 | }; |
8ecd3266 | 17423 | |
62b346ee | 17424 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17425 | .name = "bgp evpn", |
62b346ee | 17426 | .node = BGP_EVPN_NODE, |
24389580 | 17427 | .parent_node = BGP_NODE, |
62b346ee | 17428 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17429 | }; |
4e0b7b6d | 17430 | |
62b346ee | 17431 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17432 | .name = "bgp evpn vni", |
62b346ee | 17433 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17434 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17435 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17436 | }; |
90e60aa7 | 17437 | |
62b346ee | 17438 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17439 | .name = "bgp ipv4 flowspec", |
62b346ee | 17440 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17441 | .parent_node = BGP_NODE, |
62b346ee | 17442 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17443 | }; |
7c40bf39 | 17444 | |
62b346ee | 17445 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17446 | .name = "bgp ipv6 flowspec", |
62b346ee | 17447 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17448 | .parent_node = BGP_NODE, |
62b346ee | 17449 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17450 | }; |
7c40bf39 | 17451 | |
bfaab44d HS |
17452 | static struct cmd_node bgp_srv6_node = { |
17453 | .name = "bgp srv6", | |
17454 | .node = BGP_SRV6_NODE, | |
17455 | .parent_node = BGP_NODE, | |
17456 | .prompt = "%s(config-router-srv6)# ", | |
17457 | }; | |
17458 | ||
d62a17ae | 17459 | static void community_list_vty(void); |
1f8ae70b | 17460 | |
d62a17ae | 17461 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17462 | { |
d62a17ae | 17463 | struct bgp *bgp; |
17464 | struct peer *peer; | |
d62a17ae | 17465 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17466 | |
d62a17ae | 17467 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17468 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17469 | /* only provide suggestions on the appropriate input | |
17470 | * token type, | |
17471 | * they'll otherwise show up multiple times */ | |
17472 | enum cmd_token_type match_type; | |
17473 | char *name = peer->host; | |
d48ed3e0 | 17474 | |
d62a17ae | 17475 | if (peer->conf_if) { |
17476 | match_type = VARIABLE_TKN; | |
17477 | name = peer->conf_if; | |
17478 | } else if (strchr(peer->host, ':')) | |
17479 | match_type = IPV6_TKN; | |
17480 | else | |
17481 | match_type = IPV4_TKN; | |
d48ed3e0 | 17482 | |
d62a17ae | 17483 | if (token->type != match_type) |
17484 | continue; | |
d48ed3e0 | 17485 | |
d62a17ae | 17486 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17487 | } | |
d62a17ae | 17488 | } |
b8a815e5 DL |
17489 | } |
17490 | ||
17491 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17492 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17493 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17494 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17495 | {.completions = NULL}}; |
17496 | ||
47a306a0 DS |
17497 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17498 | { | |
17499 | struct bgp *bgp; | |
17500 | struct peer_group *group; | |
17501 | struct listnode *lnbgp, *lnpeer; | |
17502 | ||
17503 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17504 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17505 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17506 | group->name)); | |
17507 | } | |
17508 | } | |
17509 | ||
17510 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17511 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17512 | {.completions = NULL} }; | |
17513 | ||
d62a17ae | 17514 | void bgp_vty_init(void) |
17515 | { | |
17516 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17517 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17518 | |
17519 | /* Install bgp top node. */ | |
612c2c15 DL |
17520 | install_node(&bgp_node); |
17521 | install_node(&bgp_ipv4_unicast_node); | |
17522 | install_node(&bgp_ipv4_multicast_node); | |
17523 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17524 | install_node(&bgp_ipv6_unicast_node); | |
17525 | install_node(&bgp_ipv6_multicast_node); | |
17526 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17527 | install_node(&bgp_vpnv4_node); | |
17528 | install_node(&bgp_vpnv6_node); | |
17529 | install_node(&bgp_evpn_node); | |
17530 | install_node(&bgp_evpn_vni_node); | |
17531 | install_node(&bgp_flowspecv4_node); | |
17532 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 17533 | install_node(&bgp_srv6_node); |
d62a17ae | 17534 | |
17535 | /* Install default VTY commands to new nodes. */ | |
17536 | install_default(BGP_NODE); | |
17537 | install_default(BGP_IPV4_NODE); | |
17538 | install_default(BGP_IPV4M_NODE); | |
17539 | install_default(BGP_IPV4L_NODE); | |
17540 | install_default(BGP_IPV6_NODE); | |
17541 | install_default(BGP_IPV6M_NODE); | |
17542 | install_default(BGP_IPV6L_NODE); | |
17543 | install_default(BGP_VPNV4_NODE); | |
17544 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17545 | install_default(BGP_FLOWSPECV4_NODE); |
17546 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17547 | install_default(BGP_EVPN_NODE); |
17548 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 17549 | install_default(BGP_SRV6_NODE); |
d62a17ae | 17550 | |
8029b216 AK |
17551 | /* "bgp local-mac" hidden commands. */ |
17552 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17553 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17554 | ||
9acb67cb DS |
17555 | /* "bgp suppress-fib-pending" global */ |
17556 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17557 | ||
d62a17ae | 17558 | /* bgp route-map delay-timer commands. */ |
17559 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17560 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17561 | ||
f852eb98 PG |
17562 | /* bgp fast-convergence command */ |
17563 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17564 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17565 | ||
d70583f7 D |
17566 | /* global bgp update-delay command */ |
17567 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17568 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17569 | ||
05bd726c | 17570 | /* global bgp graceful-shutdown command */ |
17571 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17572 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17573 | ||
d62a17ae | 17574 | /* Dummy commands (Currently not supported) */ |
17575 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17576 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17577 | ||
17578 | /* "router bgp" commands. */ | |
17579 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17580 | ||
17581 | /* "no router bgp" commands. */ | |
17582 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17583 | ||
17584 | /* "bgp router-id" commands. */ | |
17585 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17586 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17587 | ||
c208c586 S |
17588 | /* "bgp suppress-fib-pending" command */ |
17589 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17590 | ||
d62a17ae | 17591 | /* "bgp cluster-id" commands. */ |
17592 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17593 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17594 | ||
c163f297 DS |
17595 | /* "bgp no-rib" commands. */ |
17596 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17597 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17598 | ||
e46723a5 DS |
17599 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17600 | ||
d62a17ae | 17601 | /* "bgp confederation" commands. */ |
17602 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17603 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17604 | ||
17605 | /* "bgp confederation peers" commands. */ | |
17606 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17607 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17608 | ||
17609 | /* bgp max-med command */ | |
17610 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17611 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17612 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17613 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17614 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17615 | ||
17616 | /* bgp disable-ebgp-connected-nh-check */ | |
17617 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17618 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17619 | ||
17620 | /* bgp update-delay command */ | |
17621 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17622 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17623 | |
17624 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17625 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17626 | |
17627 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17628 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17629 | ||
17630 | /* "maximum-paths" commands. */ | |
17631 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17632 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17633 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17634 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17635 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17636 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17637 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17638 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17639 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17640 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17641 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17642 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17643 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17644 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17645 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17646 | ||
39edabac PG |
17647 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17648 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17649 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17650 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17651 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17652 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17653 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17654 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17655 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17656 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17657 | ||
17658 | /* "timers bgp" commands. */ | |
17659 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17660 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17661 | ||
b042667a TI |
17662 | /* "minimum-holdtime" commands. */ |
17663 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17664 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17665 | ||
d62a17ae | 17666 | /* route-map delay-timer commands - per instance for backwards compat. |
17667 | */ | |
17668 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17669 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17670 | ||
17671 | /* "bgp client-to-client reflection" commands */ | |
17672 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17673 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17674 | ||
17675 | /* "bgp always-compare-med" commands */ | |
17676 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17677 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17678 | ||
9dac9fc8 DA |
17679 | /* bgp ebgp-requires-policy */ |
17680 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17681 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17682 | ||
2adac256 DA |
17683 | /* bgp suppress-duplicates */ |
17684 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17685 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17686 | ||
fb29348a DA |
17687 | /* bgp reject-as-sets */ |
17688 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17689 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17690 | ||
d62a17ae | 17691 | /* "bgp deterministic-med" commands */ |
17692 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17693 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17694 | ||
055679e9 | 17695 | /* "bgp graceful-restart" command */ |
36235319 QY |
17696 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17697 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17698 | |
17699 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17700 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17701 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17702 | |
17703 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17704 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17705 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17706 | |
17707 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17708 | install_element(BGP_NODE, | |
17709 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17710 | install_element(BGP_NODE, | |
17711 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17712 | ||
17713 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17714 | install_element(BGP_NODE, | |
17715 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17716 | install_element(BGP_NODE, | |
17717 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17718 | ||
d62a17ae | 17719 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17720 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17721 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17722 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17723 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17724 | install_element(BGP_NODE, |
17725 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17726 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17727 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17728 | ||
d6e3c15b | 17729 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17730 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17731 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17732 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17733 | |
7f323236 DW |
17734 | /* "bgp graceful-shutdown" commands */ |
17735 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17736 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17737 | ||
d62a17ae | 17738 | /* "bgp fast-external-failover" commands */ |
17739 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17740 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17741 | ||
d62a17ae | 17742 | /* "bgp bestpath compare-routerid" commands */ |
17743 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17744 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17745 | ||
17746 | /* "bgp bestpath as-path ignore" commands */ | |
17747 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17748 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17749 | ||
17750 | /* "bgp bestpath as-path confed" commands */ | |
17751 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17752 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17753 | ||
17754 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17755 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17756 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17757 | ||
ee88563a JM |
17758 | /* "bgp bestpath peer-type multipath-relax" commands */ |
17759 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
17760 | install_element(BGP_NODE, | |
17761 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
17762 | ||
d62a17ae | 17763 | /* "bgp log-neighbor-changes" commands */ |
17764 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17765 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17766 | ||
17767 | /* "bgp bestpath med" commands */ | |
17768 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17769 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17770 | ||
f7e1c681 | 17771 | /* "bgp bestpath bandwidth" commands */ |
17772 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17773 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17774 | |
b16bcbba TA |
17775 | /* "no bgp default <afi>-<safi>" commands. */ |
17776 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 17777 | |
d62a17ae | 17778 | /* "bgp network import-check" commands. */ |
17779 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17780 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17781 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17782 | ||
17783 | /* "bgp default local-preference" commands. */ | |
17784 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17785 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17786 | ||
17787 | /* bgp default show-hostname */ | |
17788 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17789 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17790 | ||
aef999a2 DA |
17791 | /* bgp default show-nexthop-hostname */ |
17792 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17793 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17794 | ||
d62a17ae | 17795 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17796 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17797 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17798 | ||
17799 | /* bgp ibgp-allow-policy-mods command */ | |
17800 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17801 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17802 | ||
17803 | /* "bgp listen limit" commands. */ | |
17804 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17805 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17806 | ||
17807 | /* "bgp listen range" commands. */ | |
17808 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17809 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17810 | ||
8175f54a | 17811 | /* "bgp default shutdown" command */ |
f26845f9 | 17812 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17813 | |
17814 | /* "bgp shutdown" commands */ | |
17815 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17816 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17817 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17818 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17819 | |
d62a17ae | 17820 | /* "neighbor remote-as" commands. */ |
17821 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17822 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17823 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17824 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17825 | install_element(BGP_NODE, | |
17826 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17827 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17828 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17829 | ||
17830 | /* "neighbor peer-group" commands. */ | |
17831 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17832 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17833 | install_element(BGP_NODE, | |
17834 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17835 | ||
17836 | /* "neighbor local-as" commands. */ | |
17837 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17838 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17839 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17840 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17841 | ||
17842 | /* "neighbor solo" commands. */ | |
17843 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17844 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17845 | ||
17846 | /* "neighbor password" commands. */ | |
17847 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17848 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17849 | ||
17850 | /* "neighbor activate" commands. */ | |
17851 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17852 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17853 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17854 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17855 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17856 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17857 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17858 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17859 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17860 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17861 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17862 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17863 | ||
17864 | /* "no neighbor activate" commands. */ | |
17865 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17866 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17867 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17868 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17869 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17870 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17871 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17872 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17873 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17874 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17875 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17876 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17877 | ||
17878 | /* "neighbor peer-group" set commands. */ | |
17879 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17880 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17881 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17882 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17883 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17884 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17885 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17886 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17887 | install_element(BGP_FLOWSPECV4_NODE, |
17888 | &neighbor_set_peer_group_hidden_cmd); | |
17889 | install_element(BGP_FLOWSPECV6_NODE, | |
17890 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17891 | |
17892 | /* "no neighbor peer-group unset" commands. */ | |
17893 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17894 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17895 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17896 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17897 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17898 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17899 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17900 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17901 | install_element(BGP_FLOWSPECV4_NODE, |
17902 | &no_neighbor_set_peer_group_hidden_cmd); | |
17903 | install_element(BGP_FLOWSPECV6_NODE, | |
17904 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17905 | |
17906 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17907 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
17908 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
17909 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17910 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17911 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17912 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17913 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17914 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17915 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17916 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17917 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17918 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17919 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17920 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17921 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17922 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17923 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17924 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 17925 | install_element(BGP_FLOWSPECV4_NODE, |
17926 | &neighbor_soft_reconfiguration_cmd); | |
17927 | install_element(BGP_FLOWSPECV4_NODE, | |
17928 | &no_neighbor_soft_reconfiguration_cmd); | |
17929 | install_element(BGP_FLOWSPECV6_NODE, | |
17930 | &neighbor_soft_reconfiguration_cmd); | |
17931 | install_element(BGP_FLOWSPECV6_NODE, | |
17932 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
17933 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
17934 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 17935 | |
17936 | /* "neighbor attribute-unchanged" commands. */ | |
17937 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
17938 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
17939 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
17940 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17941 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
17942 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17943 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
17944 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17945 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
17946 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17947 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
17948 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17949 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
17950 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17951 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
17952 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17953 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
17954 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17955 | ||
17956 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
17957 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
17958 | ||
b8ad84d2 PG |
17959 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
17960 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17961 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
17962 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17963 | ||
d62a17ae | 17964 | /* "nexthop-local unchanged" commands */ |
17965 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
17966 | install_element(BGP_IPV6_NODE, | |
17967 | &no_neighbor_nexthop_local_unchanged_cmd); | |
17968 | ||
17969 | /* "neighbor next-hop-self" commands. */ | |
17970 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
17971 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
17972 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
17973 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17974 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
17975 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
17976 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
17977 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
17978 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
17979 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
17980 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
17981 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
17982 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
17983 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
17984 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
17985 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
17986 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
17987 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
17988 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
17989 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 17990 | |
17991 | /* "neighbor next-hop-self force" commands. */ | |
17992 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
17993 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
17994 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17995 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 17996 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
17997 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
17998 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
17999 | install_element(BGP_IPV4_NODE, | |
18000 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18001 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18002 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18003 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18004 | install_element(BGP_IPV4M_NODE, | |
18005 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18006 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18007 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18008 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18009 | install_element(BGP_IPV4L_NODE, | |
18010 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18011 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18012 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18013 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18014 | install_element(BGP_IPV6_NODE, | |
18015 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18016 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18017 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18018 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18019 | install_element(BGP_IPV6M_NODE, | |
18020 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18021 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18022 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18023 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18024 | install_element(BGP_IPV6L_NODE, | |
18025 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18026 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18027 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18028 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18029 | install_element(BGP_VPNV4_NODE, | |
18030 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18031 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18032 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18033 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18034 | install_element(BGP_VPNV6_NODE, | |
18035 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18036 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18037 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18038 | |
18039 | /* "neighbor as-override" commands. */ | |
18040 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18041 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18042 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18043 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18044 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18045 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18046 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18047 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18048 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18049 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18050 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18051 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18052 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18053 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18054 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18055 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18056 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18057 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18058 | ||
18059 | /* "neighbor remove-private-AS" commands. */ | |
18060 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18061 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18062 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18063 | install_element(BGP_NODE, | |
18064 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18065 | install_element(BGP_NODE, | |
18066 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18067 | install_element(BGP_NODE, | |
18068 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18069 | install_element(BGP_NODE, | |
18070 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18071 | install_element( | |
18072 | BGP_NODE, | |
18073 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18074 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18075 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18076 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18077 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18078 | install_element(BGP_IPV4_NODE, | |
18079 | &neighbor_remove_private_as_replace_as_cmd); | |
18080 | install_element(BGP_IPV4_NODE, | |
18081 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18082 | install_element(BGP_IPV4_NODE, | |
18083 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18084 | install_element(BGP_IPV4_NODE, | |
18085 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18086 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18087 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18088 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18089 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18090 | install_element(BGP_IPV4M_NODE, | |
18091 | &neighbor_remove_private_as_replace_as_cmd); | |
18092 | install_element(BGP_IPV4M_NODE, | |
18093 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18094 | install_element(BGP_IPV4M_NODE, | |
18095 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18096 | install_element(BGP_IPV4M_NODE, | |
18097 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18098 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18099 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18100 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18101 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18102 | install_element(BGP_IPV4L_NODE, | |
18103 | &neighbor_remove_private_as_replace_as_cmd); | |
18104 | install_element(BGP_IPV4L_NODE, | |
18105 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18106 | install_element(BGP_IPV4L_NODE, | |
18107 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18108 | install_element(BGP_IPV4L_NODE, | |
18109 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18110 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18111 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18112 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18113 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18114 | install_element(BGP_IPV6_NODE, | |
18115 | &neighbor_remove_private_as_replace_as_cmd); | |
18116 | install_element(BGP_IPV6_NODE, | |
18117 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18118 | install_element(BGP_IPV6_NODE, | |
18119 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18120 | install_element(BGP_IPV6_NODE, | |
18121 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18122 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18123 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18124 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18125 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18126 | install_element(BGP_IPV6M_NODE, | |
18127 | &neighbor_remove_private_as_replace_as_cmd); | |
18128 | install_element(BGP_IPV6M_NODE, | |
18129 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18130 | install_element(BGP_IPV6M_NODE, | |
18131 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18132 | install_element(BGP_IPV6M_NODE, | |
18133 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18134 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18135 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18136 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18137 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18138 | install_element(BGP_IPV6L_NODE, | |
18139 | &neighbor_remove_private_as_replace_as_cmd); | |
18140 | install_element(BGP_IPV6L_NODE, | |
18141 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18142 | install_element(BGP_IPV6L_NODE, | |
18143 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18144 | install_element(BGP_IPV6L_NODE, | |
18145 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18146 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18147 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18148 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18149 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18150 | install_element(BGP_VPNV4_NODE, | |
18151 | &neighbor_remove_private_as_replace_as_cmd); | |
18152 | install_element(BGP_VPNV4_NODE, | |
18153 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18154 | install_element(BGP_VPNV4_NODE, | |
18155 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18156 | install_element(BGP_VPNV4_NODE, | |
18157 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18158 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18159 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18160 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18161 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18162 | install_element(BGP_VPNV6_NODE, | |
18163 | &neighbor_remove_private_as_replace_as_cmd); | |
18164 | install_element(BGP_VPNV6_NODE, | |
18165 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18166 | install_element(BGP_VPNV6_NODE, | |
18167 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18168 | install_element(BGP_VPNV6_NODE, | |
18169 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18170 | ||
18171 | /* "neighbor send-community" commands.*/ | |
18172 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18173 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18174 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18175 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18176 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18177 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18178 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18179 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18180 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18181 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18182 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18183 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18184 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18185 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18186 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18187 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18188 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18189 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18190 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18191 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18192 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18193 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18194 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18195 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18196 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18197 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18198 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18199 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18200 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18201 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18202 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18203 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18204 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18205 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18206 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18207 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18208 | ||
18209 | /* "neighbor route-reflector" commands.*/ | |
18210 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18211 | install_element(BGP_NODE, | |
18212 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18213 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18214 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18215 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18216 | install_element(BGP_IPV4M_NODE, | |
18217 | &no_neighbor_route_reflector_client_cmd); | |
18218 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18219 | install_element(BGP_IPV4L_NODE, | |
18220 | &no_neighbor_route_reflector_client_cmd); | |
18221 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18222 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18223 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18224 | install_element(BGP_IPV6M_NODE, | |
18225 | &no_neighbor_route_reflector_client_cmd); | |
18226 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18227 | install_element(BGP_IPV6L_NODE, | |
18228 | &no_neighbor_route_reflector_client_cmd); | |
18229 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18230 | install_element(BGP_VPNV4_NODE, | |
18231 | &no_neighbor_route_reflector_client_cmd); | |
18232 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18233 | install_element(BGP_VPNV6_NODE, | |
18234 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18235 | install_element(BGP_FLOWSPECV4_NODE, |
18236 | &neighbor_route_reflector_client_cmd); | |
18237 | install_element(BGP_FLOWSPECV4_NODE, | |
18238 | &no_neighbor_route_reflector_client_cmd); | |
18239 | install_element(BGP_FLOWSPECV6_NODE, | |
18240 | &neighbor_route_reflector_client_cmd); | |
18241 | install_element(BGP_FLOWSPECV6_NODE, | |
18242 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18243 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18244 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18245 | ||
18246 | /* "neighbor route-server" commands.*/ | |
18247 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18248 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18249 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18250 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18251 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18252 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18253 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18254 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18255 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18256 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18257 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18258 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18259 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18260 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18261 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18262 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18263 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18264 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18265 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18266 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18267 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18268 | install_element(BGP_FLOWSPECV4_NODE, | |
18269 | &no_neighbor_route_server_client_cmd); | |
18270 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18271 | install_element(BGP_FLOWSPECV6_NODE, | |
18272 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18273 | |
7c0e4312 DA |
18274 | /* "neighbor disable-addpath-rx" commands. */ |
18275 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18276 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18277 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18278 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18279 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18280 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18281 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18282 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18283 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18284 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18285 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18286 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18287 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18288 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18289 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18290 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18291 | ||
d62a17ae | 18292 | /* "neighbor addpath-tx-all-paths" commands.*/ |
18293 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18294 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18295 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18296 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18297 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18298 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18299 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18300 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18301 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18302 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18303 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18304 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18305 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18306 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18307 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18308 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18309 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18310 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18311 | ||
18312 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18313 | install_element(BGP_NODE, | |
18314 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18315 | install_element(BGP_NODE, | |
18316 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18317 | install_element(BGP_IPV4_NODE, | |
18318 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18319 | install_element(BGP_IPV4_NODE, | |
18320 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18321 | install_element(BGP_IPV4M_NODE, | |
18322 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18323 | install_element(BGP_IPV4M_NODE, | |
18324 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18325 | install_element(BGP_IPV4L_NODE, | |
18326 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18327 | install_element(BGP_IPV4L_NODE, | |
18328 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18329 | install_element(BGP_IPV6_NODE, | |
18330 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18331 | install_element(BGP_IPV6_NODE, | |
18332 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18333 | install_element(BGP_IPV6M_NODE, | |
18334 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18335 | install_element(BGP_IPV6M_NODE, | |
18336 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18337 | install_element(BGP_IPV6L_NODE, | |
18338 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18339 | install_element(BGP_IPV6L_NODE, | |
18340 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18341 | install_element(BGP_VPNV4_NODE, | |
18342 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18343 | install_element(BGP_VPNV4_NODE, | |
18344 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18345 | install_element(BGP_VPNV6_NODE, | |
18346 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18347 | install_element(BGP_VPNV6_NODE, | |
18348 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18349 | ||
2b31007c RZ |
18350 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18351 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18352 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18353 | ||
d62a17ae | 18354 | /* "neighbor passive" commands. */ |
18355 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18356 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18357 | ||
18358 | ||
18359 | /* "neighbor shutdown" commands. */ | |
18360 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18361 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18362 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18363 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18364 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18365 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18366 | |
18367 | /* "neighbor capability extended-nexthop" commands.*/ | |
18368 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18369 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18370 | ||
18371 | /* "neighbor capability orf prefix-list" commands.*/ | |
18372 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18373 | install_element(BGP_NODE, | |
18374 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18375 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18376 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18377 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18378 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18379 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18380 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18381 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18382 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18383 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18384 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18385 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18386 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18387 | ||
18388 | /* "neighbor capability dynamic" commands.*/ | |
18389 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18390 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18391 | ||
18392 | /* "neighbor dont-capability-negotiate" commands. */ | |
18393 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18394 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18395 | ||
18396 | /* "neighbor ebgp-multihop" commands. */ | |
18397 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18398 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18399 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18400 | ||
18401 | /* "neighbor disable-connected-check" commands. */ | |
18402 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18403 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18404 | ||
7ab294ea DA |
18405 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
18406 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18407 | install_element(BGP_NODE, | |
18408 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 18409 | |
47cbc09b PM |
18410 | /* "neighbor enforce-first-as" commands. */ |
18411 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18412 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18413 | ||
d62a17ae | 18414 | /* "neighbor description" commands. */ |
18415 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18416 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18417 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18418 | |
18419 | /* "neighbor update-source" commands. "*/ | |
18420 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18421 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18422 | ||
18423 | /* "neighbor default-originate" commands. */ | |
18424 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18425 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18426 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18427 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18428 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18429 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18430 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18431 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18432 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18433 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18434 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18435 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18436 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18437 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18438 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18439 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18440 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18441 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18442 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18443 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18444 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18445 | ||
18446 | /* "neighbor port" commands. */ | |
18447 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18448 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18449 | ||
18450 | /* "neighbor weight" commands. */ | |
18451 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18452 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18453 | ||
18454 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18455 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18456 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18457 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18458 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18459 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18460 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18461 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18462 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18463 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18464 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18465 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18466 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18467 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18468 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18469 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18470 | ||
18471 | /* "neighbor override-capability" commands. */ | |
18472 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18473 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18474 | ||
18475 | /* "neighbor strict-capability-match" commands. */ | |
18476 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18477 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18478 | ||
18479 | /* "neighbor timers" commands. */ | |
18480 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18481 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18482 | ||
18483 | /* "neighbor timers connect" commands. */ | |
18484 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18485 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18486 | ||
d43114f3 DS |
18487 | /* "neighbor timers delayopen" commands. */ |
18488 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18489 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18490 | ||
d62a17ae | 18491 | /* "neighbor advertisement-interval" commands. */ |
18492 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18493 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18494 | ||
18495 | /* "neighbor interface" commands. */ | |
18496 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18497 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18498 | ||
18499 | /* "neighbor distribute" commands. */ | |
18500 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18501 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18502 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18503 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18504 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18505 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18506 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18507 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18508 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18509 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18510 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18511 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18512 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18513 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18514 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18515 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18516 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18517 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18518 | ||
18519 | /* "neighbor prefix-list" commands. */ | |
18520 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 18521 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 18522 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18523 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18524 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18525 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18526 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18527 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18528 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18529 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18530 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18531 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18532 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18533 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18534 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18535 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18536 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18537 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18538 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18539 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18540 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18541 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18542 | |
18543 | /* "neighbor filter-list" commands. */ | |
18544 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18545 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18546 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18547 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18548 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18549 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18550 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18551 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18552 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18553 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18554 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18555 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18556 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18557 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18558 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18559 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18560 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18561 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18562 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18563 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18564 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18565 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18566 | |
18567 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
18568 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
18569 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 18570 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18571 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18572 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18573 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18574 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18575 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18576 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18577 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18578 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18579 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18580 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18581 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18582 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18583 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18584 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18585 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18586 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18587 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18588 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18589 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 18590 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18591 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18592 | |
18593 | /* "neighbor unsuppress-map" commands. */ | |
18594 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18595 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18596 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18597 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18598 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18599 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18600 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18601 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18602 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18603 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18604 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18605 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18606 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18607 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18608 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18609 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18610 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18611 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18612 | ||
7f7940e6 | 18613 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 18614 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 18615 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 18616 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18617 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18618 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18619 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18620 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18621 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18622 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18623 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18624 | |
fde246e8 DA |
18625 | /* neighbor maximum-prefix-out commands. */ |
18626 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18627 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18628 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18629 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18630 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18631 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18632 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18633 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18634 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18635 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18636 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18637 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18638 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18639 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18640 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18641 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18642 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18643 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18644 | ||
d62a17ae | 18645 | /* "neighbor maximum-prefix" commands. */ |
18646 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18647 | install_element(BGP_NODE, | |
18648 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18649 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18650 | install_element(BGP_NODE, | |
18651 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18652 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18653 | install_element(BGP_NODE, | |
18654 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18655 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18656 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18657 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18658 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18659 | install_element(BGP_IPV4_NODE, | |
18660 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18661 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18662 | install_element(BGP_IPV4_NODE, | |
18663 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18664 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18665 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18666 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18667 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18668 | install_element(BGP_IPV4M_NODE, | |
18669 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18670 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18671 | install_element(BGP_IPV4M_NODE, | |
18672 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18673 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18674 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18675 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18676 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18677 | install_element(BGP_IPV4L_NODE, | |
18678 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18679 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18680 | install_element(BGP_IPV4L_NODE, | |
18681 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18682 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18683 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18684 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18685 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18686 | install_element(BGP_IPV6_NODE, | |
18687 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18688 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18689 | install_element(BGP_IPV6_NODE, | |
18690 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18691 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18692 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18693 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18694 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18695 | install_element(BGP_IPV6M_NODE, | |
18696 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18697 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18698 | install_element(BGP_IPV6M_NODE, | |
18699 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18700 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18701 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18702 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18703 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18704 | install_element(BGP_IPV6L_NODE, | |
18705 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18706 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18707 | install_element(BGP_IPV6L_NODE, | |
18708 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18709 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18710 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18711 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18712 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18713 | install_element(BGP_VPNV4_NODE, | |
18714 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18715 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18716 | install_element(BGP_VPNV4_NODE, | |
18717 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18718 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18719 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18720 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18721 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18722 | install_element(BGP_VPNV6_NODE, | |
18723 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18724 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18725 | install_element(BGP_VPNV6_NODE, | |
18726 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18727 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18728 | ||
18729 | /* "neighbor allowas-in" */ | |
18730 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18731 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18732 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18733 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18734 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18735 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18736 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18737 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18738 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18739 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18740 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18741 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18742 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18743 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18744 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18745 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18746 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18747 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18748 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18749 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18750 | ||
18751 | /* address-family commands. */ | |
18752 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18753 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18754 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18755 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18756 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18757 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18758 | |
d62a17ae | 18759 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18760 | ||
18761 | /* "exit-address-family" command. */ | |
18762 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18763 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18764 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18765 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18766 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18767 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18768 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18769 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18770 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18771 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18772 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18773 | ||
18774 | /* "clear ip bgp commands" */ | |
18775 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18776 | ||
18777 | /* clear ip bgp prefix */ | |
18778 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18779 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18780 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18781 | ||
18782 | /* "show [ip] bgp summary" commands. */ | |
18783 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18784 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18785 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18786 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18787 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18788 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18789 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18790 | ||
18791 | /* "show [ip] bgp neighbors" commands. */ | |
18792 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18793 | ||
36235319 | 18794 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18795 | |
d62a17ae | 18796 | /* "show [ip] bgp peer-group" commands. */ |
18797 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18798 | ||
18799 | /* "show [ip] bgp paths" commands. */ | |
18800 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18801 | ||
18802 | /* "show [ip] bgp community" commands. */ | |
18803 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18804 | ||
18805 | /* "show ip bgp large-community" commands. */ | |
18806 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18807 | /* "show [ip] bgp attribute-info" commands. */ | |
18808 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18809 | /* "show [ip] bgp route-leak" command */ |
18810 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18811 | |
18812 | /* "redistribute" commands. */ | |
18813 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18814 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18815 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18816 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18817 | install_element(BGP_NODE, | |
18818 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18819 | install_element(BGP_NODE, | |
18820 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18821 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18822 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18823 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18824 | install_element(BGP_NODE, | |
18825 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18826 | install_element(BGP_NODE, | |
18827 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18828 | install_element(BGP_NODE, | |
18829 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18830 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18831 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18832 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18833 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18834 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18835 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18836 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18837 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18838 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18839 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18840 | install_element(BGP_IPV4_NODE, | |
18841 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18842 | install_element(BGP_IPV4_NODE, | |
18843 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18844 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18845 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18846 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18847 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18848 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18849 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18850 | ||
b9c7bc5a PZ |
18851 | /* import|export vpn [route-map WORD] */ |
18852 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18853 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18854 | |
12a844a5 DS |
18855 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18856 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18857 | ||
d62a17ae | 18858 | /* ttl_security commands */ |
18859 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18860 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18861 | ||
18862 | /* "show [ip] bgp memory" commands. */ | |
18863 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18864 | ||
acf71666 MK |
18865 | /* "show bgp martian next-hop" */ |
18866 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18867 | ||
48ecf8f5 DS |
18868 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18869 | ||
d62a17ae | 18870 | /* "show [ip] bgp views" commands. */ |
18871 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18872 | ||
18873 | /* "show [ip] bgp vrfs" commands. */ | |
18874 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18875 | ||
18876 | /* Community-list. */ | |
18877 | community_list_vty(); | |
ddb5b488 | 18878 | |
ed0e57e3 DA |
18879 | community_alias_vty(); |
18880 | ||
ddb5b488 | 18881 | /* vpn-policy commands */ |
b9c7bc5a PZ |
18882 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18883 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18884 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18885 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18886 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18887 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18888 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18889 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18890 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18891 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18892 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18893 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18894 | |
301ad80a PG |
18895 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18896 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18897 | ||
b9c7bc5a PZ |
18898 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18899 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18900 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18901 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18902 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18903 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18904 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18905 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18906 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
18907 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
18908 | |
18909 | /* tcp-mss command */ | |
18910 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
18911 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
18912 | |
18913 | /* srv6 commands */ | |
ea372e81 | 18914 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 18915 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
a0281b2e | 18916 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
b72c9e14 HS |
18917 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
18918 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 18919 | } |
6b0655a2 | 18920 | |
718e3744 | 18921 | #include "memory.h" |
18922 | #include "bgp_regex.h" | |
18923 | #include "bgp_clist.h" | |
18924 | #include "bgp_ecommunity.h" | |
18925 | ||
18926 | /* VTY functions. */ | |
18927 | ||
18928 | /* Direction value to string conversion. */ | |
d62a17ae | 18929 | static const char *community_direct_str(int direct) |
18930 | { | |
18931 | switch (direct) { | |
18932 | case COMMUNITY_DENY: | |
18933 | return "deny"; | |
18934 | case COMMUNITY_PERMIT: | |
18935 | return "permit"; | |
18936 | default: | |
18937 | return "unknown"; | |
18938 | } | |
718e3744 | 18939 | } |
18940 | ||
18941 | /* Display error string. */ | |
d62a17ae | 18942 | static void community_list_perror(struct vty *vty, int ret) |
18943 | { | |
18944 | switch (ret) { | |
18945 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
18946 | vty_out(vty, "%% Can't find community-list\n"); | |
18947 | break; | |
18948 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
18949 | vty_out(vty, "%% Malformed community-list value\n"); | |
18950 | break; | |
18951 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
18952 | vty_out(vty, | |
18953 | "%% Community name conflict, previously defined as standard community\n"); | |
18954 | break; | |
18955 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
18956 | vty_out(vty, | |
18957 | "%% Community name conflict, previously defined as expanded community\n"); | |
18958 | break; | |
18959 | } | |
718e3744 | 18960 | } |
18961 | ||
5bf15956 DW |
18962 | /* "community-list" keyword help string. */ |
18963 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
18964 | ||
7336e101 SP |
18965 | /*community-list standard */ |
18966 | DEFUN (community_list_standard, | |
18967 | bgp_community_list_standard_cmd, | |
a08032fe | 18968 | "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18969 | BGP_STR |
718e3744 | 18970 | COMMUNITY_LIST_STR |
18971 | "Community list number (standard)\n" | |
5bf15956 | 18972 | "Add an standard community-list entry\n" |
718e3744 | 18973 | "Community list name\n" |
2f8cc0e5 DA |
18974 | "Sequence number of an entry\n" |
18975 | "Sequence number\n" | |
718e3744 | 18976 | "Specify community to reject\n" |
18977 | "Specify community to accept\n" | |
18978 | COMMUNITY_VAL_STR) | |
18979 | { | |
d62a17ae | 18980 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18981 | char *seq = NULL; |
d62a17ae | 18982 | int direct = 0; |
18983 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 18984 | int idx = 0; |
7336e101 | 18985 | |
a08032fe | 18986 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
18987 | if (idx) |
18988 | seq = argv[idx]->arg; | |
18989 | ||
18990 | idx = 0; | |
d62a17ae | 18991 | argv_find(argv, argc, "(1-99)", &idx); |
18992 | argv_find(argv, argc, "WORD", &idx); | |
18993 | cl_name_or_number = argv[idx]->arg; | |
18994 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18995 | : COMMUNITY_DENY; | |
18996 | argv_find(argv, argc, "AA:NN", &idx); | |
18997 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18998 | |
2f8cc0e5 DA |
18999 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19000 | direct, style); | |
42f914d4 | 19001 | |
d62a17ae | 19002 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19003 | |
d62a17ae | 19004 | if (ret < 0) { |
19005 | /* Display error string. */ | |
19006 | community_list_perror(vty, ret); | |
19007 | return CMD_WARNING_CONFIG_FAILED; | |
19008 | } | |
42f914d4 | 19009 | |
d62a17ae | 19010 | return CMD_SUCCESS; |
718e3744 | 19011 | } |
19012 | ||
7336e101 SP |
19013 | DEFUN (no_community_list_standard_all, |
19014 | no_bgp_community_list_standard_all_cmd, | |
a08032fe | 19015 | "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19016 | NO_STR |
19017 | BGP_STR | |
19018 | COMMUNITY_LIST_STR | |
19019 | "Community list number (standard)\n" | |
19020 | "Add an standard community-list entry\n" | |
19021 | "Community list name\n" | |
2f8cc0e5 DA |
19022 | "Sequence number of an entry\n" |
19023 | "Sequence number\n" | |
7336e101 SP |
19024 | "Specify community to reject\n" |
19025 | "Specify community to accept\n" | |
19026 | COMMUNITY_VAL_STR) | |
718e3744 | 19027 | { |
d62a17ae | 19028 | char *cl_name_or_number = NULL; |
174b5cb9 | 19029 | char *str = NULL; |
d62a17ae | 19030 | int direct = 0; |
19031 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19032 | char *seq = NULL; |
d62a17ae | 19033 | int idx = 0; |
7336e101 | 19034 | |
a08032fe | 19035 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19036 | if (idx) |
19037 | seq = argv[idx]->arg; | |
19038 | ||
19039 | idx = 0; | |
174b5cb9 DA |
19040 | argv_find(argv, argc, "permit", &idx); |
19041 | argv_find(argv, argc, "deny", &idx); | |
19042 | ||
19043 | if (idx) { | |
19044 | direct = argv_find(argv, argc, "permit", &idx) | |
19045 | ? COMMUNITY_PERMIT | |
19046 | : COMMUNITY_DENY; | |
19047 | ||
19048 | idx = 0; | |
19049 | argv_find(argv, argc, "AA:NN", &idx); | |
19050 | str = argv_concat(argv, argc, idx); | |
19051 | } | |
19052 | ||
19053 | idx = 0; | |
d62a17ae | 19054 | argv_find(argv, argc, "(1-99)", &idx); |
19055 | argv_find(argv, argc, "WORD", &idx); | |
19056 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19057 | |
2f8cc0e5 | 19058 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19059 | direct, style); |
42f914d4 | 19060 | |
d62a17ae | 19061 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19062 | |
d62a17ae | 19063 | if (ret < 0) { |
19064 | community_list_perror(vty, ret); | |
19065 | return CMD_WARNING_CONFIG_FAILED; | |
19066 | } | |
42f914d4 | 19067 | |
d62a17ae | 19068 | return CMD_SUCCESS; |
718e3744 | 19069 | } |
7336e101 | 19070 | |
174b5cb9 DA |
19071 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
19072 | "no bgp community-list <(1-99)|standard WORD>", | |
19073 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19074 | "Community list number (standard)\n" | |
19075 | "Add an standard community-list entry\n" | |
19076 | "Community list name\n") | |
19077 | ||
7336e101 SP |
19078 | /*community-list expanded */ |
19079 | DEFUN (community_list_expanded_all, | |
19080 | bgp_community_list_expanded_all_cmd, | |
a08032fe | 19081 | "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19082 | BGP_STR |
19083 | COMMUNITY_LIST_STR | |
718e3744 | 19084 | "Community list number (expanded)\n" |
5bf15956 | 19085 | "Add an expanded community-list entry\n" |
718e3744 | 19086 | "Community list name\n" |
2f8cc0e5 DA |
19087 | "Sequence number of an entry\n" |
19088 | "Sequence number\n" | |
718e3744 | 19089 | "Specify community to reject\n" |
19090 | "Specify community to accept\n" | |
19091 | COMMUNITY_VAL_STR) | |
19092 | { | |
d62a17ae | 19093 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19094 | char *seq = NULL; |
d62a17ae | 19095 | int direct = 0; |
19096 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19097 | int idx = 0; |
7b9a4750 | 19098 | |
a08032fe | 19099 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19100 | if (idx) |
19101 | seq = argv[idx]->arg; | |
19102 | ||
19103 | idx = 0; | |
19104 | ||
d62a17ae | 19105 | argv_find(argv, argc, "(100-500)", &idx); |
19106 | argv_find(argv, argc, "WORD", &idx); | |
19107 | cl_name_or_number = argv[idx]->arg; | |
19108 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19109 | : COMMUNITY_DENY; | |
19110 | argv_find(argv, argc, "AA:NN", &idx); | |
19111 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19112 | |
2f8cc0e5 DA |
19113 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19114 | direct, style); | |
42f914d4 | 19115 | |
d62a17ae | 19116 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19117 | |
d62a17ae | 19118 | if (ret < 0) { |
19119 | /* Display error string. */ | |
19120 | community_list_perror(vty, ret); | |
19121 | return CMD_WARNING_CONFIG_FAILED; | |
19122 | } | |
42f914d4 | 19123 | |
d62a17ae | 19124 | return CMD_SUCCESS; |
718e3744 | 19125 | } |
19126 | ||
7336e101 SP |
19127 | DEFUN (no_community_list_expanded_all, |
19128 | no_bgp_community_list_expanded_all_cmd, | |
a08032fe | 19129 | "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19130 | NO_STR |
19131 | BGP_STR | |
19132 | COMMUNITY_LIST_STR | |
19133 | "Community list number (expanded)\n" | |
19134 | "Add an expanded community-list entry\n" | |
19135 | "Community list name\n" | |
2f8cc0e5 DA |
19136 | "Sequence number of an entry\n" |
19137 | "Sequence number\n" | |
7336e101 SP |
19138 | "Specify community to reject\n" |
19139 | "Specify community to accept\n" | |
19140 | COMMUNITY_VAL_STR) | |
718e3744 | 19141 | { |
d62a17ae | 19142 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19143 | char *seq = NULL; |
174b5cb9 | 19144 | char *str = NULL; |
d62a17ae | 19145 | int direct = 0; |
19146 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19147 | int idx = 0; |
174b5cb9 | 19148 | |
a08032fe | 19149 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19150 | if (idx) |
19151 | seq = argv[idx]->arg; | |
19152 | ||
19153 | idx = 0; | |
174b5cb9 DA |
19154 | argv_find(argv, argc, "permit", &idx); |
19155 | argv_find(argv, argc, "deny", &idx); | |
19156 | ||
19157 | if (idx) { | |
19158 | direct = argv_find(argv, argc, "permit", &idx) | |
19159 | ? COMMUNITY_PERMIT | |
19160 | : COMMUNITY_DENY; | |
19161 | ||
19162 | idx = 0; | |
19163 | argv_find(argv, argc, "AA:NN", &idx); | |
19164 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19165 | } |
174b5cb9 DA |
19166 | |
19167 | idx = 0; | |
d62a17ae | 19168 | argv_find(argv, argc, "(100-500)", &idx); |
19169 | argv_find(argv, argc, "WORD", &idx); | |
19170 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19171 | |
2f8cc0e5 | 19172 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19173 | direct, style); |
42f914d4 | 19174 | |
d62a17ae | 19175 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19176 | |
d62a17ae | 19177 | if (ret < 0) { |
19178 | community_list_perror(vty, ret); | |
19179 | return CMD_WARNING_CONFIG_FAILED; | |
19180 | } | |
42f914d4 | 19181 | |
d62a17ae | 19182 | return CMD_SUCCESS; |
718e3744 | 19183 | } |
19184 | ||
36d4bb44 EB |
19185 | ALIAS(no_community_list_expanded_all, |
19186 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 19187 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 19188 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19189 | "Community list number (expanded)\n" |
19190 | "Add an expanded community-list entry\n" | |
19191 | "Community list name\n") | |
19192 | ||
8d9b8ed9 PM |
19193 | /* Return configuration string of community-list entry. */ |
19194 | static const char *community_list_config_str(struct community_entry *entry) | |
19195 | { | |
19196 | const char *str; | |
19197 | ||
19198 | if (entry->any) | |
19199 | str = ""; | |
19200 | else { | |
19201 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19202 | str = community_str(entry->u.com, false); | |
19203 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19204 | str = lcommunity_str(entry->u.lcom, false); | |
19205 | else | |
19206 | str = entry->config; | |
19207 | } | |
19208 | return str; | |
19209 | } | |
19210 | ||
d62a17ae | 19211 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19212 | { |
d62a17ae | 19213 | struct community_entry *entry; |
718e3744 | 19214 | |
d62a17ae | 19215 | for (entry = list->head; entry; entry = entry->next) { |
19216 | if (entry == list->head) { | |
19217 | if (all_digit(list->name)) | |
19218 | vty_out(vty, "Community %s list %s\n", | |
19219 | entry->style == COMMUNITY_LIST_STANDARD | |
19220 | ? "standard" | |
19221 | : "(expanded) access", | |
19222 | list->name); | |
19223 | else | |
19224 | vty_out(vty, "Named Community %s list %s\n", | |
19225 | entry->style == COMMUNITY_LIST_STANDARD | |
19226 | ? "standard" | |
19227 | : "expanded", | |
19228 | list->name); | |
19229 | } | |
19230 | if (entry->any) | |
19231 | vty_out(vty, " %s\n", | |
19232 | community_direct_str(entry->direct)); | |
19233 | else | |
19234 | vty_out(vty, " %s %s\n", | |
19235 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19236 | community_list_config_str(entry)); |
d62a17ae | 19237 | } |
718e3744 | 19238 | } |
19239 | ||
7336e101 SP |
19240 | DEFUN (show_community_list, |
19241 | show_bgp_community_list_cmd, | |
19242 | "show bgp community-list", | |
718e3744 | 19243 | SHOW_STR |
7336e101 | 19244 | BGP_STR |
718e3744 | 19245 | "List community-list\n") |
19246 | { | |
d62a17ae | 19247 | struct community_list *list; |
19248 | struct community_list_master *cm; | |
718e3744 | 19249 | |
d62a17ae | 19250 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19251 | if (!cm) | |
19252 | return CMD_SUCCESS; | |
718e3744 | 19253 | |
d62a17ae | 19254 | for (list = cm->num.head; list; list = list->next) |
19255 | community_list_show(vty, list); | |
718e3744 | 19256 | |
d62a17ae | 19257 | for (list = cm->str.head; list; list = list->next) |
19258 | community_list_show(vty, list); | |
718e3744 | 19259 | |
d62a17ae | 19260 | return CMD_SUCCESS; |
718e3744 | 19261 | } |
19262 | ||
7336e101 SP |
19263 | DEFUN (show_community_list_arg, |
19264 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 19265 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
19266 | SHOW_STR |
19267 | BGP_STR | |
718e3744 | 19268 | "List community-list\n" |
19269 | "Community-list number\n" | |
960b69b9 | 19270 | "Community-list name\n" |
19271 | "Detailed information on community-list\n") | |
718e3744 | 19272 | { |
d62a17ae | 19273 | int idx_comm_list = 3; |
19274 | struct community_list *list; | |
718e3744 | 19275 | |
e237b0d2 | 19276 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19277 | COMMUNITY_LIST_MASTER); |
19278 | if (!list) { | |
19279 | vty_out(vty, "%% Can't find community-list\n"); | |
19280 | return CMD_WARNING; | |
19281 | } | |
718e3744 | 19282 | |
d62a17ae | 19283 | community_list_show(vty, list); |
718e3744 | 19284 | |
d62a17ae | 19285 | return CMD_SUCCESS; |
718e3744 | 19286 | } |
6b0655a2 | 19287 | |
57d187bc JS |
19288 | /* |
19289 | * Large Community code. | |
19290 | */ | |
d62a17ae | 19291 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19292 | struct cmd_token **argv, int style, | |
19293 | int reject_all_digit_name) | |
19294 | { | |
19295 | int ret; | |
19296 | int direct; | |
19297 | char *str; | |
19298 | int idx = 0; | |
19299 | char *cl_name; | |
2f8cc0e5 DA |
19300 | char *seq = NULL; |
19301 | ||
a08032fe | 19302 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19303 | seq = argv[idx]->arg; |
d62a17ae | 19304 | |
2f8cc0e5 | 19305 | idx = 0; |
d62a17ae | 19306 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19307 | : COMMUNITY_DENY; | |
19308 | ||
19309 | /* All digit name check. */ | |
19310 | idx = 0; | |
19311 | argv_find(argv, argc, "WORD", &idx); | |
19312 | argv_find(argv, argc, "(1-99)", &idx); | |
19313 | argv_find(argv, argc, "(100-500)", &idx); | |
19314 | cl_name = argv[idx]->arg; | |
19315 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19316 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19317 | return CMD_WARNING_CONFIG_FAILED; | |
19318 | } | |
19319 | ||
19320 | idx = 0; | |
19321 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19322 | argv_find(argv, argc, "LINE", &idx); | |
19323 | /* Concat community string argument. */ | |
19324 | if (idx) | |
19325 | str = argv_concat(argv, argc, idx); | |
19326 | else | |
19327 | str = NULL; | |
19328 | ||
2f8cc0e5 | 19329 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19330 | |
19331 | /* Free temporary community list string allocated by | |
19332 | argv_concat(). */ | |
0a22ddfb | 19333 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19334 | |
19335 | if (ret < 0) { | |
19336 | community_list_perror(vty, ret); | |
19337 | return CMD_WARNING_CONFIG_FAILED; | |
19338 | } | |
19339 | return CMD_SUCCESS; | |
19340 | } | |
19341 | ||
19342 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19343 | struct cmd_token **argv, int style) | |
19344 | { | |
19345 | int ret; | |
19346 | int direct = 0; | |
19347 | char *str = NULL; | |
19348 | int idx = 0; | |
2f8cc0e5 | 19349 | char *seq = NULL; |
d62a17ae | 19350 | |
a08032fe | 19351 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19352 | seq = argv[idx]->arg; |
d62a17ae | 19353 | |
2f8cc0e5 | 19354 | idx = 0; |
d62a17ae | 19355 | argv_find(argv, argc, "permit", &idx); |
19356 | argv_find(argv, argc, "deny", &idx); | |
19357 | ||
19358 | if (idx) { | |
19359 | /* Check the list direct. */ | |
19360 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19361 | direct = COMMUNITY_PERMIT; | |
19362 | else | |
19363 | direct = COMMUNITY_DENY; | |
19364 | ||
19365 | idx = 0; | |
19366 | argv_find(argv, argc, "LINE", &idx); | |
19367 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19368 | /* Concat community string argument. */ | |
19369 | str = argv_concat(argv, argc, idx); | |
19370 | } | |
19371 | ||
19372 | idx = 0; | |
19373 | argv_find(argv, argc, "(1-99)", &idx); | |
19374 | argv_find(argv, argc, "(100-500)", &idx); | |
19375 | argv_find(argv, argc, "WORD", &idx); | |
19376 | ||
19377 | /* Unset community list. */ | |
2f8cc0e5 | 19378 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19379 | style); |
19380 | ||
19381 | /* Free temporary community list string allocated by | |
19382 | argv_concat(). */ | |
0a22ddfb | 19383 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19384 | |
19385 | if (ret < 0) { | |
19386 | community_list_perror(vty, ret); | |
19387 | return CMD_WARNING_CONFIG_FAILED; | |
19388 | } | |
19389 | ||
19390 | return CMD_SUCCESS; | |
57d187bc JS |
19391 | } |
19392 | ||
19393 | /* "large-community-list" keyword help string. */ | |
19394 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19395 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19396 | ||
7336e101 SP |
19397 | DEFUN (lcommunity_list_standard, |
19398 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19399 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19400 | BGP_STR |
19401 | LCOMMUNITY_LIST_STR | |
19402 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19403 | "Sequence number of an entry\n" |
19404 | "Sequence number\n" | |
7336e101 SP |
19405 | "Specify large community to reject\n" |
19406 | "Specify large community to accept\n" | |
19407 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19408 | { |
d62a17ae | 19409 | return lcommunity_list_set_vty(vty, argc, argv, |
19410 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19411 | } |
19412 | ||
7336e101 SP |
19413 | DEFUN (lcommunity_list_expanded, |
19414 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19415 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19416 | BGP_STR |
19417 | LCOMMUNITY_LIST_STR | |
19418 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19419 | "Sequence number of an entry\n" |
19420 | "Sequence number\n" | |
7336e101 SP |
19421 | "Specify large community to reject\n" |
19422 | "Specify large community to accept\n" | |
19423 | "An ordered list as a regular-expression\n") | |
57d187bc | 19424 | { |
d62a17ae | 19425 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19426 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19427 | } |
19428 | ||
7336e101 SP |
19429 | DEFUN (lcommunity_list_name_standard, |
19430 | bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19431 | "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19432 | BGP_STR |
19433 | LCOMMUNITY_LIST_STR | |
19434 | "Specify standard large-community-list\n" | |
19435 | "Large Community list name\n" | |
2f8cc0e5 DA |
19436 | "Sequence number of an entry\n" |
19437 | "Sequence number\n" | |
7336e101 SP |
19438 | "Specify large community to reject\n" |
19439 | "Specify large community to accept\n" | |
19440 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19441 | { |
d62a17ae | 19442 | return lcommunity_list_set_vty(vty, argc, argv, |
19443 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19444 | } |
19445 | ||
7336e101 SP |
19446 | DEFUN (lcommunity_list_name_expanded, |
19447 | bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19448 | "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19449 | BGP_STR |
19450 | LCOMMUNITY_LIST_STR | |
19451 | "Specify expanded large-community-list\n" | |
19452 | "Large Community list name\n" | |
2f8cc0e5 DA |
19453 | "Sequence number of an entry\n" |
19454 | "Sequence number\n" | |
7336e101 SP |
19455 | "Specify large community to reject\n" |
19456 | "Specify large community to accept\n" | |
19457 | "An ordered list as a regular-expression\n") | |
57d187bc | 19458 | { |
d62a17ae | 19459 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19460 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19461 | } |
19462 | ||
4378f57c DA |
19463 | DEFUN (no_lcommunity_list_all, |
19464 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19465 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19466 | NO_STR | |
19467 | BGP_STR | |
19468 | LCOMMUNITY_LIST_STR | |
19469 | "Large Community list number (standard)\n" | |
19470 | "Large Community list number (expanded)\n" | |
19471 | "Large Community list name\n") | |
57d187bc | 19472 | { |
7336e101 SP |
19473 | return lcommunity_list_unset_vty(vty, argc, argv, |
19474 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19475 | } |
19476 | ||
4378f57c DA |
19477 | DEFUN (no_lcommunity_list_name_standard_all, |
19478 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19479 | "no bgp large-community-list standard WORD", | |
19480 | NO_STR | |
19481 | BGP_STR | |
19482 | LCOMMUNITY_LIST_STR | |
19483 | "Specify standard large-community-list\n" | |
19484 | "Large Community list name\n") | |
19485 | { | |
19486 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19487 | LARGE_COMMUNITY_LIST_STANDARD); | |
19488 | } | |
19489 | ||
7336e101 SP |
19490 | DEFUN (no_lcommunity_list_name_expanded_all, |
19491 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19492 | "no bgp large-community-list expanded WORD", | |
19493 | NO_STR | |
19494 | BGP_STR | |
19495 | LCOMMUNITY_LIST_STR | |
19496 | "Specify expanded large-community-list\n" | |
19497 | "Large Community list name\n") | |
57d187bc | 19498 | { |
d62a17ae | 19499 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19500 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19501 | } |
19502 | ||
7336e101 SP |
19503 | DEFUN (no_lcommunity_list_standard, |
19504 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19505 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19506 | NO_STR |
19507 | BGP_STR | |
19508 | LCOMMUNITY_LIST_STR | |
19509 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19510 | "Sequence number of an entry\n" |
19511 | "Sequence number\n" | |
7336e101 SP |
19512 | "Specify large community to reject\n" |
19513 | "Specify large community to accept\n" | |
19514 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19515 | { |
d62a17ae | 19516 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19517 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19518 | } |
19519 | ||
7336e101 SP |
19520 | DEFUN (no_lcommunity_list_expanded, |
19521 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19522 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19523 | NO_STR |
19524 | BGP_STR | |
19525 | LCOMMUNITY_LIST_STR | |
19526 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19527 | "Sequence number of an entry\n" |
19528 | "Sequence number\n" | |
7336e101 SP |
19529 | "Specify large community to reject\n" |
19530 | "Specify large community to accept\n" | |
19531 | "An ordered list as a regular-expression\n") | |
57d187bc | 19532 | { |
d62a17ae | 19533 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19534 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19535 | } |
19536 | ||
7336e101 SP |
19537 | DEFUN (no_lcommunity_list_name_standard, |
19538 | no_bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19539 | "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19540 | NO_STR |
19541 | BGP_STR | |
19542 | LCOMMUNITY_LIST_STR | |
19543 | "Specify standard large-community-list\n" | |
19544 | "Large Community list name\n" | |
2f8cc0e5 DA |
19545 | "Sequence number of an entry\n" |
19546 | "Sequence number\n" | |
7336e101 SP |
19547 | "Specify large community to reject\n" |
19548 | "Specify large community to accept\n" | |
19549 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19550 | { |
d62a17ae | 19551 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19552 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19553 | } |
19554 | ||
7336e101 SP |
19555 | DEFUN (no_lcommunity_list_name_expanded, |
19556 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19557 | "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19558 | NO_STR |
19559 | BGP_STR | |
19560 | LCOMMUNITY_LIST_STR | |
19561 | "Specify expanded large-community-list\n" | |
19562 | "Large community list name\n" | |
2f8cc0e5 DA |
19563 | "Sequence number of an entry\n" |
19564 | "Sequence number\n" | |
7336e101 SP |
19565 | "Specify large community to reject\n" |
19566 | "Specify large community to accept\n" | |
19567 | "An ordered list as a regular-expression\n") | |
57d187bc | 19568 | { |
d62a17ae | 19569 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19570 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19571 | } |
19572 | ||
d62a17ae | 19573 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19574 | { | |
19575 | struct community_entry *entry; | |
19576 | ||
19577 | for (entry = list->head; entry; entry = entry->next) { | |
19578 | if (entry == list->head) { | |
19579 | if (all_digit(list->name)) | |
19580 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19581 | entry->style == |
19582 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19583 | ? "standard" |
19584 | : "(expanded) access", | |
19585 | list->name); | |
19586 | else | |
19587 | vty_out(vty, | |
19588 | "Named large community %s list %s\n", | |
169b72c8 | 19589 | entry->style == |
19590 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19591 | ? "standard" |
19592 | : "expanded", | |
19593 | list->name); | |
19594 | } | |
19595 | if (entry->any) | |
19596 | vty_out(vty, " %s\n", | |
19597 | community_direct_str(entry->direct)); | |
19598 | else | |
19599 | vty_out(vty, " %s %s\n", | |
19600 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19601 | community_list_config_str(entry)); |
d62a17ae | 19602 | } |
57d187bc JS |
19603 | } |
19604 | ||
7336e101 SP |
19605 | DEFUN (show_lcommunity_list, |
19606 | show_bgp_lcommunity_list_cmd, | |
19607 | "show bgp large-community-list", | |
57d187bc | 19608 | SHOW_STR |
7336e101 | 19609 | BGP_STR |
57d187bc JS |
19610 | "List large-community list\n") |
19611 | { | |
d62a17ae | 19612 | struct community_list *list; |
19613 | struct community_list_master *cm; | |
57d187bc | 19614 | |
d62a17ae | 19615 | cm = community_list_master_lookup(bgp_clist, |
19616 | LARGE_COMMUNITY_LIST_MASTER); | |
19617 | if (!cm) | |
19618 | return CMD_SUCCESS; | |
57d187bc | 19619 | |
d62a17ae | 19620 | for (list = cm->num.head; list; list = list->next) |
19621 | lcommunity_list_show(vty, list); | |
57d187bc | 19622 | |
d62a17ae | 19623 | for (list = cm->str.head; list; list = list->next) |
19624 | lcommunity_list_show(vty, list); | |
57d187bc | 19625 | |
d62a17ae | 19626 | return CMD_SUCCESS; |
57d187bc JS |
19627 | } |
19628 | ||
7336e101 SP |
19629 | DEFUN (show_lcommunity_list_arg, |
19630 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19631 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19632 | SHOW_STR |
19633 | BGP_STR | |
57d187bc | 19634 | "List large-community list\n" |
960b69b9 | 19635 | "Large-community-list number\n" |
19636 | "Large-community-list name\n" | |
19637 | "Detailed information on large-community-list\n") | |
57d187bc | 19638 | { |
d62a17ae | 19639 | struct community_list *list; |
57d187bc | 19640 | |
e237b0d2 | 19641 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19642 | LARGE_COMMUNITY_LIST_MASTER); |
19643 | if (!list) { | |
960b69b9 | 19644 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19645 | return CMD_WARNING; |
19646 | } | |
57d187bc | 19647 | |
d62a17ae | 19648 | lcommunity_list_show(vty, list); |
57d187bc | 19649 | |
d62a17ae | 19650 | return CMD_SUCCESS; |
57d187bc JS |
19651 | } |
19652 | ||
718e3744 | 19653 | /* "extcommunity-list" keyword help string. */ |
19654 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19655 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19656 | ||
7336e101 SP |
19657 | DEFUN (extcommunity_list_standard, |
19658 | bgp_extcommunity_list_standard_cmd, | |
a08032fe | 19659 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19660 | BGP_STR |
718e3744 | 19661 | EXTCOMMUNITY_LIST_STR |
19662 | "Extended Community list number (standard)\n" | |
718e3744 | 19663 | "Specify standard extcommunity-list\n" |
5bf15956 | 19664 | "Community list name\n" |
2f8cc0e5 DA |
19665 | "Sequence number of an entry\n" |
19666 | "Sequence number\n" | |
718e3744 | 19667 | "Specify community to reject\n" |
19668 | "Specify community to accept\n" | |
19669 | EXTCOMMUNITY_VAL_STR) | |
19670 | { | |
d62a17ae | 19671 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19672 | int direct = 0; | |
19673 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19674 | char *seq = NULL; |
42f914d4 | 19675 | |
d62a17ae | 19676 | int idx = 0; |
7b9a4750 | 19677 | |
d62a17ae | 19678 | argv_find(argv, argc, "(1-99)", &idx); |
19679 | argv_find(argv, argc, "WORD", &idx); | |
19680 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19681 | |
a08032fe | 19682 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19683 | seq = argv[idx]->arg; |
19684 | ||
d62a17ae | 19685 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19686 | : COMMUNITY_DENY; | |
19687 | argv_find(argv, argc, "AA:NN", &idx); | |
19688 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19689 | |
2f8cc0e5 | 19690 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19691 | direct, style); |
42f914d4 | 19692 | |
d62a17ae | 19693 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19694 | |
d62a17ae | 19695 | if (ret < 0) { |
19696 | community_list_perror(vty, ret); | |
19697 | return CMD_WARNING_CONFIG_FAILED; | |
19698 | } | |
42f914d4 | 19699 | |
d62a17ae | 19700 | return CMD_SUCCESS; |
718e3744 | 19701 | } |
19702 | ||
7336e101 SP |
19703 | DEFUN (extcommunity_list_name_expanded, |
19704 | bgp_extcommunity_list_name_expanded_cmd, | |
a08032fe | 19705 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19706 | BGP_STR |
19707 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19708 | "Extended Community list number (expanded)\n" |
718e3744 | 19709 | "Specify expanded extcommunity-list\n" |
19710 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19711 | "Sequence number of an entry\n" |
19712 | "Sequence number\n" | |
718e3744 | 19713 | "Specify community to reject\n" |
19714 | "Specify community to accept\n" | |
19715 | "An ordered list as a regular-expression\n") | |
19716 | { | |
d62a17ae | 19717 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19718 | int direct = 0; | |
19719 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19720 | char *seq = NULL; |
d62a17ae | 19721 | int idx = 0; |
7336e101 | 19722 | |
d62a17ae | 19723 | argv_find(argv, argc, "(100-500)", &idx); |
19724 | argv_find(argv, argc, "WORD", &idx); | |
19725 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19726 | |
a08032fe | 19727 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19728 | seq = argv[idx]->arg; |
19729 | ||
d62a17ae | 19730 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19731 | : COMMUNITY_DENY; | |
19732 | argv_find(argv, argc, "LINE", &idx); | |
19733 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19734 | |
2f8cc0e5 | 19735 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19736 | direct, style); |
42f914d4 | 19737 | |
d62a17ae | 19738 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19739 | |
d62a17ae | 19740 | if (ret < 0) { |
19741 | community_list_perror(vty, ret); | |
19742 | return CMD_WARNING_CONFIG_FAILED; | |
19743 | } | |
42f914d4 | 19744 | |
d62a17ae | 19745 | return CMD_SUCCESS; |
718e3744 | 19746 | } |
19747 | ||
7336e101 SP |
19748 | DEFUN (no_extcommunity_list_standard_all, |
19749 | no_bgp_extcommunity_list_standard_all_cmd, | |
a08032fe | 19750 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19751 | NO_STR |
19752 | BGP_STR | |
19753 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19754 | "Extended Community list number (standard)\n" |
718e3744 | 19755 | "Specify standard extcommunity-list\n" |
5bf15956 | 19756 | "Community list name\n" |
2f8cc0e5 DA |
19757 | "Sequence number of an entry\n" |
19758 | "Sequence number\n" | |
718e3744 | 19759 | "Specify community to reject\n" |
19760 | "Specify community to accept\n" | |
19761 | EXTCOMMUNITY_VAL_STR) | |
19762 | { | |
d62a17ae | 19763 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19764 | int direct = 0; | |
19765 | char *cl_number_or_name = NULL; | |
d4455c89 | 19766 | char *str = NULL; |
2f8cc0e5 | 19767 | char *seq = NULL; |
d62a17ae | 19768 | int idx = 0; |
d4455c89 | 19769 | |
a08032fe | 19770 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19771 | seq = argv[idx]->arg; |
19772 | ||
19773 | idx = 0; | |
d4455c89 DA |
19774 | argv_find(argv, argc, "permit", &idx); |
19775 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19776 | if (idx) { |
19777 | direct = argv_find(argv, argc, "permit", &idx) | |
19778 | ? COMMUNITY_PERMIT | |
19779 | : COMMUNITY_DENY; | |
19780 | ||
19781 | idx = 0; | |
19782 | argv_find(argv, argc, "AA:NN", &idx); | |
19783 | str = argv_concat(argv, argc, idx); | |
19784 | } | |
19785 | ||
19786 | idx = 0; | |
d62a17ae | 19787 | argv_find(argv, argc, "(1-99)", &idx); |
19788 | argv_find(argv, argc, "WORD", &idx); | |
19789 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19790 | |
d62a17ae | 19791 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19792 | seq, direct, style); |
42f914d4 | 19793 | |
d62a17ae | 19794 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19795 | |
d62a17ae | 19796 | if (ret < 0) { |
19797 | community_list_perror(vty, ret); | |
19798 | return CMD_WARNING_CONFIG_FAILED; | |
19799 | } | |
42f914d4 | 19800 | |
d62a17ae | 19801 | return CMD_SUCCESS; |
718e3744 | 19802 | } |
19803 | ||
d4455c89 DA |
19804 | ALIAS(no_extcommunity_list_standard_all, |
19805 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19806 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19807 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19808 | "Extended Community list number (standard)\n" |
19809 | "Specify standard extcommunity-list\n" | |
19810 | "Community list name\n") | |
19811 | ||
7336e101 SP |
19812 | DEFUN (no_extcommunity_list_expanded_all, |
19813 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a08032fe | 19814 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19815 | NO_STR |
19816 | BGP_STR | |
19817 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19818 | "Extended Community list number (expanded)\n" |
718e3744 | 19819 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19820 | "Extended Community list name\n" |
2f8cc0e5 DA |
19821 | "Sequence number of an entry\n" |
19822 | "Sequence number\n" | |
718e3744 | 19823 | "Specify community to reject\n" |
19824 | "Specify community to accept\n" | |
19825 | "An ordered list as a regular-expression\n") | |
19826 | { | |
d62a17ae | 19827 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19828 | int direct = 0; | |
19829 | char *cl_number_or_name = NULL; | |
d4455c89 | 19830 | char *str = NULL; |
2f8cc0e5 | 19831 | char *seq = NULL; |
d62a17ae | 19832 | int idx = 0; |
d4455c89 | 19833 | |
a08032fe | 19834 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19835 | seq = argv[idx]->arg; |
19836 | ||
19837 | idx = 0; | |
d4455c89 DA |
19838 | argv_find(argv, argc, "permit", &idx); |
19839 | argv_find(argv, argc, "deny", &idx); | |
19840 | ||
19841 | if (idx) { | |
19842 | direct = argv_find(argv, argc, "permit", &idx) | |
19843 | ? COMMUNITY_PERMIT | |
19844 | : COMMUNITY_DENY; | |
19845 | ||
19846 | idx = 0; | |
19847 | argv_find(argv, argc, "LINE", &idx); | |
19848 | str = argv_concat(argv, argc, idx); | |
19849 | } | |
19850 | ||
19851 | idx = 0; | |
d62a17ae | 19852 | argv_find(argv, argc, "(100-500)", &idx); |
19853 | argv_find(argv, argc, "WORD", &idx); | |
19854 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19855 | |
d62a17ae | 19856 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19857 | seq, direct, style); |
42f914d4 | 19858 | |
d62a17ae | 19859 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19860 | |
d62a17ae | 19861 | if (ret < 0) { |
19862 | community_list_perror(vty, ret); | |
19863 | return CMD_WARNING_CONFIG_FAILED; | |
19864 | } | |
42f914d4 | 19865 | |
d62a17ae | 19866 | return CMD_SUCCESS; |
718e3744 | 19867 | } |
19868 | ||
d4455c89 DA |
19869 | ALIAS(no_extcommunity_list_expanded_all, |
19870 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19871 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 19872 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19873 | "Extended Community list number (expanded)\n" |
19874 | "Specify expanded extcommunity-list\n" | |
19875 | "Extended Community list name\n") | |
19876 | ||
d62a17ae | 19877 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19878 | { |
d62a17ae | 19879 | struct community_entry *entry; |
718e3744 | 19880 | |
d62a17ae | 19881 | for (entry = list->head; entry; entry = entry->next) { |
19882 | if (entry == list->head) { | |
19883 | if (all_digit(list->name)) | |
19884 | vty_out(vty, "Extended community %s list %s\n", | |
19885 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19886 | ? "standard" | |
19887 | : "(expanded) access", | |
19888 | list->name); | |
19889 | else | |
19890 | vty_out(vty, | |
19891 | "Named extended community %s list %s\n", | |
19892 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19893 | ? "standard" | |
19894 | : "expanded", | |
19895 | list->name); | |
19896 | } | |
19897 | if (entry->any) | |
19898 | vty_out(vty, " %s\n", | |
19899 | community_direct_str(entry->direct)); | |
19900 | else | |
19901 | vty_out(vty, " %s %s\n", | |
19902 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19903 | community_list_config_str(entry)); |
d62a17ae | 19904 | } |
718e3744 | 19905 | } |
19906 | ||
7336e101 SP |
19907 | DEFUN (show_extcommunity_list, |
19908 | show_bgp_extcommunity_list_cmd, | |
19909 | "show bgp extcommunity-list", | |
718e3744 | 19910 | SHOW_STR |
7336e101 | 19911 | BGP_STR |
718e3744 | 19912 | "List extended-community list\n") |
19913 | { | |
d62a17ae | 19914 | struct community_list *list; |
19915 | struct community_list_master *cm; | |
718e3744 | 19916 | |
d62a17ae | 19917 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
19918 | if (!cm) | |
19919 | return CMD_SUCCESS; | |
718e3744 | 19920 | |
d62a17ae | 19921 | for (list = cm->num.head; list; list = list->next) |
19922 | extcommunity_list_show(vty, list); | |
718e3744 | 19923 | |
d62a17ae | 19924 | for (list = cm->str.head; list; list = list->next) |
19925 | extcommunity_list_show(vty, list); | |
718e3744 | 19926 | |
d62a17ae | 19927 | return CMD_SUCCESS; |
718e3744 | 19928 | } |
19929 | ||
7336e101 SP |
19930 | DEFUN (show_extcommunity_list_arg, |
19931 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 19932 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
19933 | SHOW_STR |
19934 | BGP_STR | |
718e3744 | 19935 | "List extended-community list\n" |
19936 | "Extcommunity-list number\n" | |
960b69b9 | 19937 | "Extcommunity-list name\n" |
19938 | "Detailed information on extcommunity-list\n") | |
718e3744 | 19939 | { |
d62a17ae | 19940 | int idx_comm_list = 3; |
19941 | struct community_list *list; | |
718e3744 | 19942 | |
e237b0d2 | 19943 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19944 | EXTCOMMUNITY_LIST_MASTER); |
19945 | if (!list) { | |
19946 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
19947 | return CMD_WARNING; | |
19948 | } | |
718e3744 | 19949 | |
d62a17ae | 19950 | extcommunity_list_show(vty, list); |
718e3744 | 19951 | |
d62a17ae | 19952 | return CMD_SUCCESS; |
718e3744 | 19953 | } |
6b0655a2 | 19954 | |
718e3744 | 19955 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 19956 | static int community_list_config_write(struct vty *vty) |
19957 | { | |
19958 | struct community_list *list; | |
19959 | struct community_entry *entry; | |
19960 | struct community_list_master *cm; | |
19961 | int write = 0; | |
19962 | ||
19963 | /* Community-list. */ | |
19964 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
19965 | ||
19966 | for (list = cm->num.head; list; list = list->next) | |
19967 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19968 | vty_out(vty, |
19969 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
19970 | list->name, entry->seq, | |
d62a17ae | 19971 | community_direct_str(entry->direct), |
19972 | community_list_config_str(entry)); | |
19973 | write++; | |
19974 | } | |
19975 | for (list = cm->str.head; list; list = list->next) | |
19976 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19977 | vty_out(vty, |
19978 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 19979 | entry->style == COMMUNITY_LIST_STANDARD |
19980 | ? "standard" | |
19981 | : "expanded", | |
2f8cc0e5 DA |
19982 | list->name, entry->seq, |
19983 | community_direct_str(entry->direct), | |
d62a17ae | 19984 | community_list_config_str(entry)); |
19985 | write++; | |
19986 | } | |
19987 | ||
19988 | /* Extcommunity-list. */ | |
19989 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
19990 | ||
19991 | for (list = cm->num.head; list; list = list->next) | |
19992 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
19993 | vty_out(vty, |
19994 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
19995 | list->name, entry->seq, | |
19996 | community_direct_str(entry->direct), | |
d62a17ae | 19997 | community_list_config_str(entry)); |
19998 | write++; | |
19999 | } | |
20000 | for (list = cm->str.head; list; list = list->next) | |
20001 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20002 | vty_out(vty, |
6cde4b45 | 20003 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20004 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20005 | ? "standard" | |
20006 | : "expanded", | |
2f8cc0e5 DA |
20007 | list->name, entry->seq, |
20008 | community_direct_str(entry->direct), | |
d62a17ae | 20009 | community_list_config_str(entry)); |
20010 | write++; | |
20011 | } | |
20012 | ||
20013 | ||
20014 | /* lcommunity-list. */ | |
20015 | cm = community_list_master_lookup(bgp_clist, | |
20016 | LARGE_COMMUNITY_LIST_MASTER); | |
20017 | ||
20018 | for (list = cm->num.head; list; list = list->next) | |
20019 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20020 | vty_out(vty, |
6cde4b45 | 20021 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20022 | list->name, entry->seq, |
20023 | community_direct_str(entry->direct), | |
d62a17ae | 20024 | community_list_config_str(entry)); |
20025 | write++; | |
20026 | } | |
20027 | for (list = cm->str.head; list; list = list->next) | |
20028 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20029 | vty_out(vty, |
6cde4b45 | 20030 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20031 | |
d62a17ae | 20032 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20033 | ? "standard" | |
20034 | : "expanded", | |
2f8cc0e5 | 20035 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20036 | community_list_config_str(entry)); |
20037 | write++; | |
20038 | } | |
20039 | ||
20040 | return write; | |
20041 | } | |
20042 | ||
612c2c15 | 20043 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20044 | static struct cmd_node community_list_node = { |
f4b8291f | 20045 | .name = "community list", |
62b346ee DL |
20046 | .node = COMMUNITY_LIST_NODE, |
20047 | .prompt = "", | |
612c2c15 | 20048 | .config_write = community_list_config_write, |
718e3744 | 20049 | }; |
20050 | ||
d62a17ae | 20051 | static void community_list_vty(void) |
20052 | { | |
612c2c15 | 20053 | install_node(&community_list_node); |
d62a17ae | 20054 | |
20055 | /* Community-list. */ | |
7336e101 SP |
20056 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20057 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20058 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20059 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20060 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20061 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20062 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20063 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20064 | |
20065 | /* Extcommunity-list. */ | |
7336e101 SP |
20066 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20067 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20068 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20069 | install_element(CONFIG_NODE, |
20070 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20071 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20072 | install_element(CONFIG_NODE, |
20073 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20074 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20075 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20076 | |
20077 | /* Large Community List */ | |
7336e101 | 20078 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20079 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20080 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20081 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20082 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20083 | install_element(CONFIG_NODE, | |
20084 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20085 | install_element(CONFIG_NODE, |
20086 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20087 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20088 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20089 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20090 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20091 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20092 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
20093 | |
20094 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 20095 | } |
ed0e57e3 DA |
20096 | |
20097 | static struct cmd_node community_alias_node = { | |
20098 | .name = "community alias", | |
20099 | .node = COMMUNITY_ALIAS_NODE, | |
20100 | .prompt = "", | |
20101 | .config_write = bgp_community_alias_write, | |
20102 | }; | |
20103 | ||
20104 | void community_alias_vty(void) | |
20105 | { | |
20106 | install_node(&community_alias_node); | |
20107 | ||
20108 | /* Community-list. */ | |
20109 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
20110 | |
20111 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 20112 | } |