]>
Commit | Line | Data |
---|---|---|
1 | /* BGP VTY interface. | |
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 | */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
24 | #include "lib/json.h" | |
25 | #include "lib/sockopt.h" | |
26 | #include "lib_errors.h" | |
27 | #include "lib/zclient.h" | |
28 | #include "lib/printfrr.h" | |
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" | |
36 | #include "memory.h" | |
37 | #include "lib_vty.h" | |
38 | #include "hash.h" | |
39 | #include "queue.h" | |
40 | #include "filter.h" | |
41 | #include "frrstr.h" | |
42 | ||
43 | #include "bgpd/bgpd.h" | |
44 | #include "bgpd/bgp_attr_evpn.h" | |
45 | #include "bgpd/bgp_advertise.h" | |
46 | #include "bgpd/bgp_attr.h" | |
47 | #include "bgpd/bgp_aspath.h" | |
48 | #include "bgpd/bgp_community.h" | |
49 | #include "bgpd/bgp_community_alias.h" | |
50 | #include "bgpd/bgp_ecommunity.h" | |
51 | #include "bgpd/bgp_lcommunity.h" | |
52 | #include "bgpd/bgp_damp.h" | |
53 | #include "bgpd/bgp_debug.h" | |
54 | #include "bgpd/bgp_errors.h" | |
55 | #include "bgpd/bgp_fsm.h" | |
56 | #include "bgpd/bgp_nexthop.h" | |
57 | #include "bgpd/bgp_network.h" | |
58 | #include "bgpd/bgp_open.h" | |
59 | #include "bgpd/bgp_regex.h" | |
60 | #include "bgpd/bgp_route.h" | |
61 | #include "bgpd/bgp_mplsvpn.h" | |
62 | #include "bgpd/bgp_zebra.h" | |
63 | #include "bgpd/bgp_table.h" | |
64 | #include "bgpd/bgp_vty.h" | |
65 | #include "bgpd/bgp_mpath.h" | |
66 | #include "bgpd/bgp_packet.h" | |
67 | #include "bgpd/bgp_updgrp.h" | |
68 | #include "bgpd/bgp_bfd.h" | |
69 | #include "bgpd/bgp_io.h" | |
70 | #include "bgpd/bgp_evpn.h" | |
71 | #include "bgpd/bgp_evpn_vty.h" | |
72 | #include "bgpd/bgp_evpn_mh.h" | |
73 | #include "bgpd/bgp_addpath.h" | |
74 | #include "bgpd/bgp_mac.h" | |
75 | #include "bgpd/bgp_flowspec.h" | |
76 | #include "bgpd/bgp_conditional_adv.h" | |
77 | #ifdef ENABLE_BGP_VNC | |
78 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" | |
79 | #endif | |
80 | ||
81 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, | |
82 | { | |
83 | .val_bool = false, | |
84 | .match_profile = "traditional", | |
85 | .match_version = "< 7.4", | |
86 | }, | |
87 | { .val_bool = true }, | |
88 | ); | |
89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
90 | { .val_bool = true, .match_profile = "datacenter", }, | |
91 | { .val_bool = false }, | |
92 | ); | |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, | |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
96 | ); | |
97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
98 | { .val_bool = true, .match_profile = "datacenter", }, | |
99 | { .val_bool = false }, | |
100 | ); | |
101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
102 | { .val_bool = true, .match_profile = "datacenter", }, | |
103 | { .val_bool = false }, | |
104 | ); | |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
108 | ); | |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
112 | ); | |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
116 | ); | |
117 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, | |
118 | { .val_bool = false, .match_profile = "datacenter", }, | |
119 | { .val_bool = false, .match_version = "< 7.4", }, | |
120 | { .val_bool = true }, | |
121 | ); | |
122 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, | |
123 | { .val_bool = false, .match_version = "< 7.6", }, | |
124 | { .val_bool = true }, | |
125 | ); | |
126 | ||
127 | DEFINE_HOOK(bgp_inst_config_write, | |
128 | (struct bgp *bgp, struct vty *vty), | |
129 | (bgp, vty)); | |
130 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
131 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); | |
132 | ||
133 | static struct peer_group *listen_range_exists(struct bgp *bgp, | |
134 | struct prefix *range, int exact); | |
135 | ||
136 | /* Show BGP peer's information. */ | |
137 | enum show_type { | |
138 | show_all, | |
139 | show_peer, | |
140 | show_ipv4_all, | |
141 | show_ipv6_all, | |
142 | show_ipv4_peer, | |
143 | show_ipv6_peer | |
144 | }; | |
145 | ||
146 | static struct peer_group *listen_range_exists(struct bgp *bgp, | |
147 | struct prefix *range, int exact); | |
148 | ||
149 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
150 | struct bgp *bgp, | |
151 | bool use_json, | |
152 | json_object *json); | |
153 | ||
154 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, | |
155 | enum show_type type, | |
156 | const char *ip_str, | |
157 | afi_t afi, bool use_json); | |
158 | ||
159 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
160 | { | |
161 | switch (afi) { | |
162 | case AFI_IP: | |
163 | switch (safi) { | |
164 | case SAFI_UNICAST: | |
165 | return BGP_IPV4_NODE; | |
166 | case SAFI_MULTICAST: | |
167 | return BGP_IPV4M_NODE; | |
168 | case SAFI_LABELED_UNICAST: | |
169 | return BGP_IPV4L_NODE; | |
170 | case SAFI_MPLS_VPN: | |
171 | return BGP_VPNV4_NODE; | |
172 | case SAFI_FLOWSPEC: | |
173 | return BGP_FLOWSPECV4_NODE; | |
174 | default: | |
175 | /* not expected */ | |
176 | return BGP_IPV4_NODE; | |
177 | } | |
178 | case AFI_IP6: | |
179 | switch (safi) { | |
180 | case SAFI_UNICAST: | |
181 | return BGP_IPV6_NODE; | |
182 | case SAFI_MULTICAST: | |
183 | return BGP_IPV6M_NODE; | |
184 | case SAFI_LABELED_UNICAST: | |
185 | return BGP_IPV6L_NODE; | |
186 | case SAFI_MPLS_VPN: | |
187 | return BGP_VPNV6_NODE; | |
188 | case SAFI_FLOWSPEC: | |
189 | return BGP_FLOWSPECV6_NODE; | |
190 | default: | |
191 | /* not expected */ | |
192 | return BGP_IPV4_NODE; | |
193 | } | |
194 | case AFI_L2VPN: | |
195 | return BGP_EVPN_NODE; | |
196 | case AFI_UNSPEC: | |
197 | case AFI_MAX: | |
198 | // We should never be here but to clarify the switch statement.. | |
199 | return BGP_IPV4_NODE; | |
200 | } | |
201 | ||
202 | // Impossible to happen | |
203 | return BGP_IPV4_NODE; | |
204 | } | |
205 | ||
206 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) | |
207 | { | |
208 | if (afi == AFI_IP) { | |
209 | if (safi == SAFI_UNICAST) | |
210 | return "IPv4 Unicast"; | |
211 | if (safi == SAFI_MULTICAST) | |
212 | return "IPv4 Multicast"; | |
213 | if (safi == SAFI_LABELED_UNICAST) | |
214 | return "IPv4 Labeled Unicast"; | |
215 | if (safi == SAFI_MPLS_VPN) | |
216 | return "IPv4 VPN"; | |
217 | if (safi == SAFI_ENCAP) | |
218 | return "IPv4 Encap"; | |
219 | if (safi == SAFI_FLOWSPEC) | |
220 | return "IPv4 Flowspec"; | |
221 | } else if (afi == AFI_IP6) { | |
222 | if (safi == SAFI_UNICAST) | |
223 | return "IPv6 Unicast"; | |
224 | if (safi == SAFI_MULTICAST) | |
225 | return "IPv6 Multicast"; | |
226 | if (safi == SAFI_LABELED_UNICAST) | |
227 | return "IPv6 Labeled Unicast"; | |
228 | if (safi == SAFI_MPLS_VPN) | |
229 | return "IPv6 VPN"; | |
230 | if (safi == SAFI_ENCAP) | |
231 | return "IPv6 Encap"; | |
232 | if (safi == SAFI_FLOWSPEC) | |
233 | return "IPv6 Flowspec"; | |
234 | } else if (afi == AFI_L2VPN) { | |
235 | if (safi == SAFI_EVPN) | |
236 | return "L2VPN EVPN"; | |
237 | } | |
238 | ||
239 | return "Unknown"; | |
240 | } | |
241 | ||
242 | /* | |
243 | * Please note that we have intentionally camelCased | |
244 | * the return strings here. So if you want | |
245 | * to use this function, please ensure you | |
246 | * are doing this within json output | |
247 | */ | |
248 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
249 | { | |
250 | if (afi == AFI_IP) { | |
251 | if (safi == SAFI_UNICAST) | |
252 | return "ipv4Unicast"; | |
253 | if (safi == SAFI_MULTICAST) | |
254 | return "ipv4Multicast"; | |
255 | if (safi == SAFI_LABELED_UNICAST) | |
256 | return "ipv4LabeledUnicast"; | |
257 | if (safi == SAFI_MPLS_VPN) | |
258 | return "ipv4Vpn"; | |
259 | if (safi == SAFI_ENCAP) | |
260 | return "ipv4Encap"; | |
261 | if (safi == SAFI_FLOWSPEC) | |
262 | return "ipv4Flowspec"; | |
263 | } else if (afi == AFI_IP6) { | |
264 | if (safi == SAFI_UNICAST) | |
265 | return "ipv6Unicast"; | |
266 | if (safi == SAFI_MULTICAST) | |
267 | return "ipv6Multicast"; | |
268 | if (safi == SAFI_LABELED_UNICAST) | |
269 | return "ipv6LabeledUnicast"; | |
270 | if (safi == SAFI_MPLS_VPN) | |
271 | return "ipv6Vpn"; | |
272 | if (safi == SAFI_ENCAP) | |
273 | return "ipv6Encap"; | |
274 | if (safi == SAFI_FLOWSPEC) | |
275 | return "ipv6Flowspec"; | |
276 | } else if (afi == AFI_L2VPN) { | |
277 | if (safi == SAFI_EVPN) | |
278 | return "l2VpnEvpn"; | |
279 | } | |
280 | ||
281 | return "Unknown"; | |
282 | } | |
283 | ||
284 | /* unset srv6 locator */ | |
285 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
286 | { | |
287 | int ret; | |
288 | struct listnode *node, *nnode; | |
289 | struct prefix_ipv6 *chunk; | |
290 | struct bgp_srv6_function *func; | |
291 | struct bgp *bgp_vrf; | |
292 | struct in6_addr *tovpn_sid; | |
293 | ||
294 | /* release chunk notification via ZAPI */ | |
295 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
296 | bgp->srv6_locator_name); | |
297 | if (ret < 0) | |
298 | return -1; | |
299 | ||
300 | /* refresh chunks */ | |
301 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) | |
302 | listnode_delete(bgp->srv6_locator_chunks, chunk); | |
303 | ||
304 | /* refresh functions */ | |
305 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) | |
306 | listnode_delete(bgp->srv6_functions, func); | |
307 | ||
308 | /* refresh tovpn_sid */ | |
309 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
310 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
311 | continue; | |
312 | ||
313 | /* refresh vpnv4 tovpn_sid */ | |
314 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP].tovpn_sid; | |
315 | if (tovpn_sid) | |
316 | XFREE(MTYPE_BGP_SRV6_SID, | |
317 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
318 | ||
319 | /* refresh vpnv6 tovpn_sid */ | |
320 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid; | |
321 | if (tovpn_sid) | |
322 | XFREE(MTYPE_BGP_SRV6_SID, | |
323 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
324 | } | |
325 | ||
326 | /* update vpn bgp processes */ | |
327 | vpn_leak_postchange_all(); | |
328 | ||
329 | /* clear locator name */ | |
330 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
331 | ||
332 | return 0; | |
333 | } | |
334 | ||
335 | /* Utility function to get address family from current node. */ | |
336 | afi_t bgp_node_afi(struct vty *vty) | |
337 | { | |
338 | afi_t afi; | |
339 | switch (vty->node) { | |
340 | case BGP_IPV6_NODE: | |
341 | case BGP_IPV6M_NODE: | |
342 | case BGP_IPV6L_NODE: | |
343 | case BGP_VPNV6_NODE: | |
344 | case BGP_FLOWSPECV6_NODE: | |
345 | afi = AFI_IP6; | |
346 | break; | |
347 | case BGP_EVPN_NODE: | |
348 | afi = AFI_L2VPN; | |
349 | break; | |
350 | default: | |
351 | afi = AFI_IP; | |
352 | break; | |
353 | } | |
354 | return afi; | |
355 | } | |
356 | ||
357 | /* Utility function to get subsequent address family from current | |
358 | node. */ | |
359 | safi_t bgp_node_safi(struct vty *vty) | |
360 | { | |
361 | safi_t safi; | |
362 | switch (vty->node) { | |
363 | case BGP_VPNV4_NODE: | |
364 | case BGP_VPNV6_NODE: | |
365 | safi = SAFI_MPLS_VPN; | |
366 | break; | |
367 | case BGP_IPV4M_NODE: | |
368 | case BGP_IPV6M_NODE: | |
369 | safi = SAFI_MULTICAST; | |
370 | break; | |
371 | case BGP_EVPN_NODE: | |
372 | safi = SAFI_EVPN; | |
373 | break; | |
374 | case BGP_IPV4L_NODE: | |
375 | case BGP_IPV6L_NODE: | |
376 | safi = SAFI_LABELED_UNICAST; | |
377 | break; | |
378 | case BGP_FLOWSPECV4_NODE: | |
379 | case BGP_FLOWSPECV6_NODE: | |
380 | safi = SAFI_FLOWSPEC; | |
381 | break; | |
382 | default: | |
383 | safi = SAFI_UNICAST; | |
384 | break; | |
385 | } | |
386 | return safi; | |
387 | } | |
388 | ||
389 | /** | |
390 | * Converts an AFI in string form to afi_t | |
391 | * | |
392 | * @param afi string, one of | |
393 | * - "ipv4" | |
394 | * - "ipv6" | |
395 | * - "l2vpn" | |
396 | * @return the corresponding afi_t | |
397 | */ | |
398 | afi_t bgp_vty_afi_from_str(const char *afi_str) | |
399 | { | |
400 | afi_t afi = AFI_MAX; /* unknown */ | |
401 | if (strmatch(afi_str, "ipv4")) | |
402 | afi = AFI_IP; | |
403 | else if (strmatch(afi_str, "ipv6")) | |
404 | afi = AFI_IP6; | |
405 | else if (strmatch(afi_str, "l2vpn")) | |
406 | afi = AFI_L2VPN; | |
407 | return afi; | |
408 | } | |
409 | ||
410 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
411 | afi_t *afi) | |
412 | { | |
413 | int ret = 0; | |
414 | if (argv_find(argv, argc, "ipv4", index)) { | |
415 | ret = 1; | |
416 | if (afi) | |
417 | *afi = AFI_IP; | |
418 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
419 | ret = 1; | |
420 | if (afi) | |
421 | *afi = AFI_IP6; | |
422 | } else if (argv_find(argv, argc, "l2vpn", index)) { | |
423 | ret = 1; | |
424 | if (afi) | |
425 | *afi = AFI_L2VPN; | |
426 | } | |
427 | return ret; | |
428 | } | |
429 | ||
430 | /* supports <unicast|multicast|vpn|labeled-unicast> */ | |
431 | safi_t bgp_vty_safi_from_str(const char *safi_str) | |
432 | { | |
433 | safi_t safi = SAFI_MAX; /* unknown */ | |
434 | if (strmatch(safi_str, "multicast")) | |
435 | safi = SAFI_MULTICAST; | |
436 | else if (strmatch(safi_str, "unicast")) | |
437 | safi = SAFI_UNICAST; | |
438 | else if (strmatch(safi_str, "vpn")) | |
439 | safi = SAFI_MPLS_VPN; | |
440 | else if (strmatch(safi_str, "evpn")) | |
441 | safi = SAFI_EVPN; | |
442 | else if (strmatch(safi_str, "labeled-unicast")) | |
443 | safi = SAFI_LABELED_UNICAST; | |
444 | else if (strmatch(safi_str, "flowspec")) | |
445 | safi = SAFI_FLOWSPEC; | |
446 | return safi; | |
447 | } | |
448 | ||
449 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
450 | safi_t *safi) | |
451 | { | |
452 | int ret = 0; | |
453 | if (argv_find(argv, argc, "unicast", index)) { | |
454 | ret = 1; | |
455 | if (safi) | |
456 | *safi = SAFI_UNICAST; | |
457 | } else if (argv_find(argv, argc, "multicast", index)) { | |
458 | ret = 1; | |
459 | if (safi) | |
460 | *safi = SAFI_MULTICAST; | |
461 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
462 | ret = 1; | |
463 | if (safi) | |
464 | *safi = SAFI_LABELED_UNICAST; | |
465 | } else if (argv_find(argv, argc, "vpn", index)) { | |
466 | ret = 1; | |
467 | if (safi) | |
468 | *safi = SAFI_MPLS_VPN; | |
469 | } else if (argv_find(argv, argc, "evpn", index)) { | |
470 | ret = 1; | |
471 | if (safi) | |
472 | *safi = SAFI_EVPN; | |
473 | } else if (argv_find(argv, argc, "flowspec", index)) { | |
474 | ret = 1; | |
475 | if (safi) | |
476 | *safi = SAFI_FLOWSPEC; | |
477 | } | |
478 | return ret; | |
479 | } | |
480 | ||
481 | /* | |
482 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
483 | * | |
484 | * afi | |
485 | * address-family identifier | |
486 | * | |
487 | * safi | |
488 | * subsequent address-family identifier | |
489 | * | |
490 | * Returns: | |
491 | * default_af string corresponding to the supplied afi/safi pair. | |
492 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
493 | * return -1. | |
494 | */ | |
495 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
496 | { | |
497 | switch (afi) { | |
498 | case AFI_IP: | |
499 | switch (safi) { | |
500 | case SAFI_UNICAST: | |
501 | return "ipv4-unicast"; | |
502 | case SAFI_MULTICAST: | |
503 | return "ipv4-multicast"; | |
504 | case SAFI_MPLS_VPN: | |
505 | return "ipv4-vpn"; | |
506 | case SAFI_ENCAP: | |
507 | return "ipv4-encap"; | |
508 | case SAFI_LABELED_UNICAST: | |
509 | return "ipv4-labeled-unicast"; | |
510 | case SAFI_FLOWSPEC: | |
511 | return "ipv4-flowspec"; | |
512 | default: | |
513 | return "unknown-afi/safi"; | |
514 | } | |
515 | break; | |
516 | case AFI_IP6: | |
517 | switch (safi) { | |
518 | case SAFI_UNICAST: | |
519 | return "ipv6-unicast"; | |
520 | case SAFI_MULTICAST: | |
521 | return "ipv6-multicast"; | |
522 | case SAFI_MPLS_VPN: | |
523 | return "ipv6-vpn"; | |
524 | case SAFI_ENCAP: | |
525 | return "ipv6-encap"; | |
526 | case SAFI_LABELED_UNICAST: | |
527 | return "ipv6-labeled-unicast"; | |
528 | case SAFI_FLOWSPEC: | |
529 | return "ipv6-flowspec"; | |
530 | default: | |
531 | return "unknown-afi/safi"; | |
532 | } | |
533 | break; | |
534 | case AFI_L2VPN: | |
535 | switch (safi) { | |
536 | case SAFI_EVPN: | |
537 | return "l2vpn-evpn"; | |
538 | default: | |
539 | return "unknown-afi/safi"; | |
540 | } | |
541 | case AFI_UNSPEC: | |
542 | case AFI_MAX: | |
543 | return "unknown-afi/safi"; | |
544 | } | |
545 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
546 | return "unknown-afi/safi"; | |
547 | } | |
548 | ||
549 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, | |
550 | enum bgp_instance_type inst_type) | |
551 | { | |
552 | int ret = bgp_get(bgp, as, name, inst_type); | |
553 | ||
554 | if (ret == BGP_CREATED) { | |
555 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
556 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
557 | ||
558 | if (DFLT_BGP_IMPORT_CHECK) | |
559 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); | |
560 | if (DFLT_BGP_SHOW_HOSTNAME) | |
561 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); | |
562 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) | |
563 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
564 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) | |
565 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
566 | if (DFLT_BGP_DETERMINISTIC_MED) | |
567 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); | |
568 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) | |
569 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
570 | if (DFLT_BGP_SUPPRESS_DUPLICATES) | |
571 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
572 | ||
573 | ret = BGP_SUCCESS; | |
574 | } | |
575 | return ret; | |
576 | } | |
577 | ||
578 | /* | |
579 | * bgp_vty_find_and_parse_afi_safi_bgp | |
580 | * | |
581 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it | |
582 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
583 | * to appropriate values for the calling function. This is to allow the | |
584 | * calling function to make decisions appropriate for the show command | |
585 | * that is being parsed. | |
586 | * | |
587 | * The show commands are generally of the form: | |
588 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> | |
589 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
590 | * | |
591 | * Since we use argv_find if the show command in particular doesn't have: | |
592 | * [ip] | |
593 | * [<view|vrf> VIEWVRFNAME] | |
594 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] | |
595 | * The command parsing should still be ok. | |
596 | * | |
597 | * vty -> The vty for the command so we can output some useful data in | |
598 | * the event of a parse error in the vrf. | |
599 | * argv -> The command tokens | |
600 | * argc -> How many command tokens we have | |
601 | * idx -> The current place in the command, generally should be 0 for this | |
602 | * function | |
603 | * afi -> The parsed afi if it was included in the show command, returned here | |
604 | * safi -> The parsed safi if it was included in the show command, returned here | |
605 | * bgp -> Pointer to the bgp data structure we need to fill in. | |
606 | * use_json -> json is configured or not | |
607 | * | |
608 | * The function returns the correct location in the parse tree for the | |
609 | * last token found. | |
610 | * | |
611 | * Returns 0 for failure to parse correctly, else the idx position of where | |
612 | * it found the last token. | |
613 | */ | |
614 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, | |
615 | struct cmd_token **argv, int argc, | |
616 | int *idx, afi_t *afi, safi_t *safi, | |
617 | struct bgp **bgp, bool use_json) | |
618 | { | |
619 | char *vrf_name = NULL; | |
620 | ||
621 | assert(afi); | |
622 | assert(safi); | |
623 | assert(bgp); | |
624 | ||
625 | if (argv_find(argv, argc, "ip", idx)) | |
626 | *afi = AFI_IP; | |
627 | ||
628 | if (argv_find(argv, argc, "view", idx)) | |
629 | vrf_name = argv[*idx + 1]->arg; | |
630 | else if (argv_find(argv, argc, "vrf", idx)) { | |
631 | vrf_name = argv[*idx + 1]->arg; | |
632 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
633 | vrf_name = NULL; | |
634 | } | |
635 | if (vrf_name) { | |
636 | if (strmatch(vrf_name, "all")) | |
637 | *bgp = NULL; | |
638 | else { | |
639 | *bgp = bgp_lookup_by_name(vrf_name); | |
640 | if (!*bgp) { | |
641 | if (use_json) { | |
642 | json_object *json = NULL; | |
643 | json = json_object_new_object(); | |
644 | json_object_string_add( | |
645 | json, "warning", | |
646 | "View/Vrf is unknown"); | |
647 | vty_json(vty, json); | |
648 | } | |
649 | else | |
650 | vty_out(vty, "View/Vrf %s is unknown\n", | |
651 | vrf_name); | |
652 | *idx = 0; | |
653 | return 0; | |
654 | } | |
655 | } | |
656 | } else { | |
657 | *bgp = bgp_get_default(); | |
658 | if (!*bgp) { | |
659 | if (use_json) { | |
660 | json_object *json = NULL; | |
661 | json = json_object_new_object(); | |
662 | json_object_string_add( | |
663 | json, "warning", | |
664 | "Default BGP instance not found"); | |
665 | vty_json(vty, json); | |
666 | } | |
667 | else | |
668 | vty_out(vty, | |
669 | "Default BGP instance not found\n"); | |
670 | *idx = 0; | |
671 | return 0; | |
672 | } | |
673 | } | |
674 | ||
675 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
676 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
677 | ||
678 | *idx += 1; | |
679 | return *idx; | |
680 | } | |
681 | ||
682 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
683 | { | |
684 | struct interface *ifp = NULL; | |
685 | struct listnode *node; | |
686 | struct bgp_listener *listener; | |
687 | union sockunion all_su; | |
688 | ||
689 | if (su->sa.sa_family == AF_INET) { | |
690 | (void)str2sockunion("0.0.0.0", &all_su); | |
691 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
692 | } else if (su->sa.sa_family == AF_INET6) { | |
693 | (void)str2sockunion("::", &all_su); | |
694 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
695 | su->sin6.sin6_scope_id, | |
696 | bgp->vrf_id); | |
697 | } | |
698 | ||
699 | if (ifp) { | |
700 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
701 | if (sockunion_family(su) != | |
702 | sockunion_family(&listener->su)) | |
703 | continue; | |
704 | ||
705 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
706 | * reject. | |
707 | */ | |
708 | if (!sockunion_cmp(&listener->su, su) || | |
709 | !sockunion_cmp(&listener->su, &all_su)) | |
710 | return true; | |
711 | } | |
712 | } | |
713 | ||
714 | return false; | |
715 | } | |
716 | ||
717 | /* Utility function for looking up peer from VTY. */ | |
718 | /* This is used only for configuration, so disallow if attempted on | |
719 | * a dynamic neighbor. | |
720 | */ | |
721 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
722 | { | |
723 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
724 | int ret; | |
725 | union sockunion su; | |
726 | struct peer *peer; | |
727 | ||
728 | if (!bgp) { | |
729 | return NULL; | |
730 | } | |
731 | ||
732 | ret = str2sockunion(ip_str, &su); | |
733 | if (ret < 0) { | |
734 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
735 | if (!peer) { | |
736 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
737 | == NULL) { | |
738 | vty_out(vty, | |
739 | "%% Malformed address or name: %s\n", | |
740 | ip_str); | |
741 | return NULL; | |
742 | } | |
743 | } | |
744 | } else { | |
745 | peer = peer_lookup(bgp, &su); | |
746 | if (!peer) { | |
747 | vty_out(vty, | |
748 | "%% Specify remote-as or peer-group commands first\n"); | |
749 | return NULL; | |
750 | } | |
751 | if (peer_dynamic_neighbor(peer)) { | |
752 | vty_out(vty, | |
753 | "%% Operation not allowed on a dynamic neighbor\n"); | |
754 | return NULL; | |
755 | } | |
756 | } | |
757 | return peer; | |
758 | } | |
759 | ||
760 | /* Utility function for looking up peer or peer group. */ | |
761 | /* This is used only for configuration, so disallow if attempted on | |
762 | * a dynamic neighbor. | |
763 | */ | |
764 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) | |
765 | { | |
766 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
767 | int ret; | |
768 | union sockunion su; | |
769 | struct peer *peer = NULL; | |
770 | struct peer_group *group = NULL; | |
771 | ||
772 | if (!bgp) { | |
773 | return NULL; | |
774 | } | |
775 | ||
776 | ret = str2sockunion(peer_str, &su); | |
777 | if (ret == 0) { | |
778 | /* IP address, locate peer. */ | |
779 | peer = peer_lookup(bgp, &su); | |
780 | } else { | |
781 | /* Not IP, could match either peer configured on interface or a | |
782 | * group. */ | |
783 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
784 | if (!peer) | |
785 | group = peer_group_lookup(bgp, peer_str); | |
786 | } | |
787 | ||
788 | if (peer) { | |
789 | if (peer_dynamic_neighbor(peer)) { | |
790 | vty_out(vty, | |
791 | "%% Operation not allowed on a dynamic neighbor\n"); | |
792 | return NULL; | |
793 | } | |
794 | ||
795 | return peer; | |
796 | } | |
797 | ||
798 | if (group) | |
799 | return group->conf; | |
800 | ||
801 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
802 | ||
803 | return NULL; | |
804 | } | |
805 | ||
806 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) | |
807 | { | |
808 | const char *str = NULL; | |
809 | ||
810 | switch (ret) { | |
811 | case BGP_SUCCESS: | |
812 | case BGP_CREATED: | |
813 | case BGP_GR_NO_OPERATION: | |
814 | break; | |
815 | case BGP_ERR_INVALID_VALUE: | |
816 | str = "Invalid value"; | |
817 | break; | |
818 | case BGP_ERR_INVALID_FLAG: | |
819 | str = "Invalid flag"; | |
820 | break; | |
821 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
822 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
823 | break; | |
824 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
825 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
826 | break; | |
827 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
828 | str = "Specify remote-as or peer-group remote AS first"; | |
829 | break; | |
830 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
831 | str = "Cannot change the peer-group. Deconfigure first"; | |
832 | break; | |
833 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
834 | str = "Peer is not a member of this peer-group"; | |
835 | break; | |
836 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
837 | str = "Prefix/distribute list can not co-exist"; | |
838 | break; | |
839 | case BGP_ERR_NOT_INTERNAL_PEER: | |
840 | str = "Invalid command. Not an internal neighbor"; | |
841 | break; | |
842 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
843 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
844 | break; | |
845 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
846 | str = "Local-AS allowed only for EBGP peers"; | |
847 | break; | |
848 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
849 | str = "Cannot have local-as same as BGP AS number"; | |
850 | break; | |
851 | case BGP_ERR_TCPSIG_FAILED: | |
852 | str = "Error while applying TCP-Sig to session(s)"; | |
853 | break; | |
854 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
855 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
856 | break; | |
857 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
858 | str = "ttl-security only allowed for EBGP peers"; | |
859 | break; | |
860 | case BGP_ERR_AS_OVERRIDE: | |
861 | str = "as-override cannot be configured for IBGP peers"; | |
862 | break; | |
863 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
864 | str = "Invalid limit for number of dynamic neighbors"; | |
865 | break; | |
866 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
867 | str = "Dynamic neighbor listen range already exists"; | |
868 | break; | |
869 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
870 | str = "Operation not allowed on a dynamic neighbor"; | |
871 | break; | |
872 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
873 | str = "Operation not allowed on a directly connected neighbor"; | |
874 | break; | |
875 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
876 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
877 | break; | |
878 | case BGP_ERR_GR_INVALID_CMD: | |
879 | str = "The Graceful Restart command used is not valid at this moment."; | |
880 | break; | |
881 | case BGP_ERR_GR_OPERATION_FAILED: | |
882 | str = "The Graceful Restart Operation failed due to an err."; | |
883 | break; | |
884 | case BGP_ERR_PEER_GROUP_MEMBER: | |
885 | str = "Peer-group member cannot override remote-as of peer-group."; | |
886 | break; | |
887 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
888 | str = "Peer-group members must be all internal or all external."; | |
889 | break; | |
890 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: | |
891 | str = "Range specified cannot be deleted because it is not part of current config."; | |
892 | break; | |
893 | case BGP_ERR_INSTANCE_MISMATCH: | |
894 | str = "Instance specified does not match the current instance."; | |
895 | break; | |
896 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
897 | str = "Interface specified is not being used for interface based peer."; | |
898 | break; | |
899 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
900 | str = "No configuration already specified for soft reconfiguration."; | |
901 | break; | |
902 | case BGP_ERR_AS_MISMATCH: | |
903 | str = "BGP is already running."; | |
904 | break; | |
905 | case BGP_ERR_AF_UNCONFIGURED: | |
906 | str = "AFI/SAFI specified is not currently configured."; | |
907 | break; | |
908 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS: | |
909 | str = "AS specified for local as is the same as the remote as and this is not allowed."; | |
910 | break; | |
911 | case BGP_ERR_INVALID_AS: | |
912 | str = "Confederation AS specified is the same AS as our AS."; | |
913 | break; | |
914 | } | |
915 | if (str) { | |
916 | vty_out(vty, "%% %s\n", str); | |
917 | return CMD_WARNING_CONFIG_FAILED; | |
918 | } | |
919 | return CMD_SUCCESS; | |
920 | } | |
921 | ||
922 | /* BGP clear sort. */ | |
923 | enum clear_sort { | |
924 | clear_all, | |
925 | clear_peer, | |
926 | clear_group, | |
927 | clear_external, | |
928 | clear_as | |
929 | }; | |
930 | ||
931 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, | |
932 | safi_t safi, int error) | |
933 | { | |
934 | switch (error) { | |
935 | case BGP_ERR_AF_UNCONFIGURED: | |
936 | vty_out(vty, | |
937 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
938 | get_afi_safi_str(afi, safi, false), peer->host); | |
939 | break; | |
940 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
941 | vty_out(vty, | |
942 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
943 | peer->host); | |
944 | break; | |
945 | default: | |
946 | break; | |
947 | } | |
948 | } | |
949 | ||
950 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, | |
951 | struct listnode **nnode, enum bgp_clear_type stype) | |
952 | { | |
953 | int ret = 0; | |
954 | struct peer_af *paf; | |
955 | ||
956 | /* if afi/.safi not specified, spin thru all of them */ | |
957 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
958 | afi_t tmp_afi; | |
959 | safi_t tmp_safi; | |
960 | enum bgp_af_index index; | |
961 | ||
962 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
963 | paf = peer->peer_af_array[index]; | |
964 | if (!paf) | |
965 | continue; | |
966 | ||
967 | if (paf && paf->subgroup) | |
968 | SET_FLAG(paf->subgroup->sflags, | |
969 | SUBGRP_STATUS_FORCE_UPDATES); | |
970 | ||
971 | tmp_afi = paf->afi; | |
972 | tmp_safi = paf->safi; | |
973 | if (!peer->afc[tmp_afi][tmp_safi]) | |
974 | continue; | |
975 | ||
976 | if (stype == BGP_CLEAR_SOFT_NONE) | |
977 | ret = peer_clear(peer, nnode); | |
978 | else | |
979 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
980 | stype); | |
981 | } | |
982 | /* if afi specified and safi not, spin thru safis on this afi */ | |
983 | } else if (safi == SAFI_UNSPEC) { | |
984 | safi_t tmp_safi; | |
985 | ||
986 | for (tmp_safi = SAFI_UNICAST; | |
987 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
988 | if (!peer->afc[afi][tmp_safi]) | |
989 | continue; | |
990 | ||
991 | paf = peer_af_find(peer, afi, tmp_safi); | |
992 | if (paf && paf->subgroup) | |
993 | SET_FLAG(paf->subgroup->sflags, | |
994 | SUBGRP_STATUS_FORCE_UPDATES); | |
995 | ||
996 | if (stype == BGP_CLEAR_SOFT_NONE) | |
997 | ret = peer_clear(peer, nnode); | |
998 | else | |
999 | ret = peer_clear_soft(peer, afi, | |
1000 | tmp_safi, stype); | |
1001 | } | |
1002 | /* both afi/safi specified, let the caller know if not defined */ | |
1003 | } else { | |
1004 | if (!peer->afc[afi][safi]) | |
1005 | return 1; | |
1006 | ||
1007 | paf = peer_af_find(peer, afi, safi); | |
1008 | if (paf && paf->subgroup) | |
1009 | SET_FLAG(paf->subgroup->sflags, | |
1010 | SUBGRP_STATUS_FORCE_UPDATES); | |
1011 | ||
1012 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1013 | ret = peer_clear(peer, nnode); | |
1014 | else | |
1015 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1016 | } | |
1017 | ||
1018 | return ret; | |
1019 | } | |
1020 | ||
1021 | /* `clear ip bgp' functions. */ | |
1022 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
1023 | enum clear_sort sort, enum bgp_clear_type stype, | |
1024 | const char *arg) | |
1025 | { | |
1026 | int ret = 0; | |
1027 | bool found = false; | |
1028 | struct peer *peer; | |
1029 | ||
1030 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
1031 | ||
1032 | /* Clear all neighbors. */ | |
1033 | /* | |
1034 | * Pass along pointer to next node to peer_clear() when walking all | |
1035 | * nodes on the BGP instance as that may get freed if it is a | |
1036 | * doppelganger | |
1037 | */ | |
1038 | if (sort == clear_all) { | |
1039 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1040 | ||
1041 | bgp_peer_gr_flags_update(peer); | |
1042 | ||
1043 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
1044 | gr_router_detected = true; | |
1045 | ||
1046 | ret = bgp_peer_clear(peer, afi, safi, &nnode, | |
1047 | stype); | |
1048 | ||
1049 | if (ret < 0) | |
1050 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
1051 | } | |
1052 | ||
1053 | if (gr_router_detected | |
1054 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
1055 | bgp_zebra_send_capabilities(bgp, false); | |
1056 | } else if (!gr_router_detected | |
1057 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
1058 | bgp_zebra_send_capabilities(bgp, true); | |
1059 | } | |
1060 | ||
1061 | /* This is to apply read-only mode on this clear. */ | |
1062 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1063 | bgp->update_delay_over = 0; | |
1064 | ||
1065 | return CMD_SUCCESS; | |
1066 | } | |
1067 | ||
1068 | /* Clear specified neighbor. */ | |
1069 | if (sort == clear_peer) { | |
1070 | union sockunion su; | |
1071 | ||
1072 | /* Make sockunion for lookup. */ | |
1073 | ret = str2sockunion(arg, &su); | |
1074 | if (ret < 0) { | |
1075 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1076 | if (!peer) { | |
1077 | peer = peer_lookup_by_hostname(bgp, arg); | |
1078 | if (!peer) { | |
1079 | vty_out(vty, | |
1080 | "Malformed address or name: %s\n", | |
1081 | arg); | |
1082 | return CMD_WARNING; | |
1083 | } | |
1084 | } | |
1085 | } else { | |
1086 | peer = peer_lookup(bgp, &su); | |
1087 | if (!peer) { | |
1088 | vty_out(vty, | |
1089 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
1090 | arg); | |
1091 | return CMD_WARNING; | |
1092 | } | |
1093 | } | |
1094 | ||
1095 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
1096 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1097 | ||
1098 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); | |
1099 | ||
1100 | /* if afi/safi not defined for this peer, let caller know */ | |
1101 | if (ret == 1) | |
1102 | ret = BGP_ERR_AF_UNCONFIGURED; | |
1103 | ||
1104 | if (ret < 0) | |
1105 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
1106 | ||
1107 | return CMD_SUCCESS; | |
1108 | } | |
1109 | ||
1110 | /* Clear all neighbors belonging to a specific peer-group. */ | |
1111 | if (sort == clear_group) { | |
1112 | struct peer_group *group; | |
1113 | ||
1114 | group = peer_group_lookup(bgp, arg); | |
1115 | if (!group) { | |
1116 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
1117 | return CMD_WARNING; | |
1118 | } | |
1119 | ||
1120 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
1121 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); | |
1122 | ||
1123 | if (ret < 0) | |
1124 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
1125 | else | |
1126 | found = true; | |
1127 | } | |
1128 | ||
1129 | if (!found) | |
1130 | vty_out(vty, | |
1131 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
1132 | get_afi_safi_str(afi, safi, false), arg); | |
1133 | ||
1134 | return CMD_SUCCESS; | |
1135 | } | |
1136 | ||
1137 | /* Clear all external (eBGP) neighbors. */ | |
1138 | if (sort == clear_external) { | |
1139 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1140 | if (peer->sort == BGP_PEER_IBGP) | |
1141 | continue; | |
1142 | ||
1143 | bgp_peer_gr_flags_update(peer); | |
1144 | ||
1145 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
1146 | gr_router_detected = true; | |
1147 | ||
1148 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); | |
1149 | ||
1150 | if (ret < 0) | |
1151 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
1152 | else | |
1153 | found = true; | |
1154 | } | |
1155 | ||
1156 | if (gr_router_detected | |
1157 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
1158 | bgp_zebra_send_capabilities(bgp, false); | |
1159 | } else if (!gr_router_detected | |
1160 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
1161 | bgp_zebra_send_capabilities(bgp, true); | |
1162 | } | |
1163 | ||
1164 | if (!found) | |
1165 | vty_out(vty, | |
1166 | "%%BGP: No external %s peer is configured\n", | |
1167 | get_afi_safi_str(afi, safi, false)); | |
1168 | ||
1169 | return CMD_SUCCESS; | |
1170 | } | |
1171 | ||
1172 | /* Clear all neighbors belonging to a specific AS. */ | |
1173 | if (sort == clear_as) { | |
1174 | as_t as = strtoul(arg, NULL, 10); | |
1175 | ||
1176 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1177 | if (peer->as != as) | |
1178 | continue; | |
1179 | ||
1180 | bgp_peer_gr_flags_update(peer); | |
1181 | ||
1182 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
1183 | gr_router_detected = true; | |
1184 | ||
1185 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); | |
1186 | ||
1187 | if (ret < 0) | |
1188 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
1189 | else | |
1190 | found = true; | |
1191 | } | |
1192 | ||
1193 | if (gr_router_detected | |
1194 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
1195 | bgp_zebra_send_capabilities(bgp, false); | |
1196 | } else if (!gr_router_detected | |
1197 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
1198 | bgp_zebra_send_capabilities(bgp, true); | |
1199 | } | |
1200 | ||
1201 | if (!found) | |
1202 | vty_out(vty, | |
1203 | "%%BGP: No %s peer is configured with AS %s\n", | |
1204 | get_afi_safi_str(afi, safi, false), arg); | |
1205 | ||
1206 | return CMD_SUCCESS; | |
1207 | } | |
1208 | ||
1209 | return CMD_SUCCESS; | |
1210 | } | |
1211 | ||
1212 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1213 | safi_t safi, enum clear_sort sort, | |
1214 | enum bgp_clear_type stype, const char *arg) | |
1215 | { | |
1216 | struct bgp *bgp; | |
1217 | ||
1218 | /* BGP structure lookup. */ | |
1219 | if (name) { | |
1220 | bgp = bgp_lookup_by_name(name); | |
1221 | if (bgp == NULL) { | |
1222 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1223 | return CMD_WARNING; | |
1224 | } | |
1225 | } else { | |
1226 | bgp = bgp_get_default(); | |
1227 | if (bgp == NULL) { | |
1228 | vty_out(vty, "No BGP process is configured\n"); | |
1229 | return CMD_WARNING; | |
1230 | } | |
1231 | } | |
1232 | ||
1233 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
1234 | } | |
1235 | ||
1236 | /* clear soft inbound */ | |
1237 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) | |
1238 | { | |
1239 | afi_t afi; | |
1240 | safi_t safi; | |
1241 | ||
1242 | FOREACH_AFI_SAFI (afi, safi) | |
1243 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1244 | BGP_CLEAR_SOFT_IN, NULL); | |
1245 | } | |
1246 | ||
1247 | /* clear soft outbound */ | |
1248 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) | |
1249 | { | |
1250 | afi_t afi; | |
1251 | safi_t safi; | |
1252 | ||
1253 | FOREACH_AFI_SAFI (afi, safi) | |
1254 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1255 | BGP_CLEAR_SOFT_OUT, NULL); | |
1256 | } | |
1257 | ||
1258 | ||
1259 | #ifndef VTYSH_EXTRACT_PL | |
1260 | #include "bgpd/bgp_vty_clippy.c" | |
1261 | #endif | |
1262 | ||
1263 | DEFUN_HIDDEN (bgp_local_mac, | |
1264 | bgp_local_mac_cmd, | |
1265 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", | |
1266 | BGP_STR | |
1267 | "Local MAC config\n" | |
1268 | "VxLAN Network Identifier\n" | |
1269 | "VNI number\n" | |
1270 | "local mac\n" | |
1271 | "mac address\n" | |
1272 | "mac-mobility sequence\n" | |
1273 | "seq number\n") | |
1274 | { | |
1275 | int rv; | |
1276 | vni_t vni; | |
1277 | struct ethaddr mac; | |
1278 | struct ipaddr ip; | |
1279 | uint32_t seq; | |
1280 | struct bgp *bgp; | |
1281 | ||
1282 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1283 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1284 | vty_out(vty, "%% Malformed MAC address\n"); | |
1285 | return CMD_WARNING; | |
1286 | } | |
1287 | memset(&ip, 0, sizeof(ip)); | |
1288 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1289 | ||
1290 | bgp = bgp_get_default(); | |
1291 | if (!bgp) { | |
1292 | vty_out(vty, "Default BGP instance is not there\n"); | |
1293 | return CMD_WARNING; | |
1294 | } | |
1295 | ||
1296 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, | |
1297 | zero_esi); | |
1298 | if (rv < 0) { | |
1299 | vty_out(vty, "Internal error\n"); | |
1300 | return CMD_WARNING; | |
1301 | } | |
1302 | ||
1303 | return CMD_SUCCESS; | |
1304 | } | |
1305 | ||
1306 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1307 | no_bgp_local_mac_cmd, | |
1308 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", | |
1309 | NO_STR | |
1310 | BGP_STR | |
1311 | "Local MAC config\n" | |
1312 | "VxLAN Network Identifier\n" | |
1313 | "VNI number\n" | |
1314 | "local mac\n" | |
1315 | "mac address\n") | |
1316 | { | |
1317 | int rv; | |
1318 | vni_t vni; | |
1319 | struct ethaddr mac; | |
1320 | struct ipaddr ip; | |
1321 | struct bgp *bgp; | |
1322 | ||
1323 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1324 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1325 | vty_out(vty, "%% Malformed MAC address\n"); | |
1326 | return CMD_WARNING; | |
1327 | } | |
1328 | memset(&ip, 0, sizeof(ip)); | |
1329 | ||
1330 | bgp = bgp_get_default(); | |
1331 | if (!bgp) { | |
1332 | vty_out(vty, "Default BGP instance is not there\n"); | |
1333 | return CMD_WARNING; | |
1334 | } | |
1335 | ||
1336 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); | |
1337 | if (rv < 0) { | |
1338 | vty_out(vty, "Internal error\n"); | |
1339 | return CMD_WARNING; | |
1340 | } | |
1341 | ||
1342 | return CMD_SUCCESS; | |
1343 | } | |
1344 | ||
1345 | DEFUN (no_synchronization, | |
1346 | no_synchronization_cmd, | |
1347 | "no synchronization", | |
1348 | NO_STR | |
1349 | "Perform IGP synchronization\n") | |
1350 | { | |
1351 | return CMD_SUCCESS; | |
1352 | } | |
1353 | ||
1354 | DEFUN (no_auto_summary, | |
1355 | no_auto_summary_cmd, | |
1356 | "no auto-summary", | |
1357 | NO_STR | |
1358 | "Enable automatic network number summarization\n") | |
1359 | { | |
1360 | return CMD_SUCCESS; | |
1361 | } | |
1362 | ||
1363 | /* "router bgp" commands. */ | |
1364 | DEFUN_NOSH (router_bgp, | |
1365 | router_bgp_cmd, | |
1366 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1367 | ROUTER_STR | |
1368 | BGP_STR | |
1369 | AS_STR | |
1370 | BGP_INSTANCE_HELP_STR) | |
1371 | { | |
1372 | int idx_asn = 2; | |
1373 | int idx_view_vrf = 3; | |
1374 | int idx_vrf = 4; | |
1375 | int is_new_bgp = 0; | |
1376 | int ret; | |
1377 | as_t as; | |
1378 | struct bgp *bgp; | |
1379 | const char *name = NULL; | |
1380 | enum bgp_instance_type inst_type; | |
1381 | ||
1382 | // "router bgp" without an ASN | |
1383 | if (argc == 2) { | |
1384 | // Pending: Make VRF option available for ASN less config | |
1385 | bgp = bgp_get_default(); | |
1386 | ||
1387 | if (bgp == NULL) { | |
1388 | vty_out(vty, "%% No BGP process is configured\n"); | |
1389 | return CMD_WARNING_CONFIG_FAILED; | |
1390 | } | |
1391 | ||
1392 | if (listcount(bm->bgp) > 1) { | |
1393 | vty_out(vty, "%% Please specify ASN and VRF\n"); | |
1394 | return CMD_WARNING_CONFIG_FAILED; | |
1395 | } | |
1396 | } | |
1397 | ||
1398 | // "router bgp X" | |
1399 | else { | |
1400 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1401 | ||
1402 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) | |
1403 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1404 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1405 | ||
1406 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1407 | if (argc > 3) { | |
1408 | name = argv[idx_vrf]->arg; | |
1409 | ||
1410 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { | |
1411 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1412 | name = NULL; | |
1413 | else | |
1414 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1415 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
1416 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
1417 | } | |
1418 | ||
1419 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1420 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1421 | ||
1422 | ret = bgp_get_vty(&bgp, &as, name, inst_type); | |
1423 | switch (ret) { | |
1424 | case BGP_ERR_AS_MISMATCH: | |
1425 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1426 | return CMD_WARNING_CONFIG_FAILED; | |
1427 | case BGP_ERR_INSTANCE_MISMATCH: | |
1428 | vty_out(vty, | |
1429 | "BGP instance name and AS number mismatch\n"); | |
1430 | vty_out(vty, | |
1431 | "BGP instance is already running; AS is %u\n", | |
1432 | as); | |
1433 | return CMD_WARNING_CONFIG_FAILED; | |
1434 | } | |
1435 | ||
1436 | /* | |
1437 | * If we just instantiated the default instance, complete | |
1438 | * any pending VRF-VPN leaking that was configured via | |
1439 | * earlier "router bgp X vrf FOO" blocks. | |
1440 | */ | |
1441 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1442 | vpn_leak_postchange_all(); | |
1443 | ||
1444 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1445 | bgp_vpn_leak_export(bgp); | |
1446 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1447 | */ | |
1448 | } | |
1449 | ||
1450 | /* unset the auto created flag as the user config is now present */ | |
1451 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1452 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1453 | ||
1454 | return CMD_SUCCESS; | |
1455 | } | |
1456 | ||
1457 | /* "no router bgp" commands. */ | |
1458 | DEFUN (no_router_bgp, | |
1459 | no_router_bgp_cmd, | |
1460 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1461 | NO_STR | |
1462 | ROUTER_STR | |
1463 | BGP_STR | |
1464 | AS_STR | |
1465 | BGP_INSTANCE_HELP_STR) | |
1466 | { | |
1467 | int idx_asn = 3; | |
1468 | int idx_vrf = 5; | |
1469 | as_t as; | |
1470 | struct bgp *bgp; | |
1471 | const char *name = NULL; | |
1472 | ||
1473 | // "no router bgp" without an ASN | |
1474 | if (argc == 3) { | |
1475 | // Pending: Make VRF option available for ASN less config | |
1476 | bgp = bgp_get_default(); | |
1477 | ||
1478 | if (bgp == NULL) { | |
1479 | vty_out(vty, "%% No BGP process is configured\n"); | |
1480 | return CMD_WARNING_CONFIG_FAILED; | |
1481 | } | |
1482 | ||
1483 | if (listcount(bm->bgp) > 1) { | |
1484 | vty_out(vty, "%% Please specify ASN and VRF\n"); | |
1485 | return CMD_WARNING_CONFIG_FAILED; | |
1486 | } | |
1487 | ||
1488 | if (bgp->l3vni) { | |
1489 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1490 | bgp->l3vni); | |
1491 | return CMD_WARNING_CONFIG_FAILED; | |
1492 | } | |
1493 | } else { | |
1494 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1495 | ||
1496 | if (argc > 4) { | |
1497 | name = argv[idx_vrf]->arg; | |
1498 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") | |
1499 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1500 | name = NULL; | |
1501 | } | |
1502 | ||
1503 | /* Lookup bgp structure. */ | |
1504 | bgp = bgp_lookup(as, name); | |
1505 | if (!bgp) { | |
1506 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1507 | return CMD_WARNING_CONFIG_FAILED; | |
1508 | } | |
1509 | ||
1510 | if (bgp->l3vni) { | |
1511 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1512 | bgp->l3vni); | |
1513 | return CMD_WARNING_CONFIG_FAILED; | |
1514 | } | |
1515 | ||
1516 | /* Cannot delete default instance if vrf instances exist */ | |
1517 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1518 | struct listnode *node; | |
1519 | struct bgp *tmp_bgp; | |
1520 | ||
1521 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1522 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1523 | continue; | |
1524 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1525 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1526 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1527 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1528 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1529 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1530 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1531 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1532 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1533 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1534 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1535 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1536 | (bgp == bgp_get_evpn() && | |
1537 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1538 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1539 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1540 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1541 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1542 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1543 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1544 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
1545 | (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { | |
1546 | vty_out(vty, | |
1547 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1548 | return CMD_WARNING_CONFIG_FAILED; | |
1549 | } | |
1550 | } | |
1551 | } | |
1552 | } | |
1553 | ||
1554 | bgp_delete(bgp); | |
1555 | ||
1556 | return CMD_SUCCESS; | |
1557 | } | |
1558 | ||
1559 | ||
1560 | /* BGP router-id. */ | |
1561 | ||
1562 | DEFPY (bgp_router_id, | |
1563 | bgp_router_id_cmd, | |
1564 | "bgp router-id A.B.C.D", | |
1565 | BGP_STR | |
1566 | "Override configured router identifier\n" | |
1567 | "Manually configured router identifier\n") | |
1568 | { | |
1569 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1570 | bgp_router_id_static_set(bgp, router_id); | |
1571 | return CMD_SUCCESS; | |
1572 | } | |
1573 | ||
1574 | DEFPY (no_bgp_router_id, | |
1575 | no_bgp_router_id_cmd, | |
1576 | "no bgp router-id [A.B.C.D]", | |
1577 | NO_STR | |
1578 | BGP_STR | |
1579 | "Override configured router identifier\n" | |
1580 | "Manually configured router identifier\n") | |
1581 | { | |
1582 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1583 | ||
1584 | if (router_id_str) { | |
1585 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1586 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1587 | return CMD_WARNING_CONFIG_FAILED; | |
1588 | } | |
1589 | } | |
1590 | ||
1591 | router_id.s_addr = 0; | |
1592 | bgp_router_id_static_set(bgp, router_id); | |
1593 | ||
1594 | return CMD_SUCCESS; | |
1595 | } | |
1596 | ||
1597 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, | |
1598 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", | |
1599 | NO_STR BGP_STR | |
1600 | "Add community specific parameters\n" | |
1601 | "Create an alias for a community\n" | |
1602 | "Community (AA:BB or AA:BB:CC)\n" | |
1603 | "Alias name\n") | |
1604 | { | |
1605 | struct community_alias ca1; | |
1606 | struct community_alias ca2; | |
1607 | struct community_alias *lookup_community; | |
1608 | struct community_alias *lookup_alias; | |
1609 | ||
1610 | if (!community_str2com(community) && !lcommunity_str2com(community)) { | |
1611 | vty_out(vty, "Invalid community format\n"); | |
1612 | return CMD_WARNING; | |
1613 | } | |
1614 | ||
1615 | memset(&ca1, 0, sizeof(ca1)); | |
1616 | memset(&ca2, 0, sizeof(ca2)); | |
1617 | strlcpy(ca1.community, community, sizeof(ca1.community)); | |
1618 | strlcpy(ca1.alias, alias_name, sizeof(ca1.alias)); | |
1619 | ||
1620 | lookup_community = bgp_ca_community_lookup(&ca1); | |
1621 | lookup_alias = bgp_ca_alias_lookup(&ca1); | |
1622 | ||
1623 | if (no) { | |
1624 | bgp_ca_alias_delete(&ca1); | |
1625 | bgp_ca_community_delete(&ca1); | |
1626 | } else { | |
1627 | if (lookup_alias) { | |
1628 | /* Lookup if community hash table has an item | |
1629 | * with the same alias name. | |
1630 | */ | |
1631 | strlcpy(ca2.community, lookup_alias->community, | |
1632 | sizeof(ca2.community)); | |
1633 | if (bgp_ca_community_lookup(&ca2)) { | |
1634 | vty_out(vty, | |
1635 | "community (%s) already has this alias (%s)\n", | |
1636 | lookup_alias->community, | |
1637 | lookup_alias->alias); | |
1638 | return CMD_WARNING; | |
1639 | } | |
1640 | bgp_ca_alias_delete(&ca1); | |
1641 | } | |
1642 | ||
1643 | if (lookup_community) | |
1644 | bgp_ca_community_delete(&ca1); | |
1645 | ||
1646 | bgp_ca_alias_insert(&ca1); | |
1647 | bgp_ca_community_insert(&ca1); | |
1648 | } | |
1649 | ||
1650 | return CMD_SUCCESS; | |
1651 | } | |
1652 | ||
1653 | DEFPY (bgp_global_suppress_fib_pending, | |
1654 | bgp_global_suppress_fib_pending_cmd, | |
1655 | "[no] bgp suppress-fib-pending", | |
1656 | NO_STR | |
1657 | BGP_STR | |
1658 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1659 | { | |
1660 | bm_wait_for_fib_set(!no); | |
1661 | ||
1662 | return CMD_SUCCESS; | |
1663 | } | |
1664 | ||
1665 | DEFPY (bgp_suppress_fib_pending, | |
1666 | bgp_suppress_fib_pending_cmd, | |
1667 | "[no] bgp suppress-fib-pending", | |
1668 | NO_STR | |
1669 | BGP_STR | |
1670 | "Advertise only routes that are programmed in kernel to peers\n") | |
1671 | { | |
1672 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1673 | ||
1674 | bgp_suppress_fib_pending_set(bgp, !no); | |
1675 | return CMD_SUCCESS; | |
1676 | } | |
1677 | ||
1678 | ||
1679 | /* BGP Cluster ID. */ | |
1680 | DEFUN (bgp_cluster_id, | |
1681 | bgp_cluster_id_cmd, | |
1682 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1683 | BGP_STR | |
1684 | "Configure Route-Reflector Cluster-id\n" | |
1685 | "Route-Reflector Cluster-id in IP address format\n" | |
1686 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
1687 | { | |
1688 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1689 | int idx_ipv4 = 2; | |
1690 | int ret; | |
1691 | struct in_addr cluster; | |
1692 | ||
1693 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1694 | if (!ret) { | |
1695 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1696 | return CMD_WARNING_CONFIG_FAILED; | |
1697 | } | |
1698 | ||
1699 | bgp_cluster_id_set(bgp, &cluster); | |
1700 | bgp_clear_star_soft_out(vty, bgp->name); | |
1701 | ||
1702 | return CMD_SUCCESS; | |
1703 | } | |
1704 | ||
1705 | DEFUN (no_bgp_cluster_id, | |
1706 | no_bgp_cluster_id_cmd, | |
1707 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1708 | NO_STR | |
1709 | BGP_STR | |
1710 | "Configure Route-Reflector Cluster-id\n" | |
1711 | "Route-Reflector Cluster-id in IP address format\n" | |
1712 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
1713 | { | |
1714 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1715 | bgp_cluster_id_unset(bgp); | |
1716 | bgp_clear_star_soft_out(vty, bgp->name); | |
1717 | ||
1718 | return CMD_SUCCESS; | |
1719 | } | |
1720 | ||
1721 | DEFPY (bgp_norib, | |
1722 | bgp_norib_cmd, | |
1723 | "bgp no-rib", | |
1724 | BGP_STR | |
1725 | "Disable BGP route installation to RIB (Zebra)\n") | |
1726 | { | |
1727 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1728 | vty_out(vty, | |
1729 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1730 | return CMD_SUCCESS; | |
1731 | } | |
1732 | ||
1733 | bgp_option_norib_set_runtime(); | |
1734 | ||
1735 | return CMD_SUCCESS; | |
1736 | } | |
1737 | ||
1738 | DEFPY (no_bgp_norib, | |
1739 | no_bgp_norib_cmd, | |
1740 | "no bgp no-rib", | |
1741 | NO_STR | |
1742 | BGP_STR | |
1743 | "Disable BGP route installation to RIB (Zebra)\n") | |
1744 | { | |
1745 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1746 | vty_out(vty, | |
1747 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1748 | return CMD_SUCCESS; | |
1749 | } | |
1750 | ||
1751 | bgp_option_norib_unset_runtime(); | |
1752 | ||
1753 | return CMD_SUCCESS; | |
1754 | } | |
1755 | ||
1756 | DEFPY (no_bgp_send_extra_data, | |
1757 | no_bgp_send_extra_data_cmd, | |
1758 | "[no] bgp send-extra-data zebra", | |
1759 | NO_STR | |
1760 | BGP_STR | |
1761 | "Extra data to Zebra for display/use\n" | |
1762 | "To zebra\n") | |
1763 | { | |
1764 | if (no) | |
1765 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1766 | else | |
1767 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1768 | ||
1769 | return CMD_SUCCESS; | |
1770 | } | |
1771 | ||
1772 | DEFUN (bgp_confederation_identifier, | |
1773 | bgp_confederation_identifier_cmd, | |
1774 | "bgp confederation identifier (1-4294967295)", | |
1775 | BGP_STR | |
1776 | "AS confederation parameters\n" | |
1777 | "AS number\n" | |
1778 | "Set routing domain confederation AS\n") | |
1779 | { | |
1780 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1781 | int idx_number = 3; | |
1782 | as_t as; | |
1783 | ||
1784 | as = strtoul(argv[idx_number]->arg, NULL, 10); | |
1785 | ||
1786 | bgp_confederation_id_set(bgp, as); | |
1787 | ||
1788 | return CMD_SUCCESS; | |
1789 | } | |
1790 | ||
1791 | DEFUN (no_bgp_confederation_identifier, | |
1792 | no_bgp_confederation_identifier_cmd, | |
1793 | "no bgp confederation identifier [(1-4294967295)]", | |
1794 | NO_STR | |
1795 | BGP_STR | |
1796 | "AS confederation parameters\n" | |
1797 | "AS number\n" | |
1798 | "Set routing domain confederation AS\n") | |
1799 | { | |
1800 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1801 | bgp_confederation_id_unset(bgp); | |
1802 | ||
1803 | return CMD_SUCCESS; | |
1804 | } | |
1805 | ||
1806 | DEFUN (bgp_confederation_peers, | |
1807 | bgp_confederation_peers_cmd, | |
1808 | "bgp confederation peers (1-4294967295)...", | |
1809 | BGP_STR | |
1810 | "AS confederation parameters\n" | |
1811 | "Peer ASs in BGP confederation\n" | |
1812 | AS_STR) | |
1813 | { | |
1814 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1815 | int idx_asn = 3; | |
1816 | as_t as; | |
1817 | int i; | |
1818 | ||
1819 | for (i = idx_asn; i < argc; i++) { | |
1820 | as = strtoul(argv[i]->arg, NULL, 10); | |
1821 | ||
1822 | if (bgp->as == as) { | |
1823 | vty_out(vty, | |
1824 | "%% Local member-AS not allowed in confed peer list\n"); | |
1825 | continue; | |
1826 | } | |
1827 | ||
1828 | bgp_confederation_peers_add(bgp, as); | |
1829 | } | |
1830 | return CMD_SUCCESS; | |
1831 | } | |
1832 | ||
1833 | DEFUN (no_bgp_confederation_peers, | |
1834 | no_bgp_confederation_peers_cmd, | |
1835 | "no bgp confederation peers (1-4294967295)...", | |
1836 | NO_STR | |
1837 | BGP_STR | |
1838 | "AS confederation parameters\n" | |
1839 | "Peer ASs in BGP confederation\n" | |
1840 | AS_STR) | |
1841 | { | |
1842 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1843 | int idx_asn = 4; | |
1844 | as_t as; | |
1845 | int i; | |
1846 | ||
1847 | for (i = idx_asn; i < argc; i++) { | |
1848 | as = strtoul(argv[i]->arg, NULL, 10); | |
1849 | ||
1850 | bgp_confederation_peers_remove(bgp, as); | |
1851 | } | |
1852 | return CMD_SUCCESS; | |
1853 | } | |
1854 | ||
1855 | /** | |
1856 | * Central routine for maximum-paths configuration. | |
1857 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1858 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1859 | */ | |
1860 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, | |
1861 | const char *mpaths, uint16_t options, | |
1862 | int set) | |
1863 | { | |
1864 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1865 | uint16_t maxpaths = 0; | |
1866 | int ret; | |
1867 | afi_t afi; | |
1868 | safi_t safi; | |
1869 | ||
1870 | afi = bgp_node_afi(vty); | |
1871 | safi = bgp_node_safi(vty); | |
1872 | ||
1873 | if (set) { | |
1874 | maxpaths = strtol(mpaths, NULL, 10); | |
1875 | if (maxpaths > multipath_num) { | |
1876 | vty_out(vty, | |
1877 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1878 | maxpaths, multipath_num); | |
1879 | return CMD_WARNING_CONFIG_FAILED; | |
1880 | } | |
1881 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1882 | options); | |
1883 | } else | |
1884 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1885 | ||
1886 | if (ret < 0) { | |
1887 | vty_out(vty, | |
1888 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1889 | (set == 1) ? "" : "un", | |
1890 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1891 | maxpaths, afi, safi); | |
1892 | return CMD_WARNING_CONFIG_FAILED; | |
1893 | } | |
1894 | ||
1895 | bgp_recalculate_all_bestpaths(bgp); | |
1896 | ||
1897 | return CMD_SUCCESS; | |
1898 | } | |
1899 | ||
1900 | DEFUN (bgp_maxmed_admin, | |
1901 | bgp_maxmed_admin_cmd, | |
1902 | "bgp max-med administrative ", | |
1903 | BGP_STR | |
1904 | "Advertise routes with max-med\n" | |
1905 | "Administratively applied, for an indefinite period\n") | |
1906 | { | |
1907 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1908 | ||
1909 | bgp->v_maxmed_admin = 1; | |
1910 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1911 | ||
1912 | bgp_maxmed_update(bgp); | |
1913 | ||
1914 | return CMD_SUCCESS; | |
1915 | } | |
1916 | ||
1917 | DEFUN (bgp_maxmed_admin_medv, | |
1918 | bgp_maxmed_admin_medv_cmd, | |
1919 | "bgp max-med administrative (0-4294967295)", | |
1920 | BGP_STR | |
1921 | "Advertise routes with max-med\n" | |
1922 | "Administratively applied, for an indefinite period\n" | |
1923 | "Max MED value to be used\n") | |
1924 | { | |
1925 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1926 | int idx_number = 3; | |
1927 | ||
1928 | bgp->v_maxmed_admin = 1; | |
1929 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
1930 | ||
1931 | bgp_maxmed_update(bgp); | |
1932 | ||
1933 | return CMD_SUCCESS; | |
1934 | } | |
1935 | ||
1936 | DEFUN (no_bgp_maxmed_admin, | |
1937 | no_bgp_maxmed_admin_cmd, | |
1938 | "no bgp max-med administrative [(0-4294967295)]", | |
1939 | NO_STR | |
1940 | BGP_STR | |
1941 | "Advertise routes with max-med\n" | |
1942 | "Administratively applied, for an indefinite period\n" | |
1943 | "Max MED value to be used\n") | |
1944 | { | |
1945 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1946 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1947 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1948 | bgp_maxmed_update(bgp); | |
1949 | ||
1950 | return CMD_SUCCESS; | |
1951 | } | |
1952 | ||
1953 | DEFUN (bgp_maxmed_onstartup, | |
1954 | bgp_maxmed_onstartup_cmd, | |
1955 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1956 | BGP_STR | |
1957 | "Advertise routes with max-med\n" | |
1958 | "Effective on a startup\n" | |
1959 | "Time (seconds) period for max-med\n" | |
1960 | "Max MED value to be used\n") | |
1961 | { | |
1962 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1963 | int idx = 0; | |
1964 | ||
1965 | argv_find(argv, argc, "(5-86400)", &idx); | |
1966 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1967 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1968 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1969 | else | |
1970 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1971 | ||
1972 | bgp_maxmed_update(bgp); | |
1973 | ||
1974 | return CMD_SUCCESS; | |
1975 | } | |
1976 | ||
1977 | DEFUN (no_bgp_maxmed_onstartup, | |
1978 | no_bgp_maxmed_onstartup_cmd, | |
1979 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1980 | NO_STR | |
1981 | BGP_STR | |
1982 | "Advertise routes with max-med\n" | |
1983 | "Effective on a startup\n" | |
1984 | "Time (seconds) period for max-med\n" | |
1985 | "Max MED value to be used\n") | |
1986 | { | |
1987 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1988 | ||
1989 | /* Cancel max-med onstartup if its on */ | |
1990 | if (bgp->t_maxmed_onstartup) { | |
1991 | thread_cancel(&bgp->t_maxmed_onstartup); | |
1992 | bgp->maxmed_onstartup_over = 1; | |
1993 | } | |
1994 | ||
1995 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1996 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1997 | ||
1998 | bgp_maxmed_update(bgp); | |
1999 | ||
2000 | return CMD_SUCCESS; | |
2001 | } | |
2002 | ||
2003 | static int bgp_global_update_delay_config_vty(struct vty *vty, | |
2004 | uint16_t update_delay, | |
2005 | uint16_t establish_wait) | |
2006 | { | |
2007 | struct listnode *node, *nnode; | |
2008 | struct bgp *bgp; | |
2009 | bool vrf_cfg = false; | |
2010 | ||
2011 | /* | |
2012 | * See if update-delay is set per-vrf and warn user to delete it | |
2013 | * Note that we only need to check this if this is the first time | |
2014 | * setting the global config. | |
2015 | */ | |
2016 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
2017 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2018 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
2019 | vty_out(vty, | |
2020 | "%% update-delay configuration found in vrf %s\n", | |
2021 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
2022 | ? VRF_DEFAULT_NAME | |
2023 | : bgp->name); | |
2024 | vrf_cfg = true; | |
2025 | } | |
2026 | } | |
2027 | } | |
2028 | ||
2029 | if (vrf_cfg) { | |
2030 | vty_out(vty, | |
2031 | "%%Failed: global update-delay config not permitted\n"); | |
2032 | return CMD_WARNING; | |
2033 | } | |
2034 | ||
2035 | if (!establish_wait) { /* update-delay <delay> */ | |
2036 | bm->v_update_delay = update_delay; | |
2037 | bm->v_establish_wait = bm->v_update_delay; | |
2038 | } else { | |
2039 | /* update-delay <delay> <establish-wait> */ | |
2040 | if (update_delay < establish_wait) { | |
2041 | vty_out(vty, | |
2042 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2043 | return CMD_WARNING_CONFIG_FAILED; | |
2044 | } | |
2045 | ||
2046 | bm->v_update_delay = update_delay; | |
2047 | bm->v_establish_wait = establish_wait; | |
2048 | } | |
2049 | ||
2050 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2051 | bgp->v_update_delay = bm->v_update_delay; | |
2052 | bgp->v_establish_wait = bm->v_establish_wait; | |
2053 | } | |
2054 | ||
2055 | return CMD_SUCCESS; | |
2056 | } | |
2057 | ||
2058 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2059 | { | |
2060 | struct listnode *node, *nnode; | |
2061 | struct bgp *bgp; | |
2062 | ||
2063 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2064 | bm->v_establish_wait = bm->v_update_delay; | |
2065 | ||
2066 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2067 | bgp->v_update_delay = bm->v_update_delay; | |
2068 | bgp->v_establish_wait = bm->v_establish_wait; | |
2069 | } | |
2070 | ||
2071 | return CMD_SUCCESS; | |
2072 | } | |
2073 | ||
2074 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2075 | uint16_t establish_wait) | |
2076 | { | |
2077 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2078 | ||
2079 | /* if configured globally, per-instance config is not allowed */ | |
2080 | if (bm->v_update_delay) { | |
2081 | vty_out(vty, | |
2082 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2083 | return CMD_WARNING_CONFIG_FAILED; | |
2084 | } | |
2085 | ||
2086 | ||
2087 | if (!establish_wait) /* update-delay <delay> */ | |
2088 | { | |
2089 | bgp->v_update_delay = update_delay; | |
2090 | bgp->v_establish_wait = bgp->v_update_delay; | |
2091 | return CMD_SUCCESS; | |
2092 | } | |
2093 | ||
2094 | /* update-delay <delay> <establish-wait> */ | |
2095 | if (update_delay < establish_wait) { | |
2096 | vty_out(vty, | |
2097 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2098 | return CMD_WARNING_CONFIG_FAILED; | |
2099 | } | |
2100 | ||
2101 | bgp->v_update_delay = update_delay; | |
2102 | bgp->v_establish_wait = establish_wait; | |
2103 | ||
2104 | return CMD_SUCCESS; | |
2105 | } | |
2106 | ||
2107 | static int bgp_update_delay_deconfig_vty(struct vty *vty) | |
2108 | { | |
2109 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2110 | ||
2111 | /* If configured globally, cannot remove from one bgp instance */ | |
2112 | if (bm->v_update_delay) { | |
2113 | vty_out(vty, | |
2114 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2115 | return CMD_WARNING_CONFIG_FAILED; | |
2116 | } | |
2117 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2118 | bgp->v_establish_wait = bgp->v_update_delay; | |
2119 | ||
2120 | return CMD_SUCCESS; | |
2121 | } | |
2122 | ||
2123 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) | |
2124 | { | |
2125 | /* If configured globally, no need to display per-instance value */ | |
2126 | if (bgp->v_update_delay != bm->v_update_delay) { | |
2127 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
2128 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2129 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2130 | vty_out(vty, "\n"); | |
2131 | } | |
2132 | } | |
2133 | ||
2134 | /* Global update-delay configuration */ | |
2135 | DEFPY (bgp_global_update_delay, | |
2136 | bgp_global_update_delay_cmd, | |
2137 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2138 | BGP_STR | |
2139 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2140 | "Max delay in seconds\n" | |
2141 | "Establish wait in seconds\n") | |
2142 | { | |
2143 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2144 | } | |
2145 | ||
2146 | /* Global update-delay deconfiguration */ | |
2147 | DEFPY (no_bgp_global_update_delay, | |
2148 | no_bgp_global_update_delay_cmd, | |
2149 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2150 | NO_STR | |
2151 | BGP_STR | |
2152 | "Force initial delay for best-path and updates\n" | |
2153 | "Max delay in seconds\n" | |
2154 | "Establish wait in seconds\n") | |
2155 | { | |
2156 | return bgp_global_update_delay_deconfig_vty(vty); | |
2157 | } | |
2158 | ||
2159 | /* Update-delay configuration */ | |
2160 | ||
2161 | DEFPY (bgp_update_delay, | |
2162 | bgp_update_delay_cmd, | |
2163 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
2164 | "Force initial delay for best-path and updates\n" | |
2165 | "Max delay in seconds\n" | |
2166 | "Establish wait in seconds\n") | |
2167 | { | |
2168 | return bgp_update_delay_config_vty(vty, delay, wait); | |
2169 | } | |
2170 | ||
2171 | /* Update-delay deconfiguration */ | |
2172 | DEFPY (no_bgp_update_delay, | |
2173 | no_bgp_update_delay_cmd, | |
2174 | "no update-delay [(0-3600) [(1-3600)]]", | |
2175 | NO_STR | |
2176 | "Force initial delay for best-path and updates\n" | |
2177 | "Max delay in seconds\n" | |
2178 | "Establish wait in seconds\n") | |
2179 | { | |
2180 | return bgp_update_delay_deconfig_vty(vty); | |
2181 | } | |
2182 | ||
2183 | ||
2184 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, | |
2185 | bool set) | |
2186 | { | |
2187 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2188 | ||
2189 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; | |
2190 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
2191 | ||
2192 | return CMD_SUCCESS; | |
2193 | } | |
2194 | ||
2195 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, | |
2196 | bool set) | |
2197 | { | |
2198 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2199 | ||
2200 | quanta = set ? quanta : BGP_READ_PACKET_MAX; | |
2201 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
2202 | ||
2203 | return CMD_SUCCESS; | |
2204 | } | |
2205 | ||
2206 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) | |
2207 | { | |
2208 | uint32_t quanta = | |
2209 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2210 | if (quanta != BGP_WRITE_PACKET_MAX) | |
2211 | vty_out(vty, " write-quanta %d\n", quanta); | |
2212 | } | |
2213 | ||
2214 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) | |
2215 | { | |
2216 | uint32_t quanta = | |
2217 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2218 | if (quanta != BGP_READ_PACKET_MAX) | |
2219 | vty_out(vty, " read-quanta %d\n", quanta); | |
2220 | } | |
2221 | ||
2222 | /* Packet quanta configuration | |
2223 | * | |
2224 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2225 | * thread. When changing these limits be careful to prevent stack overflow. | |
2226 | * | |
2227 | * Furthermore, the maximums used here should correspond to | |
2228 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2229 | */ | |
2230 | DEFPY (bgp_wpkt_quanta, | |
2231 | bgp_wpkt_quanta_cmd, | |
2232 | "[no] write-quanta (1-64)$quanta", | |
2233 | NO_STR | |
2234 | "How many packets to write to peer socket per run\n" | |
2235 | "Number of packets\n") | |
2236 | { | |
2237 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2238 | } | |
2239 | ||
2240 | DEFPY (bgp_rpkt_quanta, | |
2241 | bgp_rpkt_quanta_cmd, | |
2242 | "[no] read-quanta (1-10)$quanta", | |
2243 | NO_STR | |
2244 | "How many packets to read from peer socket per I/O cycle\n" | |
2245 | "Number of packets\n") | |
2246 | { | |
2247 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
2248 | } | |
2249 | ||
2250 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) | |
2251 | { | |
2252 | if (!bgp->heuristic_coalesce) | |
2253 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); | |
2254 | } | |
2255 | ||
2256 | ||
2257 | DEFUN (bgp_coalesce_time, | |
2258 | bgp_coalesce_time_cmd, | |
2259 | "coalesce-time (0-4294967295)", | |
2260 | "Subgroup coalesce timer\n" | |
2261 | "Subgroup coalesce timer value (in ms)\n") | |
2262 | { | |
2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2264 | ||
2265 | int idx = 0; | |
2266 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
2267 | bgp->heuristic_coalesce = false; | |
2268 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2269 | return CMD_SUCCESS; | |
2270 | } | |
2271 | ||
2272 | DEFUN (no_bgp_coalesce_time, | |
2273 | no_bgp_coalesce_time_cmd, | |
2274 | "no coalesce-time (0-4294967295)", | |
2275 | NO_STR | |
2276 | "Subgroup coalesce timer\n" | |
2277 | "Subgroup coalesce timer value (in ms)\n") | |
2278 | { | |
2279 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2280 | ||
2281 | bgp->heuristic_coalesce = true; | |
2282 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2283 | return CMD_SUCCESS; | |
2284 | } | |
2285 | ||
2286 | /* Maximum-paths configuration */ | |
2287 | DEFUN (bgp_maxpaths, | |
2288 | bgp_maxpaths_cmd, | |
2289 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2290 | "Forward packets over multiple paths\n" | |
2291 | "Number of paths\n") | |
2292 | { | |
2293 | int idx_number = 1; | |
2294 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
2295 | argv[idx_number]->arg, 0, 1); | |
2296 | } | |
2297 | ||
2298 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, | |
2299 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2300 | "Forward packets over multiple paths\n" | |
2301 | "Number of paths\n") | |
2302 | ||
2303 | DEFUN (bgp_maxpaths_ibgp, | |
2304 | bgp_maxpaths_ibgp_cmd, | |
2305 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2306 | "Forward packets over multiple paths\n" | |
2307 | "iBGP-multipath\n" | |
2308 | "Number of paths\n") | |
2309 | { | |
2310 | int idx_number = 2; | |
2311 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
2312 | argv[idx_number]->arg, 0, 1); | |
2313 | } | |
2314 | ||
2315 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, | |
2316 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2317 | "Forward packets over multiple paths\n" | |
2318 | "iBGP-multipath\n" | |
2319 | "Number of paths\n") | |
2320 | ||
2321 | DEFUN (bgp_maxpaths_ibgp_cluster, | |
2322 | bgp_maxpaths_ibgp_cluster_cmd, | |
2323 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2324 | "Forward packets over multiple paths\n" | |
2325 | "iBGP-multipath\n" | |
2326 | "Number of paths\n" | |
2327 | "Match the cluster length\n") | |
2328 | { | |
2329 | int idx_number = 2; | |
2330 | return bgp_maxpaths_config_vty( | |
2331 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2332 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
2333 | } | |
2334 | ||
2335 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, | |
2336 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2337 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2338 | "Forward packets over multiple paths\n" | |
2339 | "iBGP-multipath\n" | |
2340 | "Number of paths\n" | |
2341 | "Match the cluster length\n") | |
2342 | ||
2343 | DEFUN (no_bgp_maxpaths, | |
2344 | no_bgp_maxpaths_cmd, | |
2345 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2346 | NO_STR | |
2347 | "Forward packets over multiple paths\n" | |
2348 | "Number of paths\n") | |
2349 | { | |
2350 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); | |
2351 | } | |
2352 | ||
2353 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, | |
2354 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR | |
2355 | "Forward packets over multiple paths\n" | |
2356 | "Number of paths\n") | |
2357 | ||
2358 | DEFUN (no_bgp_maxpaths_ibgp, | |
2359 | no_bgp_maxpaths_ibgp_cmd, | |
2360 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2361 | NO_STR | |
2362 | "Forward packets over multiple paths\n" | |
2363 | "iBGP-multipath\n" | |
2364 | "Number of paths\n" | |
2365 | "Match the cluster length\n") | |
2366 | { | |
2367 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); | |
2368 | } | |
2369 | ||
2370 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, | |
2371 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2372 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2373 | NO_STR | |
2374 | "Forward packets over multiple paths\n" | |
2375 | "iBGP-multipath\n" | |
2376 | "Number of paths\n" | |
2377 | "Match the cluster length\n") | |
2378 | ||
2379 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, | |
2380 | afi_t afi, safi_t safi) | |
2381 | { | |
2382 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { | |
2383 | vty_out(vty, " maximum-paths %d\n", | |
2384 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2385 | } | |
2386 | ||
2387 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { | |
2388 | vty_out(vty, " maximum-paths ibgp %d", | |
2389 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2390 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2391 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2392 | vty_out(vty, " equal-cluster-length"); | |
2393 | vty_out(vty, "\n"); | |
2394 | } | |
2395 | } | |
2396 | ||
2397 | /* BGP timers. */ | |
2398 | ||
2399 | DEFUN (bgp_timers, | |
2400 | bgp_timers_cmd, | |
2401 | "timers bgp (0-65535) (0-65535)", | |
2402 | "Adjust routing timers\n" | |
2403 | "BGP timers\n" | |
2404 | "Keepalive interval\n" | |
2405 | "Holdtime\n") | |
2406 | { | |
2407 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2408 | int idx_number = 2; | |
2409 | int idx_number_2 = 3; | |
2410 | unsigned long keepalive = 0; | |
2411 | unsigned long holdtime = 0; | |
2412 | ||
2413 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); | |
2414 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
2415 | ||
2416 | /* Holdtime value check. */ | |
2417 | if (holdtime < 3 && holdtime != 0) { | |
2418 | vty_out(vty, | |
2419 | "%% hold time value must be either 0 or greater than 3\n"); | |
2420 | return CMD_WARNING_CONFIG_FAILED; | |
2421 | } | |
2422 | ||
2423 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, | |
2424 | BGP_DEFAULT_DELAYOPEN); | |
2425 | ||
2426 | return CMD_SUCCESS; | |
2427 | } | |
2428 | ||
2429 | DEFUN (no_bgp_timers, | |
2430 | no_bgp_timers_cmd, | |
2431 | "no timers bgp [(0-65535) (0-65535)]", | |
2432 | NO_STR | |
2433 | "Adjust routing timers\n" | |
2434 | "BGP timers\n" | |
2435 | "Keepalive interval\n" | |
2436 | "Holdtime\n") | |
2437 | { | |
2438 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2439 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2440 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
2441 | ||
2442 | return CMD_SUCCESS; | |
2443 | } | |
2444 | ||
2445 | /* BGP minimum holdtime. */ | |
2446 | ||
2447 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2448 | "bgp minimum-holdtime (1-65535)", | |
2449 | "BGP specific commands\n" | |
2450 | "BGP minimum holdtime\n" | |
2451 | "Seconds\n") | |
2452 | { | |
2453 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2454 | int idx_number = 2; | |
2455 | unsigned long min_holdtime; | |
2456 | ||
2457 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2458 | ||
2459 | bgp->default_min_holdtime = min_holdtime; | |
2460 | ||
2461 | return CMD_SUCCESS; | |
2462 | } | |
2463 | ||
2464 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2465 | "no bgp minimum-holdtime [(1-65535)]", | |
2466 | NO_STR | |
2467 | "BGP specific commands\n" | |
2468 | "BGP minimum holdtime\n" | |
2469 | "Seconds\n") | |
2470 | { | |
2471 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2472 | ||
2473 | bgp->default_min_holdtime = 0; | |
2474 | ||
2475 | return CMD_SUCCESS; | |
2476 | } | |
2477 | ||
2478 | DEFUN (bgp_client_to_client_reflection, | |
2479 | bgp_client_to_client_reflection_cmd, | |
2480 | "bgp client-to-client reflection", | |
2481 | BGP_STR | |
2482 | "Configure client to client route reflection\n" | |
2483 | "reflection of routes allowed\n") | |
2484 | { | |
2485 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2486 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2487 | bgp_clear_star_soft_out(vty, bgp->name); | |
2488 | ||
2489 | return CMD_SUCCESS; | |
2490 | } | |
2491 | ||
2492 | DEFUN (no_bgp_client_to_client_reflection, | |
2493 | no_bgp_client_to_client_reflection_cmd, | |
2494 | "no bgp client-to-client reflection", | |
2495 | NO_STR | |
2496 | BGP_STR | |
2497 | "Configure client to client route reflection\n" | |
2498 | "reflection of routes allowed\n") | |
2499 | { | |
2500 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2501 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2502 | bgp_clear_star_soft_out(vty, bgp->name); | |
2503 | ||
2504 | return CMD_SUCCESS; | |
2505 | } | |
2506 | ||
2507 | /* "bgp always-compare-med" configuration. */ | |
2508 | DEFUN (bgp_always_compare_med, | |
2509 | bgp_always_compare_med_cmd, | |
2510 | "bgp always-compare-med", | |
2511 | BGP_STR | |
2512 | "Allow comparing MED from different neighbors\n") | |
2513 | { | |
2514 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2515 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2516 | bgp_recalculate_all_bestpaths(bgp); | |
2517 | ||
2518 | return CMD_SUCCESS; | |
2519 | } | |
2520 | ||
2521 | DEFUN (no_bgp_always_compare_med, | |
2522 | no_bgp_always_compare_med_cmd, | |
2523 | "no bgp always-compare-med", | |
2524 | NO_STR | |
2525 | BGP_STR | |
2526 | "Allow comparing MED from different neighbors\n") | |
2527 | { | |
2528 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2529 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2530 | bgp_recalculate_all_bestpaths(bgp); | |
2531 | ||
2532 | return CMD_SUCCESS; | |
2533 | } | |
2534 | ||
2535 | ||
2536 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2537 | "bgp ebgp-requires-policy", | |
2538 | BGP_STR | |
2539 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2540 | { | |
2541 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2542 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2543 | return CMD_SUCCESS; | |
2544 | } | |
2545 | ||
2546 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2547 | "no bgp ebgp-requires-policy", | |
2548 | NO_STR | |
2549 | BGP_STR | |
2550 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2551 | { | |
2552 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2553 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2554 | return CMD_SUCCESS; | |
2555 | } | |
2556 | ||
2557 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, | |
2558 | "bgp suppress-duplicates", | |
2559 | BGP_STR | |
2560 | "Suppress duplicate updates if the route actually not changed\n") | |
2561 | { | |
2562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2563 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2564 | return CMD_SUCCESS; | |
2565 | } | |
2566 | ||
2567 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, | |
2568 | "no bgp suppress-duplicates", | |
2569 | NO_STR | |
2570 | BGP_STR | |
2571 | "Suppress duplicate updates if the route actually not changed\n") | |
2572 | { | |
2573 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2574 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2575 | return CMD_SUCCESS; | |
2576 | } | |
2577 | ||
2578 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, | |
2579 | "bgp reject-as-sets", | |
2580 | BGP_STR | |
2581 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2582 | { | |
2583 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2584 | struct listnode *node, *nnode; | |
2585 | struct peer *peer; | |
2586 | ||
2587 | bgp->reject_as_sets = true; | |
2588 | ||
2589 | /* Reset existing BGP sessions to reject routes | |
2590 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2591 | */ | |
2592 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2593 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2594 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2595 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2596 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2597 | } | |
2598 | } | |
2599 | ||
2600 | return CMD_SUCCESS; | |
2601 | } | |
2602 | ||
2603 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2604 | "no bgp reject-as-sets", | |
2605 | NO_STR | |
2606 | BGP_STR | |
2607 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2608 | { | |
2609 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2610 | struct listnode *node, *nnode; | |
2611 | struct peer *peer; | |
2612 | ||
2613 | bgp->reject_as_sets = false; | |
2614 | ||
2615 | /* Reset existing BGP sessions to reject routes | |
2616 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2617 | */ | |
2618 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2619 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2620 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2621 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2622 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2623 | } | |
2624 | } | |
2625 | ||
2626 | return CMD_SUCCESS; | |
2627 | } | |
2628 | ||
2629 | /* "bgp deterministic-med" configuration. */ | |
2630 | DEFUN (bgp_deterministic_med, | |
2631 | bgp_deterministic_med_cmd, | |
2632 | "bgp deterministic-med", | |
2633 | BGP_STR | |
2634 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2635 | { | |
2636 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2637 | ||
2638 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2639 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2640 | bgp_recalculate_all_bestpaths(bgp); | |
2641 | } | |
2642 | ||
2643 | return CMD_SUCCESS; | |
2644 | } | |
2645 | ||
2646 | DEFUN (no_bgp_deterministic_med, | |
2647 | no_bgp_deterministic_med_cmd, | |
2648 | "no bgp deterministic-med", | |
2649 | NO_STR | |
2650 | BGP_STR | |
2651 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2652 | { | |
2653 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2654 | int bestpath_per_as_used; | |
2655 | afi_t afi; | |
2656 | safi_t safi; | |
2657 | struct peer *peer; | |
2658 | struct listnode *node, *nnode; | |
2659 | ||
2660 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2661 | bestpath_per_as_used = 0; | |
2662 | ||
2663 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2664 | FOREACH_AFI_SAFI (afi, safi) | |
2665 | if (bgp_addpath_dmed_required( | |
2666 | peer->addpath_type[afi][safi])) { | |
2667 | bestpath_per_as_used = 1; | |
2668 | break; | |
2669 | } | |
2670 | ||
2671 | if (bestpath_per_as_used) | |
2672 | break; | |
2673 | } | |
2674 | ||
2675 | if (bestpath_per_as_used) { | |
2676 | vty_out(vty, | |
2677 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2678 | return CMD_WARNING_CONFIG_FAILED; | |
2679 | } else { | |
2680 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2681 | bgp_recalculate_all_bestpaths(bgp); | |
2682 | } | |
2683 | } | |
2684 | ||
2685 | return CMD_SUCCESS; | |
2686 | } | |
2687 | ||
2688 | /* "bgp graceful-restart mode" configuration. */ | |
2689 | DEFUN (bgp_graceful_restart, | |
2690 | bgp_graceful_restart_cmd, | |
2691 | "bgp graceful-restart", | |
2692 | BGP_STR | |
2693 | GR_CMD | |
2694 | ) | |
2695 | { | |
2696 | int ret = BGP_GR_FAILURE; | |
2697 | ||
2698 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2699 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); | |
2700 | ||
2701 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2702 | ||
2703 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2704 | ||
2705 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, | |
2706 | ret); | |
2707 | ||
2708 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2709 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); | |
2710 | vty_out(vty, | |
2711 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2712 | return bgp_vty_return(vty, ret); | |
2713 | } | |
2714 | ||
2715 | DEFUN (no_bgp_graceful_restart, | |
2716 | no_bgp_graceful_restart_cmd, | |
2717 | "no bgp graceful-restart", | |
2718 | NO_STR | |
2719 | BGP_STR | |
2720 | NO_GR_CMD | |
2721 | ) | |
2722 | { | |
2723 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2724 | ||
2725 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2726 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); | |
2727 | ||
2728 | int ret = BGP_GR_FAILURE; | |
2729 | ||
2730 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2731 | ||
2732 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, | |
2733 | ret); | |
2734 | ||
2735 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2736 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); | |
2737 | vty_out(vty, | |
2738 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2739 | ||
2740 | return bgp_vty_return(vty, ret); | |
2741 | } | |
2742 | ||
2743 | DEFUN (bgp_graceful_restart_stalepath_time, | |
2744 | bgp_graceful_restart_stalepath_time_cmd, | |
2745 | "bgp graceful-restart stalepath-time (1-4095)", | |
2746 | BGP_STR | |
2747 | "Graceful restart capability parameters\n" | |
2748 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2749 | "Delay value (seconds)\n") | |
2750 | { | |
2751 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2752 | int idx_number = 3; | |
2753 | uint32_t stalepath; | |
2754 | ||
2755 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); | |
2756 | bgp->stalepath_time = stalepath; | |
2757 | return CMD_SUCCESS; | |
2758 | } | |
2759 | ||
2760 | DEFUN (bgp_graceful_restart_restart_time, | |
2761 | bgp_graceful_restart_restart_time_cmd, | |
2762 | "bgp graceful-restart restart-time (0-4095)", | |
2763 | BGP_STR | |
2764 | "Graceful restart capability parameters\n" | |
2765 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2766 | "Delay value (seconds)\n") | |
2767 | { | |
2768 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2769 | int idx_number = 3; | |
2770 | uint32_t restart; | |
2771 | ||
2772 | restart = strtoul(argv[idx_number]->arg, NULL, 10); | |
2773 | bgp->restart_time = restart; | |
2774 | return CMD_SUCCESS; | |
2775 | } | |
2776 | ||
2777 | DEFUN (bgp_graceful_restart_select_defer_time, | |
2778 | bgp_graceful_restart_select_defer_time_cmd, | |
2779 | "bgp graceful-restart select-defer-time (0-3600)", | |
2780 | BGP_STR | |
2781 | "Graceful restart capability parameters\n" | |
2782 | "Set the time to defer the BGP route selection after restart\n" | |
2783 | "Delay value (seconds, 0 - disable)\n") | |
2784 | { | |
2785 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2786 | int idx_number = 3; | |
2787 | uint32_t defer_time; | |
2788 | ||
2789 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2790 | bgp->select_defer_time = defer_time; | |
2791 | if (defer_time == 0) | |
2792 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2793 | else | |
2794 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2795 | ||
2796 | return CMD_SUCCESS; | |
2797 | } | |
2798 | ||
2799 | DEFUN (no_bgp_graceful_restart_stalepath_time, | |
2800 | no_bgp_graceful_restart_stalepath_time_cmd, | |
2801 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2802 | NO_STR | |
2803 | BGP_STR | |
2804 | "Graceful restart capability parameters\n" | |
2805 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2806 | "Delay value (seconds)\n") | |
2807 | { | |
2808 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2809 | ||
2810 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
2811 | return CMD_SUCCESS; | |
2812 | } | |
2813 | ||
2814 | DEFUN (no_bgp_graceful_restart_restart_time, | |
2815 | no_bgp_graceful_restart_restart_time_cmd, | |
2816 | "no bgp graceful-restart restart-time [(0-4095)]", | |
2817 | NO_STR | |
2818 | BGP_STR | |
2819 | "Graceful restart capability parameters\n" | |
2820 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2821 | "Delay value (seconds)\n") | |
2822 | { | |
2823 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2824 | ||
2825 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
2826 | return CMD_SUCCESS; | |
2827 | } | |
2828 | ||
2829 | DEFUN (no_bgp_graceful_restart_select_defer_time, | |
2830 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2831 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2832 | NO_STR | |
2833 | BGP_STR | |
2834 | "Graceful restart capability parameters\n" | |
2835 | "Set the time to defer the BGP route selection after restart\n" | |
2836 | "Delay value (seconds)\n") | |
2837 | { | |
2838 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2839 | ||
2840 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
2841 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2842 | ||
2843 | return CMD_SUCCESS; | |
2844 | } | |
2845 | ||
2846 | DEFUN (bgp_graceful_restart_preserve_fw, | |
2847 | bgp_graceful_restart_preserve_fw_cmd, | |
2848 | "bgp graceful-restart preserve-fw-state", | |
2849 | BGP_STR | |
2850 | "Graceful restart capability parameters\n" | |
2851 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2852 | { | |
2853 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2854 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); | |
2855 | return CMD_SUCCESS; | |
2856 | } | |
2857 | ||
2858 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2859 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2860 | "no bgp graceful-restart preserve-fw-state", | |
2861 | NO_STR | |
2862 | BGP_STR | |
2863 | "Graceful restart capability parameters\n" | |
2864 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2865 | { | |
2866 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2867 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); | |
2868 | return CMD_SUCCESS; | |
2869 | } | |
2870 | ||
2871 | DEFUN (bgp_graceful_restart_disable, | |
2872 | bgp_graceful_restart_disable_cmd, | |
2873 | "bgp graceful-restart-disable", | |
2874 | BGP_STR | |
2875 | GR_DISABLE) | |
2876 | { | |
2877 | int ret = BGP_GR_FAILURE; | |
2878 | ||
2879 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2880 | zlog_debug( | |
2881 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); | |
2882 | ||
2883 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2884 | ||
2885 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2886 | ||
2887 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, | |
2888 | bgp->peer, ret); | |
2889 | ||
2890 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2891 | zlog_debug( | |
2892 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); | |
2893 | vty_out(vty, | |
2894 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2895 | ||
2896 | return bgp_vty_return(vty, ret); | |
2897 | } | |
2898 | ||
2899 | DEFUN (no_bgp_graceful_restart_disable, | |
2900 | no_bgp_graceful_restart_disable_cmd, | |
2901 | "no bgp graceful-restart-disable", | |
2902 | NO_STR | |
2903 | BGP_STR | |
2904 | NO_GR_DISABLE | |
2905 | ) | |
2906 | { | |
2907 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2908 | ||
2909 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2910 | zlog_debug( | |
2911 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); | |
2912 | ||
2913 | int ret = BGP_GR_FAILURE; | |
2914 | ||
2915 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2916 | ||
2917 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, | |
2918 | ret); | |
2919 | ||
2920 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2921 | zlog_debug( | |
2922 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); | |
2923 | vty_out(vty, | |
2924 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2925 | ||
2926 | return bgp_vty_return(vty, ret); | |
2927 | } | |
2928 | ||
2929 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2930 | bgp_neighbor_graceful_restart_set_cmd, | |
2931 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2932 | NEIGHBOR_STR | |
2933 | NEIGHBOR_ADDR_STR2 | |
2934 | GR_NEIGHBOR_CMD | |
2935 | ) | |
2936 | { | |
2937 | int idx_peer = 1; | |
2938 | struct peer *peer; | |
2939 | int ret = BGP_GR_FAILURE; | |
2940 | ||
2941 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
2942 | ||
2943 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2944 | zlog_debug( | |
2945 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); | |
2946 | ||
2947 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2948 | if (!peer) | |
2949 | return CMD_WARNING_CONFIG_FAILED; | |
2950 | ||
2951 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2952 | ||
2953 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
2954 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2955 | ||
2956 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2957 | zlog_debug( | |
2958 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); | |
2959 | vty_out(vty, | |
2960 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
2961 | ||
2962 | return bgp_vty_return(vty, ret); | |
2963 | } | |
2964 | ||
2965 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2966 | no_bgp_neighbor_graceful_restart_set_cmd, | |
2967 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2968 | NO_STR | |
2969 | NEIGHBOR_STR | |
2970 | NEIGHBOR_ADDR_STR2 | |
2971 | NO_GR_NEIGHBOR_CMD | |
2972 | ) | |
2973 | { | |
2974 | int idx_peer = 2; | |
2975 | int ret = BGP_GR_FAILURE; | |
2976 | struct peer *peer; | |
2977 | ||
2978 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
2979 | ||
2980 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2981 | if (!peer) | |
2982 | return CMD_WARNING_CONFIG_FAILED; | |
2983 | ||
2984 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2985 | zlog_debug( | |
2986 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); | |
2987 | ||
2988 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2989 | ||
2990 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
2991 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2992 | ||
2993 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2994 | zlog_debug( | |
2995 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); | |
2996 | vty_out(vty, | |
2997 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
2998 | ||
2999 | return bgp_vty_return(vty, ret); | |
3000 | } | |
3001 | ||
3002 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
3003 | bgp_neighbor_graceful_restart_helper_set_cmd, | |
3004 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3005 | NEIGHBOR_STR | |
3006 | NEIGHBOR_ADDR_STR2 | |
3007 | GR_NEIGHBOR_HELPER_CMD | |
3008 | ) | |
3009 | { | |
3010 | int idx_peer = 1; | |
3011 | struct peer *peer; | |
3012 | int ret = BGP_GR_FAILURE; | |
3013 | ||
3014 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
3015 | ||
3016 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3017 | zlog_debug( | |
3018 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); | |
3019 | ||
3020 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3021 | ||
3022 | if (!peer) | |
3023 | return CMD_WARNING_CONFIG_FAILED; | |
3024 | ||
3025 | ||
3026 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
3027 | ||
3028 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
3029 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3030 | ||
3031 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3032 | zlog_debug( | |
3033 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); | |
3034 | vty_out(vty, | |
3035 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
3036 | ||
3037 | return bgp_vty_return(vty, ret); | |
3038 | } | |
3039 | ||
3040 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
3041 | no_bgp_neighbor_graceful_restart_helper_set_cmd, | |
3042 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3043 | NO_STR | |
3044 | NEIGHBOR_STR | |
3045 | NEIGHBOR_ADDR_STR2 | |
3046 | NO_GR_NEIGHBOR_HELPER_CMD | |
3047 | ) | |
3048 | { | |
3049 | int idx_peer = 2; | |
3050 | int ret = BGP_GR_FAILURE; | |
3051 | struct peer *peer; | |
3052 | ||
3053 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
3054 | ||
3055 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3056 | if (!peer) | |
3057 | return CMD_WARNING_CONFIG_FAILED; | |
3058 | ||
3059 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3060 | zlog_debug( | |
3061 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); | |
3062 | ||
3063 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); | |
3064 | ||
3065 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
3066 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3067 | ||
3068 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3069 | zlog_debug( | |
3070 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); | |
3071 | vty_out(vty, | |
3072 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
3073 | ||
3074 | return bgp_vty_return(vty, ret); | |
3075 | } | |
3076 | ||
3077 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
3078 | bgp_neighbor_graceful_restart_disable_set_cmd, | |
3079 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3080 | NEIGHBOR_STR | |
3081 | NEIGHBOR_ADDR_STR2 | |
3082 | GR_NEIGHBOR_DISABLE_CMD | |
3083 | ) | |
3084 | { | |
3085 | int idx_peer = 1; | |
3086 | struct peer *peer; | |
3087 | int ret = BGP_GR_FAILURE; | |
3088 | ||
3089 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
3090 | ||
3091 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3092 | zlog_debug( | |
3093 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); | |
3094 | ||
3095 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3096 | if (!peer) | |
3097 | return CMD_WARNING_CONFIG_FAILED; | |
3098 | ||
3099 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); | |
3100 | ||
3101 | if (peer->bgp->t_startup) | |
3102 | bgp_peer_gr_flags_update(peer); | |
3103 | ||
3104 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
3105 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3106 | ||
3107 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3108 | zlog_debug( | |
3109 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); | |
3110 | vty_out(vty, | |
3111 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
3112 | ||
3113 | return bgp_vty_return(vty, ret); | |
3114 | } | |
3115 | ||
3116 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
3117 | no_bgp_neighbor_graceful_restart_disable_set_cmd, | |
3118 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3119 | NO_STR | |
3120 | NEIGHBOR_STR | |
3121 | NEIGHBOR_ADDR_STR2 | |
3122 | NO_GR_NEIGHBOR_DISABLE_CMD | |
3123 | ) | |
3124 | { | |
3125 | int idx_peer = 2; | |
3126 | int ret = BGP_GR_FAILURE; | |
3127 | struct peer *peer; | |
3128 | ||
3129 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
3130 | ||
3131 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3132 | if (!peer) | |
3133 | return CMD_WARNING_CONFIG_FAILED; | |
3134 | ||
3135 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3136 | zlog_debug( | |
3137 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); | |
3138 | ||
3139 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3140 | ||
3141 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); | |
3142 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3143 | ||
3144 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3145 | zlog_debug( | |
3146 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); | |
3147 | vty_out(vty, | |
3148 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
3149 | ||
3150 | return bgp_vty_return(vty, ret); | |
3151 | } | |
3152 | ||
3153 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, | |
3154 | bgp_graceful_restart_disable_eor_cmd, | |
3155 | "bgp graceful-restart disable-eor", | |
3156 | BGP_STR | |
3157 | "Graceful restart configuration parameters\n" | |
3158 | "Disable EOR Check\n") | |
3159 | { | |
3160 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3161 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); | |
3162 | ||
3163 | return CMD_SUCCESS; | |
3164 | } | |
3165 | ||
3166 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3167 | no_bgp_graceful_restart_disable_eor_cmd, | |
3168 | "no bgp graceful-restart disable-eor", | |
3169 | NO_STR | |
3170 | BGP_STR | |
3171 | "Graceful restart configuration parameters\n" | |
3172 | "Disable EOR Check\n") | |
3173 | { | |
3174 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3175 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); | |
3176 | ||
3177 | return CMD_SUCCESS; | |
3178 | } | |
3179 | ||
3180 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3181 | bgp_graceful_restart_rib_stale_time_cmd, | |
3182 | "bgp graceful-restart rib-stale-time (1-3600)", | |
3183 | BGP_STR | |
3184 | "Graceful restart configuration parameters\n" | |
3185 | "Specify the stale route removal timer in rib\n" | |
3186 | "Delay value (seconds)\n") | |
3187 | { | |
3188 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3189 | int idx_number = 3; | |
3190 | uint32_t stale_time; | |
3191 | ||
3192 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3193 | bgp->rib_stale_time = stale_time; | |
3194 | /* Send the stale timer update message to RIB */ | |
3195 | if (bgp_zebra_stale_timer_update(bgp)) | |
3196 | return CMD_WARNING; | |
3197 | ||
3198 | return CMD_SUCCESS; | |
3199 | } | |
3200 | ||
3201 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3202 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3203 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3204 | NO_STR | |
3205 | BGP_STR | |
3206 | "Graceful restart configuration parameters\n" | |
3207 | "Specify the stale route removal timer in rib\n" | |
3208 | "Delay value (seconds)\n") | |
3209 | { | |
3210 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3211 | ||
3212 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3213 | /* Send the stale timer update message to RIB */ | |
3214 | if (bgp_zebra_stale_timer_update(bgp)) | |
3215 | return CMD_WARNING; | |
3216 | ||
3217 | return CMD_SUCCESS; | |
3218 | } | |
3219 | ||
3220 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, | |
3221 | "bgp long-lived-graceful-restart stale-time (1-4294967295)", | |
3222 | BGP_STR | |
3223 | "Enable Long-lived Graceful Restart\n" | |
3224 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3225 | "Stale time value (seconds)\n") | |
3226 | { | |
3227 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3228 | ||
3229 | uint32_t llgr_stale_time; | |
3230 | ||
3231 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3232 | bgp->llgr_stale_time = llgr_stale_time; | |
3233 | ||
3234 | return CMD_SUCCESS; | |
3235 | } | |
3236 | ||
3237 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
3238 | "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]", | |
3239 | NO_STR BGP_STR | |
3240 | "Enable Long-lived Graceful Restart\n" | |
3241 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3242 | "Stale time value (seconds)\n") | |
3243 | { | |
3244 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3245 | ||
3246 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3247 | ||
3248 | return CMD_SUCCESS; | |
3249 | } | |
3250 | ||
3251 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, | |
3252 | struct bgp *bgp) | |
3253 | { | |
3254 | bgp_static_redo_import_check(bgp); | |
3255 | bgp_redistribute_redo(bgp); | |
3256 | bgp_clear_star_soft_out(vty, bgp->name); | |
3257 | bgp_clear_star_soft_in(vty, bgp->name); | |
3258 | } | |
3259 | ||
3260 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3261 | { | |
3262 | struct listnode *node, *nnode; | |
3263 | struct bgp *bgp; | |
3264 | bool vrf_cfg = false; | |
3265 | ||
3266 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3267 | return CMD_SUCCESS; | |
3268 | ||
3269 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3270 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3271 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3272 | vty_out(vty, | |
3273 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3274 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3275 | VRF_DEFAULT_NAME : bgp->name); | |
3276 | vrf_cfg = true; | |
3277 | } | |
3278 | } | |
3279 | ||
3280 | if (vrf_cfg) { | |
3281 | vty_out(vty, | |
3282 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3283 | return CMD_WARNING; | |
3284 | } | |
3285 | ||
3286 | /* Set flag globally */ | |
3287 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3288 | ||
3289 | /* Initiate processing for all BGP instances. */ | |
3290 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) | |
3291 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3292 | ||
3293 | return CMD_SUCCESS; | |
3294 | } | |
3295 | ||
3296 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3297 | { | |
3298 | struct listnode *node, *nnode; | |
3299 | struct bgp *bgp; | |
3300 | ||
3301 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3302 | return CMD_SUCCESS; | |
3303 | ||
3304 | /* Unset flag globally */ | |
3305 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3306 | ||
3307 | /* Initiate processing for all BGP instances. */ | |
3308 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) | |
3309 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3310 | ||
3311 | return CMD_SUCCESS; | |
3312 | } | |
3313 | ||
3314 | /* "bgp graceful-shutdown" configuration */ | |
3315 | DEFUN (bgp_graceful_shutdown, | |
3316 | bgp_graceful_shutdown_cmd, | |
3317 | "bgp graceful-shutdown", | |
3318 | BGP_STR | |
3319 | "Graceful shutdown parameters\n") | |
3320 | { | |
3321 | if (vty->node == CONFIG_NODE) | |
3322 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3323 | ||
3324 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3325 | ||
3326 | /* if configured globally, per-instance config is not allowed */ | |
3327 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3328 | vty_out(vty, | |
3329 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3330 | return CMD_WARNING_CONFIG_FAILED; | |
3331 | } | |
3332 | ||
3333 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3334 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3335 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3336 | } | |
3337 | ||
3338 | return CMD_SUCCESS; | |
3339 | } | |
3340 | ||
3341 | DEFUN (no_bgp_graceful_shutdown, | |
3342 | no_bgp_graceful_shutdown_cmd, | |
3343 | "no bgp graceful-shutdown", | |
3344 | NO_STR | |
3345 | BGP_STR | |
3346 | "Graceful shutdown parameters\n") | |
3347 | { | |
3348 | if (vty->node == CONFIG_NODE) | |
3349 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3350 | ||
3351 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3352 | ||
3353 | /* If configured globally, cannot remove from one bgp instance */ | |
3354 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3355 | vty_out(vty, | |
3356 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3357 | return CMD_WARNING_CONFIG_FAILED; | |
3358 | } | |
3359 | ||
3360 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3361 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3362 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3363 | } | |
3364 | ||
3365 | return CMD_SUCCESS; | |
3366 | } | |
3367 | ||
3368 | /* "bgp fast-external-failover" configuration. */ | |
3369 | DEFUN (bgp_fast_external_failover, | |
3370 | bgp_fast_external_failover_cmd, | |
3371 | "bgp fast-external-failover", | |
3372 | BGP_STR | |
3373 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3374 | { | |
3375 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3376 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3377 | return CMD_SUCCESS; | |
3378 | } | |
3379 | ||
3380 | DEFUN (no_bgp_fast_external_failover, | |
3381 | no_bgp_fast_external_failover_cmd, | |
3382 | "no bgp fast-external-failover", | |
3383 | NO_STR | |
3384 | BGP_STR | |
3385 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3386 | { | |
3387 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3388 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3389 | return CMD_SUCCESS; | |
3390 | } | |
3391 | ||
3392 | /* "bgp bestpath compare-routerid" configuration. */ | |
3393 | DEFUN (bgp_bestpath_compare_router_id, | |
3394 | bgp_bestpath_compare_router_id_cmd, | |
3395 | "bgp bestpath compare-routerid", | |
3396 | BGP_STR | |
3397 | "Change the default bestpath selection\n" | |
3398 | "Compare router-id for identical EBGP paths\n") | |
3399 | { | |
3400 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3401 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3402 | bgp_recalculate_all_bestpaths(bgp); | |
3403 | ||
3404 | return CMD_SUCCESS; | |
3405 | } | |
3406 | ||
3407 | DEFUN (no_bgp_bestpath_compare_router_id, | |
3408 | no_bgp_bestpath_compare_router_id_cmd, | |
3409 | "no bgp bestpath compare-routerid", | |
3410 | NO_STR | |
3411 | BGP_STR | |
3412 | "Change the default bestpath selection\n" | |
3413 | "Compare router-id for identical EBGP paths\n") | |
3414 | { | |
3415 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3416 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3417 | bgp_recalculate_all_bestpaths(bgp); | |
3418 | ||
3419 | return CMD_SUCCESS; | |
3420 | } | |
3421 | ||
3422 | /* "bgp bestpath as-path ignore" configuration. */ | |
3423 | DEFUN (bgp_bestpath_aspath_ignore, | |
3424 | bgp_bestpath_aspath_ignore_cmd, | |
3425 | "bgp bestpath as-path ignore", | |
3426 | BGP_STR | |
3427 | "Change the default bestpath selection\n" | |
3428 | "AS-path attribute\n" | |
3429 | "Ignore as-path length in selecting a route\n") | |
3430 | { | |
3431 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3432 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3433 | bgp_recalculate_all_bestpaths(bgp); | |
3434 | ||
3435 | return CMD_SUCCESS; | |
3436 | } | |
3437 | ||
3438 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
3439 | no_bgp_bestpath_aspath_ignore_cmd, | |
3440 | "no bgp bestpath as-path ignore", | |
3441 | NO_STR | |
3442 | BGP_STR | |
3443 | "Change the default bestpath selection\n" | |
3444 | "AS-path attribute\n" | |
3445 | "Ignore as-path length in selecting a route\n") | |
3446 | { | |
3447 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3448 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3449 | bgp_recalculate_all_bestpaths(bgp); | |
3450 | ||
3451 | return CMD_SUCCESS; | |
3452 | } | |
3453 | ||
3454 | /* "bgp bestpath as-path confed" configuration. */ | |
3455 | DEFUN (bgp_bestpath_aspath_confed, | |
3456 | bgp_bestpath_aspath_confed_cmd, | |
3457 | "bgp bestpath as-path confed", | |
3458 | BGP_STR | |
3459 | "Change the default bestpath selection\n" | |
3460 | "AS-path attribute\n" | |
3461 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3462 | { | |
3463 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3464 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3465 | bgp_recalculate_all_bestpaths(bgp); | |
3466 | ||
3467 | return CMD_SUCCESS; | |
3468 | } | |
3469 | ||
3470 | DEFUN (no_bgp_bestpath_aspath_confed, | |
3471 | no_bgp_bestpath_aspath_confed_cmd, | |
3472 | "no bgp bestpath as-path confed", | |
3473 | NO_STR | |
3474 | BGP_STR | |
3475 | "Change the default bestpath selection\n" | |
3476 | "AS-path attribute\n" | |
3477 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3478 | { | |
3479 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3480 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3481 | bgp_recalculate_all_bestpaths(bgp); | |
3482 | ||
3483 | return CMD_SUCCESS; | |
3484 | } | |
3485 | ||
3486 | /* "bgp bestpath as-path multipath-relax" configuration. */ | |
3487 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
3488 | bgp_bestpath_aspath_multipath_relax_cmd, | |
3489 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", | |
3490 | BGP_STR | |
3491 | "Change the default bestpath selection\n" | |
3492 | "AS-path attribute\n" | |
3493 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
3494 | "Generate an AS_SET\n" | |
3495 | "Do not generate an AS_SET\n") | |
3496 | { | |
3497 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3498 | int idx = 0; | |
3499 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3500 | ||
3501 | /* no-as-set is now the default behavior so we can silently | |
3502 | * ignore it */ | |
3503 | if (argv_find(argv, argc, "as-set", &idx)) | |
3504 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3505 | else | |
3506 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3507 | ||
3508 | bgp_recalculate_all_bestpaths(bgp); | |
3509 | ||
3510 | return CMD_SUCCESS; | |
3511 | } | |
3512 | ||
3513 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, | |
3514 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
3515 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", | |
3516 | NO_STR | |
3517 | BGP_STR | |
3518 | "Change the default bestpath selection\n" | |
3519 | "AS-path attribute\n" | |
3520 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
3521 | "Generate an AS_SET\n" | |
3522 | "Do not generate an AS_SET\n") | |
3523 | { | |
3524 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3525 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3526 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3527 | bgp_recalculate_all_bestpaths(bgp); | |
3528 | ||
3529 | return CMD_SUCCESS; | |
3530 | } | |
3531 | ||
3532 | /* "bgp bestpath peer-type multipath-relax" configuration. */ | |
3533 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3534 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3535 | "bgp bestpath peer-type multipath-relax", | |
3536 | BGP_STR | |
3537 | "Change the default bestpath selection\n" | |
3538 | "Peer type\n" | |
3539 | "Allow load sharing across routes learned from different peer types\n") | |
3540 | { | |
3541 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3542 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3543 | bgp_recalculate_all_bestpaths(bgp); | |
3544 | ||
3545 | return CMD_SUCCESS; | |
3546 | } | |
3547 | ||
3548 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3549 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3550 | "no bgp bestpath peer-type multipath-relax", | |
3551 | NO_STR BGP_STR | |
3552 | "Change the default bestpath selection\n" | |
3553 | "Peer type\n" | |
3554 | "Allow load sharing across routes learned from different peer types\n") | |
3555 | { | |
3556 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3557 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3558 | bgp_recalculate_all_bestpaths(bgp); | |
3559 | ||
3560 | return CMD_SUCCESS; | |
3561 | } | |
3562 | ||
3563 | /* "bgp log-neighbor-changes" configuration. */ | |
3564 | DEFUN (bgp_log_neighbor_changes, | |
3565 | bgp_log_neighbor_changes_cmd, | |
3566 | "bgp log-neighbor-changes", | |
3567 | BGP_STR | |
3568 | "Log neighbor up/down and reset reason\n") | |
3569 | { | |
3570 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3571 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3572 | return CMD_SUCCESS; | |
3573 | } | |
3574 | ||
3575 | DEFUN (no_bgp_log_neighbor_changes, | |
3576 | no_bgp_log_neighbor_changes_cmd, | |
3577 | "no bgp log-neighbor-changes", | |
3578 | NO_STR | |
3579 | BGP_STR | |
3580 | "Log neighbor up/down and reset reason\n") | |
3581 | { | |
3582 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3583 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3584 | return CMD_SUCCESS; | |
3585 | } | |
3586 | ||
3587 | /* "bgp bestpath med" configuration. */ | |
3588 | DEFUN (bgp_bestpath_med, | |
3589 | bgp_bestpath_med_cmd, | |
3590 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", | |
3591 | BGP_STR | |
3592 | "Change the default bestpath selection\n" | |
3593 | "MED attribute\n" | |
3594 | "Compare MED among confederation paths\n" | |
3595 | "Treat missing MED as the least preferred one\n" | |
3596 | "Treat missing MED as the least preferred one\n" | |
3597 | "Compare MED among confederation paths\n") | |
3598 | { | |
3599 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3600 | ||
3601 | int idx = 0; | |
3602 | if (argv_find(argv, argc, "confed", &idx)) | |
3603 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); | |
3604 | idx = 0; | |
3605 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
3606 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); | |
3607 | ||
3608 | bgp_recalculate_all_bestpaths(bgp); | |
3609 | ||
3610 | return CMD_SUCCESS; | |
3611 | } | |
3612 | ||
3613 | DEFUN (no_bgp_bestpath_med, | |
3614 | no_bgp_bestpath_med_cmd, | |
3615 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", | |
3616 | NO_STR | |
3617 | BGP_STR | |
3618 | "Change the default bestpath selection\n" | |
3619 | "MED attribute\n" | |
3620 | "Compare MED among confederation paths\n" | |
3621 | "Treat missing MED as the least preferred one\n" | |
3622 | "Treat missing MED as the least preferred one\n" | |
3623 | "Compare MED among confederation paths\n") | |
3624 | { | |
3625 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3626 | ||
3627 | int idx = 0; | |
3628 | if (argv_find(argv, argc, "confed", &idx)) | |
3629 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); | |
3630 | idx = 0; | |
3631 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
3632 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); | |
3633 | ||
3634 | bgp_recalculate_all_bestpaths(bgp); | |
3635 | ||
3636 | return CMD_SUCCESS; | |
3637 | } | |
3638 | ||
3639 | /* "bgp bestpath bandwidth" configuration. */ | |
3640 | DEFPY (bgp_bestpath_bw, | |
3641 | bgp_bestpath_bw_cmd, | |
3642 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", | |
3643 | BGP_STR | |
3644 | "Change the default bestpath selection\n" | |
3645 | "Link Bandwidth attribute\n" | |
3646 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3647 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3648 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3649 | { | |
3650 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3651 | afi_t afi; | |
3652 | safi_t safi; | |
3653 | ||
3654 | if (!bw_cfg) { | |
3655 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3656 | return CMD_ERR_INCOMPLETE; | |
3657 | } | |
3658 | if (!strcmp(bw_cfg, "ignore")) | |
3659 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3660 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3661 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3662 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3663 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3664 | else | |
3665 | return CMD_ERR_NO_MATCH; | |
3666 | ||
3667 | /* This config is used in route install, so redo that. */ | |
3668 | FOREACH_AFI_SAFI (afi, safi) { | |
3669 | if (!bgp_fibupd_safi(safi)) | |
3670 | continue; | |
3671 | bgp_zebra_announce_table(bgp, afi, safi); | |
3672 | } | |
3673 | ||
3674 | return CMD_SUCCESS; | |
3675 | } | |
3676 | ||
3677 | DEFPY (no_bgp_bestpath_bw, | |
3678 | no_bgp_bestpath_bw_cmd, | |
3679 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3680 | NO_STR | |
3681 | BGP_STR | |
3682 | "Change the default bestpath selection\n" | |
3683 | "Link Bandwidth attribute\n" | |
3684 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3685 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3686 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3687 | { | |
3688 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3689 | afi_t afi; | |
3690 | safi_t safi; | |
3691 | ||
3692 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3693 | ||
3694 | /* This config is used in route install, so redo that. */ | |
3695 | FOREACH_AFI_SAFI (afi, safi) { | |
3696 | if (!bgp_fibupd_safi(safi)) | |
3697 | continue; | |
3698 | bgp_zebra_announce_table(bgp, afi, safi); | |
3699 | } | |
3700 | return CMD_SUCCESS; | |
3701 | } | |
3702 | ||
3703 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, | |
3704 | "[no] bgp default <ipv4-unicast|" | |
3705 | "ipv4-multicast|" | |
3706 | "ipv4-vpn|" | |
3707 | "ipv4-labeled-unicast|" | |
3708 | "ipv4-flowspec|" | |
3709 | "ipv6-unicast|" | |
3710 | "ipv6-multicast|" | |
3711 | "ipv6-vpn|" | |
3712 | "ipv6-labeled-unicast|" | |
3713 | "ipv6-flowspec|" | |
3714 | "l2vpn-evpn>$afi_safi", | |
3715 | NO_STR | |
3716 | BGP_STR | |
3717 | "Configure BGP defaults\n" | |
3718 | "Activate ipv4-unicast for a peer by default\n" | |
3719 | "Activate ipv4-multicast for a peer by default\n" | |
3720 | "Activate ipv4-vpn for a peer by default\n" | |
3721 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3722 | "Activate ipv4-flowspec for a peer by default\n" | |
3723 | "Activate ipv6-unicast for a peer by default\n" | |
3724 | "Activate ipv6-multicast for a peer by default\n" | |
3725 | "Activate ipv6-vpn for a peer by default\n" | |
3726 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3727 | "Activate ipv6-flowspec for a peer by default\n" | |
3728 | "Activate l2vpn-evpn for a peer by default\n") | |
3729 | { | |
3730 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3731 | char afi_safi_str[strlen(afi_safi) + 1]; | |
3732 | char *afi_safi_str_tok; | |
3733 | ||
3734 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); | |
3735 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3736 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3737 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
3738 | safi_t safi; | |
3739 | ||
3740 | if (strmatch(safi_str, "labeled")) | |
3741 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3742 | else | |
3743 | safi = bgp_vty_safi_from_str(safi_str); | |
3744 | ||
3745 | if (no) | |
3746 | bgp->default_af[afi][safi] = false; | |
3747 | else { | |
3748 | if ((safi == SAFI_LABELED_UNICAST | |
3749 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3750 | || (safi == SAFI_UNICAST | |
3751 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3752 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3753 | else | |
3754 | bgp->default_af[afi][safi] = true; | |
3755 | } | |
3756 | ||
3757 | return CMD_SUCCESS; | |
3758 | } | |
3759 | ||
3760 | /* Display hostname in certain command outputs */ | |
3761 | DEFUN (bgp_default_show_hostname, | |
3762 | bgp_default_show_hostname_cmd, | |
3763 | "bgp default show-hostname", | |
3764 | BGP_STR | |
3765 | "Configure BGP defaults\n" | |
3766 | "Show hostname in certain command outputs\n") | |
3767 | { | |
3768 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3769 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3770 | return CMD_SUCCESS; | |
3771 | } | |
3772 | ||
3773 | DEFUN (no_bgp_default_show_hostname, | |
3774 | no_bgp_default_show_hostname_cmd, | |
3775 | "no bgp default show-hostname", | |
3776 | NO_STR | |
3777 | BGP_STR | |
3778 | "Configure BGP defaults\n" | |
3779 | "Show hostname in certain command outputs\n") | |
3780 | { | |
3781 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3782 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3783 | return CMD_SUCCESS; | |
3784 | } | |
3785 | ||
3786 | /* Display hostname in certain command outputs */ | |
3787 | DEFUN (bgp_default_show_nexthop_hostname, | |
3788 | bgp_default_show_nexthop_hostname_cmd, | |
3789 | "bgp default show-nexthop-hostname", | |
3790 | BGP_STR | |
3791 | "Configure BGP defaults\n" | |
3792 | "Show hostname for nexthop in certain command outputs\n") | |
3793 | { | |
3794 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3795 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3796 | return CMD_SUCCESS; | |
3797 | } | |
3798 | ||
3799 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3800 | no_bgp_default_show_nexthop_hostname_cmd, | |
3801 | "no bgp default show-nexthop-hostname", | |
3802 | NO_STR | |
3803 | BGP_STR | |
3804 | "Configure BGP defaults\n" | |
3805 | "Show hostname for nexthop in certain command outputs\n") | |
3806 | { | |
3807 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3808 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3809 | return CMD_SUCCESS; | |
3810 | } | |
3811 | ||
3812 | /* "bgp network import-check" configuration. */ | |
3813 | DEFUN (bgp_network_import_check, | |
3814 | bgp_network_import_check_cmd, | |
3815 | "bgp network import-check", | |
3816 | BGP_STR | |
3817 | "BGP network command\n" | |
3818 | "Check BGP network route exists in IGP\n") | |
3819 | { | |
3820 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3821 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3822 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3823 | bgp_static_redo_import_check(bgp); | |
3824 | } | |
3825 | ||
3826 | return CMD_SUCCESS; | |
3827 | } | |
3828 | ||
3829 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, | |
3830 | "bgp network import-check exact", | |
3831 | BGP_STR | |
3832 | "BGP network command\n" | |
3833 | "Check BGP network route exists in IGP\n" | |
3834 | "Match route precisely\n") | |
3835 | ||
3836 | DEFUN (no_bgp_network_import_check, | |
3837 | no_bgp_network_import_check_cmd, | |
3838 | "no bgp network import-check", | |
3839 | NO_STR | |
3840 | BGP_STR | |
3841 | "BGP network command\n" | |
3842 | "Check BGP network route exists in IGP\n") | |
3843 | { | |
3844 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3845 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3846 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3847 | bgp_static_redo_import_check(bgp); | |
3848 | } | |
3849 | ||
3850 | return CMD_SUCCESS; | |
3851 | } | |
3852 | ||
3853 | DEFUN (bgp_default_local_preference, | |
3854 | bgp_default_local_preference_cmd, | |
3855 | "bgp default local-preference (0-4294967295)", | |
3856 | BGP_STR | |
3857 | "Configure BGP defaults\n" | |
3858 | "local preference (higher=more preferred)\n" | |
3859 | "Configure default local preference value\n") | |
3860 | { | |
3861 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3862 | int idx_number = 3; | |
3863 | uint32_t local_pref; | |
3864 | ||
3865 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); | |
3866 | ||
3867 | bgp_default_local_preference_set(bgp, local_pref); | |
3868 | bgp_clear_star_soft_in(vty, bgp->name); | |
3869 | ||
3870 | return CMD_SUCCESS; | |
3871 | } | |
3872 | ||
3873 | DEFUN (no_bgp_default_local_preference, | |
3874 | no_bgp_default_local_preference_cmd, | |
3875 | "no bgp default local-preference [(0-4294967295)]", | |
3876 | NO_STR | |
3877 | BGP_STR | |
3878 | "Configure BGP defaults\n" | |
3879 | "local preference (higher=more preferred)\n" | |
3880 | "Configure default local preference value\n") | |
3881 | { | |
3882 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3883 | bgp_default_local_preference_unset(bgp); | |
3884 | bgp_clear_star_soft_in(vty, bgp->name); | |
3885 | ||
3886 | return CMD_SUCCESS; | |
3887 | } | |
3888 | ||
3889 | ||
3890 | DEFUN (bgp_default_subgroup_pkt_queue_max, | |
3891 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3892 | "bgp default subgroup-pkt-queue-max (20-100)", | |
3893 | BGP_STR | |
3894 | "Configure BGP defaults\n" | |
3895 | "subgroup-pkt-queue-max\n" | |
3896 | "Configure subgroup packet queue max\n") | |
3897 | { | |
3898 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3899 | int idx_number = 3; | |
3900 | uint32_t max_size; | |
3901 | ||
3902 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); | |
3903 | ||
3904 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); | |
3905 | ||
3906 | return CMD_SUCCESS; | |
3907 | } | |
3908 | ||
3909 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3910 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3911 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3912 | NO_STR | |
3913 | BGP_STR | |
3914 | "Configure BGP defaults\n" | |
3915 | "subgroup-pkt-queue-max\n" | |
3916 | "Configure subgroup packet queue max\n") | |
3917 | { | |
3918 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3919 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3920 | return CMD_SUCCESS; | |
3921 | } | |
3922 | ||
3923 | ||
3924 | DEFUN (bgp_rr_allow_outbound_policy, | |
3925 | bgp_rr_allow_outbound_policy_cmd, | |
3926 | "bgp route-reflector allow-outbound-policy", | |
3927 | BGP_STR | |
3928 | "Allow modifications made by out route-map\n" | |
3929 | "on ibgp neighbors\n") | |
3930 | { | |
3931 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3932 | ||
3933 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
3934 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3935 | update_group_announce_rrclients(bgp); | |
3936 | bgp_clear_star_soft_out(vty, bgp->name); | |
3937 | } | |
3938 | ||
3939 | return CMD_SUCCESS; | |
3940 | } | |
3941 | ||
3942 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3943 | no_bgp_rr_allow_outbound_policy_cmd, | |
3944 | "no bgp route-reflector allow-outbound-policy", | |
3945 | NO_STR | |
3946 | BGP_STR | |
3947 | "Allow modifications made by out route-map\n" | |
3948 | "on ibgp neighbors\n") | |
3949 | { | |
3950 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3951 | ||
3952 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
3953 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3954 | update_group_announce_rrclients(bgp); | |
3955 | bgp_clear_star_soft_out(vty, bgp->name); | |
3956 | } | |
3957 | ||
3958 | return CMD_SUCCESS; | |
3959 | } | |
3960 | ||
3961 | DEFUN (bgp_listen_limit, | |
3962 | bgp_listen_limit_cmd, | |
3963 | "bgp listen limit (1-65535)", | |
3964 | BGP_STR | |
3965 | "BGP Dynamic Neighbors listen commands\n" | |
3966 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3967 | "Configure Dynamic Neighbors listen limit value\n") | |
3968 | { | |
3969 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3970 | int idx_number = 3; | |
3971 | int listen_limit; | |
3972 | ||
3973 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
3974 | ||
3975 | bgp_listen_limit_set(bgp, listen_limit); | |
3976 | ||
3977 | return CMD_SUCCESS; | |
3978 | } | |
3979 | ||
3980 | DEFUN (no_bgp_listen_limit, | |
3981 | no_bgp_listen_limit_cmd, | |
3982 | "no bgp listen limit [(1-65535)]", | |
3983 | NO_STR | |
3984 | BGP_STR | |
3985 | "BGP Dynamic Neighbors listen commands\n" | |
3986 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3987 | "Configure Dynamic Neighbors listen limit value\n") | |
3988 | { | |
3989 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3990 | bgp_listen_limit_unset(bgp); | |
3991 | return CMD_SUCCESS; | |
3992 | } | |
3993 | ||
3994 | ||
3995 | /* | |
3996 | * Check if this listen range is already configured. Check for exact | |
3997 | * match or overlap based on input. | |
3998 | */ | |
3999 | static struct peer_group *listen_range_exists(struct bgp *bgp, | |
4000 | struct prefix *range, int exact) | |
4001 | { | |
4002 | struct listnode *node, *nnode; | |
4003 | struct listnode *node1, *nnode1; | |
4004 | struct peer_group *group; | |
4005 | struct prefix *lr; | |
4006 | afi_t afi; | |
4007 | int match; | |
4008 | ||
4009 | afi = family2afi(range->family); | |
4010 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4011 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4012 | lr)) { | |
4013 | if (exact) | |
4014 | match = prefix_same(range, lr); | |
4015 | else | |
4016 | match = (prefix_match(range, lr) | |
4017 | || prefix_match(lr, range)); | |
4018 | if (match) | |
4019 | return group; | |
4020 | } | |
4021 | } | |
4022 | ||
4023 | return NULL; | |
4024 | } | |
4025 | ||
4026 | DEFUN (bgp_listen_range, | |
4027 | bgp_listen_range_cmd, | |
4028 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", | |
4029 | BGP_STR | |
4030 | "Configure BGP dynamic neighbors listen range\n" | |
4031 | "Configure BGP dynamic neighbors listen range\n" | |
4032 | NEIGHBOR_ADDR_STR | |
4033 | "Member of the peer-group\n" | |
4034 | "Peer-group name\n") | |
4035 | { | |
4036 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4037 | struct prefix range; | |
4038 | struct peer_group *group, *existing_group; | |
4039 | afi_t afi; | |
4040 | int ret; | |
4041 | int idx = 0; | |
4042 | ||
4043 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4044 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4045 | char *prefix = argv[idx]->arg; | |
4046 | argv_find(argv, argc, "PGNAME", &idx); | |
4047 | char *peergroup = argv[idx]->arg; | |
4048 | ||
4049 | /* Convert IP prefix string to struct prefix. */ | |
4050 | ret = str2prefix(prefix, &range); | |
4051 | if (!ret) { | |
4052 | vty_out(vty, "%% Malformed listen range\n"); | |
4053 | return CMD_WARNING_CONFIG_FAILED; | |
4054 | } | |
4055 | ||
4056 | afi = family2afi(range.family); | |
4057 | ||
4058 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4059 | vty_out(vty, | |
4060 | "%% Malformed listen range (link-local address)\n"); | |
4061 | return CMD_WARNING_CONFIG_FAILED; | |
4062 | } | |
4063 | ||
4064 | apply_mask(&range); | |
4065 | ||
4066 | /* Check if same listen range is already configured. */ | |
4067 | existing_group = listen_range_exists(bgp, &range, 1); | |
4068 | if (existing_group) { | |
4069 | if (strcmp(existing_group->name, peergroup) == 0) | |
4070 | return CMD_SUCCESS; | |
4071 | else { | |
4072 | vty_out(vty, | |
4073 | "%% Same listen range is attached to peer-group %s\n", | |
4074 | existing_group->name); | |
4075 | return CMD_WARNING_CONFIG_FAILED; | |
4076 | } | |
4077 | } | |
4078 | ||
4079 | /* Check if an overlapping listen range exists. */ | |
4080 | if (listen_range_exists(bgp, &range, 0)) { | |
4081 | vty_out(vty, | |
4082 | "%% Listen range overlaps with existing listen range\n"); | |
4083 | return CMD_WARNING_CONFIG_FAILED; | |
4084 | } | |
4085 | ||
4086 | group = peer_group_lookup(bgp, peergroup); | |
4087 | if (!group) { | |
4088 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4089 | return CMD_WARNING_CONFIG_FAILED; | |
4090 | } | |
4091 | ||
4092 | ret = peer_group_listen_range_add(group, &range); | |
4093 | return bgp_vty_return(vty, ret); | |
4094 | } | |
4095 | ||
4096 | DEFUN (no_bgp_listen_range, | |
4097 | no_bgp_listen_range_cmd, | |
4098 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", | |
4099 | NO_STR | |
4100 | BGP_STR | |
4101 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4102 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4103 | NEIGHBOR_ADDR_STR | |
4104 | "Member of the peer-group\n" | |
4105 | "Peer-group name\n") | |
4106 | { | |
4107 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4108 | struct prefix range; | |
4109 | struct peer_group *group; | |
4110 | afi_t afi; | |
4111 | int ret; | |
4112 | int idx = 0; | |
4113 | ||
4114 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4115 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4116 | char *prefix = argv[idx]->arg; | |
4117 | argv_find(argv, argc, "PGNAME", &idx); | |
4118 | char *peergroup = argv[idx]->arg; | |
4119 | ||
4120 | /* Convert IP prefix string to struct prefix. */ | |
4121 | ret = str2prefix(prefix, &range); | |
4122 | if (!ret) { | |
4123 | vty_out(vty, "%% Malformed listen range\n"); | |
4124 | return CMD_WARNING_CONFIG_FAILED; | |
4125 | } | |
4126 | ||
4127 | afi = family2afi(range.family); | |
4128 | ||
4129 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4130 | vty_out(vty, | |
4131 | "%% Malformed listen range (link-local address)\n"); | |
4132 | return CMD_WARNING_CONFIG_FAILED; | |
4133 | } | |
4134 | ||
4135 | apply_mask(&range); | |
4136 | ||
4137 | group = peer_group_lookup(bgp, peergroup); | |
4138 | if (!group) { | |
4139 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4140 | return CMD_WARNING_CONFIG_FAILED; | |
4141 | } | |
4142 | ||
4143 | ret = peer_group_listen_range_del(group, &range); | |
4144 | return bgp_vty_return(vty, ret); | |
4145 | } | |
4146 | ||
4147 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) | |
4148 | { | |
4149 | struct peer_group *group; | |
4150 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4151 | struct prefix *range; | |
4152 | afi_t afi; | |
4153 | ||
4154 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4155 | vty_out(vty, " bgp listen limit %d\n", | |
4156 | bgp->dynamic_neighbors_limit); | |
4157 | ||
4158 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4159 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4160 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4161 | nrnode, range)) { | |
4162 | vty_out(vty, | |
4163 | " bgp listen range %pFX peer-group %s\n", | |
4164 | range, group->name); | |
4165 | } | |
4166 | } | |
4167 | } | |
4168 | } | |
4169 | ||
4170 | ||
4171 | DEFUN (bgp_disable_connected_route_check, | |
4172 | bgp_disable_connected_route_check_cmd, | |
4173 | "bgp disable-ebgp-connected-route-check", | |
4174 | BGP_STR | |
4175 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
4176 | { | |
4177 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4178 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4179 | bgp_clear_star_soft_in(vty, bgp->name); | |
4180 | ||
4181 | return CMD_SUCCESS; | |
4182 | } | |
4183 | ||
4184 | DEFUN (no_bgp_disable_connected_route_check, | |
4185 | no_bgp_disable_connected_route_check_cmd, | |
4186 | "no bgp disable-ebgp-connected-route-check", | |
4187 | NO_STR | |
4188 | BGP_STR | |
4189 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
4190 | { | |
4191 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4192 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4193 | bgp_clear_star_soft_in(vty, bgp->name); | |
4194 | ||
4195 | return CMD_SUCCESS; | |
4196 | } | |
4197 | ||
4198 | ||
4199 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
4200 | const char *as_str) | |
4201 | { | |
4202 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4203 | int ret; | |
4204 | as_t as; | |
4205 | int as_type = AS_SPECIFIED; | |
4206 | union sockunion su; | |
4207 | ||
4208 | if (as_str[0] == 'i') { | |
4209 | as = 0; | |
4210 | as_type = AS_INTERNAL; | |
4211 | } else if (as_str[0] == 'e') { | |
4212 | as = 0; | |
4213 | as_type = AS_EXTERNAL; | |
4214 | } else { | |
4215 | /* Get AS number. */ | |
4216 | as = strtoul(as_str, NULL, 10); | |
4217 | } | |
4218 | ||
4219 | /* If peer is peer group or interface peer, call proper function. */ | |
4220 | ret = str2sockunion(peer_str, &su); | |
4221 | if (ret < 0) { | |
4222 | struct peer *peer; | |
4223 | ||
4224 | /* Check if existing interface peer */ | |
4225 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4226 | ||
4227 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4228 | ||
4229 | /* if not interface peer, check peer-group settings */ | |
4230 | if (ret < 0 && !peer) { | |
4231 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4232 | if (ret < 0) { | |
4233 | vty_out(vty, | |
4234 | "%% Create the peer-group or interface first\n"); | |
4235 | return CMD_WARNING_CONFIG_FAILED; | |
4236 | } | |
4237 | return CMD_SUCCESS; | |
4238 | } | |
4239 | } else { | |
4240 | if (peer_address_self_check(bgp, &su)) { | |
4241 | vty_out(vty, | |
4242 | "%% Can not configure the local system as neighbor\n"); | |
4243 | return CMD_WARNING_CONFIG_FAILED; | |
4244 | } | |
4245 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4246 | } | |
4247 | ||
4248 | return bgp_vty_return(vty, ret); | |
4249 | } | |
4250 | ||
4251 | DEFUN (bgp_default_shutdown, | |
4252 | bgp_default_shutdown_cmd, | |
4253 | "[no] bgp default shutdown", | |
4254 | NO_STR | |
4255 | BGP_STR | |
4256 | "Configure BGP defaults\n" | |
4257 | "Apply administrative shutdown to newly configured peers\n") | |
4258 | { | |
4259 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4260 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4261 | return CMD_SUCCESS; | |
4262 | } | |
4263 | ||
4264 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", | |
4265 | BGP_STR | |
4266 | "Administrative shutdown of the BGP instance\n" | |
4267 | "Add a shutdown message (RFC 8203)\n" | |
4268 | "Shutdown message\n") | |
4269 | { | |
4270 | char *msgstr = NULL; | |
4271 | ||
4272 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4273 | ||
4274 | if (argc > 3) | |
4275 | msgstr = argv_concat(argv, argc, 3); | |
4276 | ||
4277 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { | |
4278 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4279 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4280 | return CMD_WARNING_CONFIG_FAILED; | |
4281 | } | |
4282 | ||
4283 | bgp_shutdown_enable(bgp, msgstr); | |
4284 | XFREE(MTYPE_TMP, msgstr); | |
4285 | ||
4286 | return CMD_SUCCESS; | |
4287 | } | |
4288 | ||
4289 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", | |
4290 | BGP_STR "Administrative shutdown of the BGP instance\n") | |
4291 | { | |
4292 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4293 | ||
4294 | bgp_shutdown_enable(bgp, NULL); | |
4295 | ||
4296 | return CMD_SUCCESS; | |
4297 | } | |
4298 | ||
4299 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", | |
4300 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") | |
4301 | { | |
4302 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4303 | ||
4304 | bgp_shutdown_disable(bgp); | |
4305 | ||
4306 | return CMD_SUCCESS; | |
4307 | } | |
4308 | ||
4309 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, | |
4310 | "no bgp shutdown message MSG...", NO_STR BGP_STR | |
4311 | "Administrative shutdown of the BGP instance\n" | |
4312 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") | |
4313 | ||
4314 | DEFUN (neighbor_remote_as, | |
4315 | neighbor_remote_as_cmd, | |
4316 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4317 | NEIGHBOR_STR | |
4318 | NEIGHBOR_ADDR_STR2 | |
4319 | "Specify a BGP neighbor\n" | |
4320 | AS_STR | |
4321 | "Internal BGP peer\n" | |
4322 | "External BGP peer\n") | |
4323 | { | |
4324 | int idx_peer = 1; | |
4325 | int idx_remote_as = 3; | |
4326 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
4327 | argv[idx_remote_as]->arg); | |
4328 | } | |
4329 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp | |
4330 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4331 | * when nexthop becomes unreachable | |
4332 | */ | |
4333 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4334 | BGP_STR "Fast convergence for bgp sessions\n") | |
4335 | { | |
4336 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4337 | bgp->fast_convergence = true; | |
4338 | ||
4339 | return CMD_SUCCESS; | |
4340 | } | |
4341 | ||
4342 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4343 | "no bgp fast-convergence", | |
4344 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4345 | { | |
4346 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4347 | bgp->fast_convergence = false; | |
4348 | ||
4349 | return CMD_SUCCESS; | |
4350 | } | |
4351 | ||
4352 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
4353 | int v6only, | |
4354 | const char *peer_group_name, | |
4355 | const char *as_str) | |
4356 | { | |
4357 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4358 | as_t as = 0; | |
4359 | int as_type = AS_UNSPECIFIED; | |
4360 | struct peer *peer; | |
4361 | struct peer_group *group; | |
4362 | int ret = 0; | |
4363 | ||
4364 | group = peer_group_lookup(bgp, conf_if); | |
4365 | ||
4366 | if (group) { | |
4367 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
4368 | return CMD_WARNING_CONFIG_FAILED; | |
4369 | } | |
4370 | ||
4371 | if (as_str) { | |
4372 | if (as_str[0] == 'i') { | |
4373 | as_type = AS_INTERNAL; | |
4374 | } else if (as_str[0] == 'e') { | |
4375 | as_type = AS_EXTERNAL; | |
4376 | } else { | |
4377 | /* Get AS number. */ | |
4378 | as = strtoul(as_str, NULL, 10); | |
4379 | as_type = AS_SPECIFIED; | |
4380 | } | |
4381 | } | |
4382 | ||
4383 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4384 | if (peer) { | |
4385 | if (as_str) | |
4386 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); | |
4387 | } else { | |
4388 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, | |
4389 | NULL); | |
4390 | ||
4391 | if (!peer) { | |
4392 | vty_out(vty, "%% BGP failed to create peer\n"); | |
4393 | return CMD_WARNING_CONFIG_FAILED; | |
4394 | } | |
4395 | ||
4396 | if (v6only) | |
4397 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); | |
4398 | ||
4399 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4400 | * this | |
4401 | * any unnumbered peer in order to not worry about run-time | |
4402 | * transitions | |
4403 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4404 | * address | |
4405 | * gets deleted later etc.) | |
4406 | */ | |
4407 | if (peer->ifp) | |
4408 | bgp_zebra_initiate_radv(bgp, peer); | |
4409 | } | |
4410 | ||
4411 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4412 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4413 | if (v6only) | |
4414 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); | |
4415 | else | |
4416 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); | |
4417 | ||
4418 | /* v6only flag changed. Reset bgp seesion */ | |
4419 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4420 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4421 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4422 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4423 | } else | |
4424 | bgp_session_reset(peer); | |
4425 | } | |
4426 | ||
4427 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { | |
4428 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4429 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
4430 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
4431 | } | |
4432 | ||
4433 | if (peer_group_name) { | |
4434 | group = peer_group_lookup(bgp, peer_group_name); | |
4435 | if (!group) { | |
4436 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4437 | return CMD_WARNING_CONFIG_FAILED; | |
4438 | } | |
4439 | ||
4440 | ret = peer_group_bind(bgp, NULL, peer, group, &as); | |
4441 | } | |
4442 | ||
4443 | return bgp_vty_return(vty, ret); | |
4444 | } | |
4445 | ||
4446 | DEFUN (neighbor_interface_config, | |
4447 | neighbor_interface_config_cmd, | |
4448 | "neighbor WORD interface [peer-group PGNAME]", | |
4449 | NEIGHBOR_STR | |
4450 | "Interface name or neighbor tag\n" | |
4451 | "Enable BGP on interface\n" | |
4452 | "Member of the peer-group\n" | |
4453 | "Peer-group name\n") | |
4454 | { | |
4455 | int idx_word = 1; | |
4456 | int idx_peer_group_word = 4; | |
4457 | ||
4458 | if (argc > idx_peer_group_word) | |
4459 | return peer_conf_interface_get( | |
4460 | vty, argv[idx_word]->arg, 0, | |
4461 | argv[idx_peer_group_word]->arg, NULL); | |
4462 | else | |
4463 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4464 | NULL, NULL); | |
4465 | } | |
4466 | ||
4467 | DEFUN (neighbor_interface_config_v6only, | |
4468 | neighbor_interface_config_v6only_cmd, | |
4469 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4470 | NEIGHBOR_STR | |
4471 | "Interface name or neighbor tag\n" | |
4472 | "Enable BGP on interface\n" | |
4473 | "Enable BGP with v6 link-local only\n" | |
4474 | "Member of the peer-group\n" | |
4475 | "Peer-group name\n") | |
4476 | { | |
4477 | int idx_word = 1; | |
4478 | int idx_peer_group_word = 5; | |
4479 | ||
4480 | if (argc > idx_peer_group_word) | |
4481 | return peer_conf_interface_get( | |
4482 | vty, argv[idx_word]->arg, 1, | |
4483 | argv[idx_peer_group_word]->arg, NULL); | |
4484 | ||
4485 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); | |
4486 | } | |
4487 | ||
4488 | ||
4489 | DEFUN (neighbor_interface_config_remote_as, | |
4490 | neighbor_interface_config_remote_as_cmd, | |
4491 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4492 | NEIGHBOR_STR | |
4493 | "Interface name or neighbor tag\n" | |
4494 | "Enable BGP on interface\n" | |
4495 | "Specify a BGP neighbor\n" | |
4496 | AS_STR | |
4497 | "Internal BGP peer\n" | |
4498 | "External BGP peer\n") | |
4499 | { | |
4500 | int idx_word = 1; | |
4501 | int idx_remote_as = 4; | |
4502 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, | |
4503 | argv[idx_remote_as]->arg); | |
4504 | } | |
4505 | ||
4506 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
4507 | neighbor_interface_v6only_config_remote_as_cmd, | |
4508 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4509 | NEIGHBOR_STR | |
4510 | "Interface name or neighbor tag\n" | |
4511 | "Enable BGP with v6 link-local only\n" | |
4512 | "Enable BGP on interface\n" | |
4513 | "Specify a BGP neighbor\n" | |
4514 | AS_STR | |
4515 | "Internal BGP peer\n" | |
4516 | "External BGP peer\n") | |
4517 | { | |
4518 | int idx_word = 1; | |
4519 | int idx_remote_as = 5; | |
4520 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, | |
4521 | argv[idx_remote_as]->arg); | |
4522 | } | |
4523 | ||
4524 | DEFUN (neighbor_peer_group, | |
4525 | neighbor_peer_group_cmd, | |
4526 | "neighbor WORD peer-group", | |
4527 | NEIGHBOR_STR | |
4528 | "Interface name or neighbor tag\n" | |
4529 | "Configure peer-group\n") | |
4530 | { | |
4531 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4532 | int idx_word = 1; | |
4533 | struct peer *peer; | |
4534 | struct peer_group *group; | |
4535 | ||
4536 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4537 | if (peer) { | |
4538 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4539 | return CMD_WARNING_CONFIG_FAILED; | |
4540 | } | |
4541 | ||
4542 | group = peer_group_get(bgp, argv[idx_word]->arg); | |
4543 | if (!group) { | |
4544 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4545 | return CMD_WARNING_CONFIG_FAILED; | |
4546 | } | |
4547 | ||
4548 | return CMD_SUCCESS; | |
4549 | } | |
4550 | ||
4551 | DEFUN (no_neighbor, | |
4552 | no_neighbor_cmd, | |
4553 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4554 | NO_STR | |
4555 | NEIGHBOR_STR | |
4556 | NEIGHBOR_ADDR_STR2 | |
4557 | "Specify a BGP neighbor\n" | |
4558 | AS_STR | |
4559 | "Internal BGP peer\n" | |
4560 | "External BGP peer\n") | |
4561 | { | |
4562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4563 | int idx_peer = 2; | |
4564 | int ret; | |
4565 | union sockunion su; | |
4566 | struct peer_group *group; | |
4567 | struct peer *peer; | |
4568 | struct peer *other; | |
4569 | ||
4570 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4571 | if (ret < 0) { | |
4572 | /* look up for neighbor by interface name config. */ | |
4573 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4574 | if (peer) { | |
4575 | /* Request zebra to terminate IPv6 RAs on this | |
4576 | * interface. */ | |
4577 | if (peer->ifp) | |
4578 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4579 | peer_notify_unconfig(peer); | |
4580 | peer_delete(peer); | |
4581 | return CMD_SUCCESS; | |
4582 | } | |
4583 | ||
4584 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4585 | if (group) { | |
4586 | peer_group_notify_unconfig(group); | |
4587 | peer_group_delete(group); | |
4588 | } else { | |
4589 | vty_out(vty, "%% Create the peer-group first\n"); | |
4590 | return CMD_WARNING_CONFIG_FAILED; | |
4591 | } | |
4592 | } else { | |
4593 | peer = peer_lookup(bgp, &su); | |
4594 | if (peer) { | |
4595 | if (peer_dynamic_neighbor(peer)) { | |
4596 | vty_out(vty, | |
4597 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4598 | return CMD_WARNING_CONFIG_FAILED; | |
4599 | } | |
4600 | ||
4601 | other = peer->doppelganger; | |
4602 | ||
4603 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
4604 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4605 | ||
4606 | peer_notify_unconfig(peer); | |
4607 | peer_delete(peer); | |
4608 | if (other && other->status != Deleted) { | |
4609 | peer_notify_unconfig(other); | |
4610 | peer_delete(other); | |
4611 | } | |
4612 | } | |
4613 | } | |
4614 | ||
4615 | return CMD_SUCCESS; | |
4616 | } | |
4617 | ||
4618 | DEFUN (no_neighbor_interface_config, | |
4619 | no_neighbor_interface_config_cmd, | |
4620 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4621 | NO_STR | |
4622 | NEIGHBOR_STR | |
4623 | "Interface name\n" | |
4624 | "Configure BGP on interface\n" | |
4625 | "Enable BGP with v6 link-local only\n" | |
4626 | "Member of the peer-group\n" | |
4627 | "Peer-group name\n" | |
4628 | "Specify a BGP neighbor\n" | |
4629 | AS_STR | |
4630 | "Internal BGP peer\n" | |
4631 | "External BGP peer\n") | |
4632 | { | |
4633 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4634 | int idx_word = 2; | |
4635 | struct peer *peer; | |
4636 | ||
4637 | /* look up for neighbor by interface name config. */ | |
4638 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4639 | if (peer) { | |
4640 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4641 | if (peer->ifp) | |
4642 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4643 | peer_notify_unconfig(peer); | |
4644 | peer_delete(peer); | |
4645 | } else { | |
4646 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4647 | return CMD_WARNING_CONFIG_FAILED; | |
4648 | } | |
4649 | return CMD_SUCCESS; | |
4650 | } | |
4651 | ||
4652 | DEFUN (no_neighbor_peer_group, | |
4653 | no_neighbor_peer_group_cmd, | |
4654 | "no neighbor WORD peer-group", | |
4655 | NO_STR | |
4656 | NEIGHBOR_STR | |
4657 | "Neighbor tag\n" | |
4658 | "Configure peer-group\n") | |
4659 | { | |
4660 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4661 | int idx_word = 2; | |
4662 | struct peer_group *group; | |
4663 | ||
4664 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4665 | if (group) { | |
4666 | peer_group_notify_unconfig(group); | |
4667 | peer_group_delete(group); | |
4668 | } else { | |
4669 | vty_out(vty, "%% Create the peer-group first\n"); | |
4670 | return CMD_WARNING_CONFIG_FAILED; | |
4671 | } | |
4672 | return CMD_SUCCESS; | |
4673 | } | |
4674 | ||
4675 | DEFUN (no_neighbor_interface_peer_group_remote_as, | |
4676 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4677 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4678 | NO_STR | |
4679 | NEIGHBOR_STR | |
4680 | "Interface name or neighbor tag\n" | |
4681 | "Specify a BGP neighbor\n" | |
4682 | AS_STR | |
4683 | "Internal BGP peer\n" | |
4684 | "External BGP peer\n") | |
4685 | { | |
4686 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4687 | int idx_word = 2; | |
4688 | struct peer_group *group; | |
4689 | struct peer *peer; | |
4690 | ||
4691 | /* look up for neighbor by interface name config. */ | |
4692 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4693 | if (peer) { | |
4694 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4695 | return CMD_SUCCESS; | |
4696 | } | |
4697 | ||
4698 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4699 | if (group) | |
4700 | peer_group_remote_as_delete(group); | |
4701 | else { | |
4702 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4703 | return CMD_WARNING_CONFIG_FAILED; | |
4704 | } | |
4705 | return CMD_SUCCESS; | |
4706 | } | |
4707 | ||
4708 | DEFUN (neighbor_local_as, | |
4709 | neighbor_local_as_cmd, | |
4710 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4711 | NEIGHBOR_STR | |
4712 | NEIGHBOR_ADDR_STR2 | |
4713 | "Specify a local-as number\n" | |
4714 | "AS number used as local AS\n") | |
4715 | { | |
4716 | int idx_peer = 1; | |
4717 | int idx_number = 3; | |
4718 | struct peer *peer; | |
4719 | int ret; | |
4720 | as_t as; | |
4721 | ||
4722 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4723 | if (!peer) | |
4724 | return CMD_WARNING_CONFIG_FAILED; | |
4725 | ||
4726 | as = strtoul(argv[idx_number]->arg, NULL, 10); | |
4727 | ret = peer_local_as_set(peer, as, 0, 0); | |
4728 | return bgp_vty_return(vty, ret); | |
4729 | } | |
4730 | ||
4731 | DEFUN (neighbor_local_as_no_prepend, | |
4732 | neighbor_local_as_no_prepend_cmd, | |
4733 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4734 | NEIGHBOR_STR | |
4735 | NEIGHBOR_ADDR_STR2 | |
4736 | "Specify a local-as number\n" | |
4737 | "AS number used as local AS\n" | |
4738 | "Do not prepend local-as to updates from ebgp peers\n") | |
4739 | { | |
4740 | int idx_peer = 1; | |
4741 | int idx_number = 3; | |
4742 | struct peer *peer; | |
4743 | int ret; | |
4744 | as_t as; | |
4745 | ||
4746 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4747 | if (!peer) | |
4748 | return CMD_WARNING_CONFIG_FAILED; | |
4749 | ||
4750 | as = strtoul(argv[idx_number]->arg, NULL, 10); | |
4751 | ret = peer_local_as_set(peer, as, 1, 0); | |
4752 | return bgp_vty_return(vty, ret); | |
4753 | } | |
4754 | ||
4755 | DEFUN (neighbor_local_as_no_prepend_replace_as, | |
4756 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4757 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4758 | NEIGHBOR_STR | |
4759 | NEIGHBOR_ADDR_STR2 | |
4760 | "Specify a local-as number\n" | |
4761 | "AS number used as local AS\n" | |
4762 | "Do not prepend local-as to updates from ebgp peers\n" | |
4763 | "Do not prepend local-as to updates from ibgp peers\n") | |
4764 | { | |
4765 | int idx_peer = 1; | |
4766 | int idx_number = 3; | |
4767 | struct peer *peer; | |
4768 | int ret; | |
4769 | as_t as; | |
4770 | ||
4771 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4772 | if (!peer) | |
4773 | return CMD_WARNING_CONFIG_FAILED; | |
4774 | ||
4775 | as = strtoul(argv[idx_number]->arg, NULL, 10); | |
4776 | ret = peer_local_as_set(peer, as, 1, 1); | |
4777 | return bgp_vty_return(vty, ret); | |
4778 | } | |
4779 | ||
4780 | DEFUN (no_neighbor_local_as, | |
4781 | no_neighbor_local_as_cmd, | |
4782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4783 | NO_STR | |
4784 | NEIGHBOR_STR | |
4785 | NEIGHBOR_ADDR_STR2 | |
4786 | "Specify a local-as number\n" | |
4787 | "AS number used as local AS\n" | |
4788 | "Do not prepend local-as to updates from ebgp peers\n" | |
4789 | "Do not prepend local-as to updates from ibgp peers\n") | |
4790 | { | |
4791 | int idx_peer = 2; | |
4792 | struct peer *peer; | |
4793 | int ret; | |
4794 | ||
4795 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4796 | if (!peer) | |
4797 | return CMD_WARNING_CONFIG_FAILED; | |
4798 | ||
4799 | ret = peer_local_as_unset(peer); | |
4800 | return bgp_vty_return(vty, ret); | |
4801 | } | |
4802 | ||
4803 | ||
4804 | DEFUN (neighbor_solo, | |
4805 | neighbor_solo_cmd, | |
4806 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", | |
4807 | NEIGHBOR_STR | |
4808 | NEIGHBOR_ADDR_STR2 | |
4809 | "Solo peer - part of its own update group\n") | |
4810 | { | |
4811 | int idx_peer = 1; | |
4812 | struct peer *peer; | |
4813 | int ret; | |
4814 | ||
4815 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4816 | if (!peer) | |
4817 | return CMD_WARNING_CONFIG_FAILED; | |
4818 | ||
4819 | ret = update_group_adjust_soloness(peer, 1); | |
4820 | return bgp_vty_return(vty, ret); | |
4821 | } | |
4822 | ||
4823 | DEFUN (no_neighbor_solo, | |
4824 | no_neighbor_solo_cmd, | |
4825 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", | |
4826 | NO_STR | |
4827 | NEIGHBOR_STR | |
4828 | NEIGHBOR_ADDR_STR2 | |
4829 | "Solo peer - part of its own update group\n") | |
4830 | { | |
4831 | int idx_peer = 2; | |
4832 | struct peer *peer; | |
4833 | int ret; | |
4834 | ||
4835 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4836 | if (!peer) | |
4837 | return CMD_WARNING_CONFIG_FAILED; | |
4838 | ||
4839 | ret = update_group_adjust_soloness(peer, 0); | |
4840 | return bgp_vty_return(vty, ret); | |
4841 | } | |
4842 | ||
4843 | DEFUN (neighbor_password, | |
4844 | neighbor_password_cmd, | |
4845 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4846 | NEIGHBOR_STR | |
4847 | NEIGHBOR_ADDR_STR2 | |
4848 | "Set a password\n" | |
4849 | "The password\n") | |
4850 | { | |
4851 | int idx_peer = 1; | |
4852 | int idx_line = 3; | |
4853 | struct peer *peer; | |
4854 | int ret; | |
4855 | ||
4856 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4857 | if (!peer) | |
4858 | return CMD_WARNING_CONFIG_FAILED; | |
4859 | ||
4860 | ret = peer_password_set(peer, argv[idx_line]->arg); | |
4861 | return bgp_vty_return(vty, ret); | |
4862 | } | |
4863 | ||
4864 | DEFUN (no_neighbor_password, | |
4865 | no_neighbor_password_cmd, | |
4866 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4867 | NO_STR | |
4868 | NEIGHBOR_STR | |
4869 | NEIGHBOR_ADDR_STR2 | |
4870 | "Set a password\n" | |
4871 | "The password\n") | |
4872 | { | |
4873 | int idx_peer = 2; | |
4874 | struct peer *peer; | |
4875 | int ret; | |
4876 | ||
4877 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4878 | if (!peer) | |
4879 | return CMD_WARNING_CONFIG_FAILED; | |
4880 | ||
4881 | ret = peer_password_unset(peer); | |
4882 | return bgp_vty_return(vty, ret); | |
4883 | } | |
4884 | ||
4885 | DEFUN (neighbor_activate, | |
4886 | neighbor_activate_cmd, | |
4887 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4888 | NEIGHBOR_STR | |
4889 | NEIGHBOR_ADDR_STR2 | |
4890 | "Enable the Address Family for this Neighbor\n") | |
4891 | { | |
4892 | int idx_peer = 1; | |
4893 | int ret; | |
4894 | struct peer *peer; | |
4895 | ||
4896 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4897 | if (!peer) | |
4898 | return CMD_WARNING_CONFIG_FAILED; | |
4899 | ||
4900 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); | |
4901 | return bgp_vty_return(vty, ret); | |
4902 | } | |
4903 | ||
4904 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, | |
4905 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4906 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4907 | "Enable the Address Family for this Neighbor\n") | |
4908 | ||
4909 | DEFUN (no_neighbor_activate, | |
4910 | no_neighbor_activate_cmd, | |
4911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4912 | NO_STR | |
4913 | NEIGHBOR_STR | |
4914 | NEIGHBOR_ADDR_STR2 | |
4915 | "Enable the Address Family for this Neighbor\n") | |
4916 | { | |
4917 | int idx_peer = 2; | |
4918 | int ret; | |
4919 | struct peer *peer; | |
4920 | ||
4921 | /* Lookup peer. */ | |
4922 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4923 | if (!peer) | |
4924 | return CMD_WARNING_CONFIG_FAILED; | |
4925 | ||
4926 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); | |
4927 | return bgp_vty_return(vty, ret); | |
4928 | } | |
4929 | ||
4930 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, | |
4931 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4932 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4933 | "Enable the Address Family for this Neighbor\n") | |
4934 | ||
4935 | DEFUN (neighbor_set_peer_group, | |
4936 | neighbor_set_peer_group_cmd, | |
4937 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4938 | NEIGHBOR_STR | |
4939 | NEIGHBOR_ADDR_STR2 | |
4940 | "Member of the peer-group\n" | |
4941 | "Peer-group name\n") | |
4942 | { | |
4943 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4944 | int idx_peer = 1; | |
4945 | int idx_word = 3; | |
4946 | int ret; | |
4947 | as_t as; | |
4948 | union sockunion su; | |
4949 | struct peer *peer; | |
4950 | struct peer_group *group; | |
4951 | ||
4952 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4953 | if (ret < 0) { | |
4954 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4955 | if (!peer) { | |
4956 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4957 | argv[idx_peer]->arg); | |
4958 | return CMD_WARNING_CONFIG_FAILED; | |
4959 | } | |
4960 | } else { | |
4961 | if (peer_address_self_check(bgp, &su)) { | |
4962 | vty_out(vty, | |
4963 | "%% Can not configure the local system as neighbor\n"); | |
4964 | return CMD_WARNING_CONFIG_FAILED; | |
4965 | } | |
4966 | ||
4967 | /* Disallow for dynamic neighbor. */ | |
4968 | peer = peer_lookup(bgp, &su); | |
4969 | if (peer && peer_dynamic_neighbor(peer)) { | |
4970 | vty_out(vty, | |
4971 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4972 | return CMD_WARNING_CONFIG_FAILED; | |
4973 | } | |
4974 | } | |
4975 | ||
4976 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4977 | if (!group) { | |
4978 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4979 | return CMD_WARNING_CONFIG_FAILED; | |
4980 | } | |
4981 | ||
4982 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4983 | ||
4984 | return bgp_vty_return(vty, ret); | |
4985 | } | |
4986 | ||
4987 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
4988 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4989 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4990 | "Member of the peer-group\n" | |
4991 | "Peer-group name\n") | |
4992 | ||
4993 | DEFUN (no_neighbor_set_peer_group, | |
4994 | no_neighbor_set_peer_group_cmd, | |
4995 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4996 | NO_STR | |
4997 | NEIGHBOR_STR | |
4998 | NEIGHBOR_ADDR_STR2 | |
4999 | "Member of the peer-group\n" | |
5000 | "Peer-group name\n") | |
5001 | { | |
5002 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
5003 | int idx_peer = 2; | |
5004 | int idx_word = 4; | |
5005 | int ret; | |
5006 | struct peer *peer; | |
5007 | struct peer_group *group; | |
5008 | ||
5009 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
5010 | if (!peer) | |
5011 | return CMD_WARNING_CONFIG_FAILED; | |
5012 | ||
5013 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5014 | if (!group) { | |
5015 | vty_out(vty, "%% Configure the peer-group first\n"); | |
5016 | return CMD_WARNING_CONFIG_FAILED; | |
5017 | } | |
5018 | ||
5019 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
5020 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5021 | ||
5022 | peer_notify_unconfig(peer); | |
5023 | ret = peer_delete(peer); | |
5024 | ||
5025 | return bgp_vty_return(vty, ret); | |
5026 | } | |
5027 | ||
5028 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, | |
5029 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5030 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5031 | "Member of the peer-group\n" | |
5032 | "Peer-group name\n") | |
5033 | ||
5034 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, | |
5035 | uint32_t flag, int set) | |
5036 | { | |
5037 | int ret; | |
5038 | struct peer *peer; | |
5039 | ||
5040 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
5041 | if (!peer) | |
5042 | return CMD_WARNING_CONFIG_FAILED; | |
5043 | ||
5044 | /* | |
5045 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5046 | * we should not accept disable-connected-check. | |
5047 | */ | |
5048 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5049 | vty_out(vty, | |
5050 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
5051 | ip_str); | |
5052 | return CMD_WARNING_CONFIG_FAILED; | |
5053 | } | |
5054 | ||
5055 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
5056 | peer_tx_shutdown_message_unset(peer); | |
5057 | ||
5058 | if (set) | |
5059 | ret = peer_flag_set(peer, flag); | |
5060 | else | |
5061 | ret = peer_flag_unset(peer, flag); | |
5062 | ||
5063 | return bgp_vty_return(vty, ret); | |
5064 | } | |
5065 | ||
5066 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) | |
5067 | { | |
5068 | return peer_flag_modify_vty(vty, ip_str, flag, 1); | |
5069 | } | |
5070 | ||
5071 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, | |
5072 | uint32_t flag) | |
5073 | { | |
5074 | return peer_flag_modify_vty(vty, ip_str, flag, 0); | |
5075 | } | |
5076 | ||
5077 | /* neighbor passive. */ | |
5078 | DEFUN (neighbor_passive, | |
5079 | neighbor_passive_cmd, | |
5080 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5081 | NEIGHBOR_STR | |
5082 | NEIGHBOR_ADDR_STR2 | |
5083 | "Don't send open messages to this neighbor\n") | |
5084 | { | |
5085 | int idx_peer = 1; | |
5086 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
5087 | } | |
5088 | ||
5089 | DEFUN (no_neighbor_passive, | |
5090 | no_neighbor_passive_cmd, | |
5091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5092 | NO_STR | |
5093 | NEIGHBOR_STR | |
5094 | NEIGHBOR_ADDR_STR2 | |
5095 | "Don't send open messages to this neighbor\n") | |
5096 | { | |
5097 | int idx_peer = 2; | |
5098 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
5099 | } | |
5100 | ||
5101 | /* neighbor shutdown. */ | |
5102 | DEFUN (neighbor_shutdown_msg, | |
5103 | neighbor_shutdown_msg_cmd, | |
5104 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5105 | NEIGHBOR_STR | |
5106 | NEIGHBOR_ADDR_STR2 | |
5107 | "Administratively shut down this neighbor\n" | |
5108 | "Add a shutdown message (RFC 8203)\n" | |
5109 | "Shutdown message\n") | |
5110 | { | |
5111 | int idx_peer = 1; | |
5112 | ||
5113 | if (argc >= 5) { | |
5114 | struct peer *peer = | |
5115 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5116 | char *message; | |
5117 | ||
5118 | if (!peer) | |
5119 | return CMD_WARNING_CONFIG_FAILED; | |
5120 | message = argv_concat(argv, argc, 4); | |
5121 | peer_tx_shutdown_message_set(peer, message); | |
5122 | XFREE(MTYPE_TMP, message); | |
5123 | } | |
5124 | ||
5125 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
5126 | } | |
5127 | ||
5128 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, | |
5129 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
5130 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5131 | "Administratively shut down this neighbor\n") | |
5132 | ||
5133 | DEFUN (no_neighbor_shutdown_msg, | |
5134 | no_neighbor_shutdown_msg_cmd, | |
5135 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5136 | NO_STR | |
5137 | NEIGHBOR_STR | |
5138 | NEIGHBOR_ADDR_STR2 | |
5139 | "Administratively shut down this neighbor\n" | |
5140 | "Remove a shutdown message (RFC 8203)\n" | |
5141 | "Shutdown message\n") | |
5142 | { | |
5143 | int idx_peer = 2; | |
5144 | ||
5145 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5146 | PEER_FLAG_SHUTDOWN); | |
5147 | } | |
5148 | ||
5149 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, | |
5150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
5151 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5152 | "Administratively shut down this neighbor\n") | |
5153 | ||
5154 | DEFUN(neighbor_shutdown_rtt, | |
5155 | neighbor_shutdown_rtt_cmd, | |
5156 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5157 | NEIGHBOR_STR | |
5158 | NEIGHBOR_ADDR_STR2 | |
5159 | "Administratively shut down this neighbor\n" | |
5160 | "Shutdown if round-trip-time is higher than expected\n" | |
5161 | "Round-trip-time in milliseconds\n" | |
5162 | "Specify the number of keepalives before shutdown\n" | |
5163 | "The number of keepalives with higher RTT to shutdown\n") | |
5164 | { | |
5165 | int idx_peer = 1; | |
5166 | int idx_rtt = 4; | |
5167 | int idx_count = 0; | |
5168 | struct peer *peer; | |
5169 | ||
5170 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5171 | ||
5172 | if (!peer) | |
5173 | return CMD_WARNING_CONFIG_FAILED; | |
5174 | ||
5175 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5176 | ||
5177 | if (argv_find(argv, argc, "count", &idx_count)) | |
5178 | peer->rtt_keepalive_conf = | |
5179 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5180 | ||
5181 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5182 | PEER_FLAG_RTT_SHUTDOWN); | |
5183 | } | |
5184 | ||
5185 | DEFUN(no_neighbor_shutdown_rtt, | |
5186 | no_neighbor_shutdown_rtt_cmd, | |
5187 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5188 | NO_STR | |
5189 | NEIGHBOR_STR | |
5190 | NEIGHBOR_ADDR_STR2 | |
5191 | "Administratively shut down this neighbor\n" | |
5192 | "Shutdown if round-trip-time is higher than expected\n" | |
5193 | "Round-trip-time in milliseconds\n" | |
5194 | "Specify the number of keepalives before shutdown\n" | |
5195 | "The number of keepalives with higher RTT to shutdown\n") | |
5196 | { | |
5197 | int idx_peer = 2; | |
5198 | struct peer *peer; | |
5199 | ||
5200 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5201 | ||
5202 | if (!peer) | |
5203 | return CMD_WARNING_CONFIG_FAILED; | |
5204 | ||
5205 | peer->rtt_expected = 0; | |
5206 | peer->rtt_keepalive_conf = 1; | |
5207 | ||
5208 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5209 | PEER_FLAG_RTT_SHUTDOWN); | |
5210 | } | |
5211 | ||
5212 | /* neighbor capability dynamic. */ | |
5213 | DEFUN (neighbor_capability_dynamic, | |
5214 | neighbor_capability_dynamic_cmd, | |
5215 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5216 | NEIGHBOR_STR | |
5217 | NEIGHBOR_ADDR_STR2 | |
5218 | "Advertise capability to the peer\n" | |
5219 | "Advertise dynamic capability to this neighbor\n") | |
5220 | { | |
5221 | int idx_peer = 1; | |
5222 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5223 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
5224 | } | |
5225 | ||
5226 | DEFUN (no_neighbor_capability_dynamic, | |
5227 | no_neighbor_capability_dynamic_cmd, | |
5228 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5229 | NO_STR | |
5230 | NEIGHBOR_STR | |
5231 | NEIGHBOR_ADDR_STR2 | |
5232 | "Advertise capability to the peer\n" | |
5233 | "Advertise dynamic capability to this neighbor\n") | |
5234 | { | |
5235 | int idx_peer = 2; | |
5236 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5237 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
5238 | } | |
5239 | ||
5240 | /* neighbor dont-capability-negotiate */ | |
5241 | DEFUN (neighbor_dont_capability_negotiate, | |
5242 | neighbor_dont_capability_negotiate_cmd, | |
5243 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", | |
5244 | NEIGHBOR_STR | |
5245 | NEIGHBOR_ADDR_STR2 | |
5246 | "Do not perform capability negotiation\n") | |
5247 | { | |
5248 | int idx_peer = 1; | |
5249 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5250 | PEER_FLAG_DONT_CAPABILITY); | |
5251 | } | |
5252 | ||
5253 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5254 | no_neighbor_dont_capability_negotiate_cmd, | |
5255 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", | |
5256 | NO_STR | |
5257 | NEIGHBOR_STR | |
5258 | NEIGHBOR_ADDR_STR2 | |
5259 | "Do not perform capability negotiation\n") | |
5260 | { | |
5261 | int idx_peer = 2; | |
5262 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5263 | PEER_FLAG_DONT_CAPABILITY); | |
5264 | } | |
5265 | ||
5266 | /* neighbor capability extended next hop encoding */ | |
5267 | DEFUN (neighbor_capability_enhe, | |
5268 | neighbor_capability_enhe_cmd, | |
5269 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5270 | NEIGHBOR_STR | |
5271 | NEIGHBOR_ADDR_STR2 | |
5272 | "Advertise capability to the peer\n" | |
5273 | "Advertise extended next-hop capability to the peer\n") | |
5274 | { | |
5275 | int idx_peer = 1; | |
5276 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5277 | PEER_FLAG_CAPABILITY_ENHE); | |
5278 | } | |
5279 | ||
5280 | DEFUN (no_neighbor_capability_enhe, | |
5281 | no_neighbor_capability_enhe_cmd, | |
5282 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5283 | NO_STR | |
5284 | NEIGHBOR_STR | |
5285 | NEIGHBOR_ADDR_STR2 | |
5286 | "Advertise capability to the peer\n" | |
5287 | "Advertise extended next-hop capability to the peer\n") | |
5288 | { | |
5289 | int idx_peer = 2; | |
5290 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5291 | PEER_FLAG_CAPABILITY_ENHE); | |
5292 | } | |
5293 | ||
5294 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, | |
5295 | afi_t afi, safi_t safi, uint32_t flag, | |
5296 | int set) | |
5297 | { | |
5298 | int ret; | |
5299 | struct peer *peer; | |
5300 | ||
5301 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5302 | if (!peer) | |
5303 | return CMD_WARNING_CONFIG_FAILED; | |
5304 | ||
5305 | if (set) | |
5306 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5307 | else | |
5308 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
5309 | ||
5310 | return bgp_vty_return(vty, ret); | |
5311 | } | |
5312 | ||
5313 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, | |
5314 | afi_t afi, safi_t safi, uint32_t flag) | |
5315 | { | |
5316 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); | |
5317 | } | |
5318 | ||
5319 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, | |
5320 | afi_t afi, safi_t safi, uint32_t flag) | |
5321 | { | |
5322 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); | |
5323 | } | |
5324 | ||
5325 | /* neighbor capability orf prefix-list. */ | |
5326 | DEFUN (neighbor_capability_orf_prefix, | |
5327 | neighbor_capability_orf_prefix_cmd, | |
5328 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5329 | NEIGHBOR_STR | |
5330 | NEIGHBOR_ADDR_STR2 | |
5331 | "Advertise capability to the peer\n" | |
5332 | "Advertise ORF capability to the peer\n" | |
5333 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5334 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5335 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5336 | "Capability to SEND the ORF to this neighbor\n") | |
5337 | { | |
5338 | int idx_send_recv = 5; | |
5339 | char *peer_str = argv[1]->arg; | |
5340 | struct peer *peer; | |
5341 | afi_t afi = bgp_node_afi(vty); | |
5342 | safi_t safi = bgp_node_safi(vty); | |
5343 | ||
5344 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5345 | if (!peer) | |
5346 | return CMD_WARNING_CONFIG_FAILED; | |
5347 | ||
5348 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
5349 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5350 | PEER_FLAG_ORF_PREFIX_SM); | |
5351 | ||
5352 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5353 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5354 | PEER_FLAG_ORF_PREFIX_RM); | |
5355 | ||
5356 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5357 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5358 | PEER_FLAG_ORF_PREFIX_SM) | |
5359 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5360 | PEER_FLAG_ORF_PREFIX_RM); | |
5361 | ||
5362 | return CMD_WARNING_CONFIG_FAILED; | |
5363 | } | |
5364 | ||
5365 | ALIAS_HIDDEN( | |
5366 | neighbor_capability_orf_prefix, | |
5367 | neighbor_capability_orf_prefix_hidden_cmd, | |
5368 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5369 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5370 | "Advertise capability to the peer\n" | |
5371 | "Advertise ORF capability to the peer\n" | |
5372 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5373 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5374 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5375 | "Capability to SEND the ORF to this neighbor\n") | |
5376 | ||
5377 | DEFUN (no_neighbor_capability_orf_prefix, | |
5378 | no_neighbor_capability_orf_prefix_cmd, | |
5379 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5380 | NO_STR | |
5381 | NEIGHBOR_STR | |
5382 | NEIGHBOR_ADDR_STR2 | |
5383 | "Advertise capability to the peer\n" | |
5384 | "Advertise ORF capability to the peer\n" | |
5385 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5386 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5387 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5388 | "Capability to SEND the ORF to this neighbor\n") | |
5389 | { | |
5390 | int idx_send_recv = 6; | |
5391 | char *peer_str = argv[2]->arg; | |
5392 | struct peer *peer; | |
5393 | afi_t afi = bgp_node_afi(vty); | |
5394 | safi_t safi = bgp_node_safi(vty); | |
5395 | ||
5396 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5397 | if (!peer) | |
5398 | return CMD_WARNING_CONFIG_FAILED; | |
5399 | ||
5400 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
5401 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5402 | PEER_FLAG_ORF_PREFIX_SM); | |
5403 | ||
5404 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5405 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5406 | PEER_FLAG_ORF_PREFIX_RM); | |
5407 | ||
5408 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5409 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5410 | PEER_FLAG_ORF_PREFIX_SM) | |
5411 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5412 | PEER_FLAG_ORF_PREFIX_RM); | |
5413 | ||
5414 | return CMD_WARNING_CONFIG_FAILED; | |
5415 | } | |
5416 | ||
5417 | ALIAS_HIDDEN( | |
5418 | no_neighbor_capability_orf_prefix, | |
5419 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5421 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5422 | "Advertise capability to the peer\n" | |
5423 | "Advertise ORF capability to the peer\n" | |
5424 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5425 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5426 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5427 | "Capability to SEND the ORF to this neighbor\n") | |
5428 | ||
5429 | /* neighbor next-hop-self. */ | |
5430 | DEFUN (neighbor_nexthop_self, | |
5431 | neighbor_nexthop_self_cmd, | |
5432 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5433 | NEIGHBOR_STR | |
5434 | NEIGHBOR_ADDR_STR2 | |
5435 | "Disable the next hop calculation for this neighbor\n") | |
5436 | { | |
5437 | int idx_peer = 1; | |
5438 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5439 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
5440 | } | |
5441 | ||
5442 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, | |
5443 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5444 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5445 | "Disable the next hop calculation for this neighbor\n") | |
5446 | ||
5447 | /* neighbor next-hop-self. */ | |
5448 | DEFUN (neighbor_nexthop_self_force, | |
5449 | neighbor_nexthop_self_force_cmd, | |
5450 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5451 | NEIGHBOR_STR | |
5452 | NEIGHBOR_ADDR_STR2 | |
5453 | "Disable the next hop calculation for this neighbor\n" | |
5454 | "Set the next hop to self for reflected routes\n") | |
5455 | { | |
5456 | int idx_peer = 1; | |
5457 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5458 | bgp_node_safi(vty), | |
5459 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
5460 | } | |
5461 | ||
5462 | ALIAS_HIDDEN(neighbor_nexthop_self_force, | |
5463 | neighbor_nexthop_self_force_hidden_cmd, | |
5464 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5465 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5466 | "Disable the next hop calculation for this neighbor\n" | |
5467 | "Set the next hop to self for reflected routes\n") | |
5468 | ||
5469 | ALIAS_HIDDEN(neighbor_nexthop_self_force, | |
5470 | neighbor_nexthop_self_all_hidden_cmd, | |
5471 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5472 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5473 | "Disable the next hop calculation for this neighbor\n" | |
5474 | "Set the next hop to self for reflected routes\n") | |
5475 | ||
5476 | DEFUN (no_neighbor_nexthop_self, | |
5477 | no_neighbor_nexthop_self_cmd, | |
5478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5479 | NO_STR | |
5480 | NEIGHBOR_STR | |
5481 | NEIGHBOR_ADDR_STR2 | |
5482 | "Disable the next hop calculation for this neighbor\n") | |
5483 | { | |
5484 | int idx_peer = 2; | |
5485 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5486 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5487 | PEER_FLAG_NEXTHOP_SELF); | |
5488 | } | |
5489 | ||
5490 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, | |
5491 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5492 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5493 | "Disable the next hop calculation for this neighbor\n") | |
5494 | ||
5495 | DEFUN (no_neighbor_nexthop_self_force, | |
5496 | no_neighbor_nexthop_self_force_cmd, | |
5497 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5498 | NO_STR | |
5499 | NEIGHBOR_STR | |
5500 | NEIGHBOR_ADDR_STR2 | |
5501 | "Disable the next hop calculation for this neighbor\n" | |
5502 | "Set the next hop to self for reflected routes\n") | |
5503 | { | |
5504 | int idx_peer = 2; | |
5505 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5506 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5507 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
5508 | } | |
5509 | ||
5510 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, | |
5511 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5512 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5513 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5514 | "Disable the next hop calculation for this neighbor\n" | |
5515 | "Set the next hop to self for reflected routes\n") | |
5516 | ||
5517 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, | |
5518 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5519 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5520 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5521 | "Disable the next hop calculation for this neighbor\n" | |
5522 | "Set the next hop to self for reflected routes\n") | |
5523 | ||
5524 | /* neighbor as-override */ | |
5525 | DEFUN (neighbor_as_override, | |
5526 | neighbor_as_override_cmd, | |
5527 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5528 | NEIGHBOR_STR | |
5529 | NEIGHBOR_ADDR_STR2 | |
5530 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5531 | { | |
5532 | int idx_peer = 1; | |
5533 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5534 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
5535 | } | |
5536 | ||
5537 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, | |
5538 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5539 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5540 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5541 | ||
5542 | DEFUN (no_neighbor_as_override, | |
5543 | no_neighbor_as_override_cmd, | |
5544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5545 | NO_STR | |
5546 | NEIGHBOR_STR | |
5547 | NEIGHBOR_ADDR_STR2 | |
5548 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5549 | { | |
5550 | int idx_peer = 2; | |
5551 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5552 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5553 | PEER_FLAG_AS_OVERRIDE); | |
5554 | } | |
5555 | ||
5556 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, | |
5557 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5558 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5559 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5560 | ||
5561 | /* neighbor remove-private-AS. */ | |
5562 | DEFUN (neighbor_remove_private_as, | |
5563 | neighbor_remove_private_as_cmd, | |
5564 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5565 | NEIGHBOR_STR | |
5566 | NEIGHBOR_ADDR_STR2 | |
5567 | "Remove private ASNs in outbound updates\n") | |
5568 | { | |
5569 | int idx_peer = 1; | |
5570 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5571 | bgp_node_safi(vty), | |
5572 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
5573 | } | |
5574 | ||
5575 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, | |
5576 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5578 | "Remove private ASNs in outbound updates\n") | |
5579 | ||
5580 | DEFUN (neighbor_remove_private_as_all, | |
5581 | neighbor_remove_private_as_all_cmd, | |
5582 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5583 | NEIGHBOR_STR | |
5584 | NEIGHBOR_ADDR_STR2 | |
5585 | "Remove private ASNs in outbound updates\n" | |
5586 | "Apply to all AS numbers\n") | |
5587 | { | |
5588 | int idx_peer = 1; | |
5589 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5590 | bgp_node_safi(vty), | |
5591 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5592 | } | |
5593 | ||
5594 | ALIAS_HIDDEN(neighbor_remove_private_as_all, | |
5595 | neighbor_remove_private_as_all_hidden_cmd, | |
5596 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5597 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5598 | "Remove private ASNs in outbound updates\n" | |
5599 | "Apply to all AS numbers") | |
5600 | ||
5601 | DEFUN (neighbor_remove_private_as_replace_as, | |
5602 | neighbor_remove_private_as_replace_as_cmd, | |
5603 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5604 | NEIGHBOR_STR | |
5605 | NEIGHBOR_ADDR_STR2 | |
5606 | "Remove private ASNs in outbound updates\n" | |
5607 | "Replace private ASNs with our ASN in outbound updates\n") | |
5608 | { | |
5609 | int idx_peer = 1; | |
5610 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5611 | bgp_node_safi(vty), | |
5612 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5613 | } | |
5614 | ||
5615 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, | |
5616 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5617 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5618 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5619 | "Remove private ASNs in outbound updates\n" | |
5620 | "Replace private ASNs with our ASN in outbound updates\n") | |
5621 | ||
5622 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
5623 | neighbor_remove_private_as_all_replace_as_cmd, | |
5624 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5625 | NEIGHBOR_STR | |
5626 | NEIGHBOR_ADDR_STR2 | |
5627 | "Remove private ASNs in outbound updates\n" | |
5628 | "Apply to all AS numbers\n" | |
5629 | "Replace private ASNs with our ASN in outbound updates\n") | |
5630 | { | |
5631 | int idx_peer = 1; | |
5632 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5633 | bgp_node_safi(vty), | |
5634 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5635 | } | |
5636 | ||
5637 | ALIAS_HIDDEN( | |
5638 | neighbor_remove_private_as_all_replace_as, | |
5639 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5640 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5641 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5642 | "Remove private ASNs in outbound updates\n" | |
5643 | "Apply to all AS numbers\n" | |
5644 | "Replace private ASNs with our ASN in outbound updates\n") | |
5645 | ||
5646 | DEFUN (no_neighbor_remove_private_as, | |
5647 | no_neighbor_remove_private_as_cmd, | |
5648 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5649 | NO_STR | |
5650 | NEIGHBOR_STR | |
5651 | NEIGHBOR_ADDR_STR2 | |
5652 | "Remove private ASNs in outbound updates\n") | |
5653 | { | |
5654 | int idx_peer = 2; | |
5655 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5656 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5657 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
5658 | } | |
5659 | ||
5660 | ALIAS_HIDDEN(no_neighbor_remove_private_as, | |
5661 | no_neighbor_remove_private_as_hidden_cmd, | |
5662 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5663 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5664 | "Remove private ASNs in outbound updates\n") | |
5665 | ||
5666 | DEFUN (no_neighbor_remove_private_as_all, | |
5667 | no_neighbor_remove_private_as_all_cmd, | |
5668 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5669 | NO_STR | |
5670 | NEIGHBOR_STR | |
5671 | NEIGHBOR_ADDR_STR2 | |
5672 | "Remove private ASNs in outbound updates\n" | |
5673 | "Apply to all AS numbers\n") | |
5674 | { | |
5675 | int idx_peer = 2; | |
5676 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5677 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5678 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5679 | } | |
5680 | ||
5681 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, | |
5682 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5683 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5684 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5685 | "Remove private ASNs in outbound updates\n" | |
5686 | "Apply to all AS numbers\n") | |
5687 | ||
5688 | DEFUN (no_neighbor_remove_private_as_replace_as, | |
5689 | no_neighbor_remove_private_as_replace_as_cmd, | |
5690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5691 | NO_STR | |
5692 | NEIGHBOR_STR | |
5693 | NEIGHBOR_ADDR_STR2 | |
5694 | "Remove private ASNs in outbound updates\n" | |
5695 | "Replace private ASNs with our ASN in outbound updates\n") | |
5696 | { | |
5697 | int idx_peer = 2; | |
5698 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5699 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5700 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5701 | } | |
5702 | ||
5703 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, | |
5704 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5706 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5707 | "Remove private ASNs in outbound updates\n" | |
5708 | "Replace private ASNs with our ASN in outbound updates\n") | |
5709 | ||
5710 | DEFUN (no_neighbor_remove_private_as_all_replace_as, | |
5711 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5712 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5713 | NO_STR | |
5714 | NEIGHBOR_STR | |
5715 | NEIGHBOR_ADDR_STR2 | |
5716 | "Remove private ASNs in outbound updates\n" | |
5717 | "Apply to all AS numbers\n" | |
5718 | "Replace private ASNs with our ASN in outbound updates\n") | |
5719 | { | |
5720 | int idx_peer = 2; | |
5721 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5722 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5723 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5724 | } | |
5725 | ||
5726 | ALIAS_HIDDEN( | |
5727 | no_neighbor_remove_private_as_all_replace_as, | |
5728 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5729 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5730 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5731 | "Remove private ASNs in outbound updates\n" | |
5732 | "Apply to all AS numbers\n" | |
5733 | "Replace private ASNs with our ASN in outbound updates\n") | |
5734 | ||
5735 | ||
5736 | /* neighbor send-community. */ | |
5737 | DEFUN (neighbor_send_community, | |
5738 | neighbor_send_community_cmd, | |
5739 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5740 | NEIGHBOR_STR | |
5741 | NEIGHBOR_ADDR_STR2 | |
5742 | "Send Community attribute to this neighbor\n") | |
5743 | { | |
5744 | int idx_peer = 1; | |
5745 | ||
5746 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5747 | bgp_node_safi(vty), | |
5748 | PEER_FLAG_SEND_COMMUNITY); | |
5749 | } | |
5750 | ||
5751 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, | |
5752 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5753 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5754 | "Send Community attribute to this neighbor\n") | |
5755 | ||
5756 | DEFUN (no_neighbor_send_community, | |
5757 | no_neighbor_send_community_cmd, | |
5758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5759 | NO_STR | |
5760 | NEIGHBOR_STR | |
5761 | NEIGHBOR_ADDR_STR2 | |
5762 | "Send Community attribute to this neighbor\n") | |
5763 | { | |
5764 | int idx_peer = 2; | |
5765 | ||
5766 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5767 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5768 | PEER_FLAG_SEND_COMMUNITY); | |
5769 | } | |
5770 | ||
5771 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, | |
5772 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5773 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5774 | "Send Community attribute to this neighbor\n") | |
5775 | ||
5776 | /* neighbor send-community extended. */ | |
5777 | DEFUN (neighbor_send_community_type, | |
5778 | neighbor_send_community_type_cmd, | |
5779 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5780 | NEIGHBOR_STR | |
5781 | NEIGHBOR_ADDR_STR2 | |
5782 | "Send Community attribute to this neighbor\n" | |
5783 | "Send Standard and Extended Community attributes\n" | |
5784 | "Send Standard, Large and Extended Community attributes\n" | |
5785 | "Send Extended Community attributes\n" | |
5786 | "Send Standard Community attributes\n" | |
5787 | "Send Large Community attributes\n") | |
5788 | { | |
5789 | const char *type = argv[argc - 1]->text; | |
5790 | char *peer_str = argv[1]->arg; | |
5791 | struct peer *peer; | |
5792 | afi_t afi = bgp_node_afi(vty); | |
5793 | safi_t safi = bgp_node_safi(vty); | |
5794 | ||
5795 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5796 | if (!peer) | |
5797 | return CMD_WARNING_CONFIG_FAILED; | |
5798 | ||
5799 | if (strmatch(type, "standard")) | |
5800 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5801 | PEER_FLAG_SEND_COMMUNITY); | |
5802 | ||
5803 | if (strmatch(type, "extended")) | |
5804 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5805 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5806 | ||
5807 | if (strmatch(type, "large")) | |
5808 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5809 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5810 | ||
5811 | if (strmatch(type, "both")) { | |
5812 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5813 | PEER_FLAG_SEND_COMMUNITY) | |
5814 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5815 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5816 | } | |
5817 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5818 | PEER_FLAG_SEND_COMMUNITY) | |
5819 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5820 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5821 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5822 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5823 | } | |
5824 | ||
5825 | ALIAS_HIDDEN( | |
5826 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5827 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5828 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5829 | "Send Community attribute to this neighbor\n" | |
5830 | "Send Standard and Extended Community attributes\n" | |
5831 | "Send Standard, Large and Extended Community attributes\n" | |
5832 | "Send Extended Community attributes\n" | |
5833 | "Send Standard Community attributes\n" | |
5834 | "Send Large Community attributes\n") | |
5835 | ||
5836 | DEFUN (no_neighbor_send_community_type, | |
5837 | no_neighbor_send_community_type_cmd, | |
5838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5839 | NO_STR | |
5840 | NEIGHBOR_STR | |
5841 | NEIGHBOR_ADDR_STR2 | |
5842 | "Send Community attribute to this neighbor\n" | |
5843 | "Send Standard and Extended Community attributes\n" | |
5844 | "Send Standard, Large and Extended Community attributes\n" | |
5845 | "Send Extended Community attributes\n" | |
5846 | "Send Standard Community attributes\n" | |
5847 | "Send Large Community attributes\n") | |
5848 | { | |
5849 | const char *type = argv[argc - 1]->text; | |
5850 | char *peer_str = argv[2]->arg; | |
5851 | struct peer *peer; | |
5852 | afi_t afi = bgp_node_afi(vty); | |
5853 | safi_t safi = bgp_node_safi(vty); | |
5854 | ||
5855 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5856 | if (!peer) | |
5857 | return CMD_WARNING_CONFIG_FAILED; | |
5858 | ||
5859 | if (strmatch(type, "standard")) | |
5860 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5861 | PEER_FLAG_SEND_COMMUNITY); | |
5862 | ||
5863 | if (strmatch(type, "extended")) | |
5864 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5865 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5866 | ||
5867 | if (strmatch(type, "large")) | |
5868 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5869 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5870 | ||
5871 | if (strmatch(type, "both")) { | |
5872 | ||
5873 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5874 | PEER_FLAG_SEND_COMMUNITY) | |
5875 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5876 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5877 | } | |
5878 | ||
5879 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5880 | PEER_FLAG_SEND_COMMUNITY) | |
5881 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5882 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5883 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5884 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5885 | } | |
5886 | ||
5887 | ALIAS_HIDDEN( | |
5888 | no_neighbor_send_community_type, | |
5889 | no_neighbor_send_community_type_hidden_cmd, | |
5890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5891 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5892 | "Send Community attribute to this neighbor\n" | |
5893 | "Send Standard and Extended Community attributes\n" | |
5894 | "Send Standard, Large and Extended Community attributes\n" | |
5895 | "Send Extended Community attributes\n" | |
5896 | "Send Standard Community attributes\n" | |
5897 | "Send Large Community attributes\n") | |
5898 | ||
5899 | /* neighbor soft-reconfig. */ | |
5900 | DEFUN (neighbor_soft_reconfiguration, | |
5901 | neighbor_soft_reconfiguration_cmd, | |
5902 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5903 | NEIGHBOR_STR | |
5904 | NEIGHBOR_ADDR_STR2 | |
5905 | "Per neighbor soft reconfiguration\n" | |
5906 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5907 | { | |
5908 | int idx_peer = 1; | |
5909 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5910 | bgp_node_safi(vty), | |
5911 | PEER_FLAG_SOFT_RECONFIG); | |
5912 | } | |
5913 | ||
5914 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, | |
5915 | neighbor_soft_reconfiguration_hidden_cmd, | |
5916 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5917 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5918 | "Per neighbor soft reconfiguration\n" | |
5919 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5920 | ||
5921 | DEFUN (no_neighbor_soft_reconfiguration, | |
5922 | no_neighbor_soft_reconfiguration_cmd, | |
5923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5924 | NO_STR | |
5925 | NEIGHBOR_STR | |
5926 | NEIGHBOR_ADDR_STR2 | |
5927 | "Per neighbor soft reconfiguration\n" | |
5928 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5929 | { | |
5930 | int idx_peer = 2; | |
5931 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5932 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5933 | PEER_FLAG_SOFT_RECONFIG); | |
5934 | } | |
5935 | ||
5936 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, | |
5937 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5939 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5940 | "Per neighbor soft reconfiguration\n" | |
5941 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5942 | ||
5943 | DEFUN (neighbor_route_reflector_client, | |
5944 | neighbor_route_reflector_client_cmd, | |
5945 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5946 | NEIGHBOR_STR | |
5947 | NEIGHBOR_ADDR_STR2 | |
5948 | "Configure a neighbor as Route Reflector client\n") | |
5949 | { | |
5950 | int idx_peer = 1; | |
5951 | struct peer *peer; | |
5952 | ||
5953 | ||
5954 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5955 | if (!peer) | |
5956 | return CMD_WARNING_CONFIG_FAILED; | |
5957 | ||
5958 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5959 | bgp_node_safi(vty), | |
5960 | PEER_FLAG_REFLECTOR_CLIENT); | |
5961 | } | |
5962 | ||
5963 | ALIAS_HIDDEN(neighbor_route_reflector_client, | |
5964 | neighbor_route_reflector_client_hidden_cmd, | |
5965 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5966 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5967 | "Configure a neighbor as Route Reflector client\n") | |
5968 | ||
5969 | DEFUN (no_neighbor_route_reflector_client, | |
5970 | no_neighbor_route_reflector_client_cmd, | |
5971 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5972 | NO_STR | |
5973 | NEIGHBOR_STR | |
5974 | NEIGHBOR_ADDR_STR2 | |
5975 | "Configure a neighbor as Route Reflector client\n") | |
5976 | { | |
5977 | int idx_peer = 2; | |
5978 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5979 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5980 | PEER_FLAG_REFLECTOR_CLIENT); | |
5981 | } | |
5982 | ||
5983 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, | |
5984 | no_neighbor_route_reflector_client_hidden_cmd, | |
5985 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5986 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5987 | "Configure a neighbor as Route Reflector client\n") | |
5988 | ||
5989 | /* neighbor route-server-client. */ | |
5990 | DEFUN (neighbor_route_server_client, | |
5991 | neighbor_route_server_client_cmd, | |
5992 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5993 | NEIGHBOR_STR | |
5994 | NEIGHBOR_ADDR_STR2 | |
5995 | "Configure a neighbor as Route Server client\n") | |
5996 | { | |
5997 | int idx_peer = 1; | |
5998 | struct peer *peer; | |
5999 | ||
6000 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6001 | if (!peer) | |
6002 | return CMD_WARNING_CONFIG_FAILED; | |
6003 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6004 | bgp_node_safi(vty), | |
6005 | PEER_FLAG_RSERVER_CLIENT); | |
6006 | } | |
6007 | ||
6008 | ALIAS_HIDDEN(neighbor_route_server_client, | |
6009 | neighbor_route_server_client_hidden_cmd, | |
6010 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6011 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6012 | "Configure a neighbor as Route Server client\n") | |
6013 | ||
6014 | DEFUN (no_neighbor_route_server_client, | |
6015 | no_neighbor_route_server_client_cmd, | |
6016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6017 | NO_STR | |
6018 | NEIGHBOR_STR | |
6019 | NEIGHBOR_ADDR_STR2 | |
6020 | "Configure a neighbor as Route Server client\n") | |
6021 | { | |
6022 | int idx_peer = 2; | |
6023 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6024 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6025 | PEER_FLAG_RSERVER_CLIENT); | |
6026 | } | |
6027 | ||
6028 | ALIAS_HIDDEN(no_neighbor_route_server_client, | |
6029 | no_neighbor_route_server_client_hidden_cmd, | |
6030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6031 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6032 | "Configure a neighbor as Route Server client\n") | |
6033 | ||
6034 | DEFUN (neighbor_nexthop_local_unchanged, | |
6035 | neighbor_nexthop_local_unchanged_cmd, | |
6036 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", | |
6037 | NEIGHBOR_STR | |
6038 | NEIGHBOR_ADDR_STR2 | |
6039 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6040 | "Leave link-local nexthop unchanged for this peer\n") | |
6041 | { | |
6042 | int idx_peer = 1; | |
6043 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6044 | bgp_node_safi(vty), | |
6045 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
6046 | } | |
6047 | ||
6048 | DEFUN (no_neighbor_nexthop_local_unchanged, | |
6049 | no_neighbor_nexthop_local_unchanged_cmd, | |
6050 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", | |
6051 | NO_STR | |
6052 | NEIGHBOR_STR | |
6053 | NEIGHBOR_ADDR_STR2 | |
6054 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6055 | "Leave link-local nexthop unchanged for this peer\n") | |
6056 | { | |
6057 | int idx_peer = 2; | |
6058 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6059 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6060 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
6061 | } | |
6062 | ||
6063 | DEFUN (neighbor_attr_unchanged, | |
6064 | neighbor_attr_unchanged_cmd, | |
6065 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6066 | NEIGHBOR_STR | |
6067 | NEIGHBOR_ADDR_STR2 | |
6068 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6069 | "As-path attribute\n" | |
6070 | "Nexthop attribute\n" | |
6071 | "Med attribute\n") | |
6072 | { | |
6073 | int idx = 0; | |
6074 | char *peer_str = argv[1]->arg; | |
6075 | struct peer *peer; | |
6076 | bool aspath = false; | |
6077 | bool nexthop = false; | |
6078 | bool med = false; | |
6079 | afi_t afi = bgp_node_afi(vty); | |
6080 | safi_t safi = bgp_node_safi(vty); | |
6081 | int ret = 0; | |
6082 | ||
6083 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6084 | if (!peer) | |
6085 | return CMD_WARNING_CONFIG_FAILED; | |
6086 | ||
6087 | if (argv_find(argv, argc, "as-path", &idx)) | |
6088 | aspath = true; | |
6089 | ||
6090 | idx = 0; | |
6091 | if (argv_find(argv, argc, "next-hop", &idx)) | |
6092 | nexthop = true; | |
6093 | ||
6094 | idx = 0; | |
6095 | if (argv_find(argv, argc, "med", &idx)) | |
6096 | med = true; | |
6097 | ||
6098 | /* no flags means all of them! */ | |
6099 | if (!aspath && !nexthop && !med) { | |
6100 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6101 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6102 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6103 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6104 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6105 | PEER_FLAG_MED_UNCHANGED); | |
6106 | } else { | |
6107 | if (!aspath) { | |
6108 | if (peer_af_flag_check(peer, afi, safi, | |
6109 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6110 | ret |= peer_af_flag_unset_vty( | |
6111 | vty, peer_str, afi, safi, | |
6112 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6113 | } | |
6114 | } else | |
6115 | ret |= peer_af_flag_set_vty( | |
6116 | vty, peer_str, afi, safi, | |
6117 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6118 | ||
6119 | if (!nexthop) { | |
6120 | if (peer_af_flag_check(peer, afi, safi, | |
6121 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6122 | ret |= peer_af_flag_unset_vty( | |
6123 | vty, peer_str, afi, safi, | |
6124 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6125 | } | |
6126 | } else | |
6127 | ret |= peer_af_flag_set_vty( | |
6128 | vty, peer_str, afi, safi, | |
6129 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6130 | ||
6131 | if (!med) { | |
6132 | if (peer_af_flag_check(peer, afi, safi, | |
6133 | PEER_FLAG_MED_UNCHANGED)) { | |
6134 | ret |= peer_af_flag_unset_vty( | |
6135 | vty, peer_str, afi, safi, | |
6136 | PEER_FLAG_MED_UNCHANGED); | |
6137 | } | |
6138 | } else | |
6139 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6140 | PEER_FLAG_MED_UNCHANGED); | |
6141 | } | |
6142 | ||
6143 | return ret; | |
6144 | } | |
6145 | ||
6146 | ALIAS_HIDDEN( | |
6147 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6148 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6150 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6151 | "As-path attribute\n" | |
6152 | "Nexthop attribute\n" | |
6153 | "Med attribute\n") | |
6154 | ||
6155 | DEFUN (no_neighbor_attr_unchanged, | |
6156 | no_neighbor_attr_unchanged_cmd, | |
6157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6158 | NO_STR | |
6159 | NEIGHBOR_STR | |
6160 | NEIGHBOR_ADDR_STR2 | |
6161 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6162 | "As-path attribute\n" | |
6163 | "Nexthop attribute\n" | |
6164 | "Med attribute\n") | |
6165 | { | |
6166 | int idx = 0; | |
6167 | char *peer_str = argv[2]->arg; | |
6168 | struct peer *peer; | |
6169 | bool aspath = false; | |
6170 | bool nexthop = false; | |
6171 | bool med = false; | |
6172 | afi_t afi = bgp_node_afi(vty); | |
6173 | safi_t safi = bgp_node_safi(vty); | |
6174 | int ret = 0; | |
6175 | ||
6176 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6177 | if (!peer) | |
6178 | return CMD_WARNING_CONFIG_FAILED; | |
6179 | ||
6180 | if (argv_find(argv, argc, "as-path", &idx)) | |
6181 | aspath = true; | |
6182 | ||
6183 | idx = 0; | |
6184 | if (argv_find(argv, argc, "next-hop", &idx)) | |
6185 | nexthop = true; | |
6186 | ||
6187 | idx = 0; | |
6188 | if (argv_find(argv, argc, "med", &idx)) | |
6189 | med = true; | |
6190 | ||
6191 | if (!aspath && !nexthop && !med) // no flags means all of them! | |
6192 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6193 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6194 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6195 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6196 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6197 | PEER_FLAG_MED_UNCHANGED); | |
6198 | ||
6199 | if (aspath) | |
6200 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6201 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6202 | ||
6203 | if (nexthop) | |
6204 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6205 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6206 | ||
6207 | if (med) | |
6208 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6209 | PEER_FLAG_MED_UNCHANGED); | |
6210 | ||
6211 | return ret; | |
6212 | } | |
6213 | ||
6214 | ALIAS_HIDDEN( | |
6215 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6217 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6218 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6219 | "As-path attribute\n" | |
6220 | "Nexthop attribute\n" | |
6221 | "Med attribute\n") | |
6222 | ||
6223 | /* EBGP multihop configuration. */ | |
6224 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6225 | const char *ttl_str) | |
6226 | { | |
6227 | struct peer *peer; | |
6228 | unsigned int ttl; | |
6229 | ||
6230 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6231 | if (!peer) | |
6232 | return CMD_WARNING_CONFIG_FAILED; | |
6233 | ||
6234 | if (peer->conf_if) | |
6235 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6236 | ||
6237 | if (!ttl_str) | |
6238 | ttl = MAXTTL; | |
6239 | else | |
6240 | ttl = strtoul(ttl_str, NULL, 10); | |
6241 | ||
6242 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); | |
6243 | } | |
6244 | ||
6245 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) | |
6246 | { | |
6247 | struct peer *peer; | |
6248 | ||
6249 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6250 | if (!peer) | |
6251 | return CMD_WARNING_CONFIG_FAILED; | |
6252 | ||
6253 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); | |
6254 | } | |
6255 | ||
6256 | /* neighbor ebgp-multihop. */ | |
6257 | DEFUN (neighbor_ebgp_multihop, | |
6258 | neighbor_ebgp_multihop_cmd, | |
6259 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6260 | NEIGHBOR_STR | |
6261 | NEIGHBOR_ADDR_STR2 | |
6262 | "Allow EBGP neighbors not on directly connected networks\n") | |
6263 | { | |
6264 | int idx_peer = 1; | |
6265 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6266 | } | |
6267 | ||
6268 | DEFUN (neighbor_ebgp_multihop_ttl, | |
6269 | neighbor_ebgp_multihop_ttl_cmd, | |
6270 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6271 | NEIGHBOR_STR | |
6272 | NEIGHBOR_ADDR_STR2 | |
6273 | "Allow EBGP neighbors not on directly connected networks\n" | |
6274 | "maximum hop count\n") | |
6275 | { | |
6276 | int idx_peer = 1; | |
6277 | int idx_number = 3; | |
6278 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6279 | argv[idx_number]->arg); | |
6280 | } | |
6281 | ||
6282 | DEFUN (no_neighbor_ebgp_multihop, | |
6283 | no_neighbor_ebgp_multihop_cmd, | |
6284 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6285 | NO_STR | |
6286 | NEIGHBOR_STR | |
6287 | NEIGHBOR_ADDR_STR2 | |
6288 | "Allow EBGP neighbors not on directly connected networks\n" | |
6289 | "maximum hop count\n") | |
6290 | { | |
6291 | int idx_peer = 2; | |
6292 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
6293 | } | |
6294 | ||
6295 | ||
6296 | /* disable-connected-check */ | |
6297 | DEFUN (neighbor_disable_connected_check, | |
6298 | neighbor_disable_connected_check_cmd, | |
6299 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6300 | NEIGHBOR_STR | |
6301 | NEIGHBOR_ADDR_STR2 | |
6302 | "one-hop away EBGP peer using loopback address\n" | |
6303 | "Enforce EBGP neighbors perform multihop\n") | |
6304 | { | |
6305 | int idx_peer = 1; | |
6306 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6307 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6308 | } | |
6309 | ||
6310 | DEFUN (no_neighbor_disable_connected_check, | |
6311 | no_neighbor_disable_connected_check_cmd, | |
6312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6313 | NO_STR | |
6314 | NEIGHBOR_STR | |
6315 | NEIGHBOR_ADDR_STR2 | |
6316 | "one-hop away EBGP peer using loopback address\n" | |
6317 | "Enforce EBGP neighbors perform multihop\n") | |
6318 | { | |
6319 | int idx_peer = 2; | |
6320 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6321 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6322 | } | |
6323 | ||
6324 | /* disable-link-bw-encoding-ieee */ | |
6325 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6326 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
6327 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", | |
6328 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6329 | "Disable IEEE floating-point encoding for extended community bandwidth\n") | |
6330 | { | |
6331 | int idx_peer = 1; | |
6332 | ||
6333 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6334 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6335 | } | |
6336 | ||
6337 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, | |
6338 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
6339 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", | |
6340 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6341 | "Disable IEEE floating-point encoding for extended community bandwidth\n") | |
6342 | { | |
6343 | int idx_peer = 2; | |
6344 | ||
6345 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6346 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6347 | } | |
6348 | ||
6349 | /* extended-optional-parameters */ | |
6350 | DEFUN(neighbor_extended_optional_parameters, | |
6351 | neighbor_extended_optional_parameters_cmd, | |
6352 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6353 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6354 | "Force the extended optional parameters format for OPEN messages\n") | |
6355 | { | |
6356 | int idx_peer = 1; | |
6357 | ||
6358 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6359 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6360 | } | |
6361 | ||
6362 | DEFUN(no_neighbor_extended_optional_parameters, | |
6363 | no_neighbor_extended_optional_parameters_cmd, | |
6364 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6365 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6366 | "Force the extended optional parameters format for OPEN messages\n") | |
6367 | { | |
6368 | int idx_peer = 2; | |
6369 | ||
6370 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6371 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6372 | } | |
6373 | ||
6374 | /* enforce-first-as */ | |
6375 | DEFUN (neighbor_enforce_first_as, | |
6376 | neighbor_enforce_first_as_cmd, | |
6377 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6378 | NEIGHBOR_STR | |
6379 | NEIGHBOR_ADDR_STR2 | |
6380 | "Enforce the first AS for EBGP routes\n") | |
6381 | { | |
6382 | int idx_peer = 1; | |
6383 | ||
6384 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6385 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6386 | } | |
6387 | ||
6388 | DEFUN (no_neighbor_enforce_first_as, | |
6389 | no_neighbor_enforce_first_as_cmd, | |
6390 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6391 | NO_STR | |
6392 | NEIGHBOR_STR | |
6393 | NEIGHBOR_ADDR_STR2 | |
6394 | "Enforce the first AS for EBGP routes\n") | |
6395 | { | |
6396 | int idx_peer = 2; | |
6397 | ||
6398 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6399 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6400 | } | |
6401 | ||
6402 | ||
6403 | DEFUN (neighbor_description, | |
6404 | neighbor_description_cmd, | |
6405 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6406 | NEIGHBOR_STR | |
6407 | NEIGHBOR_ADDR_STR2 | |
6408 | "Neighbor specific description\n" | |
6409 | "Up to 80 characters describing this neighbor\n") | |
6410 | { | |
6411 | int idx_peer = 1; | |
6412 | int idx_line = 3; | |
6413 | struct peer *peer; | |
6414 | char *str; | |
6415 | ||
6416 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6417 | if (!peer) | |
6418 | return CMD_WARNING_CONFIG_FAILED; | |
6419 | ||
6420 | str = argv_concat(argv, argc, idx_line); | |
6421 | ||
6422 | peer_description_set(peer, str); | |
6423 | ||
6424 | XFREE(MTYPE_TMP, str); | |
6425 | ||
6426 | return CMD_SUCCESS; | |
6427 | } | |
6428 | ||
6429 | DEFUN (no_neighbor_description, | |
6430 | no_neighbor_description_cmd, | |
6431 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6432 | NO_STR | |
6433 | NEIGHBOR_STR | |
6434 | NEIGHBOR_ADDR_STR2 | |
6435 | "Neighbor specific description\n") | |
6436 | { | |
6437 | int idx_peer = 2; | |
6438 | struct peer *peer; | |
6439 | ||
6440 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6441 | if (!peer) | |
6442 | return CMD_WARNING_CONFIG_FAILED; | |
6443 | ||
6444 | peer_description_unset(peer); | |
6445 | ||
6446 | return CMD_SUCCESS; | |
6447 | } | |
6448 | ||
6449 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, | |
6450 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6451 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6452 | "Neighbor specific description\n" | |
6453 | "Up to 80 characters describing this neighbor\n") | |
6454 | ||
6455 | /* Neighbor update-source. */ | |
6456 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6457 | const char *source_str) | |
6458 | { | |
6459 | struct peer *peer; | |
6460 | struct prefix p; | |
6461 | union sockunion su; | |
6462 | ||
6463 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6464 | if (!peer) | |
6465 | return CMD_WARNING_CONFIG_FAILED; | |
6466 | ||
6467 | if (peer->conf_if) | |
6468 | return CMD_WARNING; | |
6469 | ||
6470 | if (source_str) { | |
6471 | if (str2sockunion(source_str, &su) == 0) | |
6472 | peer_update_source_addr_set(peer, &su); | |
6473 | else { | |
6474 | if (str2prefix(source_str, &p)) { | |
6475 | vty_out(vty, | |
6476 | "%% Invalid update-source, remove prefix length \n"); | |
6477 | return CMD_WARNING_CONFIG_FAILED; | |
6478 | } else | |
6479 | peer_update_source_if_set(peer, source_str); | |
6480 | } | |
6481 | } else | |
6482 | peer_update_source_unset(peer); | |
6483 | ||
6484 | return CMD_SUCCESS; | |
6485 | } | |
6486 | ||
6487 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
6488 | "IPv4 address\n" \ | |
6489 | "IPv6 address\n" \ | |
6490 | "Interface name (requires zebra to be running)\n" | |
6491 | ||
6492 | DEFUN (neighbor_update_source, | |
6493 | neighbor_update_source_cmd, | |
6494 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6495 | NEIGHBOR_STR | |
6496 | NEIGHBOR_ADDR_STR2 | |
6497 | "Source of routing updates\n" | |
6498 | BGP_UPDATE_SOURCE_HELP_STR) | |
6499 | { | |
6500 | int idx_peer = 1; | |
6501 | int idx_peer_2 = 3; | |
6502 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
6503 | argv[idx_peer_2]->arg); | |
6504 | } | |
6505 | ||
6506 | DEFUN (no_neighbor_update_source, | |
6507 | no_neighbor_update_source_cmd, | |
6508 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6509 | NO_STR | |
6510 | NEIGHBOR_STR | |
6511 | NEIGHBOR_ADDR_STR2 | |
6512 | "Source of routing updates\n" | |
6513 | BGP_UPDATE_SOURCE_HELP_STR) | |
6514 | { | |
6515 | int idx_peer = 2; | |
6516 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
6517 | } | |
6518 | ||
6519 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, | |
6520 | afi_t afi, safi_t safi, | |
6521 | const char *rmap, int set) | |
6522 | { | |
6523 | int ret; | |
6524 | struct peer *peer; | |
6525 | struct route_map *route_map = NULL; | |
6526 | ||
6527 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6528 | if (!peer) | |
6529 | return CMD_WARNING_CONFIG_FAILED; | |
6530 | ||
6531 | if (set) { | |
6532 | if (rmap) | |
6533 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
6534 | ret = peer_default_originate_set(peer, afi, safi, | |
6535 | rmap, route_map); | |
6536 | } else | |
6537 | ret = peer_default_originate_unset(peer, afi, safi); | |
6538 | ||
6539 | return bgp_vty_return(vty, ret); | |
6540 | } | |
6541 | ||
6542 | /* neighbor default-originate. */ | |
6543 | DEFUN (neighbor_default_originate, | |
6544 | neighbor_default_originate_cmd, | |
6545 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6546 | NEIGHBOR_STR | |
6547 | NEIGHBOR_ADDR_STR2 | |
6548 | "Originate default route to this neighbor\n") | |
6549 | { | |
6550 | int idx_peer = 1; | |
6551 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6552 | bgp_node_afi(vty), | |
6553 | bgp_node_safi(vty), NULL, 1); | |
6554 | } | |
6555 | ||
6556 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, | |
6557 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6558 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6559 | "Originate default route to this neighbor\n") | |
6560 | ||
6561 | DEFUN (neighbor_default_originate_rmap, | |
6562 | neighbor_default_originate_rmap_cmd, | |
6563 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6564 | NEIGHBOR_STR | |
6565 | NEIGHBOR_ADDR_STR2 | |
6566 | "Originate default route to this neighbor\n" | |
6567 | "Route-map to specify criteria to originate default\n" | |
6568 | "route-map name\n") | |
6569 | { | |
6570 | int idx_peer = 1; | |
6571 | int idx_word = 4; | |
6572 | return peer_default_originate_set_vty( | |
6573 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6574 | argv[idx_word]->arg, 1); | |
6575 | } | |
6576 | ||
6577 | ALIAS_HIDDEN( | |
6578 | neighbor_default_originate_rmap, | |
6579 | neighbor_default_originate_rmap_hidden_cmd, | |
6580 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6581 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6582 | "Originate default route to this neighbor\n" | |
6583 | "Route-map to specify criteria to originate default\n" | |
6584 | "route-map name\n") | |
6585 | ||
6586 | DEFUN (no_neighbor_default_originate, | |
6587 | no_neighbor_default_originate_cmd, | |
6588 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6589 | NO_STR | |
6590 | NEIGHBOR_STR | |
6591 | NEIGHBOR_ADDR_STR2 | |
6592 | "Originate default route to this neighbor\n" | |
6593 | "Route-map to specify criteria to originate default\n" | |
6594 | "route-map name\n") | |
6595 | { | |
6596 | int idx_peer = 2; | |
6597 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6598 | bgp_node_afi(vty), | |
6599 | bgp_node_safi(vty), NULL, 0); | |
6600 | } | |
6601 | ||
6602 | ALIAS_HIDDEN( | |
6603 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6604 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6605 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6606 | "Originate default route to this neighbor\n" | |
6607 | "Route-map to specify criteria to originate default\n" | |
6608 | "route-map name\n") | |
6609 | ||
6610 | ||
6611 | /* Set neighbor's BGP port. */ | |
6612 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6613 | const char *port_str) | |
6614 | { | |
6615 | struct peer *peer; | |
6616 | uint16_t port; | |
6617 | struct servent *sp; | |
6618 | ||
6619 | peer = peer_lookup_vty(vty, ip_str); | |
6620 | if (!peer) | |
6621 | return CMD_WARNING_CONFIG_FAILED; | |
6622 | ||
6623 | if (!port_str) { | |
6624 | sp = getservbyname("bgp", "tcp"); | |
6625 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6626 | } else { | |
6627 | port = strtoul(port_str, NULL, 10); | |
6628 | } | |
6629 | ||
6630 | peer_port_set(peer, port); | |
6631 | ||
6632 | return CMD_SUCCESS; | |
6633 | } | |
6634 | ||
6635 | /* Set specified peer's BGP port. */ | |
6636 | DEFUN (neighbor_port, | |
6637 | neighbor_port_cmd, | |
6638 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6639 | NEIGHBOR_STR | |
6640 | NEIGHBOR_ADDR_STR | |
6641 | "Neighbor's BGP port\n" | |
6642 | "TCP port number\n") | |
6643 | { | |
6644 | int idx_ip = 1; | |
6645 | int idx_number = 3; | |
6646 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6647 | argv[idx_number]->arg); | |
6648 | } | |
6649 | ||
6650 | DEFUN (no_neighbor_port, | |
6651 | no_neighbor_port_cmd, | |
6652 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6653 | NO_STR | |
6654 | NEIGHBOR_STR | |
6655 | NEIGHBOR_ADDR_STR | |
6656 | "Neighbor's BGP port\n" | |
6657 | "TCP port number\n") | |
6658 | { | |
6659 | int idx_ip = 2; | |
6660 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
6661 | } | |
6662 | ||
6663 | ||
6664 | /* neighbor weight. */ | |
6665 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6666 | safi_t safi, const char *weight_str) | |
6667 | { | |
6668 | int ret; | |
6669 | struct peer *peer; | |
6670 | unsigned long weight; | |
6671 | ||
6672 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6673 | if (!peer) | |
6674 | return CMD_WARNING_CONFIG_FAILED; | |
6675 | ||
6676 | weight = strtoul(weight_str, NULL, 10); | |
6677 | ||
6678 | ret = peer_weight_set(peer, afi, safi, weight); | |
6679 | return bgp_vty_return(vty, ret); | |
6680 | } | |
6681 | ||
6682 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6683 | safi_t safi) | |
6684 | { | |
6685 | int ret; | |
6686 | struct peer *peer; | |
6687 | ||
6688 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6689 | if (!peer) | |
6690 | return CMD_WARNING_CONFIG_FAILED; | |
6691 | ||
6692 | ret = peer_weight_unset(peer, afi, safi); | |
6693 | return bgp_vty_return(vty, ret); | |
6694 | } | |
6695 | ||
6696 | DEFUN (neighbor_weight, | |
6697 | neighbor_weight_cmd, | |
6698 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6699 | NEIGHBOR_STR | |
6700 | NEIGHBOR_ADDR_STR2 | |
6701 | "Set default weight for routes from this neighbor\n" | |
6702 | "default weight\n") | |
6703 | { | |
6704 | int idx_peer = 1; | |
6705 | int idx_number = 3; | |
6706 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6707 | bgp_node_safi(vty), argv[idx_number]->arg); | |
6708 | } | |
6709 | ||
6710 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, | |
6711 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6712 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6713 | "Set default weight for routes from this neighbor\n" | |
6714 | "default weight\n") | |
6715 | ||
6716 | DEFUN (no_neighbor_weight, | |
6717 | no_neighbor_weight_cmd, | |
6718 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6719 | NO_STR | |
6720 | NEIGHBOR_STR | |
6721 | NEIGHBOR_ADDR_STR2 | |
6722 | "Set default weight for routes from this neighbor\n" | |
6723 | "default weight\n") | |
6724 | { | |
6725 | int idx_peer = 2; | |
6726 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
6727 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
6728 | } | |
6729 | ||
6730 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, | |
6731 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6732 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6733 | "Set default weight for routes from this neighbor\n" | |
6734 | "default weight\n") | |
6735 | ||
6736 | ||
6737 | /* Override capability negotiation. */ | |
6738 | DEFUN (neighbor_override_capability, | |
6739 | neighbor_override_capability_cmd, | |
6740 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6741 | NEIGHBOR_STR | |
6742 | NEIGHBOR_ADDR_STR2 | |
6743 | "Override capability negotiation result\n") | |
6744 | { | |
6745 | int idx_peer = 1; | |
6746 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6747 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
6748 | } | |
6749 | ||
6750 | DEFUN (no_neighbor_override_capability, | |
6751 | no_neighbor_override_capability_cmd, | |
6752 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6753 | NO_STR | |
6754 | NEIGHBOR_STR | |
6755 | NEIGHBOR_ADDR_STR2 | |
6756 | "Override capability negotiation result\n") | |
6757 | { | |
6758 | int idx_peer = 2; | |
6759 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6760 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
6761 | } | |
6762 | ||
6763 | DEFUN (neighbor_strict_capability, | |
6764 | neighbor_strict_capability_cmd, | |
6765 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6766 | NEIGHBOR_STR | |
6767 | NEIGHBOR_ADDR_STR2 | |
6768 | "Strict capability negotiation match\n") | |
6769 | { | |
6770 | int idx_peer = 1; | |
6771 | ||
6772 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6773 | PEER_FLAG_STRICT_CAP_MATCH); | |
6774 | } | |
6775 | ||
6776 | DEFUN (no_neighbor_strict_capability, | |
6777 | no_neighbor_strict_capability_cmd, | |
6778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6779 | NO_STR | |
6780 | NEIGHBOR_STR | |
6781 | NEIGHBOR_ADDR_STR2 | |
6782 | "Strict capability negotiation match\n") | |
6783 | { | |
6784 | int idx_peer = 2; | |
6785 | ||
6786 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6787 | PEER_FLAG_STRICT_CAP_MATCH); | |
6788 | } | |
6789 | ||
6790 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, | |
6791 | const char *keep_str, const char *hold_str) | |
6792 | { | |
6793 | int ret; | |
6794 | struct peer *peer; | |
6795 | uint32_t keepalive; | |
6796 | uint32_t holdtime; | |
6797 | ||
6798 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6799 | if (!peer) | |
6800 | return CMD_WARNING_CONFIG_FAILED; | |
6801 | ||
6802 | keepalive = strtoul(keep_str, NULL, 10); | |
6803 | holdtime = strtoul(hold_str, NULL, 10); | |
6804 | ||
6805 | ret = peer_timers_set(peer, keepalive, holdtime); | |
6806 | ||
6807 | return bgp_vty_return(vty, ret); | |
6808 | } | |
6809 | ||
6810 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) | |
6811 | { | |
6812 | int ret; | |
6813 | struct peer *peer; | |
6814 | ||
6815 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6816 | if (!peer) | |
6817 | return CMD_WARNING_CONFIG_FAILED; | |
6818 | ||
6819 | ret = peer_timers_unset(peer); | |
6820 | ||
6821 | return bgp_vty_return(vty, ret); | |
6822 | } | |
6823 | ||
6824 | DEFUN (neighbor_timers, | |
6825 | neighbor_timers_cmd, | |
6826 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6827 | NEIGHBOR_STR | |
6828 | NEIGHBOR_ADDR_STR2 | |
6829 | "BGP per neighbor timers\n" | |
6830 | "Keepalive interval\n" | |
6831 | "Holdtime\n") | |
6832 | { | |
6833 | int idx_peer = 1; | |
6834 | int idx_number = 3; | |
6835 | int idx_number_2 = 4; | |
6836 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6837 | argv[idx_number]->arg, | |
6838 | argv[idx_number_2]->arg); | |
6839 | } | |
6840 | ||
6841 | DEFUN (no_neighbor_timers, | |
6842 | no_neighbor_timers_cmd, | |
6843 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6844 | NO_STR | |
6845 | NEIGHBOR_STR | |
6846 | NEIGHBOR_ADDR_STR2 | |
6847 | "BGP per neighbor timers\n" | |
6848 | "Keepalive interval\n" | |
6849 | "Holdtime\n") | |
6850 | { | |
6851 | int idx_peer = 2; | |
6852 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6853 | } | |
6854 | ||
6855 | ||
6856 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6857 | const char *time_str) | |
6858 | { | |
6859 | int ret; | |
6860 | struct peer *peer; | |
6861 | uint32_t connect; | |
6862 | ||
6863 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6864 | if (!peer) | |
6865 | return CMD_WARNING_CONFIG_FAILED; | |
6866 | ||
6867 | connect = strtoul(time_str, NULL, 10); | |
6868 | ||
6869 | ret = peer_timers_connect_set(peer, connect); | |
6870 | ||
6871 | return bgp_vty_return(vty, ret); | |
6872 | } | |
6873 | ||
6874 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) | |
6875 | { | |
6876 | int ret; | |
6877 | struct peer *peer; | |
6878 | ||
6879 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6880 | if (!peer) | |
6881 | return CMD_WARNING_CONFIG_FAILED; | |
6882 | ||
6883 | ret = peer_timers_connect_unset(peer); | |
6884 | ||
6885 | return bgp_vty_return(vty, ret); | |
6886 | } | |
6887 | ||
6888 | DEFUN (neighbor_timers_connect, | |
6889 | neighbor_timers_connect_cmd, | |
6890 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
6891 | NEIGHBOR_STR | |
6892 | NEIGHBOR_ADDR_STR2 | |
6893 | "BGP per neighbor timers\n" | |
6894 | "BGP connect timer\n" | |
6895 | "Connect timer\n") | |
6896 | { | |
6897 | int idx_peer = 1; | |
6898 | int idx_number = 4; | |
6899 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6900 | argv[idx_number]->arg); | |
6901 | } | |
6902 | ||
6903 | DEFUN (no_neighbor_timers_connect, | |
6904 | no_neighbor_timers_connect_cmd, | |
6905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
6906 | NO_STR | |
6907 | NEIGHBOR_STR | |
6908 | NEIGHBOR_ADDR_STR2 | |
6909 | "BGP per neighbor timers\n" | |
6910 | "BGP connect timer\n" | |
6911 | "Connect timer\n") | |
6912 | { | |
6913 | int idx_peer = 2; | |
6914 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
6915 | } | |
6916 | ||
6917 | DEFPY (neighbor_timers_delayopen, | |
6918 | neighbor_timers_delayopen_cmd, | |
6919 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
6920 | NEIGHBOR_STR | |
6921 | NEIGHBOR_ADDR_STR2 | |
6922 | "BGP per neighbor timers\n" | |
6923 | "RFC 4271 DelayOpenTimer\n" | |
6924 | "DelayOpenTime timer interval\n") | |
6925 | { | |
6926 | struct peer *peer; | |
6927 | ||
6928 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6929 | if (!peer) | |
6930 | return CMD_WARNING_CONFIG_FAILED; | |
6931 | ||
6932 | if (!interval) { | |
6933 | if (peer_timers_delayopen_unset(peer)) | |
6934 | return CMD_WARNING_CONFIG_FAILED; | |
6935 | } else { | |
6936 | if (peer_timers_delayopen_set(peer, interval)) | |
6937 | return CMD_WARNING_CONFIG_FAILED; | |
6938 | } | |
6939 | ||
6940 | return CMD_SUCCESS; | |
6941 | } | |
6942 | ||
6943 | DEFPY (no_neighbor_timers_delayopen, | |
6944 | no_neighbor_timers_delayopen_cmd, | |
6945 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
6946 | NO_STR | |
6947 | NEIGHBOR_STR | |
6948 | NEIGHBOR_ADDR_STR2 | |
6949 | "BGP per neighbor timers\n" | |
6950 | "RFC 4271 DelayOpenTimer\n" | |
6951 | "DelayOpenTime timer interval\n") | |
6952 | { | |
6953 | struct peer *peer; | |
6954 | ||
6955 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6956 | if (!peer) | |
6957 | return CMD_WARNING_CONFIG_FAILED; | |
6958 | ||
6959 | if (peer_timers_delayopen_unset(peer)) | |
6960 | return CMD_WARNING_CONFIG_FAILED; | |
6961 | ||
6962 | return CMD_SUCCESS; | |
6963 | } | |
6964 | ||
6965 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, | |
6966 | const char *time_str, int set) | |
6967 | { | |
6968 | int ret; | |
6969 | struct peer *peer; | |
6970 | uint32_t routeadv = 0; | |
6971 | ||
6972 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
6973 | if (!peer) | |
6974 | return CMD_WARNING_CONFIG_FAILED; | |
6975 | ||
6976 | if (time_str) | |
6977 | routeadv = strtoul(time_str, NULL, 10); | |
6978 | ||
6979 | if (set) | |
6980 | ret = peer_advertise_interval_set(peer, routeadv); | |
6981 | else | |
6982 | ret = peer_advertise_interval_unset(peer); | |
6983 | ||
6984 | return bgp_vty_return(vty, ret); | |
6985 | } | |
6986 | ||
6987 | DEFUN (neighbor_advertise_interval, | |
6988 | neighbor_advertise_interval_cmd, | |
6989 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
6990 | NEIGHBOR_STR | |
6991 | NEIGHBOR_ADDR_STR2 | |
6992 | "Minimum interval between sending BGP routing updates\n" | |
6993 | "time in seconds\n") | |
6994 | { | |
6995 | int idx_peer = 1; | |
6996 | int idx_number = 3; | |
6997 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6998 | argv[idx_number]->arg, 1); | |
6999 | } | |
7000 | ||
7001 | DEFUN (no_neighbor_advertise_interval, | |
7002 | no_neighbor_advertise_interval_cmd, | |
7003 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7004 | NO_STR | |
7005 | NEIGHBOR_STR | |
7006 | NEIGHBOR_ADDR_STR2 | |
7007 | "Minimum interval between sending BGP routing updates\n" | |
7008 | "time in seconds\n") | |
7009 | { | |
7010 | int idx_peer = 2; | |
7011 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
7012 | } | |
7013 | ||
7014 | ||
7015 | /* Time to wait before processing route-map updates */ | |
7016 | DEFUN (bgp_set_route_map_delay_timer, | |
7017 | bgp_set_route_map_delay_timer_cmd, | |
7018 | "bgp route-map delay-timer (0-600)", | |
7019 | SET_STR | |
7020 | "BGP route-map delay timer\n" | |
7021 | "Time in secs to wait before processing route-map changes\n" | |
7022 | "0 disables the timer, no route updates happen when route-maps change\n") | |
7023 | { | |
7024 | int idx_number = 3; | |
7025 | uint32_t rmap_delay_timer; | |
7026 | ||
7027 | if (argv[idx_number]->arg) { | |
7028 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7029 | bm->rmap_update_timer = rmap_delay_timer; | |
7030 | ||
7031 | /* if the dynamic update handling is being disabled, and a timer | |
7032 | * is | |
7033 | * running, stop the timer and act as if the timer has already | |
7034 | * fired. | |
7035 | */ | |
7036 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7037 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7038 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7039 | NULL, 0); | |
7040 | } | |
7041 | return CMD_SUCCESS; | |
7042 | } else { | |
7043 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7044 | return CMD_WARNING_CONFIG_FAILED; | |
7045 | } | |
7046 | } | |
7047 | ||
7048 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7049 | no_bgp_set_route_map_delay_timer_cmd, | |
7050 | "no bgp route-map delay-timer [(0-600)]", | |
7051 | NO_STR | |
7052 | BGP_STR | |
7053 | "Default BGP route-map delay timer\n" | |
7054 | "Reset to default time to wait for processing route-map changes\n" | |
7055 | "0 disables the timer, no route updates happen when route-maps change\n") | |
7056 | { | |
7057 | ||
7058 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; | |
7059 | ||
7060 | return CMD_SUCCESS; | |
7061 | } | |
7062 | ||
7063 | /* neighbor interface */ | |
7064 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7065 | const char *str) | |
7066 | { | |
7067 | struct peer *peer; | |
7068 | ||
7069 | peer = peer_lookup_vty(vty, ip_str); | |
7070 | if (!peer || peer->conf_if) { | |
7071 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7072 | return CMD_WARNING_CONFIG_FAILED; | |
7073 | } | |
7074 | ||
7075 | if (str) | |
7076 | peer_interface_set(peer, str); | |
7077 | else | |
7078 | peer_interface_unset(peer); | |
7079 | ||
7080 | return CMD_SUCCESS; | |
7081 | } | |
7082 | ||
7083 | DEFUN (neighbor_interface, | |
7084 | neighbor_interface_cmd, | |
7085 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7086 | NEIGHBOR_STR | |
7087 | NEIGHBOR_ADDR_STR | |
7088 | "Interface\n" | |
7089 | "Interface name\n") | |
7090 | { | |
7091 | int idx_ip = 1; | |
7092 | int idx_word = 3; | |
7093 | ||
7094 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
7095 | } | |
7096 | ||
7097 | DEFUN (no_neighbor_interface, | |
7098 | no_neighbor_interface_cmd, | |
7099 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7100 | NO_STR | |
7101 | NEIGHBOR_STR | |
7102 | NEIGHBOR_ADDR_STR | |
7103 | "Interface\n" | |
7104 | "Interface name\n") | |
7105 | { | |
7106 | int idx_peer = 2; | |
7107 | ||
7108 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
7109 | } | |
7110 | ||
7111 | DEFUN (neighbor_distribute_list, | |
7112 | neighbor_distribute_list_cmd, | |
7113 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", | |
7114 | NEIGHBOR_STR | |
7115 | NEIGHBOR_ADDR_STR2 | |
7116 | "Filter updates to/from this neighbor\n" | |
7117 | "IP Access-list name\n" | |
7118 | "Filter incoming updates\n" | |
7119 | "Filter outgoing updates\n") | |
7120 | { | |
7121 | int idx_peer = 1; | |
7122 | int idx_acl = 3; | |
7123 | int direct, ret; | |
7124 | struct peer *peer; | |
7125 | ||
7126 | const char *pstr = argv[idx_peer]->arg; | |
7127 | const char *acl = argv[idx_acl]->arg; | |
7128 | const char *inout = argv[argc - 1]->text; | |
7129 | ||
7130 | peer = peer_and_group_lookup_vty(vty, pstr); | |
7131 | if (!peer) | |
7132 | return CMD_WARNING_CONFIG_FAILED; | |
7133 | ||
7134 | /* Check filter direction. */ | |
7135 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7136 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7137 | direct, acl); | |
7138 | ||
7139 | return bgp_vty_return(vty, ret); | |
7140 | } | |
7141 | ||
7142 | ALIAS_HIDDEN( | |
7143 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7144 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", | |
7145 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7146 | "Filter updates to/from this neighbor\n" | |
7147 | "IP Access-list name\n" | |
7148 | "Filter incoming updates\n" | |
7149 | "Filter outgoing updates\n") | |
7150 | ||
7151 | DEFUN (no_neighbor_distribute_list, | |
7152 | no_neighbor_distribute_list_cmd, | |
7153 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", | |
7154 | NO_STR | |
7155 | NEIGHBOR_STR | |
7156 | NEIGHBOR_ADDR_STR2 | |
7157 | "Filter updates to/from this neighbor\n" | |
7158 | "IP Access-list name\n" | |
7159 | "Filter incoming updates\n" | |
7160 | "Filter outgoing updates\n") | |
7161 | { | |
7162 | int idx_peer = 2; | |
7163 | int direct, ret; | |
7164 | struct peer *peer; | |
7165 | ||
7166 | const char *pstr = argv[idx_peer]->arg; | |
7167 | const char *inout = argv[argc - 1]->text; | |
7168 | ||
7169 | peer = peer_and_group_lookup_vty(vty, pstr); | |
7170 | if (!peer) | |
7171 | return CMD_WARNING_CONFIG_FAILED; | |
7172 | ||
7173 | /* Check filter direction. */ | |
7174 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7175 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7176 | direct); | |
7177 | ||
7178 | return bgp_vty_return(vty, ret); | |
7179 | } | |
7180 | ||
7181 | ALIAS_HIDDEN( | |
7182 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", | |
7184 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7185 | "Filter updates to/from this neighbor\n" | |
7186 | "IP Access-list name\n" | |
7187 | "Filter incoming updates\n" | |
7188 | "Filter outgoing updates\n") | |
7189 | ||
7190 | /* Set prefix list to the peer. */ | |
7191 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, | |
7192 | afi_t afi, safi_t safi, | |
7193 | const char *name_str, | |
7194 | const char *direct_str) | |
7195 | { | |
7196 | int ret; | |
7197 | int direct = FILTER_IN; | |
7198 | struct peer *peer; | |
7199 | ||
7200 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7201 | if (!peer) | |
7202 | return CMD_WARNING_CONFIG_FAILED; | |
7203 | ||
7204 | /* Check filter direction. */ | |
7205 | if (strncmp(direct_str, "i", 1) == 0) | |
7206 | direct = FILTER_IN; | |
7207 | else if (strncmp(direct_str, "o", 1) == 0) | |
7208 | direct = FILTER_OUT; | |
7209 | ||
7210 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); | |
7211 | ||
7212 | return bgp_vty_return(vty, ret); | |
7213 | } | |
7214 | ||
7215 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7216 | afi_t afi, safi_t safi, | |
7217 | const char *direct_str) | |
7218 | { | |
7219 | int ret; | |
7220 | struct peer *peer; | |
7221 | int direct = FILTER_IN; | |
7222 | ||
7223 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7224 | if (!peer) | |
7225 | return CMD_WARNING_CONFIG_FAILED; | |
7226 | ||
7227 | /* Check filter direction. */ | |
7228 | if (strncmp(direct_str, "i", 1) == 0) | |
7229 | direct = FILTER_IN; | |
7230 | else if (strncmp(direct_str, "o", 1) == 0) | |
7231 | direct = FILTER_OUT; | |
7232 | ||
7233 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7234 | ||
7235 | return bgp_vty_return(vty, ret); | |
7236 | } | |
7237 | ||
7238 | DEFUN (neighbor_prefix_list, | |
7239 | neighbor_prefix_list_cmd, | |
7240 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7241 | NEIGHBOR_STR | |
7242 | NEIGHBOR_ADDR_STR2 | |
7243 | "Filter updates to/from this neighbor\n" | |
7244 | "Name of a prefix list\n" | |
7245 | "Filter incoming updates\n" | |
7246 | "Filter outgoing updates\n") | |
7247 | { | |
7248 | int idx_peer = 1; | |
7249 | int idx_word = 3; | |
7250 | int idx_in_out = 4; | |
7251 | return peer_prefix_list_set_vty( | |
7252 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7253 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
7254 | } | |
7255 | ||
7256 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, | |
7257 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7258 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7259 | "Filter updates to/from this neighbor\n" | |
7260 | "Name of a prefix list\n" | |
7261 | "Filter incoming updates\n" | |
7262 | "Filter outgoing updates\n") | |
7263 | ||
7264 | DEFUN (no_neighbor_prefix_list, | |
7265 | no_neighbor_prefix_list_cmd, | |
7266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7267 | NO_STR | |
7268 | NEIGHBOR_STR | |
7269 | NEIGHBOR_ADDR_STR2 | |
7270 | "Filter updates to/from this neighbor\n" | |
7271 | "Name of a prefix list\n" | |
7272 | "Filter incoming updates\n" | |
7273 | "Filter outgoing updates\n") | |
7274 | { | |
7275 | int idx_peer = 2; | |
7276 | int idx_in_out = 5; | |
7277 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7278 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7279 | argv[idx_in_out]->arg); | |
7280 | } | |
7281 | ||
7282 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7283 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7284 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7285 | "Filter updates to/from this neighbor\n" | |
7286 | "Name of a prefix list\n" | |
7287 | "Filter incoming updates\n" | |
7288 | "Filter outgoing updates\n") | |
7289 | ||
7290 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7291 | safi_t safi, const char *name_str, | |
7292 | const char *direct_str) | |
7293 | { | |
7294 | int ret; | |
7295 | struct peer *peer; | |
7296 | int direct = FILTER_IN; | |
7297 | ||
7298 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7299 | if (!peer) | |
7300 | return CMD_WARNING_CONFIG_FAILED; | |
7301 | ||
7302 | /* Check filter direction. */ | |
7303 | if (strncmp(direct_str, "i", 1) == 0) | |
7304 | direct = FILTER_IN; | |
7305 | else if (strncmp(direct_str, "o", 1) == 0) | |
7306 | direct = FILTER_OUT; | |
7307 | ||
7308 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); | |
7309 | ||
7310 | return bgp_vty_return(vty, ret); | |
7311 | } | |
7312 | ||
7313 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7314 | safi_t safi, const char *direct_str) | |
7315 | { | |
7316 | int ret; | |
7317 | struct peer *peer; | |
7318 | int direct = FILTER_IN; | |
7319 | ||
7320 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7321 | if (!peer) | |
7322 | return CMD_WARNING_CONFIG_FAILED; | |
7323 | ||
7324 | /* Check filter direction. */ | |
7325 | if (strncmp(direct_str, "i", 1) == 0) | |
7326 | direct = FILTER_IN; | |
7327 | else if (strncmp(direct_str, "o", 1) == 0) | |
7328 | direct = FILTER_OUT; | |
7329 | ||
7330 | ret = peer_aslist_unset(peer, afi, safi, direct); | |
7331 | ||
7332 | return bgp_vty_return(vty, ret); | |
7333 | } | |
7334 | ||
7335 | DEFUN (neighbor_filter_list, | |
7336 | neighbor_filter_list_cmd, | |
7337 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", | |
7338 | NEIGHBOR_STR | |
7339 | NEIGHBOR_ADDR_STR2 | |
7340 | "Establish BGP filters\n" | |
7341 | "AS path access-list name\n" | |
7342 | "Filter incoming routes\n" | |
7343 | "Filter outgoing routes\n") | |
7344 | { | |
7345 | int idx_peer = 1; | |
7346 | int idx_word = 3; | |
7347 | int idx_in_out = 4; | |
7348 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7349 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7350 | argv[idx_in_out]->arg); | |
7351 | } | |
7352 | ||
7353 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, | |
7354 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", | |
7355 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7356 | "Establish BGP filters\n" | |
7357 | "AS path access-list name\n" | |
7358 | "Filter incoming routes\n" | |
7359 | "Filter outgoing routes\n") | |
7360 | ||
7361 | DEFUN (no_neighbor_filter_list, | |
7362 | no_neighbor_filter_list_cmd, | |
7363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", | |
7364 | NO_STR | |
7365 | NEIGHBOR_STR | |
7366 | NEIGHBOR_ADDR_STR2 | |
7367 | "Establish BGP filters\n" | |
7368 | "AS path access-list name\n" | |
7369 | "Filter incoming routes\n" | |
7370 | "Filter outgoing routes\n") | |
7371 | { | |
7372 | int idx_peer = 2; | |
7373 | int idx_in_out = 5; | |
7374 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7375 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7376 | argv[idx_in_out]->arg); | |
7377 | } | |
7378 | ||
7379 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, | |
7380 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", | |
7381 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7382 | "Establish BGP filters\n" | |
7383 | "AS path access-list name\n" | |
7384 | "Filter incoming routes\n" | |
7385 | "Filter outgoing routes\n") | |
7386 | ||
7387 | /* Set advertise-map to the peer. */ | |
7388 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7389 | afi_t afi, safi_t safi, | |
7390 | const char *advertise_str, | |
7391 | const char *condition_str, bool condition, | |
7392 | bool set) | |
7393 | { | |
7394 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7395 | struct peer *peer; | |
7396 | struct route_map *advertise_map; | |
7397 | struct route_map *condition_map; | |
7398 | ||
7399 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7400 | if (!peer) | |
7401 | return ret; | |
7402 | ||
7403 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7404 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7405 | ||
7406 | if (set) | |
7407 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7408 | advertise_map, condition_str, | |
7409 | condition_map, condition); | |
7410 | else | |
7411 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7412 | advertise_map, condition_str, | |
7413 | condition_map, condition); | |
7414 | ||
7415 | return bgp_vty_return(vty, ret); | |
7416 | } | |
7417 | ||
7418 | DEFPY (bgp_condadv_period, | |
7419 | bgp_condadv_period_cmd, | |
7420 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7421 | NO_STR | |
7422 | BGP_STR | |
7423 | "Conditional advertisement settings\n" | |
7424 | "Set period to rescan BGP table to check if condition is met\n" | |
7425 | "Period between BGP table scans, in seconds; default 60\n") | |
7426 | { | |
7427 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7428 | ||
7429 | bgp->condition_check_period = | |
7430 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7431 | ||
7432 | return CMD_SUCCESS; | |
7433 | } | |
7434 | ||
7435 | DEFPY (neighbor_advertise_map, | |
7436 | neighbor_advertise_map_cmd, | |
7437 | "[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", | |
7438 | NO_STR | |
7439 | NEIGHBOR_STR | |
7440 | NEIGHBOR_ADDR_STR2 | |
7441 | "Route-map to conditionally advertise routes\n" | |
7442 | "Name of advertise map\n" | |
7443 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7444 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7445 | "Name of the exist or non exist map\n") | |
7446 | { | |
7447 | bool condition = CONDITION_EXIST; | |
7448 | ||
7449 | if (!strcmp(exist, "non-exist-map")) | |
7450 | condition = CONDITION_NON_EXIST; | |
7451 | ||
7452 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), | |
7453 | bgp_node_safi(vty), advertise_str, | |
7454 | condition_str, condition, !no); | |
7455 | } | |
7456 | ||
7457 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
7458 | "[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", | |
7459 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7460 | "Route-map to conditionally advertise routes\n" | |
7461 | "Name of advertise map\n" | |
7462 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7463 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7464 | "Name of the exist or non exist map\n") | |
7465 | ||
7466 | /* Set route-map to the peer. */ | |
7467 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, | |
7468 | afi_t afi, safi_t safi, const char *name_str, | |
7469 | const char *direct_str) | |
7470 | { | |
7471 | int ret; | |
7472 | struct peer *peer; | |
7473 | int direct = RMAP_IN; | |
7474 | struct route_map *route_map; | |
7475 | ||
7476 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7477 | if (!peer) | |
7478 | return CMD_WARNING_CONFIG_FAILED; | |
7479 | ||
7480 | /* Check filter direction. */ | |
7481 | if (strncmp(direct_str, "in", 2) == 0) | |
7482 | direct = RMAP_IN; | |
7483 | else if (strncmp(direct_str, "o", 1) == 0) | |
7484 | direct = RMAP_OUT; | |
7485 | ||
7486 | route_map = route_map_lookup_warn_noexist(vty, name_str); | |
7487 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
7488 | ||
7489 | return bgp_vty_return(vty, ret); | |
7490 | } | |
7491 | ||
7492 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7493 | afi_t afi, safi_t safi, | |
7494 | const char *direct_str) | |
7495 | { | |
7496 | int ret; | |
7497 | struct peer *peer; | |
7498 | int direct = RMAP_IN; | |
7499 | ||
7500 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7501 | if (!peer) | |
7502 | return CMD_WARNING_CONFIG_FAILED; | |
7503 | ||
7504 | /* Check filter direction. */ | |
7505 | if (strncmp(direct_str, "in", 2) == 0) | |
7506 | direct = RMAP_IN; | |
7507 | else if (strncmp(direct_str, "o", 1) == 0) | |
7508 | direct = RMAP_OUT; | |
7509 | ||
7510 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7511 | ||
7512 | return bgp_vty_return(vty, ret); | |
7513 | } | |
7514 | ||
7515 | DEFUN (neighbor_route_map, | |
7516 | neighbor_route_map_cmd, | |
7517 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7518 | NEIGHBOR_STR | |
7519 | NEIGHBOR_ADDR_STR2 | |
7520 | "Apply route map to neighbor\n" | |
7521 | "Name of route map\n" | |
7522 | "Apply map to incoming routes\n" | |
7523 | "Apply map to outbound routes\n") | |
7524 | { | |
7525 | int idx_peer = 1; | |
7526 | int idx_word = 3; | |
7527 | int idx_in_out = 4; | |
7528 | return peer_route_map_set_vty( | |
7529 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7530 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
7531 | } | |
7532 | ||
7533 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, | |
7534 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7535 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7536 | "Apply route map to neighbor\n" | |
7537 | "Name of route map\n" | |
7538 | "Apply map to incoming routes\n" | |
7539 | "Apply map to outbound routes\n") | |
7540 | ||
7541 | DEFUN (no_neighbor_route_map, | |
7542 | no_neighbor_route_map_cmd, | |
7543 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7544 | NO_STR | |
7545 | NEIGHBOR_STR | |
7546 | NEIGHBOR_ADDR_STR2 | |
7547 | "Apply route map to neighbor\n" | |
7548 | "Name of route map\n" | |
7549 | "Apply map to incoming routes\n" | |
7550 | "Apply map to outbound routes\n") | |
7551 | { | |
7552 | int idx_peer = 2; | |
7553 | int idx_in_out = 5; | |
7554 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7555 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7556 | argv[idx_in_out]->arg); | |
7557 | } | |
7558 | ||
7559 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
7560 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7561 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7562 | "Apply route map to neighbor\n" | |
7563 | "Name of route map\n" | |
7564 | "Apply map to incoming routes\n" | |
7565 | "Apply map to outbound routes\n") | |
7566 | ||
7567 | /* Set unsuppress-map to the peer. */ | |
7568 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, | |
7569 | afi_t afi, safi_t safi, | |
7570 | const char *name_str) | |
7571 | { | |
7572 | int ret; | |
7573 | struct peer *peer; | |
7574 | struct route_map *route_map; | |
7575 | ||
7576 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7577 | if (!peer) | |
7578 | return CMD_WARNING_CONFIG_FAILED; | |
7579 | ||
7580 | route_map = route_map_lookup_warn_noexist(vty, name_str); | |
7581 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
7582 | ||
7583 | return bgp_vty_return(vty, ret); | |
7584 | } | |
7585 | ||
7586 | /* Unset route-map from the peer. */ | |
7587 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, | |
7588 | afi_t afi, safi_t safi) | |
7589 | { | |
7590 | int ret; | |
7591 | struct peer *peer; | |
7592 | ||
7593 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7594 | if (!peer) | |
7595 | return CMD_WARNING_CONFIG_FAILED; | |
7596 | ||
7597 | ret = peer_unsuppress_map_unset(peer, afi, safi); | |
7598 | ||
7599 | return bgp_vty_return(vty, ret); | |
7600 | } | |
7601 | ||
7602 | DEFUN (neighbor_unsuppress_map, | |
7603 | neighbor_unsuppress_map_cmd, | |
7604 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7605 | NEIGHBOR_STR | |
7606 | NEIGHBOR_ADDR_STR2 | |
7607 | "Route-map to selectively unsuppress suppressed routes\n" | |
7608 | "Name of route map\n") | |
7609 | { | |
7610 | int idx_peer = 1; | |
7611 | int idx_word = 3; | |
7612 | return peer_unsuppress_map_set_vty( | |
7613 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7614 | argv[idx_word]->arg); | |
7615 | } | |
7616 | ||
7617 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, | |
7618 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7619 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7620 | "Route-map to selectively unsuppress suppressed routes\n" | |
7621 | "Name of route map\n") | |
7622 | ||
7623 | DEFUN (no_neighbor_unsuppress_map, | |
7624 | no_neighbor_unsuppress_map_cmd, | |
7625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7626 | NO_STR | |
7627 | NEIGHBOR_STR | |
7628 | NEIGHBOR_ADDR_STR2 | |
7629 | "Route-map to selectively unsuppress suppressed routes\n" | |
7630 | "Name of route map\n") | |
7631 | { | |
7632 | int idx_peer = 2; | |
7633 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7634 | bgp_node_afi(vty), | |
7635 | bgp_node_safi(vty)); | |
7636 | } | |
7637 | ||
7638 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, | |
7639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7640 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7641 | "Route-map to selectively unsuppress suppressed routes\n" | |
7642 | "Name of route map\n") | |
7643 | ||
7644 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, | |
7645 | afi_t afi, safi_t safi, | |
7646 | const char *num_str, | |
7647 | const char *threshold_str, int warning, | |
7648 | const char *restart_str, | |
7649 | const char *force_str) | |
7650 | { | |
7651 | int ret; | |
7652 | struct peer *peer; | |
7653 | uint32_t max; | |
7654 | uint8_t threshold; | |
7655 | uint16_t restart; | |
7656 | ||
7657 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7658 | if (!peer) | |
7659 | return CMD_WARNING_CONFIG_FAILED; | |
7660 | ||
7661 | max = strtoul(num_str, NULL, 10); | |
7662 | if (threshold_str) | |
7663 | threshold = atoi(threshold_str); | |
7664 | else | |
7665 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7666 | ||
7667 | if (restart_str) | |
7668 | restart = atoi(restart_str); | |
7669 | else | |
7670 | restart = 0; | |
7671 | ||
7672 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7673 | restart, force_str ? true : false); | |
7674 | ||
7675 | return bgp_vty_return(vty, ret); | |
7676 | } | |
7677 | ||
7678 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7679 | afi_t afi, safi_t safi) | |
7680 | { | |
7681 | int ret; | |
7682 | struct peer *peer; | |
7683 | ||
7684 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7685 | if (!peer) | |
7686 | return CMD_WARNING_CONFIG_FAILED; | |
7687 | ||
7688 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7689 | ||
7690 | return bgp_vty_return(vty, ret); | |
7691 | } | |
7692 | ||
7693 | /* Maximum number of prefix to be sent to the neighbor. */ | |
7694 | DEFUN(neighbor_maximum_prefix_out, | |
7695 | neighbor_maximum_prefix_out_cmd, | |
7696 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7697 | NEIGHBOR_STR | |
7698 | NEIGHBOR_ADDR_STR2 | |
7699 | "Maximum number of prefixes to be sent to this peer\n" | |
7700 | "Maximum no. of prefix limit\n") | |
7701 | { | |
7702 | int ret; | |
7703 | int idx_peer = 1; | |
7704 | int idx_number = 3; | |
7705 | struct peer *peer; | |
7706 | uint32_t max; | |
7707 | afi_t afi = bgp_node_afi(vty); | |
7708 | safi_t safi = bgp_node_safi(vty); | |
7709 | ||
7710 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7711 | if (!peer) | |
7712 | return CMD_WARNING_CONFIG_FAILED; | |
7713 | ||
7714 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
7715 | ||
7716 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); | |
7717 | ||
7718 | return bgp_vty_return(vty, ret); | |
7719 | } | |
7720 | ||
7721 | DEFUN(no_neighbor_maximum_prefix_out, | |
7722 | no_neighbor_maximum_prefix_out_cmd, | |
7723 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", | |
7724 | NO_STR | |
7725 | NEIGHBOR_STR | |
7726 | NEIGHBOR_ADDR_STR2 | |
7727 | "Maximum number of prefixes to be sent to this peer\n" | |
7728 | "Maximum no. of prefix limit\n") | |
7729 | { | |
7730 | int ret; | |
7731 | int idx_peer = 2; | |
7732 | struct peer *peer; | |
7733 | afi_t afi = bgp_node_afi(vty); | |
7734 | safi_t safi = bgp_node_safi(vty); | |
7735 | ||
7736 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7737 | if (!peer) | |
7738 | return CMD_WARNING_CONFIG_FAILED; | |
7739 | ||
7740 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); | |
7741 | ||
7742 | return bgp_vty_return(vty, ret); | |
7743 | } | |
7744 | ||
7745 | /* Maximum number of prefix configuration. Prefix count is different | |
7746 | for each peer configuration. So this configuration can be set for | |
7747 | each peer configuration. */ | |
7748 | DEFUN (neighbor_maximum_prefix, | |
7749 | neighbor_maximum_prefix_cmd, | |
7750 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7751 | NEIGHBOR_STR | |
7752 | NEIGHBOR_ADDR_STR2 | |
7753 | "Maximum number of prefix accept from this peer\n" | |
7754 | "maximum no. of prefix limit\n" | |
7755 | "Force checking all received routes not only accepted\n") | |
7756 | { | |
7757 | int idx_peer = 1; | |
7758 | int idx_number = 3; | |
7759 | int idx_force = 0; | |
7760 | char *force = NULL; | |
7761 | ||
7762 | if (argv_find(argv, argc, "force", &idx_force)) | |
7763 | force = argv[idx_force]->arg; | |
7764 | ||
7765 | return peer_maximum_prefix_set_vty( | |
7766 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7767 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
7768 | } | |
7769 | ||
7770 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, | |
7771 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7772 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7773 | "Maximum number of prefix accept from this peer\n" | |
7774 | "maximum no. of prefix limit\n" | |
7775 | "Force checking all received routes not only accepted\n") | |
7776 | ||
7777 | DEFUN (neighbor_maximum_prefix_threshold, | |
7778 | neighbor_maximum_prefix_threshold_cmd, | |
7779 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7780 | NEIGHBOR_STR | |
7781 | NEIGHBOR_ADDR_STR2 | |
7782 | "Maximum number of prefix accept from this peer\n" | |
7783 | "maximum no. of prefix limit\n" | |
7784 | "Threshold value (%) at which to generate a warning msg\n" | |
7785 | "Force checking all received routes not only accepted\n") | |
7786 | { | |
7787 | int idx_peer = 1; | |
7788 | int idx_number = 3; | |
7789 | int idx_number_2 = 4; | |
7790 | int idx_force = 0; | |
7791 | char *force = NULL; | |
7792 | ||
7793 | if (argv_find(argv, argc, "force", &idx_force)) | |
7794 | force = argv[idx_force]->arg; | |
7795 | ||
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, NULL, force); | |
7799 | } | |
7800 | ||
7801 | ALIAS_HIDDEN( | |
7802 | neighbor_maximum_prefix_threshold, | |
7803 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
7804 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7805 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7806 | "Maximum number of prefix accept from this peer\n" | |
7807 | "maximum no. of prefix limit\n" | |
7808 | "Threshold value (%) at which to generate a warning msg\n" | |
7809 | "Force checking all received routes not only accepted\n") | |
7810 | ||
7811 | DEFUN (neighbor_maximum_prefix_warning, | |
7812 | neighbor_maximum_prefix_warning_cmd, | |
7813 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7814 | NEIGHBOR_STR | |
7815 | NEIGHBOR_ADDR_STR2 | |
7816 | "Maximum number of prefix accept from this peer\n" | |
7817 | "maximum no. of prefix limit\n" | |
7818 | "Only give warning message when limit is exceeded\n" | |
7819 | "Force checking all received routes not only accepted\n") | |
7820 | { | |
7821 | int idx_peer = 1; | |
7822 | int idx_number = 3; | |
7823 | int idx_force = 0; | |
7824 | char *force = NULL; | |
7825 | ||
7826 | if (argv_find(argv, argc, "force", &idx_force)) | |
7827 | force = argv[idx_force]->arg; | |
7828 | ||
7829 | return peer_maximum_prefix_set_vty( | |
7830 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7831 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
7832 | } | |
7833 | ||
7834 | ALIAS_HIDDEN( | |
7835 | neighbor_maximum_prefix_warning, | |
7836 | neighbor_maximum_prefix_warning_hidden_cmd, | |
7837 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7838 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7839 | "Maximum number of prefix accept from this peer\n" | |
7840 | "maximum no. of prefix limit\n" | |
7841 | "Only give warning message when limit is exceeded\n" | |
7842 | "Force checking all received routes not only accepted\n") | |
7843 | ||
7844 | DEFUN (neighbor_maximum_prefix_threshold_warning, | |
7845 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7846 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7847 | NEIGHBOR_STR | |
7848 | NEIGHBOR_ADDR_STR2 | |
7849 | "Maximum number of prefix accept from this peer\n" | |
7850 | "maximum no. of prefix limit\n" | |
7851 | "Threshold value (%) at which to generate a warning msg\n" | |
7852 | "Only give warning message when limit is exceeded\n" | |
7853 | "Force checking all received routes not only accepted\n") | |
7854 | { | |
7855 | int idx_peer = 1; | |
7856 | int idx_number = 3; | |
7857 | int idx_number_2 = 4; | |
7858 | int idx_force = 0; | |
7859 | char *force = NULL; | |
7860 | ||
7861 | if (argv_find(argv, argc, "force", &idx_force)) | |
7862 | force = argv[idx_force]->arg; | |
7863 | ||
7864 | return peer_maximum_prefix_set_vty( | |
7865 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7866 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
7867 | } | |
7868 | ||
7869 | ALIAS_HIDDEN( | |
7870 | neighbor_maximum_prefix_threshold_warning, | |
7871 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
7872 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7873 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7874 | "Maximum number of prefix accept from this peer\n" | |
7875 | "maximum no. of prefix limit\n" | |
7876 | "Threshold value (%) at which to generate a warning msg\n" | |
7877 | "Only give warning message when limit is exceeded\n" | |
7878 | "Force checking all received routes not only accepted\n") | |
7879 | ||
7880 | DEFUN (neighbor_maximum_prefix_restart, | |
7881 | neighbor_maximum_prefix_restart_cmd, | |
7882 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7883 | NEIGHBOR_STR | |
7884 | NEIGHBOR_ADDR_STR2 | |
7885 | "Maximum number of prefix accept from this peer\n" | |
7886 | "maximum no. of prefix limit\n" | |
7887 | "Restart bgp connection after limit is exceeded\n" | |
7888 | "Restart interval in minutes\n" | |
7889 | "Force checking all received routes not only accepted\n") | |
7890 | { | |
7891 | int idx_peer = 1; | |
7892 | int idx_number = 3; | |
7893 | int idx_number_2 = 5; | |
7894 | int idx_force = 0; | |
7895 | char *force = NULL; | |
7896 | ||
7897 | if (argv_find(argv, argc, "force", &idx_force)) | |
7898 | force = argv[idx_force]->arg; | |
7899 | ||
7900 | return peer_maximum_prefix_set_vty( | |
7901 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7902 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
7903 | } | |
7904 | ||
7905 | ALIAS_HIDDEN( | |
7906 | neighbor_maximum_prefix_restart, | |
7907 | neighbor_maximum_prefix_restart_hidden_cmd, | |
7908 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7909 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7910 | "Maximum number of prefix accept from this peer\n" | |
7911 | "maximum no. of prefix limit\n" | |
7912 | "Restart bgp connection after limit is exceeded\n" | |
7913 | "Restart interval in minutes\n" | |
7914 | "Force checking all received routes not only accepted\n") | |
7915 | ||
7916 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
7917 | neighbor_maximum_prefix_threshold_restart_cmd, | |
7918 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7919 | NEIGHBOR_STR | |
7920 | NEIGHBOR_ADDR_STR2 | |
7921 | "Maximum number of prefixes to accept from this peer\n" | |
7922 | "maximum no. of prefix limit\n" | |
7923 | "Threshold value (%) at which to generate a warning msg\n" | |
7924 | "Restart bgp connection after limit is exceeded\n" | |
7925 | "Restart interval in minutes\n" | |
7926 | "Force checking all received routes not only accepted\n") | |
7927 | { | |
7928 | int idx_peer = 1; | |
7929 | int idx_number = 3; | |
7930 | int idx_number_2 = 4; | |
7931 | int idx_number_3 = 6; | |
7932 | int idx_force = 0; | |
7933 | char *force = NULL; | |
7934 | ||
7935 | if (argv_find(argv, argc, "force", &idx_force)) | |
7936 | force = argv[idx_force]->arg; | |
7937 | ||
7938 | return peer_maximum_prefix_set_vty( | |
7939 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7940 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
7941 | argv[idx_number_3]->arg, force); | |
7942 | } | |
7943 | ||
7944 | ALIAS_HIDDEN( | |
7945 | neighbor_maximum_prefix_threshold_restart, | |
7946 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
7947 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7948 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7949 | "Maximum number of prefixes to accept from this peer\n" | |
7950 | "maximum no. of prefix limit\n" | |
7951 | "Threshold value (%) at which to generate a warning msg\n" | |
7952 | "Restart bgp connection after limit is exceeded\n" | |
7953 | "Restart interval in minutes\n" | |
7954 | "Force checking all received routes not only accepted\n") | |
7955 | ||
7956 | DEFUN (no_neighbor_maximum_prefix, | |
7957 | no_neighbor_maximum_prefix_cmd, | |
7958 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7959 | NO_STR | |
7960 | NEIGHBOR_STR | |
7961 | NEIGHBOR_ADDR_STR2 | |
7962 | "Maximum number of prefixes to accept from this peer\n" | |
7963 | "maximum no. of prefix limit\n" | |
7964 | "Threshold value (%) at which to generate a warning msg\n" | |
7965 | "Restart bgp connection after limit is exceeded\n" | |
7966 | "Restart interval in minutes\n" | |
7967 | "Only give warning message when limit is exceeded\n" | |
7968 | "Force checking all received routes not only accepted\n") | |
7969 | { | |
7970 | int idx_peer = 2; | |
7971 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
7972 | bgp_node_afi(vty), | |
7973 | bgp_node_safi(vty)); | |
7974 | } | |
7975 | ||
7976 | ALIAS_HIDDEN( | |
7977 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
7978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7979 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7980 | "Maximum number of prefixes to accept from this peer\n" | |
7981 | "maximum no. of prefix limit\n" | |
7982 | "Threshold value (%) at which to generate a warning msg\n" | |
7983 | "Restart bgp connection after limit is exceeded\n" | |
7984 | "Restart interval in minutes\n" | |
7985 | "Only give warning message when limit is exceeded\n" | |
7986 | "Force checking all received routes not only accepted\n") | |
7987 | ||
7988 | ||
7989 | /* "neighbor allowas-in" */ | |
7990 | DEFUN (neighbor_allowas_in, | |
7991 | neighbor_allowas_in_cmd, | |
7992 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7993 | NEIGHBOR_STR | |
7994 | NEIGHBOR_ADDR_STR2 | |
7995 | "Accept as-path with my AS present in it\n" | |
7996 | "Number of occurrences of AS number\n" | |
7997 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
7998 | { | |
7999 | int idx_peer = 1; | |
8000 | int idx_number_origin = 3; | |
8001 | int ret; | |
8002 | int origin = 0; | |
8003 | struct peer *peer; | |
8004 | int allow_num = 0; | |
8005 | ||
8006 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8007 | if (!peer) | |
8008 | return CMD_WARNING_CONFIG_FAILED; | |
8009 | ||
8010 | if (argc <= idx_number_origin) | |
8011 | allow_num = 3; | |
8012 | else { | |
8013 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8014 | origin = 1; | |
8015 | else | |
8016 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8017 | } | |
8018 | ||
8019 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8020 | allow_num, origin); | |
8021 | ||
8022 | return bgp_vty_return(vty, ret); | |
8023 | } | |
8024 | ||
8025 | ALIAS_HIDDEN( | |
8026 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8027 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8028 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8029 | "Accept as-path with my AS present in it\n" | |
8030 | "Number of occurrences of AS number\n" | |
8031 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
8032 | ||
8033 | DEFUN (no_neighbor_allowas_in, | |
8034 | no_neighbor_allowas_in_cmd, | |
8035 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8036 | NO_STR | |
8037 | NEIGHBOR_STR | |
8038 | NEIGHBOR_ADDR_STR2 | |
8039 | "allow local ASN appears in aspath attribute\n" | |
8040 | "Number of occurrences of AS number\n" | |
8041 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
8042 | { | |
8043 | int idx_peer = 2; | |
8044 | int ret; | |
8045 | struct peer *peer; | |
8046 | ||
8047 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8048 | if (!peer) | |
8049 | return CMD_WARNING_CONFIG_FAILED; | |
8050 | ||
8051 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), | |
8052 | bgp_node_safi(vty)); | |
8053 | ||
8054 | return bgp_vty_return(vty, ret); | |
8055 | } | |
8056 | ||
8057 | ALIAS_HIDDEN( | |
8058 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8059 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8060 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8061 | "allow local ASN appears in aspath attribute\n" | |
8062 | "Number of occurrences of AS number\n" | |
8063 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
8064 | ||
8065 | DEFUN (neighbor_ttl_security, | |
8066 | neighbor_ttl_security_cmd, | |
8067 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8068 | NEIGHBOR_STR | |
8069 | NEIGHBOR_ADDR_STR2 | |
8070 | "BGP ttl-security parameters\n" | |
8071 | "Specify the maximum number of hops to the BGP peer\n" | |
8072 | "Number of hops to BGP peer\n") | |
8073 | { | |
8074 | int idx_peer = 1; | |
8075 | int idx_number = 4; | |
8076 | struct peer *peer; | |
8077 | int gtsm_hops; | |
8078 | ||
8079 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8080 | if (!peer) | |
8081 | return CMD_WARNING_CONFIG_FAILED; | |
8082 | ||
8083 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
8084 | ||
8085 | /* | |
8086 | * If 'neighbor swpX', then this is for directly connected peers, | |
8087 | * we should not accept a ttl-security hops value greater than 1. | |
8088 | */ | |
8089 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8090 | vty_out(vty, | |
8091 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8092 | argv[idx_peer]->arg); | |
8093 | return CMD_WARNING_CONFIG_FAILED; | |
8094 | } | |
8095 | ||
8096 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); | |
8097 | } | |
8098 | ||
8099 | DEFUN (no_neighbor_ttl_security, | |
8100 | no_neighbor_ttl_security_cmd, | |
8101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8102 | NO_STR | |
8103 | NEIGHBOR_STR | |
8104 | NEIGHBOR_ADDR_STR2 | |
8105 | "BGP ttl-security parameters\n" | |
8106 | "Specify the maximum number of hops to the BGP peer\n" | |
8107 | "Number of hops to BGP peer\n") | |
8108 | { | |
8109 | int idx_peer = 2; | |
8110 | struct peer *peer; | |
8111 | ||
8112 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8113 | if (!peer) | |
8114 | return CMD_WARNING_CONFIG_FAILED; | |
8115 | ||
8116 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); | |
8117 | } | |
8118 | ||
8119 | /* disable-addpath-rx */ | |
8120 | DEFUN(neighbor_disable_addpath_rx, | |
8121 | neighbor_disable_addpath_rx_cmd, | |
8122 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8123 | NEIGHBOR_STR | |
8124 | NEIGHBOR_ADDR_STR2 | |
8125 | "Do not accept additional paths\n") | |
8126 | { | |
8127 | char *peer_str = argv[1]->arg; | |
8128 | struct peer *peer; | |
8129 | afi_t afi = bgp_node_afi(vty); | |
8130 | safi_t safi = bgp_node_safi(vty); | |
8131 | ||
8132 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8133 | if (!peer) | |
8134 | return CMD_WARNING_CONFIG_FAILED; | |
8135 | ||
8136 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8137 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8138 | } | |
8139 | ||
8140 | DEFUN(no_neighbor_disable_addpath_rx, | |
8141 | no_neighbor_disable_addpath_rx_cmd, | |
8142 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8143 | NO_STR | |
8144 | NEIGHBOR_STR | |
8145 | NEIGHBOR_ADDR_STR2 | |
8146 | "Do not accept additional paths\n") | |
8147 | { | |
8148 | char *peer_str = argv[2]->arg; | |
8149 | struct peer *peer; | |
8150 | afi_t afi = bgp_node_afi(vty); | |
8151 | safi_t safi = bgp_node_safi(vty); | |
8152 | ||
8153 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8154 | if (!peer) | |
8155 | return CMD_WARNING_CONFIG_FAILED; | |
8156 | ||
8157 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8158 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8159 | } | |
8160 | ||
8161 | DEFUN (neighbor_addpath_tx_all_paths, | |
8162 | neighbor_addpath_tx_all_paths_cmd, | |
8163 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8164 | NEIGHBOR_STR | |
8165 | NEIGHBOR_ADDR_STR2 | |
8166 | "Use addpath to advertise all paths to a neighbor\n") | |
8167 | { | |
8168 | int idx_peer = 1; | |
8169 | struct peer *peer; | |
8170 | ||
8171 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8172 | if (!peer) | |
8173 | return CMD_WARNING_CONFIG_FAILED; | |
8174 | ||
8175 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8176 | BGP_ADDPATH_ALL); | |
8177 | return CMD_SUCCESS; | |
8178 | } | |
8179 | ||
8180 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, | |
8181 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8182 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8183 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8184 | "Use addpath to advertise all paths to a neighbor\n") | |
8185 | ||
8186 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
8187 | no_neighbor_addpath_tx_all_paths_cmd, | |
8188 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8189 | NO_STR | |
8190 | NEIGHBOR_STR | |
8191 | NEIGHBOR_ADDR_STR2 | |
8192 | "Use addpath to advertise all paths to a neighbor\n") | |
8193 | { | |
8194 | int idx_peer = 2; | |
8195 | struct peer *peer; | |
8196 | ||
8197 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8198 | if (!peer) | |
8199 | return CMD_WARNING_CONFIG_FAILED; | |
8200 | ||
8201 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8202 | != BGP_ADDPATH_ALL) { | |
8203 | vty_out(vty, | |
8204 | "%% Peer not currently configured to transmit all paths."); | |
8205 | return CMD_WARNING_CONFIG_FAILED; | |
8206 | } | |
8207 | ||
8208 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8209 | BGP_ADDPATH_NONE); | |
8210 | ||
8211 | return CMD_SUCCESS; | |
8212 | } | |
8213 | ||
8214 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, | |
8215 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8217 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8218 | "Use addpath to advertise all paths to a neighbor\n") | |
8219 | ||
8220 | DEFUN (neighbor_addpath_tx_bestpath_per_as, | |
8221 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
8222 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8223 | NEIGHBOR_STR | |
8224 | NEIGHBOR_ADDR_STR2 | |
8225 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8226 | { | |
8227 | int idx_peer = 1; | |
8228 | struct peer *peer; | |
8229 | ||
8230 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8231 | if (!peer) | |
8232 | return CMD_WARNING_CONFIG_FAILED; | |
8233 | ||
8234 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8235 | BGP_ADDPATH_BEST_PER_AS); | |
8236 | ||
8237 | return CMD_SUCCESS; | |
8238 | } | |
8239 | ||
8240 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, | |
8241 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8242 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8243 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8244 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8245 | ||
8246 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
8247 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
8248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8249 | NO_STR | |
8250 | NEIGHBOR_STR | |
8251 | NEIGHBOR_ADDR_STR2 | |
8252 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8253 | { | |
8254 | int idx_peer = 2; | |
8255 | struct peer *peer; | |
8256 | ||
8257 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8258 | if (!peer) | |
8259 | return CMD_WARNING_CONFIG_FAILED; | |
8260 | ||
8261 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8262 | != BGP_ADDPATH_BEST_PER_AS) { | |
8263 | vty_out(vty, | |
8264 | "%% Peer not currently configured to transmit all best path per as."); | |
8265 | return CMD_WARNING_CONFIG_FAILED; | |
8266 | } | |
8267 | ||
8268 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8269 | BGP_ADDPATH_NONE); | |
8270 | ||
8271 | return CMD_SUCCESS; | |
8272 | } | |
8273 | ||
8274 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, | |
8275 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8276 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8277 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8278 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8279 | ||
8280 | DEFPY( | |
8281 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8282 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8283 | NEIGHBOR_STR | |
8284 | NEIGHBOR_ADDR_STR2 | |
8285 | "Detect AS loops before sending to neighbor\n") | |
8286 | { | |
8287 | struct peer *peer; | |
8288 | ||
8289 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8290 | if (!peer) | |
8291 | return CMD_WARNING_CONFIG_FAILED; | |
8292 | ||
8293 | peer->as_path_loop_detection = true; | |
8294 | ||
8295 | return CMD_SUCCESS; | |
8296 | } | |
8297 | ||
8298 | DEFPY( | |
8299 | no_neighbor_aspath_loop_detection, | |
8300 | no_neighbor_aspath_loop_detection_cmd, | |
8301 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8302 | NO_STR | |
8303 | NEIGHBOR_STR | |
8304 | NEIGHBOR_ADDR_STR2 | |
8305 | "Detect AS loops before sending to neighbor\n") | |
8306 | { | |
8307 | struct peer *peer; | |
8308 | ||
8309 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8310 | if (!peer) | |
8311 | return CMD_WARNING_CONFIG_FAILED; | |
8312 | ||
8313 | peer->as_path_loop_detection = false; | |
8314 | ||
8315 | return CMD_SUCCESS; | |
8316 | } | |
8317 | ||
8318 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, | |
8319 | struct ecommunity **list, bool is_rt6) | |
8320 | { | |
8321 | struct ecommunity *ecom = NULL; | |
8322 | struct ecommunity *ecomadd; | |
8323 | ||
8324 | for (; argc; --argc, ++argv) { | |
8325 | if (is_rt6) | |
8326 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8327 | ECOMMUNITY_ROUTE_TARGET, | |
8328 | 0); | |
8329 | else | |
8330 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8331 | ECOMMUNITY_ROUTE_TARGET, | |
8332 | 0); | |
8333 | if (!ecomadd) { | |
8334 | vty_out(vty, "Malformed community-list value\n"); | |
8335 | if (ecom) | |
8336 | ecommunity_free(&ecom); | |
8337 | return CMD_WARNING_CONFIG_FAILED; | |
8338 | } | |
8339 | ||
8340 | if (ecom) { | |
8341 | ecommunity_merge(ecom, ecomadd); | |
8342 | ecommunity_free(&ecomadd); | |
8343 | } else { | |
8344 | ecom = ecomadd; | |
8345 | } | |
8346 | } | |
8347 | ||
8348 | if (*list) { | |
8349 | ecommunity_free(&*list); | |
8350 | } | |
8351 | *list = ecom; | |
8352 | ||
8353 | return CMD_SUCCESS; | |
8354 | } | |
8355 | ||
8356 | /* | |
8357 | * v2vimport is true if we are handling a `import vrf ...` command | |
8358 | */ | |
8359 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
8360 | { | |
8361 | afi_t afi; | |
8362 | ||
8363 | switch (vty->node) { | |
8364 | case BGP_IPV4_NODE: | |
8365 | afi = AFI_IP; | |
8366 | break; | |
8367 | case BGP_IPV6_NODE: | |
8368 | afi = AFI_IP6; | |
8369 | break; | |
8370 | default: | |
8371 | vty_out(vty, | |
8372 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); | |
8373 | return AFI_MAX; | |
8374 | } | |
8375 | ||
8376 | if (!v2vimport) { | |
8377 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8378 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8379 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8380 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8381 | vty_out(vty, | |
8382 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8383 | return AFI_MAX; | |
8384 | } | |
8385 | } else { | |
8386 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8387 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8388 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8389 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8390 | vty_out(vty, | |
8391 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8392 | return AFI_MAX; | |
8393 | } | |
8394 | } | |
8395 | return afi; | |
8396 | } | |
8397 | ||
8398 | DEFPY (af_rd_vpn_export, | |
8399 | af_rd_vpn_export_cmd, | |
8400 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8401 | NO_STR | |
8402 | "Specify route distinguisher\n" | |
8403 | "Between current address-family and vpn\n" | |
8404 | "For routes leaked from current address-family to vpn\n" | |
8405 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
8406 | { | |
8407 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8408 | struct prefix_rd prd; | |
8409 | int ret; | |
8410 | afi_t afi; | |
8411 | int idx = 0; | |
8412 | bool yes = true; | |
8413 | ||
8414 | if (argv_find(argv, argc, "no", &idx)) | |
8415 | yes = false; | |
8416 | ||
8417 | if (yes) { | |
8418 | ret = str2prefix_rd(rd_str, &prd); | |
8419 | if (!ret) { | |
8420 | vty_out(vty, "%% Malformed rd\n"); | |
8421 | return CMD_WARNING_CONFIG_FAILED; | |
8422 | } | |
8423 | } | |
8424 | ||
8425 | afi = vpn_policy_getafi(vty, bgp, false); | |
8426 | if (afi == AFI_MAX) | |
8427 | return CMD_WARNING_CONFIG_FAILED; | |
8428 | ||
8429 | /* | |
8430 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8431 | */ | |
8432 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8433 | bgp_get_default(), bgp); | |
8434 | ||
8435 | if (yes) { | |
8436 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8437 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8438 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8439 | } else { | |
8440 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8441 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8442 | } | |
8443 | ||
8444 | /* post-change: re-export vpn routes */ | |
8445 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8446 | bgp_get_default(), bgp); | |
8447 | ||
8448 | return CMD_SUCCESS; | |
8449 | } | |
8450 | ||
8451 | ALIAS (af_rd_vpn_export, | |
8452 | af_no_rd_vpn_export_cmd, | |
8453 | "no rd vpn export", | |
8454 | NO_STR | |
8455 | "Specify route distinguisher\n" | |
8456 | "Between current address-family and vpn\n" | |
8457 | "For routes leaked from current address-family to vpn\n") | |
8458 | ||
8459 | DEFPY (af_label_vpn_export, | |
8460 | af_label_vpn_export_cmd, | |
8461 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", | |
8462 | NO_STR | |
8463 | "label value for VRF\n" | |
8464 | "Between current address-family and vpn\n" | |
8465 | "For routes leaked from current address-family to vpn\n" | |
8466 | "Label Value <0-1048575>\n" | |
8467 | "Automatically assign a label\n") | |
8468 | { | |
8469 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8470 | mpls_label_t label = MPLS_LABEL_NONE; | |
8471 | afi_t afi; | |
8472 | int idx = 0; | |
8473 | bool yes = true; | |
8474 | ||
8475 | if (argv_find(argv, argc, "no", &idx)) | |
8476 | yes = false; | |
8477 | ||
8478 | /* If "no ...", squash trailing parameter */ | |
8479 | if (!yes) | |
8480 | label_auto = NULL; | |
8481 | ||
8482 | if (yes) { | |
8483 | if (!label_auto) | |
8484 | label = label_val; /* parser should force unsigned */ | |
8485 | } | |
8486 | ||
8487 | afi = vpn_policy_getafi(vty, bgp, false); | |
8488 | if (afi == AFI_MAX) | |
8489 | return CMD_WARNING_CONFIG_FAILED; | |
8490 | ||
8491 | ||
8492 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8493 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8494 | /* no change */ | |
8495 | return CMD_SUCCESS; | |
8496 | ||
8497 | /* | |
8498 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8499 | */ | |
8500 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8501 | bgp_get_default(), bgp); | |
8502 | ||
8503 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8504 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8505 | ||
8506 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8507 | ||
8508 | /* | |
8509 | * label has previously been automatically | |
8510 | * assigned by labelpool: release it | |
8511 | * | |
8512 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8513 | * means the automatic assignment is in flight | |
8514 | * and therefore the labelpool callback must | |
8515 | * detect that the auto label is not needed. | |
8516 | */ | |
8517 | ||
8518 | bgp_lp_release(LP_TYPE_VRF, | |
8519 | &bgp->vpn_policy[afi], | |
8520 | bgp->vpn_policy[afi].tovpn_label); | |
8521 | } | |
8522 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8523 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8524 | } | |
8525 | ||
8526 | bgp->vpn_policy[afi].tovpn_label = label; | |
8527 | if (label_auto) { | |
8528 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8529 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8530 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8531 | vpn_leak_label_callback); | |
8532 | } | |
8533 | ||
8534 | /* post-change: re-export vpn routes */ | |
8535 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8536 | bgp_get_default(), bgp); | |
8537 | ||
8538 | hook_call(bgp_snmp_update_last_changed, bgp); | |
8539 | return CMD_SUCCESS; | |
8540 | } | |
8541 | ||
8542 | DEFPY (af_sid_vpn_export, | |
8543 | af_sid_vpn_export_cmd, | |
8544 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8545 | NO_STR | |
8546 | "sid value for VRF\n" | |
8547 | "Between current address-family and vpn\n" | |
8548 | "For routes leaked from current address-family to vpn\n" | |
8549 | "Sid allocation index\n" | |
8550 | "Automatically assign a label\n") | |
8551 | { | |
8552 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8553 | afi_t afi; | |
8554 | int debug = 0; | |
8555 | int idx = 0; | |
8556 | bool yes = true; | |
8557 | ||
8558 | if (argv_find(argv, argc, "no", &idx)) | |
8559 | yes = false; | |
8560 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8561 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8562 | ||
8563 | afi = vpn_policy_getafi(vty, bgp, false); | |
8564 | if (afi == AFI_MAX) | |
8565 | return CMD_WARNING_CONFIG_FAILED; | |
8566 | ||
8567 | if (!yes) { | |
8568 | /* implement me */ | |
8569 | vty_out(vty, "It's not implemented"); | |
8570 | return CMD_WARNING_CONFIG_FAILED; | |
8571 | } | |
8572 | ||
8573 | /* skip when it's already configured */ | |
8574 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8575 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8576 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8577 | return CMD_SUCCESS; | |
8578 | ||
8579 | /* | |
8580 | * mode change between sid_idx and sid_auto isn't supported. | |
8581 | * user must negate sid vpn export when they want to change the mode | |
8582 | */ | |
8583 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8584 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8585 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8586 | vty_out(vty, "it's already configured as %s.\n", | |
8587 | sid_auto ? "auto-mode" : "idx-mode"); | |
8588 | return CMD_WARNING_CONFIG_FAILED; | |
8589 | } | |
8590 | ||
8591 | /* pre-change */ | |
8592 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8593 | bgp_get_default(), bgp); | |
8594 | ||
8595 | if (sid_auto) { | |
8596 | /* SID allocation auto-mode */ | |
8597 | if (debug) | |
8598 | zlog_debug("%s: auto sid alloc.", __func__); | |
8599 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8600 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8601 | } else { | |
8602 | /* SID allocation index-mode */ | |
8603 | if (debug) | |
8604 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8605 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8606 | } | |
8607 | ||
8608 | /* post-change */ | |
8609 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8610 | bgp_get_default(), bgp); | |
8611 | return CMD_SUCCESS; | |
8612 | } | |
8613 | ||
8614 | ALIAS (af_label_vpn_export, | |
8615 | af_no_label_vpn_export_cmd, | |
8616 | "no label vpn export", | |
8617 | NO_STR | |
8618 | "label value for VRF\n" | |
8619 | "Between current address-family and vpn\n" | |
8620 | "For routes leaked from current address-family to vpn\n") | |
8621 | ||
8622 | DEFPY (af_nexthop_vpn_export, | |
8623 | af_nexthop_vpn_export_cmd, | |
8624 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", | |
8625 | NO_STR | |
8626 | "Specify next hop to use for VRF advertised prefixes\n" | |
8627 | "Between current address-family and vpn\n" | |
8628 | "For routes leaked from current address-family to vpn\n" | |
8629 | "IPv4 prefix\n" | |
8630 | "IPv6 prefix\n") | |
8631 | { | |
8632 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8633 | afi_t afi; | |
8634 | struct prefix p; | |
8635 | ||
8636 | if (!no) { | |
8637 | if (!nexthop_su) { | |
8638 | vty_out(vty, "%% Nexthop required\n"); | |
8639 | return CMD_WARNING_CONFIG_FAILED; | |
8640 | } | |
8641 | if (!sockunion2hostprefix(nexthop_su, &p)) | |
8642 | return CMD_WARNING_CONFIG_FAILED; | |
8643 | } | |
8644 | ||
8645 | afi = vpn_policy_getafi(vty, bgp, false); | |
8646 | if (afi == AFI_MAX) | |
8647 | return CMD_WARNING_CONFIG_FAILED; | |
8648 | ||
8649 | /* | |
8650 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8651 | */ | |
8652 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8653 | bgp_get_default(), bgp); | |
8654 | ||
8655 | if (!no) { | |
8656 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8657 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8658 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8659 | } else { | |
8660 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8661 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8662 | } | |
8663 | ||
8664 | /* post-change: re-export vpn routes */ | |
8665 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8666 | bgp_get_default(), bgp); | |
8667 | ||
8668 | return CMD_SUCCESS; | |
8669 | } | |
8670 | ||
8671 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) | |
8672 | { | |
8673 | if (!strcmp(dstr, "import")) { | |
8674 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8675 | } else if (!strcmp(dstr, "export")) { | |
8676 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8677 | } else if (!strcmp(dstr, "both")) { | |
8678 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8679 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8680 | } else { | |
8681 | vty_out(vty, "%% direction parse error\n"); | |
8682 | return CMD_WARNING_CONFIG_FAILED; | |
8683 | } | |
8684 | return CMD_SUCCESS; | |
8685 | } | |
8686 | ||
8687 | DEFPY (af_rt_vpn_imexport, | |
8688 | af_rt_vpn_imexport_cmd, | |
8689 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8690 | NO_STR | |
8691 | "Specify route target list\n" | |
8692 | "Specify route target list\n" | |
8693 | "Between current address-family and vpn\n" | |
8694 | "For routes leaked from vpn to current address-family: match any\n" | |
8695 | "For routes leaked from current address-family to vpn: set\n" | |
8696 | "both import: match any and export: set\n" | |
8697 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
8698 | { | |
8699 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8700 | int ret; | |
8701 | struct ecommunity *ecom = NULL; | |
8702 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8703 | vpn_policy_direction_t dir; | |
8704 | afi_t afi; | |
8705 | int idx = 0; | |
8706 | bool yes = true; | |
8707 | ||
8708 | if (argv_find(argv, argc, "no", &idx)) | |
8709 | yes = false; | |
8710 | ||
8711 | afi = vpn_policy_getafi(vty, bgp, false); | |
8712 | if (afi == AFI_MAX) | |
8713 | return CMD_WARNING_CONFIG_FAILED; | |
8714 | ||
8715 | ret = vpn_policy_getdirs(vty, direction_str, dodir); | |
8716 | if (ret != CMD_SUCCESS) | |
8717 | return ret; | |
8718 | ||
8719 | if (yes) { | |
8720 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8721 | vty_out(vty, "%% Missing RTLIST\n"); | |
8722 | return CMD_WARNING_CONFIG_FAILED; | |
8723 | } | |
8724 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); | |
8725 | if (ret != CMD_SUCCESS) { | |
8726 | return ret; | |
8727 | } | |
8728 | } | |
8729 | ||
8730 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { | |
8731 | if (!dodir[dir]) | |
8732 | continue; | |
8733 | ||
8734 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8735 | ||
8736 | if (yes) { | |
8737 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8738 | ecommunity_free( | |
8739 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8740 | bgp->vpn_policy[afi].rtlist[dir] = | |
8741 | ecommunity_dup(ecom); | |
8742 | } else { | |
8743 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8744 | ecommunity_free( | |
8745 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8746 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
8747 | } | |
8748 | ||
8749 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8750 | } | |
8751 | ||
8752 | if (ecom) | |
8753 | ecommunity_free(&ecom); | |
8754 | ||
8755 | return CMD_SUCCESS; | |
8756 | } | |
8757 | ||
8758 | ALIAS (af_rt_vpn_imexport, | |
8759 | af_no_rt_vpn_imexport_cmd, | |
8760 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
8761 | NO_STR | |
8762 | "Specify route target list\n" | |
8763 | "Specify route target list\n" | |
8764 | "Between current address-family and vpn\n" | |
8765 | "For routes leaked from vpn to current address-family\n" | |
8766 | "For routes leaked from current address-family to vpn\n" | |
8767 | "both import and export\n") | |
8768 | ||
8769 | DEFPY (af_route_map_vpn_imexport, | |
8770 | af_route_map_vpn_imexport_cmd, | |
8771 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8772 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8773 | NO_STR | |
8774 | "Specify route map\n" | |
8775 | "Between current address-family and vpn\n" | |
8776 | "For routes leaked from vpn to current address-family\n" | |
8777 | "For routes leaked from current address-family to vpn\n" | |
8778 | "name of route-map\n") | |
8779 | { | |
8780 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8781 | int ret; | |
8782 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8783 | vpn_policy_direction_t dir; | |
8784 | afi_t afi; | |
8785 | int idx = 0; | |
8786 | bool yes = true; | |
8787 | ||
8788 | if (argv_find(argv, argc, "no", &idx)) | |
8789 | yes = false; | |
8790 | ||
8791 | afi = vpn_policy_getafi(vty, bgp, false); | |
8792 | if (afi == AFI_MAX) | |
8793 | return CMD_WARNING_CONFIG_FAILED; | |
8794 | ||
8795 | ret = vpn_policy_getdirs(vty, direction_str, dodir); | |
8796 | if (ret != CMD_SUCCESS) | |
8797 | return ret; | |
8798 | ||
8799 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { | |
8800 | if (!dodir[dir]) | |
8801 | continue; | |
8802 | ||
8803 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8804 | ||
8805 | if (yes) { | |
8806 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8807 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8808 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8809 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8810 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8811 | bgp->vpn_policy[afi].rmap[dir] = | |
8812 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8813 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8814 | return CMD_SUCCESS; | |
8815 | } else { | |
8816 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8817 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8818 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8819 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8820 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8821 | } | |
8822 | ||
8823 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8824 | } | |
8825 | ||
8826 | return CMD_SUCCESS; | |
8827 | } | |
8828 | ||
8829 | ALIAS (af_route_map_vpn_imexport, | |
8830 | af_no_route_map_vpn_imexport_cmd, | |
8831 | "no route-map vpn <import|export>$direction_str", | |
8832 | NO_STR | |
8833 | "Specify route map\n" | |
8834 | "Between current address-family and vpn\n" | |
8835 | "For routes leaked from vpn to current address-family\n" | |
8836 | "For routes leaked from current address-family to vpn\n") | |
8837 | ||
8838 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, | |
8839 | "import vrf route-map RMAP$rmap_str", | |
8840 | "Import routes from another VRF\n" | |
8841 | "Vrf routes being filtered\n" | |
8842 | "Specify route map\n" | |
8843 | "name of route-map\n") | |
8844 | { | |
8845 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8846 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8847 | afi_t afi; | |
8848 | struct bgp *bgp_default; | |
8849 | ||
8850 | afi = vpn_policy_getafi(vty, bgp, true); | |
8851 | if (afi == AFI_MAX) | |
8852 | return CMD_WARNING_CONFIG_FAILED; | |
8853 | ||
8854 | bgp_default = bgp_get_default(); | |
8855 | if (!bgp_default) { | |
8856 | int32_t ret; | |
8857 | as_t as = bgp->as; | |
8858 | ||
8859 | /* Auto-create assuming the same AS */ | |
8860 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8861 | BGP_INSTANCE_TYPE_DEFAULT); | |
8862 | ||
8863 | if (ret) { | |
8864 | vty_out(vty, | |
8865 | "VRF default is not configured as a bgp instance\n"); | |
8866 | return CMD_WARNING; | |
8867 | } | |
8868 | } | |
8869 | ||
8870 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8871 | ||
8872 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8873 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8874 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8875 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8876 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8877 | bgp->vpn_policy[afi].rmap[dir] = | |
8878 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8879 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8880 | return CMD_SUCCESS; | |
8881 | ||
8882 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8883 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8884 | ||
8885 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8886 | ||
8887 | return CMD_SUCCESS; | |
8888 | } | |
8889 | ||
8890 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
8891 | "no import vrf route-map [RMAP$rmap_str]", | |
8892 | NO_STR | |
8893 | "Import routes from another VRF\n" | |
8894 | "Vrf routes being filtered\n" | |
8895 | "Specify route map\n" | |
8896 | "name of route-map\n") | |
8897 | { | |
8898 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8899 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8900 | afi_t afi; | |
8901 | ||
8902 | afi = vpn_policy_getafi(vty, bgp, true); | |
8903 | if (afi == AFI_MAX) | |
8904 | return CMD_WARNING_CONFIG_FAILED; | |
8905 | ||
8906 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8907 | ||
8908 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8909 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8910 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8911 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8912 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8913 | ||
8914 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8915 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8916 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8917 | ||
8918 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8919 | ||
8920 | return CMD_SUCCESS; | |
8921 | } | |
8922 | ||
8923 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, | |
8924 | "[no] import vrf VIEWVRFNAME$import_name", | |
8925 | NO_STR | |
8926 | "Import routes from another VRF\n" | |
8927 | "VRF to import from\n" | |
8928 | "The name of the VRF\n") | |
8929 | { | |
8930 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8931 | struct listnode *node; | |
8932 | struct bgp *vrf_bgp, *bgp_default; | |
8933 | int32_t ret = 0; | |
8934 | as_t as = bgp->as; | |
8935 | bool remove = false; | |
8936 | int32_t idx = 0; | |
8937 | char *vname; | |
8938 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
8939 | safi_t safi; | |
8940 | afi_t afi; | |
8941 | ||
8942 | if (import_name == NULL) { | |
8943 | vty_out(vty, "%% Missing import name\n"); | |
8944 | return CMD_WARNING; | |
8945 | } | |
8946 | ||
8947 | if (strcmp(import_name, "route-map") == 0) { | |
8948 | vty_out(vty, "%% Must include route-map name\n"); | |
8949 | return CMD_WARNING; | |
8950 | } | |
8951 | ||
8952 | if (argv_find(argv, argc, "no", &idx)) | |
8953 | remove = true; | |
8954 | ||
8955 | afi = vpn_policy_getafi(vty, bgp, true); | |
8956 | if (afi == AFI_MAX) | |
8957 | return CMD_WARNING_CONFIG_FAILED; | |
8958 | ||
8959 | safi = bgp_node_safi(vty); | |
8960 | ||
8961 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) | |
8962 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
8963 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
8964 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8965 | remove ? "unimport" : "import", import_name); | |
8966 | return CMD_WARNING; | |
8967 | } | |
8968 | ||
8969 | bgp_default = bgp_get_default(); | |
8970 | if (!bgp_default) { | |
8971 | /* Auto-create assuming the same AS */ | |
8972 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8973 | BGP_INSTANCE_TYPE_DEFAULT); | |
8974 | ||
8975 | if (ret) { | |
8976 | vty_out(vty, | |
8977 | "VRF default is not configured as a bgp instance\n"); | |
8978 | return CMD_WARNING; | |
8979 | } | |
8980 | } | |
8981 | ||
8982 | vrf_bgp = bgp_lookup_by_name(import_name); | |
8983 | if (!vrf_bgp) { | |
8984 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
8985 | vrf_bgp = bgp_default; | |
8986 | else | |
8987 | /* Auto-create assuming the same AS */ | |
8988 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
8989 | ||
8990 | if (ret) { | |
8991 | vty_out(vty, | |
8992 | "VRF %s is not configured as a bgp instance\n", | |
8993 | import_name); | |
8994 | return CMD_WARNING; | |
8995 | } | |
8996 | } | |
8997 | ||
8998 | if (remove) { | |
8999 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9000 | } else { | |
9001 | /* Already importing from "import_vrf"? */ | |
9002 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9003 | vname)) { | |
9004 | if (strcmp(vname, import_name) == 0) | |
9005 | return CMD_WARNING; | |
9006 | } | |
9007 | ||
9008 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9009 | } | |
9010 | ||
9011 | return CMD_SUCCESS; | |
9012 | } | |
9013 | ||
9014 | /* This command is valid only in a bgp vrf instance or the default instance */ | |
9015 | DEFPY (bgp_imexport_vpn, | |
9016 | bgp_imexport_vpn_cmd, | |
9017 | "[no] <import|export>$direction_str vpn", | |
9018 | NO_STR | |
9019 | "Import routes to this address-family\n" | |
9020 | "Export routes from this address-family\n" | |
9021 | "to/from default instance VPN RIB\n") | |
9022 | { | |
9023 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9024 | int previous_state; | |
9025 | afi_t afi; | |
9026 | safi_t safi; | |
9027 | int idx = 0; | |
9028 | bool yes = true; | |
9029 | int flag; | |
9030 | vpn_policy_direction_t dir; | |
9031 | ||
9032 | if (argv_find(argv, argc, "no", &idx)) | |
9033 | yes = false; | |
9034 | ||
9035 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9036 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9037 | ||
9038 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9039 | return CMD_WARNING_CONFIG_FAILED; | |
9040 | } | |
9041 | ||
9042 | afi = bgp_node_afi(vty); | |
9043 | safi = bgp_node_safi(vty); | |
9044 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
9045 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9046 | return CMD_WARNING_CONFIG_FAILED; | |
9047 | } | |
9048 | ||
9049 | if (!strcmp(direction_str, "import")) { | |
9050 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
9051 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
9052 | } else if (!strcmp(direction_str, "export")) { | |
9053 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
9054 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
9055 | } else { | |
9056 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9057 | return CMD_WARNING_CONFIG_FAILED; | |
9058 | } | |
9059 | ||
9060 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
9061 | ||
9062 | if (yes) { | |
9063 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9064 | if (!previous_state) { | |
9065 | /* trigger export current vrf */ | |
9066 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9067 | } | |
9068 | } else { | |
9069 | if (previous_state) { | |
9070 | /* trigger un-export current vrf */ | |
9071 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9072 | } | |
9073 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9074 | } | |
9075 | ||
9076 | hook_call(bgp_snmp_init_stats, bgp); | |
9077 | ||
9078 | return CMD_SUCCESS; | |
9079 | } | |
9080 | ||
9081 | DEFPY (af_routetarget_import, | |
9082 | af_routetarget_import_cmd, | |
9083 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", | |
9084 | NO_STR | |
9085 | "Specify route target list\n" | |
9086 | "Specify route target list\n" | |
9087 | "Specify route target list\n" | |
9088 | "Specify route target list\n" | |
9089 | "Flow-spec redirect type route target\n" | |
9090 | "Import routes to this address-family\n" | |
9091 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") | |
9092 | { | |
9093 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9094 | int ret; | |
9095 | struct ecommunity *ecom = NULL; | |
9096 | afi_t afi; | |
9097 | int idx = 0, idx_unused = 0; | |
9098 | bool yes = true; | |
9099 | bool rt6 = false; | |
9100 | ||
9101 | if (argv_find(argv, argc, "no", &idx)) | |
9102 | yes = false; | |
9103 | ||
9104 | if (argv_find(argv, argc, "rt6", &idx_unused) || | |
9105 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
9106 | rt6 = true; | |
9107 | ||
9108 | afi = vpn_policy_getafi(vty, bgp, false); | |
9109 | if (afi == AFI_MAX) | |
9110 | return CMD_WARNING_CONFIG_FAILED; | |
9111 | ||
9112 | if (rt6 && afi != AFI_IP6) | |
9113 | return CMD_WARNING_CONFIG_FAILED; | |
9114 | ||
9115 | if (yes) { | |
9116 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9117 | vty_out(vty, "%% Missing RTLIST\n"); | |
9118 | return CMD_WARNING_CONFIG_FAILED; | |
9119 | } | |
9120 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); | |
9121 | if (ret != CMD_SUCCESS) | |
9122 | return ret; | |
9123 | } | |
9124 | ||
9125 | if (yes) { | |
9126 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9127 | ecommunity_free(&bgp->vpn_policy[afi] | |
9128 | .import_redirect_rtlist); | |
9129 | bgp->vpn_policy[afi].import_redirect_rtlist = | |
9130 | ecommunity_dup(ecom); | |
9131 | } else { | |
9132 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9133 | ecommunity_free(&bgp->vpn_policy[afi] | |
9134 | .import_redirect_rtlist); | |
9135 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; | |
9136 | } | |
9137 | ||
9138 | if (ecom) | |
9139 | ecommunity_free(&ecom); | |
9140 | ||
9141 | return CMD_SUCCESS; | |
9142 | } | |
9143 | ||
9144 | DEFUN_NOSH (address_family_ipv4_safi, | |
9145 | address_family_ipv4_safi_cmd, | |
9146 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9147 | "Enter Address Family command mode\n" | |
9148 | "Address Family\n" | |
9149 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
9150 | { | |
9151 | ||
9152 | if (argc == 3) { | |
9153 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9154 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9155 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
9156 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9157 | && safi != SAFI_EVPN) { | |
9158 | vty_out(vty, | |
9159 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
9160 | return CMD_WARNING_CONFIG_FAILED; | |
9161 | } | |
9162 | vty->node = bgp_node_type(AFI_IP, safi); | |
9163 | } else | |
9164 | vty->node = BGP_IPV4_NODE; | |
9165 | ||
9166 | return CMD_SUCCESS; | |
9167 | } | |
9168 | ||
9169 | DEFUN_NOSH (address_family_ipv6_safi, | |
9170 | address_family_ipv6_safi_cmd, | |
9171 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9172 | "Enter Address Family command mode\n" | |
9173 | "Address Family\n" | |
9174 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
9175 | { | |
9176 | if (argc == 3) { | |
9177 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9178 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9179 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
9180 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9181 | && safi != SAFI_EVPN) { | |
9182 | vty_out(vty, | |
9183 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
9184 | return CMD_WARNING_CONFIG_FAILED; | |
9185 | } | |
9186 | vty->node = bgp_node_type(AFI_IP6, safi); | |
9187 | } else | |
9188 | vty->node = BGP_IPV6_NODE; | |
9189 | ||
9190 | return CMD_SUCCESS; | |
9191 | } | |
9192 | ||
9193 | #ifdef KEEP_OLD_VPN_COMMANDS | |
9194 | DEFUN_NOSH (address_family_vpnv4, | |
9195 | address_family_vpnv4_cmd, | |
9196 | "address-family vpnv4 [unicast]", | |
9197 | "Enter Address Family command mode\n" | |
9198 | "Address Family\n" | |
9199 | "Address Family modifier\n") | |
9200 | { | |
9201 | vty->node = BGP_VPNV4_NODE; | |
9202 | return CMD_SUCCESS; | |
9203 | } | |
9204 | ||
9205 | DEFUN_NOSH (address_family_vpnv6, | |
9206 | address_family_vpnv6_cmd, | |
9207 | "address-family vpnv6 [unicast]", | |
9208 | "Enter Address Family command mode\n" | |
9209 | "Address Family\n" | |
9210 | "Address Family modifier\n") | |
9211 | { | |
9212 | vty->node = BGP_VPNV6_NODE; | |
9213 | return CMD_SUCCESS; | |
9214 | } | |
9215 | #endif /* KEEP_OLD_VPN_COMMANDS */ | |
9216 | ||
9217 | DEFUN_NOSH (address_family_evpn, | |
9218 | address_family_evpn_cmd, | |
9219 | "address-family l2vpn evpn", | |
9220 | "Enter Address Family command mode\n" | |
9221 | "Address Family\n" | |
9222 | "Address Family modifier\n") | |
9223 | { | |
9224 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9225 | vty->node = BGP_EVPN_NODE; | |
9226 | return CMD_SUCCESS; | |
9227 | } | |
9228 | ||
9229 | DEFUN_NOSH (bgp_segment_routing_srv6, | |
9230 | bgp_segment_routing_srv6_cmd, | |
9231 | "segment-routing srv6", | |
9232 | "Segment-Routing configuration\n" | |
9233 | "Segment-Routing SRv6 configuration\n") | |
9234 | { | |
9235 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9236 | bgp->srv6_enabled = true; | |
9237 | vty->node = BGP_SRV6_NODE; | |
9238 | return CMD_SUCCESS; | |
9239 | } | |
9240 | ||
9241 | DEFUN (no_bgp_segment_routing_srv6, | |
9242 | no_bgp_segment_routing_srv6_cmd, | |
9243 | "no segment-routing srv6", | |
9244 | NO_STR | |
9245 | "Segment-Routing configuration\n" | |
9246 | "Segment-Routing SRv6 configuration\n") | |
9247 | { | |
9248 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9249 | ||
9250 | if (strlen(bgp->srv6_locator_name) > 0) | |
9251 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9252 | return CMD_WARNING_CONFIG_FAILED; | |
9253 | ||
9254 | bgp->srv6_enabled = false; | |
9255 | return CMD_SUCCESS; | |
9256 | } | |
9257 | ||
9258 | DEFPY (bgp_srv6_locator, | |
9259 | bgp_srv6_locator_cmd, | |
9260 | "locator NAME$name", | |
9261 | "Specify SRv6 locator\n" | |
9262 | "Specify SRv6 locator\n") | |
9263 | { | |
9264 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9265 | int ret; | |
9266 | ||
9267 | if (strlen(bgp->srv6_locator_name) > 0 | |
9268 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9269 | vty_out(vty, "srv6 locator is already configured\n"); | |
9270 | return CMD_WARNING_CONFIG_FAILED; | |
9271 | } | |
9272 | ||
9273 | snprintf(bgp->srv6_locator_name, | |
9274 | sizeof(bgp->srv6_locator_name), "%s", name); | |
9275 | ||
9276 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); | |
9277 | if (ret < 0) | |
9278 | return CMD_WARNING_CONFIG_FAILED; | |
9279 | ||
9280 | return CMD_SUCCESS; | |
9281 | } | |
9282 | ||
9283 | DEFPY (no_bgp_srv6_locator, | |
9284 | no_bgp_srv6_locator_cmd, | |
9285 | "no locator NAME$name", | |
9286 | NO_STR | |
9287 | "Specify SRv6 locator\n" | |
9288 | "Specify SRv6 locator\n") | |
9289 | { | |
9290 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9291 | ||
9292 | /* when locator isn't configured, do nothing */ | |
9293 | if (strlen(bgp->srv6_locator_name) < 1) | |
9294 | return CMD_SUCCESS; | |
9295 | ||
9296 | /* name validation */ | |
9297 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9298 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9299 | return CMD_WARNING_CONFIG_FAILED; | |
9300 | } | |
9301 | ||
9302 | /* unset locator */ | |
9303 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9304 | return CMD_WARNING_CONFIG_FAILED; | |
9305 | ||
9306 | return CMD_SUCCESS; | |
9307 | } | |
9308 | ||
9309 | DEFPY (show_bgp_srv6, | |
9310 | show_bgp_srv6_cmd, | |
9311 | "show bgp segment-routing srv6", | |
9312 | SHOW_STR | |
9313 | BGP_STR | |
9314 | "BGP Segment Routing\n" | |
9315 | "BGP Segment Routing SRv6\n") | |
9316 | { | |
9317 | struct bgp *bgp; | |
9318 | struct listnode *node; | |
9319 | struct prefix_ipv6 *chunk; | |
9320 | struct bgp_srv6_function *func; | |
9321 | struct in6_addr *tovpn4_sid; | |
9322 | struct in6_addr *tovpn6_sid; | |
9323 | char buf[256]; | |
9324 | char buf_tovpn4_sid[256]; | |
9325 | char buf_tovpn6_sid[256]; | |
9326 | ||
9327 | bgp = bgp_get_default(); | |
9328 | if (!bgp) | |
9329 | return CMD_SUCCESS; | |
9330 | ||
9331 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9332 | vty_out(vty, "locator_chunks:\n"); | |
9333 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
9334 | prefix2str(chunk, buf, sizeof(buf)); | |
9335 | vty_out(vty, "- %s\n", buf); | |
9336 | } | |
9337 | ||
9338 | vty_out(vty, "functions:\n"); | |
9339 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9340 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9341 | vty_out(vty, "- sid: %s\n", buf); | |
9342 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9343 | } | |
9344 | ||
9345 | vty_out(vty, "bgps:\n"); | |
9346 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9347 | vty_out(vty, "- name: %s\n", | |
9348 | bgp->name ? bgp->name : "default"); | |
9349 | ||
9350 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9351 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9352 | if (tovpn4_sid) | |
9353 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9354 | sizeof(buf_tovpn4_sid)); | |
9355 | if (tovpn6_sid) | |
9356 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9357 | sizeof(buf_tovpn6_sid)); | |
9358 | ||
9359 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9360 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9361 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9362 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9363 | } | |
9364 | ||
9365 | return CMD_SUCCESS; | |
9366 | } | |
9367 | ||
9368 | DEFUN_NOSH (exit_address_family, | |
9369 | exit_address_family_cmd, | |
9370 | "exit-address-family", | |
9371 | "Exit from Address Family configuration mode\n") | |
9372 | { | |
9373 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE | |
9374 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9375 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9376 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
9377 | || vty->node == BGP_EVPN_NODE | |
9378 | || vty->node == BGP_FLOWSPECV4_NODE | |
9379 | || vty->node == BGP_FLOWSPECV6_NODE) | |
9380 | vty->node = BGP_NODE; | |
9381 | return CMD_SUCCESS; | |
9382 | } | |
9383 | ||
9384 | /* Recalculate bestpath and re-advertise a prefix */ | |
9385 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, | |
9386 | const char *ip_str, afi_t afi, safi_t safi, | |
9387 | struct prefix_rd *prd) | |
9388 | { | |
9389 | int ret; | |
9390 | struct prefix match; | |
9391 | struct bgp_dest *dest; | |
9392 | struct bgp_dest *rm; | |
9393 | struct bgp *bgp; | |
9394 | struct bgp_table *table; | |
9395 | struct bgp_table *rib; | |
9396 | ||
9397 | /* BGP structure lookup. */ | |
9398 | if (view_name) { | |
9399 | bgp = bgp_lookup_by_name(view_name); | |
9400 | if (bgp == NULL) { | |
9401 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9402 | view_name); | |
9403 | return CMD_WARNING; | |
9404 | } | |
9405 | } else { | |
9406 | bgp = bgp_get_default(); | |
9407 | if (bgp == NULL) { | |
9408 | vty_out(vty, "%% No BGP process is configured\n"); | |
9409 | return CMD_WARNING; | |
9410 | } | |
9411 | } | |
9412 | ||
9413 | /* Check IP address argument. */ | |
9414 | ret = str2prefix(ip_str, &match); | |
9415 | if (!ret) { | |
9416 | vty_out(vty, "%% address is malformed\n"); | |
9417 | return CMD_WARNING; | |
9418 | } | |
9419 | ||
9420 | match.family = afi2family(afi); | |
9421 | rib = bgp->rib[afi][safi]; | |
9422 | ||
9423 | if (safi == SAFI_MPLS_VPN) { | |
9424 | for (dest = bgp_table_top(rib); dest; | |
9425 | dest = bgp_route_next(dest)) { | |
9426 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
9427 | ||
9428 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) | |
9429 | continue; | |
9430 | ||
9431 | table = bgp_dest_get_bgp_table_info(dest); | |
9432 | if (table == NULL) | |
9433 | continue; | |
9434 | ||
9435 | rm = bgp_node_match(table, &match); | |
9436 | if (rm != NULL) { | |
9437 | const struct prefix *rm_p = | |
9438 | bgp_dest_get_prefix(rm); | |
9439 | ||
9440 | if (rm_p->prefixlen == match.prefixlen) { | |
9441 | SET_FLAG(rm->flags, | |
9442 | BGP_NODE_USER_CLEAR); | |
9443 | bgp_process(bgp, rm, afi, safi); | |
9444 | } | |
9445 | bgp_dest_unlock_node(rm); | |
9446 | } | |
9447 | } | |
9448 | } else { | |
9449 | dest = bgp_node_match(rib, &match); | |
9450 | if (dest != NULL) { | |
9451 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
9452 | ||
9453 | if (dest_p->prefixlen == match.prefixlen) { | |
9454 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9455 | bgp_process(bgp, dest, afi, safi); | |
9456 | } | |
9457 | bgp_dest_unlock_node(dest); | |
9458 | } | |
9459 | } | |
9460 | ||
9461 | return CMD_SUCCESS; | |
9462 | } | |
9463 | ||
9464 | /* one clear bgp command to rule them all */ | |
9465 | DEFUN (clear_ip_bgp_all, | |
9466 | clear_ip_bgp_all_cmd, | |
9467 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]", | |
9468 | CLEAR_STR | |
9469 | IP_STR | |
9470 | BGP_STR | |
9471 | BGP_INSTANCE_HELP_STR | |
9472 | BGP_AFI_HELP_STR | |
9473 | "Address Family\n" | |
9474 | BGP_SAFI_WITH_LABEL_HELP_STR | |
9475 | "Address Family modifier\n" | |
9476 | "Clear all peers\n" | |
9477 | "BGP IPv4 neighbor to clear\n" | |
9478 | "BGP IPv6 neighbor to clear\n" | |
9479 | "BGP neighbor on interface to clear\n" | |
9480 | "Clear peers with the AS number\n" | |
9481 | "Clear all external peers\n" | |
9482 | "Clear all members of peer-group\n" | |
9483 | "BGP peer-group name\n" | |
9484 | BGP_SOFT_STR | |
9485 | BGP_SOFT_IN_STR | |
9486 | BGP_SOFT_OUT_STR | |
9487 | BGP_SOFT_IN_STR | |
9488 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
9489 | BGP_SOFT_OUT_STR | |
9490 | "Reset message statistics\n") | |
9491 | { | |
9492 | char *vrf = NULL; | |
9493 | ||
9494 | afi_t afi = AFI_UNSPEC; | |
9495 | safi_t safi = SAFI_UNSPEC; | |
9496 | enum clear_sort clr_sort = clear_peer; | |
9497 | enum bgp_clear_type clr_type; | |
9498 | char *clr_arg = NULL; | |
9499 | ||
9500 | int idx = 0; | |
9501 | ||
9502 | /* clear [ip] bgp */ | |
9503 | if (argv_find(argv, argc, "ip", &idx)) | |
9504 | afi = AFI_IP; | |
9505 | ||
9506 | /* [<vrf> VIEWVRFNAME] */ | |
9507 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9508 | vrf = argv[idx + 1]->arg; | |
9509 | idx += 2; | |
9510 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9511 | vrf = NULL; | |
9512 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9513 | /* [<view> VIEWVRFNAME] */ | |
9514 | vrf = argv[idx + 1]->arg; | |
9515 | idx += 2; | |
9516 | } | |
9517 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
9518 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9519 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9520 | ||
9521 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ | |
9522 | if (argv_find(argv, argc, "*", &idx)) { | |
9523 | clr_sort = clear_all; | |
9524 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9525 | clr_sort = clear_peer; | |
9526 | clr_arg = argv[idx]->arg; | |
9527 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9528 | clr_sort = clear_peer; | |
9529 | clr_arg = argv[idx]->arg; | |
9530 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9531 | clr_sort = clear_group; | |
9532 | idx++; | |
9533 | clr_arg = argv[idx]->arg; | |
9534 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { | |
9535 | clr_sort = clear_peer; | |
9536 | clr_arg = argv[idx]->arg; | |
9537 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
9538 | clr_sort = clear_peer; | |
9539 | clr_arg = argv[idx]->arg; | |
9540 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
9541 | clr_sort = clear_as; | |
9542 | clr_arg = argv[idx]->arg; | |
9543 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9544 | clr_sort = clear_external; | |
9545 | } | |
9546 | ||
9547 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ | |
9548 | if (argv_find(argv, argc, "soft", &idx)) { | |
9549 | if (argv_find(argv, argc, "in", &idx) | |
9550 | || argv_find(argv, argc, "out", &idx)) | |
9551 | clr_type = strmatch(argv[idx]->text, "in") | |
9552 | ? BGP_CLEAR_SOFT_IN | |
9553 | : BGP_CLEAR_SOFT_OUT; | |
9554 | else | |
9555 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9556 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9557 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9558 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9559 | : BGP_CLEAR_SOFT_IN; | |
9560 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9561 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9562 | } else if (argv_find(argv, argc, "message-stats", &idx)) { | |
9563 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
9564 | } else | |
9565 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9566 | ||
9567 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
9568 | } | |
9569 | ||
9570 | DEFUN (clear_ip_bgp_prefix, | |
9571 | clear_ip_bgp_prefix_cmd, | |
9572 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", | |
9573 | CLEAR_STR | |
9574 | IP_STR | |
9575 | BGP_STR | |
9576 | BGP_INSTANCE_HELP_STR | |
9577 | "Clear bestpath and re-advertise\n" | |
9578 | "IPv4 prefix\n") | |
9579 | { | |
9580 | char *vrf = NULL; | |
9581 | char *prefix = NULL; | |
9582 | ||
9583 | int idx = 0; | |
9584 | ||
9585 | /* [<view|vrf> VIEWVRFNAME] */ | |
9586 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9587 | vrf = argv[idx + 1]->arg; | |
9588 | idx += 2; | |
9589 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9590 | vrf = NULL; | |
9591 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9592 | /* [<view> VIEWVRFNAME] */ | |
9593 | vrf = argv[idx + 1]->arg; | |
9594 | idx += 2; | |
9595 | } | |
9596 | ||
9597 | prefix = argv[argc - 1]->arg; | |
9598 | ||
9599 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); | |
9600 | } | |
9601 | ||
9602 | DEFUN (clear_bgp_ipv6_safi_prefix, | |
9603 | clear_bgp_ipv6_safi_prefix_cmd, | |
9604 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", | |
9605 | CLEAR_STR | |
9606 | IP_STR | |
9607 | BGP_STR | |
9608 | "Address Family\n" | |
9609 | BGP_SAFI_HELP_STR | |
9610 | "Clear bestpath and re-advertise\n" | |
9611 | "IPv6 prefix\n") | |
9612 | { | |
9613 | int idx_safi = 0; | |
9614 | int idx_ipv6_prefix = 0; | |
9615 | safi_t safi = SAFI_UNICAST; | |
9616 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9617 | argv[idx_ipv6_prefix]->arg : NULL; | |
9618 | ||
9619 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
9620 | return bgp_clear_prefix( | |
9621 | vty, NULL, prefix, AFI_IP6, | |
9622 | safi, NULL); | |
9623 | } | |
9624 | ||
9625 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, | |
9626 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
9627 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", | |
9628 | CLEAR_STR | |
9629 | IP_STR | |
9630 | BGP_STR | |
9631 | BGP_INSTANCE_HELP_STR | |
9632 | "Address Family\n" | |
9633 | BGP_SAFI_HELP_STR | |
9634 | "Clear bestpath and re-advertise\n" | |
9635 | "IPv6 prefix\n") | |
9636 | { | |
9637 | int idx_safi = 0; | |
9638 | int idx_vrfview = 0; | |
9639 | int idx_ipv6_prefix = 0; | |
9640 | safi_t safi = SAFI_UNICAST; | |
9641 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9642 | argv[idx_ipv6_prefix]->arg : NULL; | |
9643 | char *vrfview = NULL; | |
9644 | ||
9645 | /* [<view|vrf> VIEWVRFNAME] */ | |
9646 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9647 | vrfview = argv[idx_vrfview + 1]->arg; | |
9648 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9649 | vrfview = NULL; | |
9650 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9651 | /* [<view> VIEWVRFNAME] */ | |
9652 | vrfview = argv[idx_vrfview + 1]->arg; | |
9653 | } | |
9654 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
9655 | ||
9656 | return bgp_clear_prefix( | |
9657 | vty, vrfview, prefix, | |
9658 | AFI_IP6, safi, NULL); | |
9659 | } | |
9660 | ||
9661 | DEFUN (show_bgp_views, | |
9662 | show_bgp_views_cmd, | |
9663 | "show [ip] bgp views", | |
9664 | SHOW_STR | |
9665 | IP_STR | |
9666 | BGP_STR | |
9667 | "Show the defined BGP views\n") | |
9668 | { | |
9669 | struct list *inst = bm->bgp; | |
9670 | struct listnode *node; | |
9671 | struct bgp *bgp; | |
9672 | ||
9673 | vty_out(vty, "Defined BGP views:\n"); | |
9674 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9675 | /* Skip VRFs. */ | |
9676 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9677 | continue; | |
9678 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9679 | bgp->as); | |
9680 | } | |
9681 | ||
9682 | return CMD_SUCCESS; | |
9683 | } | |
9684 | ||
9685 | DEFUN (show_bgp_vrfs, | |
9686 | show_bgp_vrfs_cmd, | |
9687 | "show [ip] bgp vrfs [json]", | |
9688 | SHOW_STR | |
9689 | IP_STR | |
9690 | BGP_STR | |
9691 | "Show BGP VRFs\n" | |
9692 | JSON_STR) | |
9693 | { | |
9694 | char buf[ETHER_ADDR_STRLEN]; | |
9695 | struct list *inst = bm->bgp; | |
9696 | struct listnode *node; | |
9697 | struct bgp *bgp; | |
9698 | bool uj = use_json(argc, argv); | |
9699 | json_object *json = NULL; | |
9700 | json_object *json_vrfs = NULL; | |
9701 | int count = 0; | |
9702 | ||
9703 | if (uj) { | |
9704 | json = json_object_new_object(); | |
9705 | json_vrfs = json_object_new_object(); | |
9706 | } | |
9707 | ||
9708 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9709 | const char *name, *type; | |
9710 | struct peer *peer; | |
9711 | struct listnode *node2, *nnode2; | |
9712 | int peers_cfg, peers_estb; | |
9713 | json_object *json_vrf = NULL; | |
9714 | ||
9715 | /* Skip Views. */ | |
9716 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9717 | continue; | |
9718 | ||
9719 | count++; | |
9720 | if (!uj && count == 1) { | |
9721 | vty_out(vty, | |
9722 | "%4s %-5s %-16s %9s %10s %-37s\n", | |
9723 | "Type", "Id", "routerId", "#PeersCfg", | |
9724 | "#PeersEstb", "Name"); | |
9725 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9726 | "L3-VNI", "RouterMAC", "Interface"); | |
9727 | } | |
9728 | ||
9729 | peers_cfg = peers_estb = 0; | |
9730 | if (uj) | |
9731 | json_vrf = json_object_new_object(); | |
9732 | ||
9733 | ||
9734 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { | |
9735 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9736 | continue; | |
9737 | peers_cfg++; | |
9738 | if (peer_established(peer)) | |
9739 | peers_estb++; | |
9740 | } | |
9741 | ||
9742 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
9743 | name = VRF_DEFAULT_NAME; | |
9744 | type = "DFLT"; | |
9745 | } else { | |
9746 | name = bgp->name; | |
9747 | type = "VRF"; | |
9748 | } | |
9749 | ||
9750 | ||
9751 | if (uj) { | |
9752 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
9753 | ? -1 | |
9754 | : (int64_t)bgp->vrf_id; | |
9755 | char buf[BUFSIZ] = {0}; | |
9756 | ||
9757 | json_object_string_add(json_vrf, "type", type); | |
9758 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9759 | json_object_string_addf(json_vrf, "routerId", "%pI4", | |
9760 | &bgp->router_id); | |
9761 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
9762 | peers_cfg); | |
9763 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9764 | peers_estb); | |
9765 | ||
9766 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); | |
9767 | json_object_string_add( | |
9768 | json_vrf, "rmac", | |
9769 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
9770 | json_object_string_add(json_vrf, "interface", | |
9771 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9772 | bgp->vrf_id)); | |
9773 | json_object_object_add(json_vrfs, name, json_vrf); | |
9774 | } else { | |
9775 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", | |
9776 | type, | |
9777 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9778 | : (int)bgp->vrf_id, | |
9779 | &bgp->router_id, peers_cfg, peers_estb, name); | |
9780 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
9781 | bgp->l3vni, | |
9782 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9783 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9784 | bgp->vrf_id)); | |
9785 | } | |
9786 | } | |
9787 | ||
9788 | if (uj) { | |
9789 | json_object_object_add(json, "vrfs", json_vrfs); | |
9790 | ||
9791 | json_object_int_add(json, "totalVrfs", count); | |
9792 | ||
9793 | vty_json(vty, json); | |
9794 | } else { | |
9795 | if (count) | |
9796 | vty_out(vty, | |
9797 | "\nTotal number of VRFs (including default): %d\n", | |
9798 | count); | |
9799 | } | |
9800 | ||
9801 | return CMD_SUCCESS; | |
9802 | } | |
9803 | ||
9804 | DEFUN (show_bgp_mac_hash, | |
9805 | show_bgp_mac_hash_cmd, | |
9806 | "show bgp mac hash", | |
9807 | SHOW_STR | |
9808 | BGP_STR | |
9809 | "Mac Address\n" | |
9810 | "Mac Address database\n") | |
9811 | { | |
9812 | bgp_mac_dump_table(vty); | |
9813 | ||
9814 | return CMD_SUCCESS; | |
9815 | } | |
9816 | ||
9817 | static void show_tip_entry(struct hash_bucket *bucket, void *args) | |
9818 | { | |
9819 | struct vty *vty = (struct vty *)args; | |
9820 | struct tip_addr *tip = (struct tip_addr *)bucket->data; | |
9821 | ||
9822 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); | |
9823 | } | |
9824 | ||
9825 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9826 | { | |
9827 | vty_out(vty, "self nexthop database:\n"); | |
9828 | bgp_nexthop_show_address_hash(vty, bgp); | |
9829 | ||
9830 | vty_out(vty, "Tunnel-ip database:\n"); | |
9831 | hash_iterate(bgp->tip_hash, | |
9832 | (void (*)(struct hash_bucket *, void *))show_tip_entry, | |
9833 | vty); | |
9834 | } | |
9835 | ||
9836 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, | |
9837 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9838 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
9839 | "martian next-hops\n" | |
9840 | "martian next-hop database\n") | |
9841 | { | |
9842 | struct bgp *bgp = NULL; | |
9843 | int idx = 0; | |
9844 | char *name = NULL; | |
9845 | ||
9846 | /* [<vrf> VIEWVRFNAME] */ | |
9847 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9848 | name = argv[idx + 1]->arg; | |
9849 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9850 | name = NULL; | |
9851 | } else if (argv_find(argv, argc, "view", &idx)) | |
9852 | /* [<view> VIEWVRFNAME] */ | |
9853 | name = argv[idx + 1]->arg; | |
9854 | if (name) | |
9855 | bgp = bgp_lookup_by_name(name); | |
9856 | else | |
9857 | bgp = bgp_get_default(); | |
9858 | ||
9859 | if (!bgp) { | |
9860 | vty_out(vty, "%% No BGP process is configured\n"); | |
9861 | return CMD_WARNING; | |
9862 | } | |
9863 | bgp_show_martian_nexthops(vty, bgp); | |
9864 | ||
9865 | return CMD_SUCCESS; | |
9866 | } | |
9867 | ||
9868 | DEFUN (show_bgp_memory, | |
9869 | show_bgp_memory_cmd, | |
9870 | "show [ip] bgp memory", | |
9871 | SHOW_STR | |
9872 | IP_STR | |
9873 | BGP_STR | |
9874 | "Global BGP memory statistics\n") | |
9875 | { | |
9876 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
9877 | unsigned long count; | |
9878 | ||
9879 | /* RIB related usage stats */ | |
9880 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9881 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9882 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9883 | count * sizeof(struct bgp_dest))); | |
9884 | ||
9885 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9886 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9887 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9888 | count * sizeof(struct bgp_path_info))); | |
9889 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
9890 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9891 | count, | |
9892 | mtype_memstr( | |
9893 | memstrbuf, sizeof(memstrbuf), | |
9894 | count * sizeof(struct bgp_path_info_extra))); | |
9895 | ||
9896 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9897 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9898 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9899 | count * sizeof(struct bgp_static))); | |
9900 | ||
9901 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9902 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9903 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9904 | count * sizeof(struct bpacket))); | |
9905 | ||
9906 | /* Adj-In/Out */ | |
9907 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9908 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9909 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9910 | count * sizeof(struct bgp_adj_in))); | |
9911 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9912 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9913 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9914 | count * sizeof(struct bgp_adj_out))); | |
9915 | ||
9916 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9917 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9918 | count, | |
9919 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9920 | count * sizeof(struct bgp_nexthop_cache))); | |
9921 | ||
9922 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9923 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9924 | count, | |
9925 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9926 | count * sizeof(struct bgp_damp_info))); | |
9927 | ||
9928 | /* Attributes */ | |
9929 | count = attr_count(); | |
9930 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9931 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9932 | count * sizeof(struct attr))); | |
9933 | ||
9934 | if ((count = attr_unknown_count())) | |
9935 | vty_out(vty, "%ld unknown attributes\n", count); | |
9936 | ||
9937 | /* AS_PATH attributes */ | |
9938 | count = aspath_count(); | |
9939 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9940 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9941 | count * sizeof(struct aspath))); | |
9942 | ||
9943 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9944 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9945 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9946 | count * sizeof(struct assegment))); | |
9947 | ||
9948 | /* Other attributes */ | |
9949 | if ((count = community_count())) | |
9950 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9951 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9952 | count * sizeof(struct community))); | |
9953 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) | |
9954 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9955 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9956 | count * sizeof(struct ecommunity))); | |
9957 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) | |
9958 | vty_out(vty, | |
9959 | "%ld BGP large-community entries, using %s of memory\n", | |
9960 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9961 | count * sizeof(struct lcommunity))); | |
9962 | ||
9963 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9964 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9965 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9966 | count * sizeof(struct cluster_list))); | |
9967 | ||
9968 | /* Peer related usage */ | |
9969 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9970 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9971 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9972 | count * sizeof(struct peer))); | |
9973 | ||
9974 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9975 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9976 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9977 | count * sizeof(struct peer_group))); | |
9978 | ||
9979 | /* Other */ | |
9980 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
9981 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
9982 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9983 | count * sizeof(regex_t))); | |
9984 | return CMD_SUCCESS; | |
9985 | } | |
9986 | ||
9987 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) | |
9988 | { | |
9989 | json_object *bestpath = json_object_new_object(); | |
9990 | ||
9991 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) | |
9992 | json_object_string_add(bestpath, "asPath", "ignore"); | |
9993 | ||
9994 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) | |
9995 | json_object_string_add(bestpath, "asPath", "confed"); | |
9996 | ||
9997 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
9998 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
9999 | json_object_string_add(bestpath, "multiPathRelax", | |
10000 | "as-set"); | |
10001 | else | |
10002 | json_object_string_add(bestpath, "multiPathRelax", | |
10003 | "true"); | |
10004 | } else | |
10005 | json_object_string_add(bestpath, "multiPathRelax", "false"); | |
10006 | ||
10007 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) | |
10008 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10009 | ||
10010 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) | |
10011 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
10012 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) | |
10013 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10014 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
10015 | json_object_string_add(bestpath, "med", "confed"); | |
10016 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) | |
10017 | json_object_string_add(bestpath, "med", | |
10018 | "missing-as-worst"); | |
10019 | else | |
10020 | json_object_string_add(bestpath, "med", "true"); | |
10021 | } | |
10022 | ||
10023 | json_object_object_add(json, "bestPath", bestpath); | |
10024 | } | |
10025 | ||
10026 | /* Print the error code/subcode for why the peer is down */ | |
10027 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10028 | json_object *json_peer, bool use_json) | |
10029 | { | |
10030 | const char *code_str; | |
10031 | const char *subcode_str; | |
10032 | ||
10033 | if (use_json) { | |
10034 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10035 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10036 | char errorcodesubcode_hexstr[5]; | |
10037 | char errorcodesubcode_str[256]; | |
10038 | ||
10039 | code_str = bgp_notify_code_str(peer->notify.code); | |
10040 | subcode_str = bgp_notify_subcode_str( | |
10041 | peer->notify.code, | |
10042 | peer->notify.subcode); | |
10043 | ||
10044 | snprintf(errorcodesubcode_hexstr, | |
10045 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10046 | peer->notify.code, peer->notify.subcode); | |
10047 | json_object_string_add(json_peer, | |
10048 | "lastErrorCodeSubcode", | |
10049 | errorcodesubcode_hexstr); | |
10050 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10051 | code_str, subcode_str); | |
10052 | json_object_string_add(json_peer, | |
10053 | "lastNotificationReason", | |
10054 | errorcodesubcode_str); | |
10055 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10056 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10057 | && (peer->notify.subcode | |
10058 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10059 | || peer->notify.subcode | |
10060 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10061 | && peer->notify.length) { | |
10062 | char msgbuf[1024]; | |
10063 | const char *msg_str; | |
10064 | ||
10065 | msg_str = bgp_notify_admin_message( | |
10066 | msgbuf, sizeof(msgbuf), | |
10067 | (uint8_t *)peer->notify.data, | |
10068 | peer->notify.length); | |
10069 | if (msg_str) | |
10070 | json_object_string_add( | |
10071 | json_peer, | |
10072 | "lastShutdownDescription", | |
10073 | msg_str); | |
10074 | } | |
10075 | ||
10076 | } | |
10077 | json_object_string_add(json_peer, "lastResetDueTo", | |
10078 | peer_down_str[(int)peer->last_reset]); | |
10079 | json_object_int_add(json_peer, "lastResetCode", | |
10080 | peer->last_reset); | |
10081 | } else { | |
10082 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10083 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10084 | code_str = bgp_notify_code_str(peer->notify.code); | |
10085 | subcode_str = | |
10086 | bgp_notify_subcode_str(peer->notify.code, | |
10087 | peer->notify.subcode); | |
10088 | vty_out(vty, " Notification %s (%s%s)\n", | |
10089 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10090 | ? "sent" | |
10091 | : "received", | |
10092 | code_str, subcode_str); | |
10093 | } else { | |
10094 | vty_out(vty, " %s\n", | |
10095 | peer_down_str[(int)peer->last_reset]); | |
10096 | } | |
10097 | } | |
10098 | } | |
10099 | ||
10100 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10101 | safi_t safi) | |
10102 | { | |
10103 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); | |
10104 | } | |
10105 | ||
10106 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10107 | struct peer *peer, json_object *json_peer, | |
10108 | int max_neighbor_width, bool use_json) | |
10109 | { | |
10110 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10111 | int len; | |
10112 | ||
10113 | if (use_json) { | |
10114 | if (peer_dynamic_neighbor(peer)) | |
10115 | json_object_boolean_true_add(json_peer, | |
10116 | "dynamicPeer"); | |
10117 | if (peer->hostname) | |
10118 | json_object_string_add(json_peer, "hostname", | |
10119 | peer->hostname); | |
10120 | ||
10121 | if (peer->domainname) | |
10122 | json_object_string_add(json_peer, "domainname", | |
10123 | peer->domainname); | |
10124 | json_object_int_add(json_peer, "connectionsEstablished", | |
10125 | peer->established); | |
10126 | json_object_int_add(json_peer, "connectionsDropped", | |
10127 | peer->dropped); | |
10128 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10129 | use_json, json_peer); | |
10130 | if (peer_established(peer)) | |
10131 | json_object_string_add(json_peer, "lastResetDueTo", | |
10132 | "AFI/SAFI Not Negotiated"); | |
10133 | else | |
10134 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10135 | } else { | |
10136 | dn_flag[1] = '\0'; | |
10137 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10138 | if (peer->hostname | |
10139 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) | |
10140 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
10141 | peer->hostname, peer->host); | |
10142 | else | |
10143 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10144 | ||
10145 | /* pad the neighbor column with spaces */ | |
10146 | if (len < max_neighbor_width) | |
10147 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10148 | " "); | |
10149 | vty_out(vty, "%7d %7d %9s", peer->established, | |
10150 | peer->dropped, | |
10151 | peer_uptime(peer->uptime, timebuf, | |
10152 | BGP_UPTIME_LEN, 0, NULL)); | |
10153 | if (peer_established(peer)) | |
10154 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
10155 | else | |
10156 | bgp_show_peer_reset(vty, peer, NULL, | |
10157 | false); | |
10158 | } | |
10159 | } | |
10160 | ||
10161 | /* Strip peer's description to the given size. */ | |
10162 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) | |
10163 | { | |
10164 | static char stripped[BUFSIZ]; | |
10165 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; | |
10166 | ||
10167 | strlcpy(stripped, desc, len + 1); | |
10168 | ||
10169 | return stripped; | |
10170 | } | |
10171 | ||
10172 | /* Determine whether var peer should be filtered out of the summary. */ | |
10173 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10174 | struct peer *fpeer, int as_type, | |
10175 | as_t as) | |
10176 | { | |
10177 | ||
10178 | /* filter neighbor XXXX */ | |
10179 | if (fpeer && fpeer != peer) | |
10180 | return true; | |
10181 | ||
10182 | /* filter remote-as (internal|external) */ | |
10183 | if (as_type != AS_UNSPECIFIED) { | |
10184 | if (peer->as_type == AS_SPECIFIED) { | |
10185 | if (as_type == AS_INTERNAL) { | |
10186 | if (peer->as != peer->local_as) | |
10187 | return true; | |
10188 | } else if (peer->as == peer->local_as) | |
10189 | return true; | |
10190 | } else if (as_type != peer->as_type) | |
10191 | return true; | |
10192 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10193 | return true; | |
10194 | ||
10195 | return false; | |
10196 | } | |
10197 | ||
10198 | /* Show BGP peer's summary information. | |
10199 | * | |
10200 | * Peer's description is stripped according to if `wide` option is given | |
10201 | * or not. | |
10202 | * | |
10203 | * When adding new columns to `show bgp summary` output, please make | |
10204 | * sure `Desc` is the lastest column to show because it can contain | |
10205 | * whitespaces and the whole output will be tricky. | |
10206 | */ | |
10207 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, | |
10208 | struct peer *fpeer, int as_type, as_t as, | |
10209 | uint16_t show_flags) | |
10210 | { | |
10211 | struct peer *peer; | |
10212 | struct listnode *node, *nnode; | |
10213 | unsigned int count = 0, dn_count = 0; | |
10214 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10215 | char neighbor_buf[VTY_BUFSIZ]; | |
10216 | int neighbor_col_default_width = 16; | |
10217 | int len, failed_count = 0; | |
10218 | unsigned int filtered_count = 0; | |
10219 | int max_neighbor_width = 0; | |
10220 | int pfx_rcd_safi; | |
10221 | json_object *json = NULL; | |
10222 | json_object *json_peer = NULL; | |
10223 | json_object *json_peers = NULL; | |
10224 | struct peer_af *paf; | |
10225 | struct bgp_filter *filter; | |
10226 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
10227 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10228 | bool show_established = | |
10229 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10230 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
10231 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
10232 | ||
10233 | /* labeled-unicast routes are installed in the unicast table so in order | |
10234 | * to | |
10235 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10236 | */ | |
10237 | ||
10238 | if (safi == SAFI_LABELED_UNICAST) | |
10239 | pfx_rcd_safi = SAFI_UNICAST; | |
10240 | else | |
10241 | pfx_rcd_safi = safi; | |
10242 | ||
10243 | if (use_json) { | |
10244 | json = json_object_new_object(); | |
10245 | json_peers = json_object_new_object(); | |
10246 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10247 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, | |
10248 | as_type, as)) { | |
10249 | filtered_count++; | |
10250 | count++; | |
10251 | continue; | |
10252 | } | |
10253 | ||
10254 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10255 | continue; | |
10256 | ||
10257 | if (peer->afc[afi][safi]) { | |
10258 | /* See if we have at least a single failed peer */ | |
10259 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10260 | failed_count++; | |
10261 | count++; | |
10262 | } | |
10263 | if (peer_dynamic_neighbor(peer)) | |
10264 | dn_count++; | |
10265 | } | |
10266 | ||
10267 | } else { | |
10268 | /* Loop over all neighbors that will be displayed to determine | |
10269 | * how many | |
10270 | * characters are needed for the Neighbor column | |
10271 | */ | |
10272 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10273 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, | |
10274 | as_type, as)) { | |
10275 | filtered_count++; | |
10276 | count++; | |
10277 | continue; | |
10278 | } | |
10279 | ||
10280 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10281 | continue; | |
10282 | ||
10283 | if (peer->afc[afi][safi]) { | |
10284 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10285 | if (peer_dynamic_neighbor(peer)) | |
10286 | dn_flag[0] = '*'; | |
10287 | ||
10288 | if (peer->hostname | |
10289 | && CHECK_FLAG(bgp->flags, | |
10290 | BGP_FLAG_SHOW_HOSTNAME)) | |
10291 | snprintf(neighbor_buf, | |
10292 | sizeof(neighbor_buf), | |
10293 | "%s%s(%s) ", dn_flag, | |
10294 | peer->hostname, peer->host); | |
10295 | else | |
10296 | snprintf(neighbor_buf, | |
10297 | sizeof(neighbor_buf), "%s%s ", | |
10298 | dn_flag, peer->host); | |
10299 | ||
10300 | len = strlen(neighbor_buf); | |
10301 | ||
10302 | if (len > max_neighbor_width) | |
10303 | max_neighbor_width = len; | |
10304 | ||
10305 | /* See if we have at least a single failed peer */ | |
10306 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10307 | failed_count++; | |
10308 | count++; | |
10309 | } | |
10310 | } | |
10311 | ||
10312 | /* Originally we displayed the Neighbor column as 16 | |
10313 | * characters wide so make that the default | |
10314 | */ | |
10315 | if (max_neighbor_width < neighbor_col_default_width) | |
10316 | max_neighbor_width = neighbor_col_default_width; | |
10317 | } | |
10318 | ||
10319 | if (show_failed && !failed_count) { | |
10320 | if (use_json) { | |
10321 | json_object_int_add(json, "failedPeersCount", 0); | |
10322 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10323 | json_object_int_add(json, "totalPeers", count); | |
10324 | ||
10325 | vty_json(vty, json); | |
10326 | } else { | |
10327 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
10328 | } | |
10329 | return CMD_SUCCESS; | |
10330 | } | |
10331 | ||
10332 | count = 0; /* Reset the value as its used again */ | |
10333 | filtered_count = 0; | |
10334 | dn_count = 0; | |
10335 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10336 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10337 | continue; | |
10338 | ||
10339 | if (!peer->afc[afi][safi]) | |
10340 | continue; | |
10341 | ||
10342 | if (!count) { | |
10343 | unsigned long ents; | |
10344 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
10345 | int64_t vrf_id_ui; | |
10346 | ||
10347 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
10348 | ? -1 | |
10349 | : (int64_t)bgp->vrf_id; | |
10350 | ||
10351 | /* Usage summary and header */ | |
10352 | if (use_json) { | |
10353 | json_object_string_addf(json, "routerId", | |
10354 | "%pI4", | |
10355 | &bgp->router_id); | |
10356 | json_object_int_add(json, "as", bgp->as); | |
10357 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
10358 | json_object_string_add( | |
10359 | json, "vrfName", | |
10360 | (bgp->inst_type | |
10361 | == BGP_INSTANCE_TYPE_DEFAULT) | |
10362 | ? VRF_DEFAULT_NAME | |
10363 | : bgp->name); | |
10364 | } else { | |
10365 | vty_out(vty, | |
10366 | "BGP router identifier %pI4, local AS number %u vrf-id %d", | |
10367 | &bgp->router_id, bgp->as, | |
10368 | bgp->vrf_id == VRF_UNKNOWN | |
10369 | ? -1 | |
10370 | : (int)bgp->vrf_id); | |
10371 | vty_out(vty, "\n"); | |
10372 | } | |
10373 | ||
10374 | if (bgp_update_delay_configured(bgp)) { | |
10375 | if (use_json) { | |
10376 | json_object_int_add( | |
10377 | json, "updateDelayLimit", | |
10378 | bgp->v_update_delay); | |
10379 | ||
10380 | if (bgp->v_update_delay | |
10381 | != bgp->v_establish_wait) | |
10382 | json_object_int_add( | |
10383 | json, | |
10384 | "updateDelayEstablishWait", | |
10385 | bgp->v_establish_wait); | |
10386 | ||
10387 | if (bgp_update_delay_active(bgp)) { | |
10388 | json_object_string_add( | |
10389 | json, | |
10390 | "updateDelayFirstNeighbor", | |
10391 | bgp->update_delay_begin_time); | |
10392 | json_object_boolean_true_add( | |
10393 | json, | |
10394 | "updateDelayInProgress"); | |
10395 | } else { | |
10396 | if (bgp->update_delay_over) { | |
10397 | json_object_string_add( | |
10398 | json, | |
10399 | "updateDelayFirstNeighbor", | |
10400 | bgp->update_delay_begin_time); | |
10401 | json_object_string_add( | |
10402 | json, | |
10403 | "updateDelayBestpathResumed", | |
10404 | bgp->update_delay_end_time); | |
10405 | json_object_string_add( | |
10406 | json, | |
10407 | "updateDelayZebraUpdateResume", | |
10408 | bgp->update_delay_zebra_resume_time); | |
10409 | json_object_string_add( | |
10410 | json, | |
10411 | "updateDelayPeerUpdateResume", | |
10412 | bgp->update_delay_peers_resume_time); | |
10413 | } | |
10414 | } | |
10415 | } else { | |
10416 | vty_out(vty, | |
10417 | "Read-only mode update-delay limit: %d seconds\n", | |
10418 | bgp->v_update_delay); | |
10419 | if (bgp->v_update_delay | |
10420 | != bgp->v_establish_wait) | |
10421 | vty_out(vty, | |
10422 | " Establish wait: %d seconds\n", | |
10423 | bgp->v_establish_wait); | |
10424 | ||
10425 | if (bgp_update_delay_active(bgp)) { | |
10426 | vty_out(vty, | |
10427 | " First neighbor established: %s\n", | |
10428 | bgp->update_delay_begin_time); | |
10429 | vty_out(vty, | |
10430 | " Delay in progress\n"); | |
10431 | } else { | |
10432 | if (bgp->update_delay_over) { | |
10433 | vty_out(vty, | |
10434 | " First neighbor established: %s\n", | |
10435 | bgp->update_delay_begin_time); | |
10436 | vty_out(vty, | |
10437 | " Best-paths resumed: %s\n", | |
10438 | bgp->update_delay_end_time); | |
10439 | vty_out(vty, | |
10440 | " zebra update resumed: %s\n", | |
10441 | bgp->update_delay_zebra_resume_time); | |
10442 | vty_out(vty, | |
10443 | " peers update resumed: %s\n", | |
10444 | bgp->update_delay_peers_resume_time); | |
10445 | } | |
10446 | } | |
10447 | } | |
10448 | } | |
10449 | ||
10450 | if (use_json) { | |
10451 | if (bgp_maxmed_onstartup_configured(bgp) | |
10452 | && bgp->maxmed_active) | |
10453 | json_object_boolean_true_add( | |
10454 | json, "maxMedOnStartup"); | |
10455 | if (bgp->v_maxmed_admin) | |
10456 | json_object_boolean_true_add( | |
10457 | json, "maxMedAdministrative"); | |
10458 | ||
10459 | json_object_int_add( | |
10460 | json, "tableVersion", | |
10461 | bgp_table_version(bgp->rib[afi][safi])); | |
10462 | ||
10463 | ents = bgp_table_count(bgp->rib[afi][safi]); | |
10464 | json_object_int_add(json, "ribCount", ents); | |
10465 | json_object_int_add( | |
10466 | json, "ribMemory", | |
10467 | ents * sizeof(struct bgp_dest)); | |
10468 | ||
10469 | ents = bgp->af_peer_count[afi][safi]; | |
10470 | json_object_int_add(json, "peerCount", ents); | |
10471 | json_object_int_add(json, "peerMemory", | |
10472 | ents * sizeof(struct peer)); | |
10473 | ||
10474 | if ((ents = listcount(bgp->group))) { | |
10475 | json_object_int_add( | |
10476 | json, "peerGroupCount", ents); | |
10477 | json_object_int_add( | |
10478 | json, "peerGroupMemory", | |
10479 | ents * sizeof(struct | |
10480 | peer_group)); | |
10481 | } | |
10482 | ||
10483 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10484 | BGP_CONFIG_DAMPENING)) | |
10485 | json_object_boolean_true_add( | |
10486 | json, "dampeningEnabled"); | |
10487 | } else { | |
10488 | if (!show_terse) { | |
10489 | if (bgp_maxmed_onstartup_configured(bgp) | |
10490 | && bgp->maxmed_active) | |
10491 | vty_out(vty, | |
10492 | "Max-med on-startup active\n"); | |
10493 | if (bgp->v_maxmed_admin) | |
10494 | vty_out(vty, | |
10495 | "Max-med administrative active\n"); | |
10496 | ||
10497 | vty_out(vty, | |
10498 | "BGP table version %" PRIu64 | |
10499 | "\n", | |
10500 | bgp_table_version( | |
10501 | bgp->rib[afi][safi])); | |
10502 | ||
10503 | ents = bgp_table_count( | |
10504 | bgp->rib[afi][safi]); | |
10505 | vty_out(vty, | |
10506 | "RIB entries %ld, using %s of memory\n", | |
10507 | ents, | |
10508 | mtype_memstr( | |
10509 | memstrbuf, | |
10510 | sizeof(memstrbuf), | |
10511 | ents | |
10512 | * sizeof( | |
10513 | struct | |
10514 | bgp_dest))); | |
10515 | ||
10516 | /* Peer related usage */ | |
10517 | ents = bgp->af_peer_count[afi][safi]; | |
10518 | vty_out(vty, | |
10519 | "Peers %ld, using %s of memory\n", | |
10520 | ents, | |
10521 | mtype_memstr( | |
10522 | memstrbuf, | |
10523 | sizeof(memstrbuf), | |
10524 | ents | |
10525 | * sizeof( | |
10526 | struct | |
10527 | peer))); | |
10528 | ||
10529 | if ((ents = listcount(bgp->group))) | |
10530 | vty_out(vty, | |
10531 | "Peer groups %ld, using %s of memory\n", | |
10532 | ents, | |
10533 | mtype_memstr( | |
10534 | memstrbuf, | |
10535 | sizeof(memstrbuf), | |
10536 | ents | |
10537 | * sizeof( | |
10538 | struct | |
10539 | peer_group))); | |
10540 | ||
10541 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10542 | BGP_CONFIG_DAMPENING)) | |
10543 | vty_out(vty, | |
10544 | "Dampening enabled.\n"); | |
10545 | } | |
10546 | if (show_failed) { | |
10547 | vty_out(vty, "\n"); | |
10548 | ||
10549 | /* Subtract 8 here because 'Neighbor' is | |
10550 | * 8 characters */ | |
10551 | vty_out(vty, "Neighbor"); | |
10552 | vty_out(vty, "%*s", | |
10553 | max_neighbor_width - 8, " "); | |
10554 | vty_out(vty, | |
10555 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
10556 | } | |
10557 | } | |
10558 | } | |
10559 | ||
10560 | paf = peer_af_find(peer, afi, safi); | |
10561 | filter = &peer->filter[afi][safi]; | |
10562 | ||
10563 | count++; | |
10564 | /* Works for both failed & successful cases */ | |
10565 | if (peer_dynamic_neighbor(peer)) | |
10566 | dn_count++; | |
10567 | ||
10568 | if (use_json) { | |
10569 | json_peer = NULL; | |
10570 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, | |
10571 | as_type, as)) { | |
10572 | filtered_count++; | |
10573 | continue; | |
10574 | } | |
10575 | if (show_failed && | |
10576 | bgp_has_peer_failed(peer, afi, safi)) { | |
10577 | json_peer = json_object_new_object(); | |
10578 | bgp_show_failed_summary(vty, bgp, peer, | |
10579 | json_peer, 0, use_json); | |
10580 | } else if (!show_failed) { | |
10581 | if (show_established | |
10582 | && bgp_has_peer_failed(peer, afi, safi)) { | |
10583 | filtered_count++; | |
10584 | continue; | |
10585 | } | |
10586 | ||
10587 | json_peer = json_object_new_object(); | |
10588 | if (peer_dynamic_neighbor(peer)) { | |
10589 | json_object_boolean_true_add(json_peer, | |
10590 | "dynamicPeer"); | |
10591 | } | |
10592 | ||
10593 | if (peer->hostname) | |
10594 | json_object_string_add(json_peer, "hostname", | |
10595 | peer->hostname); | |
10596 | ||
10597 | if (peer->domainname) | |
10598 | json_object_string_add(json_peer, "domainname", | |
10599 | peer->domainname); | |
10600 | ||
10601 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
10602 | json_object_int_add( | |
10603 | json_peer, "localAs", | |
10604 | peer->change_local_as | |
10605 | ? peer->change_local_as | |
10606 | : peer->local_as); | |
10607 | json_object_int_add(json_peer, "version", 4); | |
10608 | json_object_int_add(json_peer, "msgRcvd", | |
10609 | PEER_TOTAL_RX(peer)); | |
10610 | json_object_int_add(json_peer, "msgSent", | |
10611 | PEER_TOTAL_TX(peer)); | |
10612 | ||
10613 | atomic_size_t outq_count, inq_count; | |
10614 | outq_count = atomic_load_explicit( | |
10615 | &peer->obuf->count, | |
10616 | memory_order_relaxed); | |
10617 | inq_count = atomic_load_explicit( | |
10618 | &peer->ibuf->count, | |
10619 | memory_order_relaxed); | |
10620 | ||
10621 | json_object_int_add(json_peer, "tableVersion", | |
10622 | peer->version[afi][safi]); | |
10623 | json_object_int_add(json_peer, "outq", | |
10624 | outq_count); | |
10625 | json_object_int_add(json_peer, "inq", | |
10626 | inq_count); | |
10627 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10628 | use_json, json_peer); | |
10629 | ||
10630 | json_object_int_add(json_peer, "pfxRcd", | |
10631 | peer->pcount[afi][pfx_rcd_safi]); | |
10632 | ||
10633 | if (paf && PAF_SUBGRP(paf)) | |
10634 | json_object_int_add( | |
10635 | json_peer, "pfxSnt", | |
10636 | (PAF_SUBGRP(paf))->scount); | |
10637 | else | |
10638 | json_object_int_add(json_peer, "pfxSnt", | |
10639 | 0); | |
10640 | ||
10641 | /* BGP FSM state */ | |
10642 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10643 | || CHECK_FLAG(peer->bgp->flags, | |
10644 | BGP_FLAG_SHUTDOWN)) | |
10645 | json_object_string_add(json_peer, | |
10646 | "state", | |
10647 | "Idle (Admin)"); | |
10648 | else if (peer->afc_recv[afi][safi]) | |
10649 | json_object_string_add( | |
10650 | json_peer, "state", | |
10651 | lookup_msg(bgp_status_msg, | |
10652 | peer->status, NULL)); | |
10653 | else if (CHECK_FLAG( | |
10654 | peer->sflags, | |
10655 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10656 | json_object_string_add(json_peer, | |
10657 | "state", | |
10658 | "Idle (PfxCt)"); | |
10659 | else | |
10660 | json_object_string_add( | |
10661 | json_peer, "state", | |
10662 | lookup_msg(bgp_status_msg, | |
10663 | peer->status, NULL)); | |
10664 | ||
10665 | /* BGP peer state */ | |
10666 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10667 | || CHECK_FLAG(peer->bgp->flags, | |
10668 | BGP_FLAG_SHUTDOWN)) | |
10669 | json_object_string_add(json_peer, | |
10670 | "peerState", | |
10671 | "Admin"); | |
10672 | else if (CHECK_FLAG( | |
10673 | peer->sflags, | |
10674 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10675 | json_object_string_add(json_peer, | |
10676 | "peerState", | |
10677 | "PfxCt"); | |
10678 | else if (CHECK_FLAG(peer->flags, | |
10679 | PEER_FLAG_PASSIVE)) | |
10680 | json_object_string_add(json_peer, | |
10681 | "peerState", | |
10682 | "Passive"); | |
10683 | else if (CHECK_FLAG(peer->sflags, | |
10684 | PEER_STATUS_NSF_WAIT)) | |
10685 | json_object_string_add(json_peer, | |
10686 | "peerState", | |
10687 | "NSF passive"); | |
10688 | else if (CHECK_FLAG( | |
10689 | peer->bgp->flags, | |
10690 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10691 | && (!bgp_inbound_policy_exists(peer, | |
10692 | filter) | |
10693 | || !bgp_outbound_policy_exists( | |
10694 | peer, filter))) | |
10695 | json_object_string_add(json_peer, | |
10696 | "peerState", | |
10697 | "Policy"); | |
10698 | else | |
10699 | json_object_string_add( | |
10700 | json_peer, "peerState", "OK"); | |
10701 | ||
10702 | json_object_int_add(json_peer, "connectionsEstablished", | |
10703 | peer->established); | |
10704 | json_object_int_add(json_peer, "connectionsDropped", | |
10705 | peer->dropped); | |
10706 | if (peer->desc) | |
10707 | json_object_string_add( | |
10708 | json_peer, "desc", peer->desc); | |
10709 | } | |
10710 | /* Avoid creating empty peer dicts in JSON */ | |
10711 | if (json_peer == NULL) | |
10712 | continue; | |
10713 | ||
10714 | if (peer->conf_if) | |
10715 | json_object_string_add(json_peer, "idType", | |
10716 | "interface"); | |
10717 | else if (peer->su.sa.sa_family == AF_INET) | |
10718 | json_object_string_add(json_peer, "idType", | |
10719 | "ipv4"); | |
10720 | else if (peer->su.sa.sa_family == AF_INET6) | |
10721 | json_object_string_add(json_peer, "idType", | |
10722 | "ipv6"); | |
10723 | json_object_object_add(json_peers, peer->host, | |
10724 | json_peer); | |
10725 | } else { | |
10726 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, | |
10727 | as_type, as)) { | |
10728 | filtered_count++; | |
10729 | continue; | |
10730 | } | |
10731 | if (show_failed && | |
10732 | bgp_has_peer_failed(peer, afi, safi)) { | |
10733 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10734 | max_neighbor_width, | |
10735 | use_json); | |
10736 | } else if (!show_failed) { | |
10737 | if (show_established | |
10738 | && bgp_has_peer_failed(peer, afi, safi)) { | |
10739 | filtered_count++; | |
10740 | continue; | |
10741 | } | |
10742 | ||
10743 | if ((count - filtered_count) == 1) { | |
10744 | /* display headline before the first | |
10745 | * neighbor line */ | |
10746 | vty_out(vty, "\n"); | |
10747 | ||
10748 | /* Subtract 8 here because 'Neighbor' is | |
10749 | * 8 characters */ | |
10750 | vty_out(vty, "Neighbor"); | |
10751 | vty_out(vty, "%*s", | |
10752 | max_neighbor_width - 8, " "); | |
10753 | vty_out(vty, | |
10754 | show_wide | |
10755 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10756 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10757 | } | |
10758 | ||
10759 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10760 | if (peer_dynamic_neighbor(peer)) { | |
10761 | dn_flag[0] = '*'; | |
10762 | } | |
10763 | ||
10764 | if (peer->hostname | |
10765 | && CHECK_FLAG(bgp->flags, | |
10766 | BGP_FLAG_SHOW_HOSTNAME)) | |
10767 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
10768 | peer->hostname, | |
10769 | peer->host); | |
10770 | else | |
10771 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10772 | ||
10773 | /* pad the neighbor column with spaces */ | |
10774 | if (len < max_neighbor_width) | |
10775 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10776 | " "); | |
10777 | ||
10778 | atomic_size_t outq_count, inq_count; | |
10779 | outq_count = atomic_load_explicit( | |
10780 | &peer->obuf->count, | |
10781 | memory_order_relaxed); | |
10782 | inq_count = atomic_load_explicit( | |
10783 | &peer->ibuf->count, | |
10784 | memory_order_relaxed); | |
10785 | ||
10786 | if (show_wide) | |
10787 | vty_out(vty, | |
10788 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10789 | " %4zu %4zu %8s", | |
10790 | peer->as, | |
10791 | peer->change_local_as | |
10792 | ? peer->change_local_as | |
10793 | : peer->local_as, | |
10794 | PEER_TOTAL_RX(peer), | |
10795 | PEER_TOTAL_TX(peer), | |
10796 | peer->version[afi][safi], | |
10797 | inq_count, outq_count, | |
10798 | peer_uptime(peer->uptime, | |
10799 | timebuf, | |
10800 | BGP_UPTIME_LEN, 0, | |
10801 | NULL)); | |
10802 | else | |
10803 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10804 | " %4zu %4zu %8s", | |
10805 | peer->as, PEER_TOTAL_RX(peer), | |
10806 | PEER_TOTAL_TX(peer), | |
10807 | peer->version[afi][safi], | |
10808 | inq_count, outq_count, | |
10809 | peer_uptime(peer->uptime, | |
10810 | timebuf, | |
10811 | BGP_UPTIME_LEN, 0, | |
10812 | NULL)); | |
10813 | ||
10814 | if (peer_established(peer)) { | |
10815 | if (peer->afc_recv[afi][safi]) { | |
10816 | if (CHECK_FLAG( | |
10817 | bgp->flags, | |
10818 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10819 | && !bgp_inbound_policy_exists( | |
10820 | peer, filter)) | |
10821 | vty_out(vty, " %12s", | |
10822 | "(Policy)"); | |
10823 | else | |
10824 | vty_out(vty, | |
10825 | " %12u", | |
10826 | peer->pcount | |
10827 | [afi] | |
10828 | [pfx_rcd_safi]); | |
10829 | } else { | |
10830 | vty_out(vty, " NoNeg"); | |
10831 | } | |
10832 | ||
10833 | if (paf && PAF_SUBGRP(paf)) { | |
10834 | if (CHECK_FLAG( | |
10835 | bgp->flags, | |
10836 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10837 | && !bgp_outbound_policy_exists( | |
10838 | peer, filter)) | |
10839 | vty_out(vty, " %8s", | |
10840 | "(Policy)"); | |
10841 | else | |
10842 | vty_out(vty, | |
10843 | " %8u", | |
10844 | (PAF_SUBGRP( | |
10845 | paf)) | |
10846 | ->scount); | |
10847 | } else { | |
10848 | vty_out(vty, " NoNeg"); | |
10849 | } | |
10850 | } else { | |
10851 | if (CHECK_FLAG(peer->flags, | |
10852 | PEER_FLAG_SHUTDOWN) | |
10853 | || CHECK_FLAG(peer->bgp->flags, | |
10854 | BGP_FLAG_SHUTDOWN)) | |
10855 | vty_out(vty, " Idle (Admin)"); | |
10856 | else if (CHECK_FLAG( | |
10857 | peer->sflags, | |
10858 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10859 | vty_out(vty, " Idle (PfxCt)"); | |
10860 | else | |
10861 | vty_out(vty, " %12s", | |
10862 | lookup_msg(bgp_status_msg, | |
10863 | peer->status, NULL)); | |
10864 | ||
10865 | vty_out(vty, " %8u", 0); | |
10866 | } | |
10867 | /* Make sure `Desc` column is the lastest in | |
10868 | * the output. | |
10869 | */ | |
10870 | if (peer->desc) | |
10871 | vty_out(vty, " %s", | |
10872 | bgp_peer_description_stripped( | |
10873 | peer->desc, | |
10874 | show_wide ? 64 : 20)); | |
10875 | else | |
10876 | vty_out(vty, " N/A"); | |
10877 | vty_out(vty, "\n"); | |
10878 | } | |
10879 | ||
10880 | } | |
10881 | } | |
10882 | ||
10883 | if (use_json) { | |
10884 | json_object_object_add(json, "peers", json_peers); | |
10885 | json_object_int_add(json, "failedPeers", failed_count); | |
10886 | json_object_int_add(json, "displayedPeers", | |
10887 | count - filtered_count); | |
10888 | json_object_int_add(json, "totalPeers", count); | |
10889 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10890 | ||
10891 | if (!show_failed) | |
10892 | bgp_show_bestpath_json(bgp, json); | |
10893 | ||
10894 | vty_json(vty, json); | |
10895 | } else { | |
10896 | if (count) { | |
10897 | if (filtered_count == count) | |
10898 | vty_out(vty, "\n%% No matching neighbor\n"); | |
10899 | else { | |
10900 | if (show_failed) | |
10901 | vty_out(vty, "\nDisplayed neighbors %d", | |
10902 | failed_count); | |
10903 | else if (as_type != AS_UNSPECIFIED || as | |
10904 | || fpeer || show_established) | |
10905 | vty_out(vty, "\nDisplayed neighbors %d", | |
10906 | count - filtered_count); | |
10907 | ||
10908 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
10909 | count); | |
10910 | } | |
10911 | } else { | |
10912 | vty_out(vty, "No %s neighbor is configured\n", | |
10913 | get_afi_safi_str(afi, safi, false)); | |
10914 | } | |
10915 | ||
10916 | if (dn_count) { | |
10917 | vty_out(vty, "* - dynamic neighbor\n"); | |
10918 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10919 | dn_count, bgp->dynamic_neighbors_limit); | |
10920 | } | |
10921 | } | |
10922 | ||
10923 | return CMD_SUCCESS; | |
10924 | } | |
10925 | ||
10926 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, | |
10927 | int safi, struct peer *fpeer, int as_type, | |
10928 | as_t as, uint16_t show_flags) | |
10929 | { | |
10930 | int is_first = 1; | |
10931 | int afi_wildcard = (afi == AFI_MAX); | |
10932 | int safi_wildcard = (safi == SAFI_MAX); | |
10933 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
10934 | bool nbr_output = false; | |
10935 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
10936 | ||
10937 | if (use_json && is_wildcard) | |
10938 | vty_out(vty, "{\n"); | |
10939 | if (afi_wildcard) | |
10940 | afi = 1; /* AFI_IP */ | |
10941 | while (afi < AFI_MAX) { | |
10942 | if (safi_wildcard) | |
10943 | safi = 1; /* SAFI_UNICAST */ | |
10944 | while (safi < SAFI_MAX) { | |
10945 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { | |
10946 | nbr_output = true; | |
10947 | ||
10948 | if (is_wildcard) { | |
10949 | /* | |
10950 | * So limit output to those afi/safi | |
10951 | * pairs that | |
10952 | * actualy have something interesting in | |
10953 | * them | |
10954 | */ | |
10955 | if (use_json) { | |
10956 | if (!is_first) | |
10957 | vty_out(vty, ",\n"); | |
10958 | else | |
10959 | is_first = 0; | |
10960 | ||
10961 | vty_out(vty, "\"%s\":", | |
10962 | get_afi_safi_str(afi, | |
10963 | safi, | |
10964 | true)); | |
10965 | } else { | |
10966 | vty_out(vty, | |
10967 | "\n%s Summary (%s):\n", | |
10968 | get_afi_safi_str(afi, | |
10969 | safi, | |
10970 | false), | |
10971 | bgp->name_pretty); | |
10972 | } | |
10973 | } | |
10974 | bgp_show_summary(vty, bgp, afi, safi, fpeer, | |
10975 | as_type, as, show_flags); | |
10976 | } | |
10977 | safi++; | |
10978 | if (!safi_wildcard) | |
10979 | safi = SAFI_MAX; | |
10980 | } | |
10981 | afi++; | |
10982 | if (!afi_wildcard) | |
10983 | afi = AFI_MAX; | |
10984 | } | |
10985 | ||
10986 | if (use_json && is_wildcard) | |
10987 | vty_out(vty, "}\n"); | |
10988 | else if (!nbr_output) { | |
10989 | if (use_json) | |
10990 | vty_out(vty, "{}\n"); | |
10991 | else | |
10992 | vty_out(vty, "%% No BGP neighbors found in %s\n", | |
10993 | bgp->name_pretty); | |
10994 | } | |
10995 | } | |
10996 | ||
10997 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
10998 | safi_t safi, | |
10999 | const char *neighbor, | |
11000 | int as_type, as_t as, | |
11001 | uint16_t show_flags) | |
11002 | { | |
11003 | struct listnode *node, *nnode; | |
11004 | struct bgp *bgp; | |
11005 | struct peer *fpeer = NULL; | |
11006 | int is_first = 1; | |
11007 | bool nbr_output = false; | |
11008 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
11009 | ||
11010 | if (use_json) | |
11011 | vty_out(vty, "{\n"); | |
11012 | ||
11013 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11014 | nbr_output = true; | |
11015 | if (use_json) { | |
11016 | if (!is_first) | |
11017 | vty_out(vty, ",\n"); | |
11018 | else | |
11019 | is_first = 0; | |
11020 | ||
11021 | vty_out(vty, "\"%s\":", | |
11022 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11023 | ? VRF_DEFAULT_NAME | |
11024 | : bgp->name); | |
11025 | } | |
11026 | if (neighbor) { | |
11027 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11028 | use_json); | |
11029 | if (!fpeer) | |
11030 | continue; | |
11031 | } | |
11032 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11033 | as, show_flags); | |
11034 | } | |
11035 | ||
11036 | if (use_json) | |
11037 | vty_out(vty, "}\n"); | |
11038 | else if (!nbr_output) | |
11039 | vty_out(vty, "%% BGP instance not found\n"); | |
11040 | } | |
11041 | ||
11042 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
11043 | safi_t safi, const char *neighbor, int as_type, | |
11044 | as_t as, uint16_t show_flags) | |
11045 | { | |
11046 | struct bgp *bgp; | |
11047 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
11048 | struct peer *fpeer = NULL; | |
11049 | ||
11050 | if (name) { | |
11051 | if (strmatch(name, "all")) { | |
11052 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
11053 | neighbor, as_type, | |
11054 | as, show_flags); | |
11055 | return CMD_SUCCESS; | |
11056 | } else { | |
11057 | bgp = bgp_lookup_by_name(name); | |
11058 | ||
11059 | if (!bgp) { | |
11060 | if (use_json) | |
11061 | vty_out(vty, "{}\n"); | |
11062 | else | |
11063 | vty_out(vty, | |
11064 | "%% BGP instance not found\n"); | |
11065 | return CMD_WARNING; | |
11066 | } | |
11067 | ||
11068 | if (neighbor) { | |
11069 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11070 | use_json); | |
11071 | if (!fpeer) | |
11072 | return CMD_WARNING; | |
11073 | } | |
11074 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11075 | as_type, as, show_flags); | |
11076 | return CMD_SUCCESS; | |
11077 | } | |
11078 | } | |
11079 | ||
11080 | bgp = bgp_get_default(); | |
11081 | ||
11082 | if (bgp) { | |
11083 | if (neighbor) { | |
11084 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11085 | use_json); | |
11086 | if (!fpeer) | |
11087 | return CMD_WARNING; | |
11088 | } | |
11089 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11090 | as, show_flags); | |
11091 | } else { | |
11092 | if (use_json) | |
11093 | vty_out(vty, "{}\n"); | |
11094 | else | |
11095 | vty_out(vty, "%% BGP instance not found\n"); | |
11096 | return CMD_WARNING; | |
11097 | } | |
11098 | ||
11099 | return CMD_SUCCESS; | |
11100 | } | |
11101 | ||
11102 | /* `show [ip] bgp summary' commands. */ | |
11103 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, | |
11104 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11105 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
11106 | "]] [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]", | |
11107 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11108 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11109 | "Display the entries for all address families\n" | |
11110 | "Summary of BGP neighbor status\n" | |
11111 | "Show only sessions in Established state\n" | |
11112 | "Show only sessions not in Established state\n" | |
11113 | "Show only the specified neighbor session\n" | |
11114 | "Neighbor to display information about\n" | |
11115 | "Neighbor to display information about\n" | |
11116 | "Neighbor on BGP configured interface\n" | |
11117 | "Show only the specified remote AS sessions\n" | |
11118 | "AS number\n" | |
11119 | "Internal (iBGP) AS sessions\n" | |
11120 | "External (eBGP) AS sessions\n" | |
11121 | "Shorten the information on BGP instances\n" | |
11122 | "Increase table width for longer output\n" JSON_STR) | |
11123 | { | |
11124 | char *vrf = NULL; | |
11125 | afi_t afi = AFI_MAX; | |
11126 | safi_t safi = SAFI_MAX; | |
11127 | as_t as = 0; /* 0 means AS filter not set */ | |
11128 | int as_type = AS_UNSPECIFIED; | |
11129 | uint16_t show_flags = 0; | |
11130 | ||
11131 | int idx = 0; | |
11132 | ||
11133 | /* show [ip] bgp */ | |
11134 | if (!all && argv_find(argv, argc, "ip", &idx)) | |
11135 | afi = AFI_IP; | |
11136 | /* [<vrf> VIEWVRFNAME] */ | |
11137 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11138 | vrf = argv[idx + 1]->arg; | |
11139 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11140 | vrf = NULL; | |
11141 | } else if (argv_find(argv, argc, "view", &idx)) | |
11142 | /* [<view> VIEWVRFNAME] */ | |
11143 | vrf = argv[idx + 1]->arg; | |
11144 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11145 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11146 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11147 | } | |
11148 | ||
11149 | if (argv_find(argv, argc, "failed", &idx)) | |
11150 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
11151 | ||
11152 | if (argv_find(argv, argc, "established", &idx)) | |
11153 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
11154 | ||
11155 | if (argv_find(argv, argc, "remote-as", &idx)) { | |
11156 | if (argv[idx + 1]->arg[0] == 'i') | |
11157 | as_type = AS_INTERNAL; | |
11158 | else if (argv[idx + 1]->arg[0] == 'e') | |
11159 | as_type = AS_EXTERNAL; | |
11160 | else | |
11161 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11162 | } | |
11163 | ||
11164 | if (argv_find(argv, argc, "terse", &idx)) | |
11165 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11166 | ||
11167 | if (argv_find(argv, argc, "wide", &idx)) | |
11168 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11169 | ||
11170 | if (argv_find(argv, argc, "json", &idx)) | |
11171 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
11172 | ||
11173 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, | |
11174 | show_flags); | |
11175 | } | |
11176 | ||
11177 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) | |
11178 | { | |
11179 | if (for_json) | |
11180 | return get_afi_safi_json_str(afi, safi); | |
11181 | else | |
11182 | return get_afi_safi_vty_str(afi, safi); | |
11183 | } | |
11184 | ||
11185 | ||
11186 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11187 | afi_t afi, safi_t safi, | |
11188 | uint16_t adv_smcap, uint16_t adv_rmcap, | |
11189 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
11190 | bool use_json, json_object *json_pref) | |
11191 | { | |
11192 | /* Send-Mode */ | |
11193 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11194 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11195 | if (use_json) { | |
11196 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11197 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11198 | json_object_string_add(json_pref, "sendMode", | |
11199 | "advertisedAndReceived"); | |
11200 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11201 | json_object_string_add(json_pref, "sendMode", | |
11202 | "advertised"); | |
11203 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11204 | json_object_string_add(json_pref, "sendMode", | |
11205 | "received"); | |
11206 | } else { | |
11207 | vty_out(vty, " Send-mode: "); | |
11208 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11209 | vty_out(vty, "advertised"); | |
11210 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11211 | vty_out(vty, "%sreceived", | |
11212 | CHECK_FLAG(p->af_cap[afi][safi], | |
11213 | adv_smcap) | |
11214 | ? ", " | |
11215 | : ""); | |
11216 | vty_out(vty, "\n"); | |
11217 | } | |
11218 | } | |
11219 | ||
11220 | /* Receive-Mode */ | |
11221 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11222 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11223 | if (use_json) { | |
11224 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11225 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11226 | json_object_string_add(json_pref, "recvMode", | |
11227 | "advertisedAndReceived"); | |
11228 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11229 | json_object_string_add(json_pref, "recvMode", | |
11230 | "advertised"); | |
11231 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11232 | json_object_string_add(json_pref, "recvMode", | |
11233 | "received"); | |
11234 | } else { | |
11235 | vty_out(vty, " Receive-mode: "); | |
11236 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11237 | vty_out(vty, "advertised"); | |
11238 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11239 | vty_out(vty, "%sreceived", | |
11240 | CHECK_FLAG(p->af_cap[afi][safi], | |
11241 | adv_rmcap) | |
11242 | ? ", " | |
11243 | : ""); | |
11244 | vty_out(vty, "\n"); | |
11245 | } | |
11246 | } | |
11247 | } | |
11248 | ||
11249 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, | |
11250 | struct peer *p, | |
11251 | bool use_json, | |
11252 | json_object *json) | |
11253 | { | |
11254 | bool rbit_status = false; | |
11255 | ||
11256 | if (!use_json) | |
11257 | vty_out(vty, "\n R bit: "); | |
11258 | ||
11259 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) | |
11260 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
11261 | && (peer_established(p))) { | |
11262 | ||
11263 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
11264 | rbit_status = true; | |
11265 | else | |
11266 | rbit_status = false; | |
11267 | } | |
11268 | ||
11269 | if (rbit_status) { | |
11270 | if (use_json) | |
11271 | json_object_boolean_true_add(json, "rBit"); | |
11272 | else | |
11273 | vty_out(vty, "True\n"); | |
11274 | } else { | |
11275 | if (use_json) | |
11276 | json_object_boolean_false_add(json, "rBit"); | |
11277 | else | |
11278 | vty_out(vty, "False\n"); | |
11279 | } | |
11280 | } | |
11281 | ||
11282 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, | |
11283 | struct peer *peer, | |
11284 | bool use_json, | |
11285 | json_object *json) | |
11286 | { | |
11287 | const char *mode = "NotApplicable"; | |
11288 | ||
11289 | if (!use_json) | |
11290 | vty_out(vty, "\n Remote GR Mode: "); | |
11291 | ||
11292 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) | |
11293 | && (peer_established(peer))) { | |
11294 | ||
11295 | if ((peer->nsf_af_count == 0) | |
11296 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
11297 | ||
11298 | mode = "Disable"; | |
11299 | ||
11300 | } else if (peer->nsf_af_count == 0 | |
11301 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
11302 | ||
11303 | mode = "Helper"; | |
11304 | ||
11305 | } else if (peer->nsf_af_count != 0 | |
11306 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
11307 | ||
11308 | mode = "Restart"; | |
11309 | } | |
11310 | } | |
11311 | ||
11312 | if (use_json) { | |
11313 | json_object_string_add(json, "remoteGrMode", mode); | |
11314 | } else | |
11315 | vty_out(vty, mode, "\n"); | |
11316 | } | |
11317 | ||
11318 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, | |
11319 | struct peer *p, | |
11320 | bool use_json, | |
11321 | json_object *json) | |
11322 | { | |
11323 | const char *mode = "Invalid"; | |
11324 | ||
11325 | if (!use_json) | |
11326 | vty_out(vty, " Local GR Mode: "); | |
11327 | ||
11328 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11329 | mode = "Helper"; | |
11330 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11331 | mode = "Restart"; | |
11332 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11333 | mode = "Disable"; | |
11334 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { | |
11335 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) | |
11336 | mode = "Helper*"; | |
11337 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11338 | mode = "Restart*"; | |
11339 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11340 | mode = "Disable*"; | |
11341 | else | |
11342 | mode = "Invalid*"; | |
11343 | } | |
11344 | ||
11345 | if (use_json) { | |
11346 | json_object_string_add(json, "localGrMode", mode); | |
11347 | } else { | |
11348 | vty_out(vty, mode, "\n"); | |
11349 | } | |
11350 | } | |
11351 | ||
11352 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( | |
11353 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
11354 | { | |
11355 | afi_t afi; | |
11356 | safi_t safi; | |
11357 | json_object *json_afi_safi = NULL; | |
11358 | json_object *json_timer = NULL; | |
11359 | json_object *json_endofrib_status = NULL; | |
11360 | bool eor_flag = false; | |
11361 | ||
11362 | FOREACH_AFI_SAFI_NSF (afi, safi) { | |
11363 | if (!peer->afc[afi][safi]) | |
11364 | continue; | |
11365 | ||
11366 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || | |
11367 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11368 | continue; | |
11369 | ||
11370 | if (use_json) { | |
11371 | json_afi_safi = json_object_new_object(); | |
11372 | json_endofrib_status = json_object_new_object(); | |
11373 | json_timer = json_object_new_object(); | |
11374 | } | |
11375 | ||
11376 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) | |
11377 | eor_flag = true; | |
11378 | else | |
11379 | eor_flag = false; | |
11380 | ||
11381 | if (!use_json) { | |
11382 | vty_out(vty, " %s:\n", | |
11383 | get_afi_safi_str(afi, safi, false)); | |
11384 | ||
11385 | vty_out(vty, " F bit: "); | |
11386 | } | |
11387 | ||
11388 | if (peer->nsf[afi][safi] && | |
11389 | CHECK_FLAG(peer->af_cap[afi][safi], | |
11390 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
11391 | ||
11392 | if (use_json) { | |
11393 | json_object_boolean_true_add(json_afi_safi, | |
11394 | "fBit"); | |
11395 | } else | |
11396 | vty_out(vty, "True\n"); | |
11397 | } else { | |
11398 | if (use_json) | |
11399 | json_object_boolean_false_add(json_afi_safi, | |
11400 | "fBit"); | |
11401 | else | |
11402 | vty_out(vty, "False\n"); | |
11403 | } | |
11404 | ||
11405 | if (!use_json) | |
11406 | vty_out(vty, " End-of-RIB sent: "); | |
11407 | ||
11408 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11409 | PEER_STATUS_EOR_SEND)) { | |
11410 | if (use_json) { | |
11411 | json_object_boolean_true_add( | |
11412 | json_endofrib_status, "endOfRibSend"); | |
11413 | ||
11414 | PRINT_EOR_JSON(eor_flag); | |
11415 | } else { | |
11416 | vty_out(vty, "Yes\n"); | |
11417 | vty_out(vty, | |
11418 | " End-of-RIB sent after update: "); | |
11419 | ||
11420 | PRINT_EOR(eor_flag); | |
11421 | } | |
11422 | } else { | |
11423 | if (use_json) { | |
11424 | json_object_boolean_false_add( | |
11425 | json_endofrib_status, "endOfRibSend"); | |
11426 | json_object_boolean_false_add( | |
11427 | json_endofrib_status, | |
11428 | "endOfRibSentAfterUpdate"); | |
11429 | } else { | |
11430 | vty_out(vty, "No\n"); | |
11431 | vty_out(vty, | |
11432 | " End-of-RIB sent after update: "); | |
11433 | vty_out(vty, "No\n"); | |
11434 | } | |
11435 | } | |
11436 | ||
11437 | if (!use_json) | |
11438 | vty_out(vty, " End-of-RIB received: "); | |
11439 | ||
11440 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11441 | PEER_STATUS_EOR_RECEIVED)) { | |
11442 | if (use_json) | |
11443 | json_object_boolean_true_add( | |
11444 | json_endofrib_status, "endOfRibRecv"); | |
11445 | else | |
11446 | vty_out(vty, "Yes\n"); | |
11447 | } else { | |
11448 | if (use_json) | |
11449 | json_object_boolean_false_add( | |
11450 | json_endofrib_status, "endOfRibRecv"); | |
11451 | else | |
11452 | vty_out(vty, "No\n"); | |
11453 | } | |
11454 | ||
11455 | if (use_json) { | |
11456 | json_object_int_add(json_timer, "stalePathTimer", | |
11457 | peer->bgp->stalepath_time); | |
11458 | ||
11459 | if (peer->t_gr_stale != NULL) { | |
11460 | json_object_int_add(json_timer, | |
11461 | "stalePathTimerRemaining", | |
11462 | thread_timer_remain_second( | |
11463 | peer->t_gr_stale)); | |
11464 | } | |
11465 | ||
11466 | /* Display Configured Selection | |
11467 | * Deferral only when when | |
11468 | * Gr mode is enabled. | |
11469 | */ | |
11470 | if (CHECK_FLAG(peer->flags, | |
11471 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11472 | json_object_int_add(json_timer, | |
11473 | "selectionDeferralTimer", | |
11474 | peer->bgp->stalepath_time); | |
11475 | } | |
11476 | ||
11477 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != | |
11478 | NULL) { | |
11479 | ||
11480 | json_object_int_add( | |
11481 | json_timer, | |
11482 | "selectionDeferralTimerRemaining", | |
11483 | thread_timer_remain_second( | |
11484 | peer->bgp->gr_info[afi][safi] | |
11485 | .t_select_deferral)); | |
11486 | } | |
11487 | } else { | |
11488 | vty_out(vty, " Timers:\n"); | |
11489 | vty_out(vty, | |
11490 | " Configured Stale Path Time(sec): %u\n", | |
11491 | peer->bgp->stalepath_time); | |
11492 | ||
11493 | if (peer->t_gr_stale != NULL) | |
11494 | vty_out(vty, | |
11495 | " Stale Path Remaining(sec): %ld\n", | |
11496 | thread_timer_remain_second( | |
11497 | peer->t_gr_stale)); | |
11498 | /* Display Configured Selection | |
11499 | * Deferral only when when | |
11500 | * Gr mode is enabled. | |
11501 | */ | |
11502 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
11503 | vty_out(vty, | |
11504 | " Configured Selection Deferral Time(sec): %u\n", | |
11505 | peer->bgp->select_defer_time); | |
11506 | ||
11507 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != | |
11508 | NULL) | |
11509 | vty_out(vty, | |
11510 | " Selection Deferral Time Remaining(sec): %ld\n", | |
11511 | thread_timer_remain_second( | |
11512 | peer->bgp->gr_info[afi][safi] | |
11513 | .t_select_deferral)); | |
11514 | } | |
11515 | if (use_json) { | |
11516 | json_object_object_add(json_afi_safi, "endOfRibStatus", | |
11517 | json_endofrib_status); | |
11518 | json_object_object_add(json_afi_safi, "timers", | |
11519 | json_timer); | |
11520 | json_object_object_add( | |
11521 | json, get_afi_safi_str(afi, safi, true), | |
11522 | json_afi_safi); | |
11523 | } | |
11524 | } | |
11525 | } | |
11526 | ||
11527 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, | |
11528 | struct peer *p, | |
11529 | bool use_json, | |
11530 | json_object *json) | |
11531 | { | |
11532 | if (use_json) { | |
11533 | json_object *json_timer = NULL; | |
11534 | ||
11535 | json_timer = json_object_new_object(); | |
11536 | ||
11537 | json_object_int_add(json_timer, "configuredRestartTimer", | |
11538 | p->bgp->restart_time); | |
11539 | ||
11540 | json_object_int_add(json_timer, "receivedRestartTimer", | |
11541 | p->v_gr_restart); | |
11542 | ||
11543 | if (p->t_gr_restart != NULL) | |
11544 | json_object_int_add( | |
11545 | json_timer, "restartTimerRemaining", | |
11546 | thread_timer_remain_second(p->t_gr_restart)); | |
11547 | ||
11548 | json_object_object_add(json, "timers", json_timer); | |
11549 | } else { | |
11550 | ||
11551 | vty_out(vty, " Timers:\n"); | |
11552 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
11553 | p->bgp->restart_time); | |
11554 | ||
11555 | vty_out(vty, " Received Restart Time(sec): %u\n", | |
11556 | p->v_gr_restart); | |
11557 | if (p->t_gr_restart != NULL) | |
11558 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", | |
11559 | thread_timer_remain_second(p->t_gr_restart)); | |
11560 | if (p->t_gr_restart != NULL) { | |
11561 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", | |
11562 | thread_timer_remain_second(p->t_gr_restart)); | |
11563 | } | |
11564 | } | |
11565 | } | |
11566 | ||
11567 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
11568 | bool use_json, json_object *json) | |
11569 | { | |
11570 | char buf[SU_ADDRSTRLEN] = {0}; | |
11571 | char dn_flag[2] = {0}; | |
11572 | /* '*' + v6 address of neighbor */ | |
11573 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
11574 | ||
11575 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
11576 | dn_flag[0] = '*'; | |
11577 | ||
11578 | if (p->conf_if) { | |
11579 | if (use_json) | |
11580 | json_object_string_add( | |
11581 | json, "neighborAddr", | |
11582 | BGP_PEER_SU_UNSPEC(p) | |
11583 | ? "none" | |
11584 | : sockunion2str(&p->su, buf, | |
11585 | SU_ADDRSTRLEN)); | |
11586 | else | |
11587 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, | |
11588 | BGP_PEER_SU_UNSPEC(p) | |
11589 | ? "none" | |
11590 | : sockunion2str(&p->su, buf, | |
11591 | SU_ADDRSTRLEN)); | |
11592 | } else { | |
11593 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, | |
11594 | p->host); | |
11595 | ||
11596 | if (use_json) | |
11597 | json_object_string_add(json, "neighborAddr", | |
11598 | neighborAddr); | |
11599 | else | |
11600 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); | |
11601 | } | |
11602 | ||
11603 | /* more gr info in new format */ | |
11604 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11605 | } | |
11606 | ||
11607 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
11608 | safi_t safi, bool use_json, | |
11609 | json_object *json_neigh) | |
11610 | { | |
11611 | struct bgp_filter *filter; | |
11612 | struct peer_af *paf; | |
11613 | char orf_pfx_name[BUFSIZ]; | |
11614 | int orf_pfx_count; | |
11615 | json_object *json_af = NULL; | |
11616 | json_object *json_prefA = NULL; | |
11617 | json_object *json_prefB = NULL; | |
11618 | json_object *json_addr = NULL; | |
11619 | json_object *json_advmap = NULL; | |
11620 | ||
11621 | if (use_json) { | |
11622 | json_addr = json_object_new_object(); | |
11623 | json_af = json_object_new_object(); | |
11624 | filter = &p->filter[afi][safi]; | |
11625 | ||
11626 | if (peer_group_active(p)) | |
11627 | json_object_string_add(json_addr, "peerGroupMember", | |
11628 | p->group->name); | |
11629 | ||
11630 | paf = peer_af_find(p, afi, safi); | |
11631 | if (paf && PAF_SUBGRP(paf)) { | |
11632 | json_object_int_add(json_addr, "updateGroupId", | |
11633 | PAF_UPDGRP(paf)->id); | |
11634 | json_object_int_add(json_addr, "subGroupId", | |
11635 | PAF_SUBGRP(paf)->id); | |
11636 | json_object_int_add(json_addr, "packetQueueLength", | |
11637 | bpacket_queue_virtual_length(paf)); | |
11638 | } | |
11639 | ||
11640 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11641 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11642 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11643 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11644 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11645 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11646 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11647 | json_object_int_add(json_af, "orfType", | |
11648 | ORF_TYPE_PREFIX); | |
11649 | json_prefA = json_object_new_object(); | |
11650 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11651 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11652 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11653 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11654 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11655 | use_json, json_prefA); | |
11656 | json_object_object_add(json_af, "orfPrefixList", | |
11657 | json_prefA); | |
11658 | } | |
11659 | ||
11660 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11661 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11662 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11663 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11664 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11665 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11666 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11667 | json_object_int_add(json_af, "orfOldType", | |
11668 | ORF_TYPE_PREFIX_OLD); | |
11669 | json_prefB = json_object_new_object(); | |
11670 | bgp_show_peer_afi_orf_cap( | |
11671 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11672 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11673 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11674 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11675 | json_prefB); | |
11676 | json_object_object_add(json_af, "orfOldPrefixList", | |
11677 | json_prefB); | |
11678 | } | |
11679 | ||
11680 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11681 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11682 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11683 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11684 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11685 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11686 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11687 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11688 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11689 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11690 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11691 | json_object_object_add(json_addr, "afDependentCap", | |
11692 | json_af); | |
11693 | else | |
11694 | json_object_free(json_af); | |
11695 | ||
11696 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", | |
11697 | p->host, afi, safi); | |
11698 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
11699 | NULL, afi, orf_pfx_name, use_json); | |
11700 | ||
11701 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11702 | PEER_STATUS_ORF_PREFIX_SEND) | |
11703 | || orf_pfx_count) { | |
11704 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11705 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11706 | json_object_boolean_true_add(json_neigh, | |
11707 | "orfSent"); | |
11708 | if (orf_pfx_count) | |
11709 | json_object_int_add(json_addr, "orfRecvCounter", | |
11710 | orf_pfx_count); | |
11711 | } | |
11712 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11713 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11714 | json_object_string_add( | |
11715 | json_addr, "orfFirstUpdate", | |
11716 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11717 | ||
11718 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11719 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11720 | json_object_boolean_true_add(json_addr, | |
11721 | "routeReflectorClient"); | |
11722 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11723 | PEER_FLAG_RSERVER_CLIENT)) | |
11724 | json_object_boolean_true_add(json_addr, | |
11725 | "routeServerClient"); | |
11726 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11727 | json_object_boolean_true_add(json_addr, | |
11728 | "inboundSoftConfigPermit"); | |
11729 | ||
11730 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11731 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11732 | json_object_boolean_true_add( | |
11733 | json_addr, | |
11734 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11735 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11736 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11737 | json_object_boolean_true_add( | |
11738 | json_addr, | |
11739 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11740 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11741 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11742 | json_object_boolean_true_add( | |
11743 | json_addr, | |
11744 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11745 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11746 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11747 | json_object_boolean_true_add( | |
11748 | json_addr, | |
11749 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11750 | ||
11751 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) | |
11752 | json_object_boolean_true_add( | |
11753 | json_addr, | |
11754 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11755 | ->type_json_name); | |
11756 | ||
11757 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11758 | json_object_string_add(json_addr, | |
11759 | "overrideASNsInOutboundUpdates", | |
11760 | "ifAspathEqualRemoteAs"); | |
11761 | ||
11762 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11763 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11764 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11765 | json_object_boolean_true_add(json_addr, | |
11766 | "routerAlwaysNextHop"); | |
11767 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11768 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11769 | json_object_boolean_true_add( | |
11770 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11771 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11772 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11773 | json_object_boolean_true_add( | |
11774 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11775 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11776 | json_object_boolean_true_add( | |
11777 | json_addr, "unchangedMedPropogatedToNbr"); | |
11778 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11779 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11780 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11781 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11782 | PEER_FLAG_SEND_COMMUNITY) | |
11783 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11784 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11785 | json_object_string_add(json_addr, | |
11786 | "commAttriSentToNbr", | |
11787 | "extendedAndStandard"); | |
11788 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11789 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11790 | json_object_string_add(json_addr, | |
11791 | "commAttriSentToNbr", | |
11792 | "extended"); | |
11793 | else | |
11794 | json_object_string_add(json_addr, | |
11795 | "commAttriSentToNbr", | |
11796 | "standard"); | |
11797 | } | |
11798 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11799 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11800 | if (p->default_rmap[afi][safi].name) | |
11801 | json_object_string_add( | |
11802 | json_addr, "defaultRouteMap", | |
11803 | p->default_rmap[afi][safi].name); | |
11804 | ||
11805 | if (paf && PAF_SUBGRP(paf) | |
11806 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11807 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11808 | json_object_boolean_true_add(json_addr, | |
11809 | "defaultSent"); | |
11810 | else | |
11811 | json_object_boolean_true_add(json_addr, | |
11812 | "defaultNotSent"); | |
11813 | } | |
11814 | ||
11815 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
11816 | if (is_evpn_enabled()) | |
11817 | json_object_boolean_true_add( | |
11818 | json_addr, "advertiseAllVnis"); | |
11819 | } | |
11820 | ||
11821 | if (filter->plist[FILTER_IN].name | |
11822 | || filter->dlist[FILTER_IN].name | |
11823 | || filter->aslist[FILTER_IN].name | |
11824 | || filter->map[RMAP_IN].name) | |
11825 | json_object_boolean_true_add(json_addr, | |
11826 | "inboundPathPolicyConfig"); | |
11827 | if (filter->plist[FILTER_OUT].name | |
11828 | || filter->dlist[FILTER_OUT].name | |
11829 | || filter->aslist[FILTER_OUT].name | |
11830 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11831 | json_object_boolean_true_add( | |
11832 | json_addr, "outboundPathPolicyConfig"); | |
11833 | ||
11834 | /* prefix-list */ | |
11835 | if (filter->plist[FILTER_IN].name) | |
11836 | json_object_string_add(json_addr, | |
11837 | "incomingUpdatePrefixFilterList", | |
11838 | filter->plist[FILTER_IN].name); | |
11839 | if (filter->plist[FILTER_OUT].name) | |
11840 | json_object_string_add(json_addr, | |
11841 | "outgoingUpdatePrefixFilterList", | |
11842 | filter->plist[FILTER_OUT].name); | |
11843 | ||
11844 | /* distribute-list */ | |
11845 | if (filter->dlist[FILTER_IN].name) | |
11846 | json_object_string_add( | |
11847 | json_addr, "incomingUpdateNetworkFilterList", | |
11848 | filter->dlist[FILTER_IN].name); | |
11849 | if (filter->dlist[FILTER_OUT].name) | |
11850 | json_object_string_add( | |
11851 | json_addr, "outgoingUpdateNetworkFilterList", | |
11852 | filter->dlist[FILTER_OUT].name); | |
11853 | ||
11854 | /* filter-list. */ | |
11855 | if (filter->aslist[FILTER_IN].name) | |
11856 | json_object_string_add(json_addr, | |
11857 | "incomingUpdateAsPathFilterList", | |
11858 | filter->aslist[FILTER_IN].name); | |
11859 | if (filter->aslist[FILTER_OUT].name) | |
11860 | json_object_string_add(json_addr, | |
11861 | "outgoingUpdateAsPathFilterList", | |
11862 | filter->aslist[FILTER_OUT].name); | |
11863 | ||
11864 | /* route-map. */ | |
11865 | if (filter->map[RMAP_IN].name) | |
11866 | json_object_string_add( | |
11867 | json_addr, "routeMapForIncomingAdvertisements", | |
11868 | filter->map[RMAP_IN].name); | |
11869 | if (filter->map[RMAP_OUT].name) | |
11870 | json_object_string_add( | |
11871 | json_addr, "routeMapForOutgoingAdvertisements", | |
11872 | filter->map[RMAP_OUT].name); | |
11873 | ||
11874 | /* ebgp-requires-policy (inbound) */ | |
11875 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11876 | && !bgp_inbound_policy_exists(p, filter)) | |
11877 | json_object_string_add( | |
11878 | json_addr, "inboundEbgpRequiresPolicy", | |
11879 | "Inbound updates discarded due to missing policy"); | |
11880 | ||
11881 | /* ebgp-requires-policy (outbound) */ | |
11882 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11883 | && (!bgp_outbound_policy_exists(p, filter))) | |
11884 | json_object_string_add( | |
11885 | json_addr, "outboundEbgpRequiresPolicy", | |
11886 | "Outbound updates discarded due to missing policy"); | |
11887 | ||
11888 | /* unsuppress-map */ | |
11889 | if (filter->usmap.name) | |
11890 | json_object_string_add(json_addr, | |
11891 | "selectiveUnsuppressRouteMap", | |
11892 | filter->usmap.name); | |
11893 | ||
11894 | /* advertise-map */ | |
11895 | if (filter->advmap.aname) { | |
11896 | json_advmap = json_object_new_object(); | |
11897 | json_object_string_add(json_advmap, "condition", | |
11898 | filter->advmap.condition | |
11899 | ? "EXIST" | |
11900 | : "NON_EXIST"); | |
11901 | json_object_string_add(json_advmap, "conditionMap", | |
11902 | filter->advmap.cname); | |
11903 | json_object_string_add(json_advmap, "advertiseMap", | |
11904 | filter->advmap.aname); | |
11905 | json_object_string_add(json_advmap, "advertiseStatus", | |
11906 | filter->advmap.update_type | |
11907 | == ADVERTISE | |
11908 | ? "Advertise" | |
11909 | : "Withdraw"); | |
11910 | json_object_object_add(json_addr, "advertiseMap", | |
11911 | json_advmap); | |
11912 | } | |
11913 | ||
11914 | /* Receive prefix count */ | |
11915 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11916 | p->pcount[afi][safi]); | |
11917 | if (paf && PAF_SUBGRP(paf)) | |
11918 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11919 | (PAF_SUBGRP(paf))->scount); | |
11920 | ||
11921 | /* Maximum prefix */ | |
11922 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11923 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11924 | p->pmax_out[afi][safi]); | |
11925 | ||
11926 | /* Maximum prefix */ | |
11927 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11928 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11929 | p->pmax[afi][safi]); | |
11930 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11931 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11932 | json_object_boolean_true_add( | |
11933 | json_addr, "prefixAllowedMaxWarning"); | |
11934 | json_object_int_add(json_addr, | |
11935 | "prefixAllowedWarningThresh", | |
11936 | p->pmax_threshold[afi][safi]); | |
11937 | if (p->pmax_restart[afi][safi]) | |
11938 | json_object_int_add( | |
11939 | json_addr, | |
11940 | "prefixAllowedRestartIntervalMsecs", | |
11941 | p->pmax_restart[afi][safi] * 60000); | |
11942 | } | |
11943 | json_object_object_add(json_neigh, | |
11944 | get_afi_safi_str(afi, safi, true), | |
11945 | json_addr); | |
11946 | ||
11947 | } else { | |
11948 | filter = &p->filter[afi][safi]; | |
11949 | ||
11950 | vty_out(vty, " For address family: %s\n", | |
11951 | get_afi_safi_str(afi, safi, false)); | |
11952 | ||
11953 | if (peer_group_active(p)) | |
11954 | vty_out(vty, " %s peer-group member\n", | |
11955 | p->group->name); | |
11956 | ||
11957 | paf = peer_af_find(p, afi, safi); | |
11958 | if (paf && PAF_SUBGRP(paf)) { | |
11959 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", | |
11960 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); | |
11961 | vty_out(vty, " Packet Queue length %d\n", | |
11962 | bpacket_queue_virtual_length(paf)); | |
11963 | } else { | |
11964 | vty_out(vty, " Not part of any update group\n"); | |
11965 | } | |
11966 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11967 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11968 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11969 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11970 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11971 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11972 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11973 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11974 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11975 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11976 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11977 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11978 | ||
11979 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11980 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11981 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11982 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11983 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11984 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11985 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11986 | vty_out(vty, | |
11987 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11988 | ORF_TYPE_PREFIX); | |
11989 | bgp_show_peer_afi_orf_cap( | |
11990 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11991 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11992 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11993 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11994 | } | |
11995 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11996 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11997 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11998 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11999 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12000 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12001 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12002 | vty_out(vty, | |
12003 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12004 | ORF_TYPE_PREFIX_OLD); | |
12005 | bgp_show_peer_afi_orf_cap( | |
12006 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12007 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12008 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12009 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12010 | } | |
12011 | ||
12012 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", | |
12013 | p->host, afi, safi); | |
12014 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
12015 | NULL, afi, orf_pfx_name, use_json); | |
12016 | ||
12017 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12018 | PEER_STATUS_ORF_PREFIX_SEND) | |
12019 | || orf_pfx_count) { | |
12020 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12021 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12022 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12023 | vty_out(vty, " sent;"); | |
12024 | if (orf_pfx_count) | |
12025 | vty_out(vty, " received (%d entries)", | |
12026 | orf_pfx_count); | |
12027 | vty_out(vty, "\n"); | |
12028 | } | |
12029 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12030 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12031 | vty_out(vty, | |
12032 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12033 | ||
12034 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12035 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12036 | vty_out(vty, " Route-Reflector Client\n"); | |
12037 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12038 | PEER_FLAG_RSERVER_CLIENT)) | |
12039 | vty_out(vty, " Route-Server Client\n"); | |
12040 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12041 | vty_out(vty, | |
12042 | " Inbound soft reconfiguration allowed\n"); | |
12043 | ||
12044 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12045 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12046 | vty_out(vty, | |
12047 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12048 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12049 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12050 | vty_out(vty, | |
12051 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12052 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12053 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12054 | vty_out(vty, | |
12055 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12056 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12057 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12058 | vty_out(vty, | |
12059 | " Private AS numbers removed in updates to this neighbor\n"); | |
12060 | ||
12061 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) | |
12062 | vty_out(vty, " %s\n", | |
12063 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12064 | ->human_description); | |
12065 | ||
12066 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12067 | vty_out(vty, | |
12068 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12069 | ||
12070 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12071 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12072 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12073 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12074 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12075 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12076 | vty_out(vty, | |
12077 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12078 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12079 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12080 | vty_out(vty, | |
12081 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12082 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12083 | vty_out(vty, | |
12084 | " MED is propagated unchanged to this neighbor\n"); | |
12085 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12086 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12087 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12088 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12089 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12090 | vty_out(vty, | |
12091 | " Community attribute sent to this neighbor"); | |
12092 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12093 | PEER_FLAG_SEND_COMMUNITY) | |
12094 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12095 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12096 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12097 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12098 | vty_out(vty, "(all)\n"); | |
12099 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12100 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12101 | vty_out(vty, "(large)\n"); | |
12102 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12103 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12104 | vty_out(vty, "(extended)\n"); | |
12105 | else | |
12106 | vty_out(vty, "(standard)\n"); | |
12107 | } | |
12108 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12109 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12110 | vty_out(vty, " Default information originate,"); | |
12111 | ||
12112 | if (p->default_rmap[afi][safi].name) | |
12113 | vty_out(vty, " default route-map %s%s,", | |
12114 | p->default_rmap[afi][safi].map ? "*" | |
12115 | : "", | |
12116 | p->default_rmap[afi][safi].name); | |
12117 | if (paf && PAF_SUBGRP(paf) | |
12118 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12119 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12120 | vty_out(vty, " default sent\n"); | |
12121 | else | |
12122 | vty_out(vty, " default not sent\n"); | |
12123 | } | |
12124 | ||
12125 | /* advertise-vni-all */ | |
12126 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
12127 | if (is_evpn_enabled()) | |
12128 | vty_out(vty, " advertise-all-vni\n"); | |
12129 | } | |
12130 | ||
12131 | if (filter->plist[FILTER_IN].name | |
12132 | || filter->dlist[FILTER_IN].name | |
12133 | || filter->aslist[FILTER_IN].name | |
12134 | || filter->map[RMAP_IN].name) | |
12135 | vty_out(vty, " Inbound path policy configured\n"); | |
12136 | if (filter->plist[FILTER_OUT].name | |
12137 | || filter->dlist[FILTER_OUT].name | |
12138 | || filter->aslist[FILTER_OUT].name | |
12139 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12140 | vty_out(vty, " Outbound path policy configured\n"); | |
12141 | ||
12142 | /* prefix-list */ | |
12143 | if (filter->plist[FILTER_IN].name) | |
12144 | vty_out(vty, | |
12145 | " Incoming update prefix filter list is %s%s\n", | |
12146 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12147 | filter->plist[FILTER_IN].name); | |
12148 | if (filter->plist[FILTER_OUT].name) | |
12149 | vty_out(vty, | |
12150 | " Outgoing update prefix filter list is %s%s\n", | |
12151 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12152 | filter->plist[FILTER_OUT].name); | |
12153 | ||
12154 | /* distribute-list */ | |
12155 | if (filter->dlist[FILTER_IN].name) | |
12156 | vty_out(vty, | |
12157 | " Incoming update network filter list is %s%s\n", | |
12158 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12159 | filter->dlist[FILTER_IN].name); | |
12160 | if (filter->dlist[FILTER_OUT].name) | |
12161 | vty_out(vty, | |
12162 | " Outgoing update network filter list is %s%s\n", | |
12163 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12164 | filter->dlist[FILTER_OUT].name); | |
12165 | ||
12166 | /* filter-list. */ | |
12167 | if (filter->aslist[FILTER_IN].name) | |
12168 | vty_out(vty, | |
12169 | " Incoming update AS path filter list is %s%s\n", | |
12170 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12171 | filter->aslist[FILTER_IN].name); | |
12172 | if (filter->aslist[FILTER_OUT].name) | |
12173 | vty_out(vty, | |
12174 | " Outgoing update AS path filter list is %s%s\n", | |
12175 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12176 | filter->aslist[FILTER_OUT].name); | |
12177 | ||
12178 | /* route-map. */ | |
12179 | if (filter->map[RMAP_IN].name) | |
12180 | vty_out(vty, | |
12181 | " Route map for incoming advertisements is %s%s\n", | |
12182 | filter->map[RMAP_IN].map ? "*" : "", | |
12183 | filter->map[RMAP_IN].name); | |
12184 | if (filter->map[RMAP_OUT].name) | |
12185 | vty_out(vty, | |
12186 | " Route map for outgoing advertisements is %s%s\n", | |
12187 | filter->map[RMAP_OUT].map ? "*" : "", | |
12188 | filter->map[RMAP_OUT].name); | |
12189 | ||
12190 | /* ebgp-requires-policy (inbound) */ | |
12191 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) | |
12192 | && !bgp_inbound_policy_exists(p, filter)) | |
12193 | vty_out(vty, | |
12194 | " Inbound updates discarded due to missing policy\n"); | |
12195 | ||
12196 | /* ebgp-requires-policy (outbound) */ | |
12197 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) | |
12198 | && !bgp_outbound_policy_exists(p, filter)) | |
12199 | vty_out(vty, | |
12200 | " Outbound updates discarded due to missing policy\n"); | |
12201 | ||
12202 | /* unsuppress-map */ | |
12203 | if (filter->usmap.name) | |
12204 | vty_out(vty, | |
12205 | " Route map for selective unsuppress is %s%s\n", | |
12206 | filter->usmap.map ? "*" : "", | |
12207 | filter->usmap.name); | |
12208 | ||
12209 | /* advertise-map */ | |
12210 | if (filter->advmap.aname && filter->advmap.cname) | |
12211 | vty_out(vty, | |
12212 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12213 | filter->advmap.condition ? "EXIST" | |
12214 | : "NON_EXIST", | |
12215 | filter->advmap.cmap ? "*" : "", | |
12216 | filter->advmap.cname, | |
12217 | filter->advmap.amap ? "*" : "", | |
12218 | filter->advmap.aname, | |
12219 | filter->advmap.update_type == ADVERTISE | |
12220 | ? "Advertise" | |
12221 | : "Withdraw"); | |
12222 | ||
12223 | /* Receive prefix count */ | |
12224 | vty_out(vty, " %u accepted prefixes\n", | |
12225 | p->pcount[afi][safi]); | |
12226 | ||
12227 | /* maximum-prefix-out */ | |
12228 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12229 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12230 | vty_out(vty, | |
12231 | " Maximum allowed prefixes sent %u\n", | |
12232 | p->pmax_out[afi][safi]); | |
12233 | ||
12234 | /* Maximum prefix */ | |
12235 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12236 | vty_out(vty, | |
12237 | " Maximum prefixes allowed %u%s\n", | |
12238 | p->pmax[afi][safi], | |
12239 | CHECK_FLAG(p->af_flags[afi][safi], | |
12240 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12241 | ? " (warning-only)" | |
12242 | : ""); | |
12243 | vty_out(vty, " Threshold for warning message %d%%", | |
12244 | p->pmax_threshold[afi][safi]); | |
12245 | if (p->pmax_restart[afi][safi]) | |
12246 | vty_out(vty, ", restart interval %d min", | |
12247 | p->pmax_restart[afi][safi]); | |
12248 | vty_out(vty, "\n"); | |
12249 | } | |
12250 | ||
12251 | vty_out(vty, "\n"); | |
12252 | } | |
12253 | } | |
12254 | ||
12255 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, | |
12256 | json_object *json) | |
12257 | { | |
12258 | struct bgp *bgp; | |
12259 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12260 | char timebuf[BGP_UPTIME_LEN]; | |
12261 | char dn_flag[2]; | |
12262 | afi_t afi; | |
12263 | safi_t safi; | |
12264 | uint16_t i; | |
12265 | uint8_t *msg; | |
12266 | json_object *json_neigh = NULL; | |
12267 | time_t epoch_tbuf; | |
12268 | uint32_t sync_tcp_mss; | |
12269 | ||
12270 | bgp = p->bgp; | |
12271 | ||
12272 | if (use_json) | |
12273 | json_neigh = json_object_new_object(); | |
12274 | ||
12275 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12276 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12277 | dn_flag[0] = '*'; | |
12278 | ||
12279 | if (!use_json) { | |
12280 | if (p->conf_if) /* Configured interface name. */ | |
12281 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12282 | BGP_PEER_SU_UNSPEC(p) | |
12283 | ? "None" | |
12284 | : sockunion2str(&p->su, buf, | |
12285 | SU_ADDRSTRLEN)); | |
12286 | else /* Configured IP address. */ | |
12287 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12288 | p->host); | |
12289 | } | |
12290 | ||
12291 | if (use_json) { | |
12292 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12293 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12294 | "none"); | |
12295 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12296 | json_object_string_add( | |
12297 | json_neigh, "bgpNeighborAddr", | |
12298 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12299 | ||
12300 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12301 | ||
12302 | if (p->change_local_as) | |
12303 | json_object_int_add(json_neigh, "localAs", | |
12304 | p->change_local_as); | |
12305 | else | |
12306 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12307 | ||
12308 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12309 | json_object_boolean_true_add(json_neigh, | |
12310 | "localAsNoPrepend"); | |
12311 | ||
12312 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12313 | json_object_boolean_true_add(json_neigh, | |
12314 | "localAsReplaceAs"); | |
12315 | } else { | |
12316 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12317 | || (p->as_type == AS_INTERNAL)) | |
12318 | vty_out(vty, "remote AS %u, ", p->as); | |
12319 | else | |
12320 | vty_out(vty, "remote AS Unspecified, "); | |
12321 | vty_out(vty, "local AS %u%s%s, ", | |
12322 | p->change_local_as ? p->change_local_as : p->local_as, | |
12323 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12324 | ? " no-prepend" | |
12325 | : "", | |
12326 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12327 | ? " replace-as" | |
12328 | : ""); | |
12329 | } | |
12330 | /* peer type internal or confed-internal */ | |
12331 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
12332 | if (use_json) { | |
12333 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12334 | json_object_boolean_true_add( | |
12335 | json_neigh, "nbrConfedInternalLink"); | |
12336 | else | |
12337 | json_object_boolean_true_add(json_neigh, | |
12338 | "nbrInternalLink"); | |
12339 | } else { | |
12340 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12341 | vty_out(vty, "confed-internal link\n"); | |
12342 | else | |
12343 | vty_out(vty, "internal link\n"); | |
12344 | } | |
12345 | /* peer type external or confed-external */ | |
12346 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
12347 | if (use_json) { | |
12348 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12349 | json_object_boolean_true_add( | |
12350 | json_neigh, "nbrConfedExternalLink"); | |
12351 | else | |
12352 | json_object_boolean_true_add(json_neigh, | |
12353 | "nbrExternalLink"); | |
12354 | } else { | |
12355 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12356 | vty_out(vty, "confed-external link\n"); | |
12357 | else | |
12358 | vty_out(vty, "external link\n"); | |
12359 | } | |
12360 | } else { | |
12361 | if (use_json) | |
12362 | json_object_boolean_true_add(json_neigh, | |
12363 | "nbrUnspecifiedLink"); | |
12364 | else | |
12365 | vty_out(vty, "unspecified link\n"); | |
12366 | } | |
12367 | ||
12368 | /* Description. */ | |
12369 | if (p->desc) { | |
12370 | if (use_json) | |
12371 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12372 | else | |
12373 | vty_out(vty, " Description: %s\n", p->desc); | |
12374 | } | |
12375 | ||
12376 | if (p->hostname) { | |
12377 | if (use_json) { | |
12378 | if (p->hostname) | |
12379 | json_object_string_add(json_neigh, "hostname", | |
12380 | p->hostname); | |
12381 | ||
12382 | if (p->domainname) | |
12383 | json_object_string_add(json_neigh, "domainname", | |
12384 | p->domainname); | |
12385 | } else { | |
12386 | if (p->domainname && (p->domainname[0] != '\0')) | |
12387 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12388 | p->domainname); | |
12389 | else | |
12390 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12391 | } | |
12392 | } | |
12393 | ||
12394 | /* Peer-group */ | |
12395 | if (p->group) { | |
12396 | if (use_json) { | |
12397 | json_object_string_add(json_neigh, "peerGroup", | |
12398 | p->group->name); | |
12399 | ||
12400 | if (dn_flag[0]) { | |
12401 | struct prefix prefix, *range = NULL; | |
12402 | ||
12403 | if (sockunion2hostprefix(&(p->su), &prefix)) | |
12404 | range = peer_group_lookup_dynamic_neighbor_range( | |
12405 | p->group, &prefix); | |
12406 | ||
12407 | if (range) { | |
12408 | json_object_string_addf( | |
12409 | json_neigh, | |
12410 | "peerSubnetRangeGroup", "%pFX", | |
12411 | range); | |
12412 | } | |
12413 | } | |
12414 | } else { | |
12415 | vty_out(vty, | |
12416 | " Member of peer-group %s for session parameters\n", | |
12417 | p->group->name); | |
12418 | ||
12419 | if (dn_flag[0]) { | |
12420 | struct prefix prefix, *range = NULL; | |
12421 | ||
12422 | if (sockunion2hostprefix(&(p->su), &prefix)) | |
12423 | range = peer_group_lookup_dynamic_neighbor_range( | |
12424 | p->group, &prefix); | |
12425 | ||
12426 | if (range) { | |
12427 | vty_out(vty, | |
12428 | " Belongs to the subnet range group: %pFX\n", | |
12429 | range); | |
12430 | } | |
12431 | } | |
12432 | } | |
12433 | } | |
12434 | ||
12435 | if (use_json) { | |
12436 | /* Administrative shutdown. */ | |
12437 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) | |
12438 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
12439 | json_object_boolean_true_add(json_neigh, | |
12440 | "adminShutDown"); | |
12441 | ||
12442 | /* BGP Version. */ | |
12443 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12444 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", | |
12445 | &p->remote_id); | |
12446 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
12447 | &bgp->router_id); | |
12448 | ||
12449 | /* Confederation */ | |
12450 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12451 | && bgp_confederation_peers_check(bgp, p->as)) | |
12452 | json_object_boolean_true_add(json_neigh, | |
12453 | "nbrCommonAdmin"); | |
12454 | ||
12455 | /* Status. */ | |
12456 | json_object_string_add( | |
12457 | json_neigh, "bgpState", | |
12458 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12459 | ||
12460 | if (peer_established(p)) { | |
12461 | time_t uptime; | |
12462 | ||
12463 | uptime = bgp_clock(); | |
12464 | uptime -= p->uptime; | |
12465 | epoch_tbuf = time(NULL) - uptime; | |
12466 | ||
12467 | json_object_int_add(json_neigh, "bgpTimerUpMsec", | |
12468 | uptime * 1000); | |
12469 | json_object_string_add(json_neigh, "bgpTimerUpString", | |
12470 | peer_uptime(p->uptime, timebuf, | |
12471 | BGP_UPTIME_LEN, 0, | |
12472 | NULL)); | |
12473 | json_object_int_add(json_neigh, | |
12474 | "bgpTimerUpEstablishedEpoch", | |
12475 | epoch_tbuf); | |
12476 | } | |
12477 | ||
12478 | else if (p->status == Active) { | |
12479 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12480 | json_object_string_add(json_neigh, "bgpStateIs", | |
12481 | "passive"); | |
12482 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12483 | json_object_string_add(json_neigh, "bgpStateIs", | |
12484 | "passiveNSF"); | |
12485 | } | |
12486 | ||
12487 | /* read timer */ | |
12488 | time_t uptime; | |
12489 | struct tm tm; | |
12490 | ||
12491 | uptime = bgp_clock(); | |
12492 | uptime -= p->readtime; | |
12493 | gmtime_r(&uptime, &tm); | |
12494 | ||
12495 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
12496 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) | |
12497 | + (tm.tm_hour * 3600000)); | |
12498 | ||
12499 | uptime = bgp_clock(); | |
12500 | uptime -= p->last_write; | |
12501 | gmtime_r(&uptime, &tm); | |
12502 | ||
12503 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
12504 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) | |
12505 | + (tm.tm_hour * 3600000)); | |
12506 | ||
12507 | uptime = bgp_clock(); | |
12508 | uptime -= p->update_time; | |
12509 | gmtime_r(&uptime, &tm); | |
12510 | ||
12511 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
12512 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) | |
12513 | + (tm.tm_hour * 3600000)); | |
12514 | ||
12515 | /* Configured timer values. */ | |
12516 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12517 | p->v_holdtime * 1000); | |
12518 | json_object_int_add(json_neigh, | |
12519 | "bgpTimerKeepAliveIntervalMsecs", | |
12520 | p->v_keepalive * 1000); | |
12521 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { | |
12522 | json_object_int_add(json_neigh, | |
12523 | "bgpTimerDelayOpenTimeMsecs", | |
12524 | p->v_delayopen * 1000); | |
12525 | } | |
12526 | ||
12527 | /* Configured and Synced tcp-mss value for peer */ | |
12528 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12529 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12530 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12531 | p->tcp_mss); | |
12532 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12533 | sync_tcp_mss); | |
12534 | } | |
12535 | ||
12536 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { | |
12537 | json_object_int_add(json_neigh, | |
12538 | "bgpTimerConfiguredHoldTimeMsecs", | |
12539 | p->holdtime * 1000); | |
12540 | json_object_int_add( | |
12541 | json_neigh, | |
12542 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12543 | p->keepalive * 1000); | |
12544 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
12545 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
12546 | json_object_int_add(json_neigh, | |
12547 | "bgpTimerConfiguredHoldTimeMsecs", | |
12548 | bgp->default_holdtime); | |
12549 | json_object_int_add( | |
12550 | json_neigh, | |
12551 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12552 | bgp->default_keepalive); | |
12553 | } | |
12554 | ||
12555 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12556 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12557 | json_object_boolean_true_add( | |
12558 | json_neigh, "extendedOptionalParametersLength"); | |
12559 | else | |
12560 | json_object_boolean_false_add( | |
12561 | json_neigh, "extendedOptionalParametersLength"); | |
12562 | } else { | |
12563 | /* Administrative shutdown. */ | |
12564 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) | |
12565 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
12566 | vty_out(vty, " Administratively shut down\n"); | |
12567 | ||
12568 | /* BGP Version. */ | |
12569 | vty_out(vty, " BGP version 4"); | |
12570 | vty_out(vty, ", remote router ID %s", | |
12571 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
12572 | vty_out(vty, ", local router ID %s\n", | |
12573 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12574 | sizeof(buf1))); | |
12575 | ||
12576 | /* Confederation */ | |
12577 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12578 | && bgp_confederation_peers_check(bgp, p->as)) | |
12579 | vty_out(vty, | |
12580 | " Neighbor under common administration\n"); | |
12581 | ||
12582 | /* Status. */ | |
12583 | vty_out(vty, " BGP state = %s", | |
12584 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12585 | ||
12586 | if (peer_established(p)) | |
12587 | vty_out(vty, ", up for %8s", | |
12588 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12589 | 0, NULL)); | |
12590 | ||
12591 | else if (p->status == Active) { | |
12592 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12593 | vty_out(vty, " (passive)"); | |
12594 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12595 | vty_out(vty, " (NSF passive)"); | |
12596 | } | |
12597 | vty_out(vty, "\n"); | |
12598 | ||
12599 | /* read timer */ | |
12600 | vty_out(vty, " Last read %s", | |
12601 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12602 | NULL)); | |
12603 | vty_out(vty, ", Last write %s\n", | |
12604 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12605 | NULL)); | |
12606 | ||
12607 | /* Configured timer values. */ | |
12608 | vty_out(vty, | |
12609 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12610 | p->v_holdtime, p->v_keepalive); | |
12611 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { | |
12612 | vty_out(vty, " Configured hold time is %d", | |
12613 | p->holdtime); | |
12614 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12615 | p->keepalive); | |
12616 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
12617 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
12618 | vty_out(vty, " Configured hold time is %d", | |
12619 | bgp->default_holdtime); | |
12620 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12621 | bgp->default_keepalive); | |
12622 | } | |
12623 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) | |
12624 | vty_out(vty, | |
12625 | " Configured DelayOpenTime is %d seconds\n", | |
12626 | p->delayopen); | |
12627 | ||
12628 | /* Configured and synced tcp-mss value for peer */ | |
12629 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12630 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12631 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12632 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12633 | } | |
12634 | ||
12635 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12636 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12637 | vty_out(vty, | |
12638 | " Extended Optional Parameters Length is enabled\n"); | |
12639 | } | |
12640 | /* Capability. */ | |
12641 | if (peer_established(p) && | |
12642 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
12643 | if (use_json) { | |
12644 | json_object *json_cap = NULL; | |
12645 | ||
12646 | json_cap = json_object_new_object(); | |
12647 | ||
12648 | /* AS4 */ | |
12649 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
12650 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12651 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
12652 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
12653 | json_object_string_add( | |
12654 | json_cap, "4byteAs", | |
12655 | "advertisedAndReceived"); | |
12656 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
12657 | json_object_string_add(json_cap, | |
12658 | "4byteAs", | |
12659 | "advertised"); | |
12660 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
12661 | json_object_string_add(json_cap, | |
12662 | "4byteAs", | |
12663 | "received"); | |
12664 | } | |
12665 | ||
12666 | /* Extended Message Support */ | |
12667 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
12668 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12669 | json_object_string_add(json_cap, | |
12670 | "extendedMessage", | |
12671 | "advertisedAndReceived"); | |
12672 | else if (CHECK_FLAG(p->cap, | |
12673 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12674 | json_object_string_add(json_cap, | |
12675 | "extendedMessage", | |
12676 | "advertised"); | |
12677 | else if (CHECK_FLAG(p->cap, | |
12678 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12679 | json_object_string_add(json_cap, | |
12680 | "extendedMessage", | |
12681 | "received"); | |
12682 | ||
12683 | /* AddPath */ | |
12684 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
12685 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
12686 | json_object *json_add = NULL; | |
12687 | const char *print_store; | |
12688 | ||
12689 | json_add = json_object_new_object(); | |
12690 | ||
12691 | FOREACH_AFI_SAFI (afi, safi) { | |
12692 | json_object *json_sub = NULL; | |
12693 | json_sub = json_object_new_object(); | |
12694 | print_store = get_afi_safi_str( | |
12695 | afi, safi, true); | |
12696 | ||
12697 | if (CHECK_FLAG( | |
12698 | p->af_cap[afi][safi], | |
12699 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12700 | CHECK_FLAG( | |
12701 | p->af_cap[afi][safi], | |
12702 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
12703 | if (CHECK_FLAG( | |
12704 | p->af_cap[afi] | |
12705 | [safi], | |
12706 | PEER_CAP_ADDPATH_AF_TX_ADV) && | |
12707 | CHECK_FLAG( | |
12708 | p->af_cap[afi] | |
12709 | [safi], | |
12710 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12711 | json_object_boolean_true_add( | |
12712 | json_sub, | |
12713 | "txAdvertisedAndReceived"); | |
12714 | else if ( | |
12715 | CHECK_FLAG( | |
12716 | p->af_cap[afi] | |
12717 | [safi], | |
12718 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12719 | json_object_boolean_true_add( | |
12720 | json_sub, | |
12721 | "txAdvertised"); | |
12722 | else if ( | |
12723 | CHECK_FLAG( | |
12724 | p->af_cap[afi] | |
12725 | [safi], | |
12726 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12727 | json_object_boolean_true_add( | |
12728 | json_sub, | |
12729 | "txReceived"); | |
12730 | } | |
12731 | ||
12732 | if (CHECK_FLAG( | |
12733 | p->af_cap[afi][safi], | |
12734 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12735 | CHECK_FLAG( | |
12736 | p->af_cap[afi][safi], | |
12737 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
12738 | if (CHECK_FLAG( | |
12739 | p->af_cap[afi] | |
12740 | [safi], | |
12741 | PEER_CAP_ADDPATH_AF_RX_ADV) && | |
12742 | CHECK_FLAG( | |
12743 | p->af_cap[afi] | |
12744 | [safi], | |
12745 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12746 | json_object_boolean_true_add( | |
12747 | json_sub, | |
12748 | "rxAdvertisedAndReceived"); | |
12749 | else if ( | |
12750 | CHECK_FLAG( | |
12751 | p->af_cap[afi] | |
12752 | [safi], | |
12753 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12754 | json_object_boolean_true_add( | |
12755 | json_sub, | |
12756 | "rxAdvertised"); | |
12757 | else if ( | |
12758 | CHECK_FLAG( | |
12759 | p->af_cap[afi] | |
12760 | [safi], | |
12761 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12762 | json_object_boolean_true_add( | |
12763 | json_sub, | |
12764 | "rxReceived"); | |
12765 | } | |
12766 | ||
12767 | if (CHECK_FLAG( | |
12768 | p->af_cap[afi][safi], | |
12769 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12770 | CHECK_FLAG( | |
12771 | p->af_cap[afi][safi], | |
12772 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
12773 | CHECK_FLAG( | |
12774 | p->af_cap[afi][safi], | |
12775 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12776 | CHECK_FLAG( | |
12777 | p->af_cap[afi][safi], | |
12778 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12779 | json_object_object_add( | |
12780 | json_add, print_store, | |
12781 | json_sub); | |
12782 | else | |
12783 | json_object_free(json_sub); | |
12784 | } | |
12785 | ||
12786 | json_object_object_add(json_cap, "addPath", | |
12787 | json_add); | |
12788 | } | |
12789 | ||
12790 | /* Dynamic */ | |
12791 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
12792 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
12793 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
12794 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
12795 | json_object_string_add( | |
12796 | json_cap, "dynamic", | |
12797 | "advertisedAndReceived"); | |
12798 | else if (CHECK_FLAG(p->cap, | |
12799 | PEER_CAP_DYNAMIC_ADV)) | |
12800 | json_object_string_add(json_cap, | |
12801 | "dynamic", | |
12802 | "advertised"); | |
12803 | else if (CHECK_FLAG(p->cap, | |
12804 | PEER_CAP_DYNAMIC_RCV)) | |
12805 | json_object_string_add(json_cap, | |
12806 | "dynamic", | |
12807 | "received"); | |
12808 | } | |
12809 | ||
12810 | /* Extended nexthop */ | |
12811 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
12812 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12813 | json_object *json_nxt = NULL; | |
12814 | const char *print_store; | |
12815 | ||
12816 | ||
12817 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && | |
12818 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12819 | json_object_string_add( | |
12820 | json_cap, "extendedNexthop", | |
12821 | "advertisedAndReceived"); | |
12822 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
12823 | json_object_string_add( | |
12824 | json_cap, "extendedNexthop", | |
12825 | "advertised"); | |
12826 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12827 | json_object_string_add( | |
12828 | json_cap, "extendedNexthop", | |
12829 | "received"); | |
12830 | ||
12831 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { | |
12832 | json_nxt = json_object_new_object(); | |
12833 | ||
12834 | for (safi = SAFI_UNICAST; | |
12835 | safi < SAFI_MAX; safi++) { | |
12836 | if (CHECK_FLAG( | |
12837 | p->af_cap[AFI_IP] | |
12838 | [safi], | |
12839 | PEER_CAP_ENHE_AF_RCV)) { | |
12840 | print_store = | |
12841 | get_afi_safi_str( | |
12842 | AFI_IP, | |
12843 | safi, | |
12844 | true); | |
12845 | json_object_string_add( | |
12846 | json_nxt, | |
12847 | print_store, | |
12848 | "recieved"); /* misspelled for compatibility */ | |
12849 | } | |
12850 | } | |
12851 | json_object_object_add( | |
12852 | json_cap, | |
12853 | "extendedNexthopFamililesByPeer", | |
12854 | json_nxt); | |
12855 | } | |
12856 | } | |
12857 | ||
12858 | /* Long-lived Graceful Restart */ | |
12859 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
12860 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
12861 | json_object *json_llgr = NULL; | |
12862 | const char *afi_safi_str; | |
12863 | ||
12864 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && | |
12865 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
12866 | json_object_string_add( | |
12867 | json_cap, | |
12868 | "longLivedGracefulRestart", | |
12869 | "advertisedAndReceived"); | |
12870 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
12871 | json_object_string_add( | |
12872 | json_cap, | |
12873 | "longLivedGracefulRestart", | |
12874 | "advertised"); | |
12875 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
12876 | json_object_string_add( | |
12877 | json_cap, | |
12878 | "longLivedGracefulRestart", | |
12879 | "received"); | |
12880 | ||
12881 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { | |
12882 | json_llgr = json_object_new_object(); | |
12883 | ||
12884 | FOREACH_AFI_SAFI (afi, safi) { | |
12885 | if (CHECK_FLAG( | |
12886 | p->af_cap[afi] | |
12887 | [safi], | |
12888 | PEER_CAP_ENHE_AF_RCV)) { | |
12889 | afi_safi_str = | |
12890 | get_afi_safi_str( | |
12891 | afi, | |
12892 | safi, | |
12893 | true); | |
12894 | json_object_string_add( | |
12895 | json_llgr, | |
12896 | afi_safi_str, | |
12897 | "received"); | |
12898 | } | |
12899 | } | |
12900 | json_object_object_add( | |
12901 | json_cap, | |
12902 | "longLivedGracefulRestartByPeer", | |
12903 | json_llgr); | |
12904 | } | |
12905 | } | |
12906 | ||
12907 | /* Route Refresh */ | |
12908 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
12909 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
12910 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
12911 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
12912 | (CHECK_FLAG(p->cap, | |
12913 | PEER_CAP_REFRESH_NEW_RCV) || | |
12914 | CHECK_FLAG(p->cap, | |
12915 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12916 | if (CHECK_FLAG( | |
12917 | p->cap, | |
12918 | PEER_CAP_REFRESH_OLD_RCV) && | |
12919 | CHECK_FLAG( | |
12920 | p->cap, | |
12921 | PEER_CAP_REFRESH_NEW_RCV)) | |
12922 | json_object_string_add( | |
12923 | json_cap, | |
12924 | "routeRefresh", | |
12925 | "advertisedAndReceivedOldNew"); | |
12926 | else { | |
12927 | if (CHECK_FLAG( | |
12928 | p->cap, | |
12929 | PEER_CAP_REFRESH_OLD_RCV)) | |
12930 | json_object_string_add( | |
12931 | json_cap, | |
12932 | "routeRefresh", | |
12933 | "advertisedAndReceivedOld"); | |
12934 | else | |
12935 | json_object_string_add( | |
12936 | json_cap, | |
12937 | "routeRefresh", | |
12938 | "advertisedAndReceivedNew"); | |
12939 | } | |
12940 | } else if (CHECK_FLAG(p->cap, | |
12941 | PEER_CAP_REFRESH_ADV)) | |
12942 | json_object_string_add(json_cap, | |
12943 | "routeRefresh", | |
12944 | "advertised"); | |
12945 | else if (CHECK_FLAG(p->cap, | |
12946 | PEER_CAP_REFRESH_NEW_RCV) || | |
12947 | CHECK_FLAG(p->cap, | |
12948 | PEER_CAP_REFRESH_OLD_RCV)) | |
12949 | json_object_string_add(json_cap, | |
12950 | "routeRefresh", | |
12951 | "received"); | |
12952 | } | |
12953 | ||
12954 | /* Enhanced Route Refresh */ | |
12955 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
12956 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
12957 | if (CHECK_FLAG(p->cap, | |
12958 | PEER_CAP_ENHANCED_RR_ADV) && | |
12959 | CHECK_FLAG(p->cap, | |
12960 | PEER_CAP_ENHANCED_RR_RCV)) | |
12961 | json_object_string_add( | |
12962 | json_cap, | |
12963 | "enhancedRouteRefresh", | |
12964 | "advertisedAndReceived"); | |
12965 | else if (CHECK_FLAG(p->cap, | |
12966 | PEER_CAP_ENHANCED_RR_ADV)) | |
12967 | json_object_string_add( | |
12968 | json_cap, | |
12969 | "enhancedRouteRefresh", | |
12970 | "advertised"); | |
12971 | else if (CHECK_FLAG(p->cap, | |
12972 | PEER_CAP_ENHANCED_RR_RCV)) | |
12973 | json_object_string_add( | |
12974 | json_cap, | |
12975 | "enhancedRouteRefresh", | |
12976 | "received"); | |
12977 | } | |
12978 | ||
12979 | /* Multiprotocol Extensions */ | |
12980 | json_object *json_multi = NULL; | |
12981 | ||
12982 | json_multi = json_object_new_object(); | |
12983 | ||
12984 | FOREACH_AFI_SAFI (afi, safi) { | |
12985 | if (p->afc_adv[afi][safi] || | |
12986 | p->afc_recv[afi][safi]) { | |
12987 | json_object *json_exten = NULL; | |
12988 | json_exten = json_object_new_object(); | |
12989 | ||
12990 | if (p->afc_adv[afi][safi] && | |
12991 | p->afc_recv[afi][safi]) | |
12992 | json_object_boolean_true_add( | |
12993 | json_exten, | |
12994 | "advertisedAndReceived"); | |
12995 | else if (p->afc_adv[afi][safi]) | |
12996 | json_object_boolean_true_add( | |
12997 | json_exten, | |
12998 | "advertised"); | |
12999 | else if (p->afc_recv[afi][safi]) | |
13000 | json_object_boolean_true_add( | |
13001 | json_exten, "received"); | |
13002 | ||
13003 | json_object_object_add( | |
13004 | json_multi, | |
13005 | get_afi_safi_str(afi, safi, | |
13006 | true), | |
13007 | json_exten); | |
13008 | } | |
13009 | } | |
13010 | json_object_object_add(json_cap, | |
13011 | "multiprotocolExtensions", | |
13012 | json_multi); | |
13013 | ||
13014 | /* Hostname capabilities */ | |
13015 | json_object *json_hname = NULL; | |
13016 | ||
13017 | json_hname = json_object_new_object(); | |
13018 | ||
13019 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13020 | json_object_string_add( | |
13021 | json_hname, "advHostName", | |
13022 | bgp->peer_self->hostname | |
13023 | ? bgp->peer_self->hostname | |
13024 | : "n/a"); | |
13025 | json_object_string_add( | |
13026 | json_hname, "advDomainName", | |
13027 | bgp->peer_self->domainname | |
13028 | ? bgp->peer_self->domainname | |
13029 | : "n/a"); | |
13030 | } | |
13031 | ||
13032 | ||
13033 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13034 | json_object_string_add( | |
13035 | json_hname, "rcvHostName", | |
13036 | p->hostname ? p->hostname : "n/a"); | |
13037 | json_object_string_add( | |
13038 | json_hname, "rcvDomainName", | |
13039 | p->domainname ? p->domainname : "n/a"); | |
13040 | } | |
13041 | ||
13042 | json_object_object_add(json_cap, "hostName", | |
13043 | json_hname); | |
13044 | ||
13045 | /* Gracefull Restart */ | |
13046 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
13047 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13048 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13049 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
13050 | json_object_string_add( | |
13051 | json_cap, "gracefulRestart", | |
13052 | "advertisedAndReceived"); | |
13053 | else if (CHECK_FLAG(p->cap, | |
13054 | PEER_CAP_RESTART_ADV)) | |
13055 | json_object_string_add( | |
13056 | json_cap, | |
13057 | "gracefulRestartCapability", | |
13058 | "advertised"); | |
13059 | else if (CHECK_FLAG(p->cap, | |
13060 | PEER_CAP_RESTART_RCV)) | |
13061 | json_object_string_add( | |
13062 | json_cap, | |
13063 | "gracefulRestartCapability", | |
13064 | "received"); | |
13065 | ||
13066 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13067 | int restart_af_count = 0; | |
13068 | json_object *json_restart = NULL; | |
13069 | json_restart = json_object_new_object(); | |
13070 | ||
13071 | json_object_int_add( | |
13072 | json_cap, | |
13073 | "gracefulRestartRemoteTimerMsecs", | |
13074 | p->v_gr_restart * 1000); | |
13075 | ||
13076 | FOREACH_AFI_SAFI (afi, safi) { | |
13077 | if (CHECK_FLAG( | |
13078 | p->af_cap[afi] | |
13079 | [safi], | |
13080 | PEER_CAP_RESTART_AF_RCV)) { | |
13081 | json_object *json_sub = | |
13082 | NULL; | |
13083 | json_sub = | |
13084 | json_object_new_object(); | |
13085 | ||
13086 | if (CHECK_FLAG( | |
13087 | p->af_cap | |
13088 | [afi] | |
13089 | [safi], | |
13090 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
13091 | json_object_boolean_true_add( | |
13092 | json_sub, | |
13093 | "preserved"); | |
13094 | restart_af_count++; | |
13095 | json_object_object_add( | |
13096 | json_restart, | |
13097 | get_afi_safi_str( | |
13098 | afi, | |
13099 | safi, | |
13100 | true), | |
13101 | json_sub); | |
13102 | } | |
13103 | } | |
13104 | if (!restart_af_count) { | |
13105 | json_object_string_add( | |
13106 | json_cap, | |
13107 | "addressFamiliesByPeer", | |
13108 | "none"); | |
13109 | json_object_free(json_restart); | |
13110 | } else | |
13111 | json_object_object_add( | |
13112 | json_cap, | |
13113 | "addressFamiliesByPeer", | |
13114 | json_restart); | |
13115 | } | |
13116 | } | |
13117 | json_object_object_add( | |
13118 | json_neigh, "neighborCapabilities", json_cap); | |
13119 | } else { | |
13120 | vty_out(vty, " Neighbor capabilities:\n"); | |
13121 | ||
13122 | /* AS4 */ | |
13123 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13124 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13125 | vty_out(vty, " 4 Byte AS:"); | |
13126 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13127 | vty_out(vty, " advertised"); | |
13128 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13129 | vty_out(vty, " %sreceived", | |
13130 | CHECK_FLAG(p->cap, | |
13131 | PEER_CAP_AS4_ADV) | |
13132 | ? "and " | |
13133 | : ""); | |
13134 | vty_out(vty, "\n"); | |
13135 | } | |
13136 | ||
13137 | /* Extended Message Support */ | |
13138 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13139 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13140 | vty_out(vty, " Extended Message:"); | |
13141 | if (CHECK_FLAG(p->cap, | |
13142 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13143 | vty_out(vty, " advertised"); | |
13144 | if (CHECK_FLAG(p->cap, | |
13145 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13146 | vty_out(vty, " %sreceived", | |
13147 | CHECK_FLAG( | |
13148 | p->cap, | |
13149 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13150 | ? "and " | |
13151 | : ""); | |
13152 | vty_out(vty, "\n"); | |
13153 | } | |
13154 | ||
13155 | /* AddPath */ | |
13156 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13157 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13158 | vty_out(vty, " AddPath:\n"); | |
13159 | ||
13160 | FOREACH_AFI_SAFI (afi, safi) { | |
13161 | if (CHECK_FLAG( | |
13162 | p->af_cap[afi][safi], | |
13163 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13164 | CHECK_FLAG( | |
13165 | p->af_cap[afi][safi], | |
13166 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13167 | vty_out(vty, " %s: TX ", | |
13168 | get_afi_safi_str( | |
13169 | afi, safi, | |
13170 | false)); | |
13171 | ||
13172 | if (CHECK_FLAG( | |
13173 | p->af_cap[afi] | |
13174 | [safi], | |
13175 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13176 | vty_out(vty, | |
13177 | "advertised"); | |
13178 | ||
13179 | if (CHECK_FLAG( | |
13180 | p->af_cap[afi] | |
13181 | [safi], | |
13182 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13183 | vty_out(vty, | |
13184 | "%sreceived", | |
13185 | CHECK_FLAG( | |
13186 | p->af_cap | |
13187 | [afi] | |
13188 | [safi], | |
13189 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13190 | ? " and " | |
13191 | : ""); | |
13192 | ||
13193 | vty_out(vty, "\n"); | |
13194 | } | |
13195 | ||
13196 | if (CHECK_FLAG( | |
13197 | p->af_cap[afi][safi], | |
13198 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13199 | CHECK_FLAG( | |
13200 | p->af_cap[afi][safi], | |
13201 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13202 | vty_out(vty, " %s: RX ", | |
13203 | get_afi_safi_str( | |
13204 | afi, safi, | |
13205 | false)); | |
13206 | ||
13207 | if (CHECK_FLAG( | |
13208 | p->af_cap[afi] | |
13209 | [safi], | |
13210 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13211 | vty_out(vty, | |
13212 | "advertised"); | |
13213 | ||
13214 | if (CHECK_FLAG( | |
13215 | p->af_cap[afi] | |
13216 | [safi], | |
13217 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13218 | vty_out(vty, | |
13219 | "%sreceived", | |
13220 | CHECK_FLAG( | |
13221 | p->af_cap | |
13222 | [afi] | |
13223 | [safi], | |
13224 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13225 | ? " and " | |
13226 | : ""); | |
13227 | ||
13228 | vty_out(vty, "\n"); | |
13229 | } | |
13230 | } | |
13231 | } | |
13232 | ||
13233 | /* Dynamic */ | |
13234 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13235 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13236 | vty_out(vty, " Dynamic:"); | |
13237 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13238 | vty_out(vty, " advertised"); | |
13239 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13240 | vty_out(vty, " %sreceived", | |
13241 | CHECK_FLAG(p->cap, | |
13242 | PEER_CAP_DYNAMIC_ADV) | |
13243 | ? "and " | |
13244 | : ""); | |
13245 | vty_out(vty, "\n"); | |
13246 | } | |
13247 | ||
13248 | /* Extended nexthop */ | |
13249 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13250 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13251 | vty_out(vty, " Extended nexthop:"); | |
13252 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13253 | vty_out(vty, " advertised"); | |
13254 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13255 | vty_out(vty, " %sreceived", | |
13256 | CHECK_FLAG(p->cap, | |
13257 | PEER_CAP_ENHE_ADV) | |
13258 | ? "and " | |
13259 | : ""); | |
13260 | vty_out(vty, "\n"); | |
13261 | ||
13262 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { | |
13263 | vty_out(vty, | |
13264 | " Address families by peer:\n "); | |
13265 | for (safi = SAFI_UNICAST; | |
13266 | safi < SAFI_MAX; safi++) | |
13267 | if (CHECK_FLAG( | |
13268 | p->af_cap[AFI_IP] | |
13269 | [safi], | |
13270 | PEER_CAP_ENHE_AF_RCV)) | |
13271 | vty_out(vty, | |
13272 | " %s\n", | |
13273 | get_afi_safi_str( | |
13274 | AFI_IP, | |
13275 | safi, | |
13276 | false)); | |
13277 | } | |
13278 | } | |
13279 | ||
13280 | /* Long-lived Graceful Restart */ | |
13281 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13282 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13283 | vty_out(vty, | |
13284 | " Long-lived Graceful Restart:"); | |
13285 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13286 | vty_out(vty, " advertised"); | |
13287 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13288 | vty_out(vty, " %sreceived", | |
13289 | CHECK_FLAG(p->cap, | |
13290 | PEER_CAP_LLGR_ADV) | |
13291 | ? "and " | |
13292 | : ""); | |
13293 | vty_out(vty, "\n"); | |
13294 | ||
13295 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { | |
13296 | vty_out(vty, | |
13297 | " Address families by peer:\n"); | |
13298 | FOREACH_AFI_SAFI (afi, safi) | |
13299 | if (CHECK_FLAG( | |
13300 | p->af_cap[afi] | |
13301 | [safi], | |
13302 | PEER_CAP_LLGR_AF_RCV)) | |
13303 | vty_out(vty, | |
13304 | " %s\n", | |
13305 | get_afi_safi_str( | |
13306 | afi, | |
13307 | safi, | |
13308 | false)); | |
13309 | } | |
13310 | } | |
13311 | ||
13312 | /* Route Refresh */ | |
13313 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13314 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13315 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13316 | vty_out(vty, " Route refresh:"); | |
13317 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
13318 | vty_out(vty, " advertised"); | |
13319 | if (CHECK_FLAG(p->cap, | |
13320 | PEER_CAP_REFRESH_NEW_RCV) || | |
13321 | CHECK_FLAG(p->cap, | |
13322 | PEER_CAP_REFRESH_OLD_RCV)) | |
13323 | vty_out(vty, " %sreceived(%s)", | |
13324 | CHECK_FLAG(p->cap, | |
13325 | PEER_CAP_REFRESH_ADV) | |
13326 | ? "and " | |
13327 | : "", | |
13328 | (CHECK_FLAG( | |
13329 | p->cap, | |
13330 | PEER_CAP_REFRESH_OLD_RCV) && | |
13331 | CHECK_FLAG( | |
13332 | p->cap, | |
13333 | PEER_CAP_REFRESH_NEW_RCV)) | |
13334 | ? "old & new" | |
13335 | : CHECK_FLAG( | |
13336 | p->cap, | |
13337 | PEER_CAP_REFRESH_OLD_RCV) | |
13338 | ? "old" | |
13339 | : "new"); | |
13340 | ||
13341 | vty_out(vty, "\n"); | |
13342 | } | |
13343 | ||
13344 | /* Enhanced Route Refresh */ | |
13345 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13346 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13347 | vty_out(vty, " Enhanced Route Refresh:"); | |
13348 | if (CHECK_FLAG(p->cap, | |
13349 | PEER_CAP_ENHANCED_RR_ADV)) | |
13350 | vty_out(vty, " advertised"); | |
13351 | if (CHECK_FLAG(p->cap, | |
13352 | PEER_CAP_ENHANCED_RR_RCV)) | |
13353 | vty_out(vty, " %sreceived", | |
13354 | CHECK_FLAG(p->cap, | |
13355 | PEER_CAP_REFRESH_ADV) | |
13356 | ? "and " | |
13357 | : ""); | |
13358 | vty_out(vty, "\n"); | |
13359 | } | |
13360 | ||
13361 | /* Multiprotocol Extensions */ | |
13362 | FOREACH_AFI_SAFI (afi, safi) | |
13363 | if (p->afc_adv[afi][safi] || | |
13364 | p->afc_recv[afi][safi]) { | |
13365 | vty_out(vty, " Address Family %s:", | |
13366 | get_afi_safi_str(afi, safi, | |
13367 | false)); | |
13368 | if (p->afc_adv[afi][safi]) | |
13369 | vty_out(vty, " advertised"); | |
13370 | if (p->afc_recv[afi][safi]) | |
13371 | vty_out(vty, " %sreceived", | |
13372 | p->afc_adv[afi][safi] | |
13373 | ? "and " | |
13374 | : ""); | |
13375 | vty_out(vty, "\n"); | |
13376 | } | |
13377 | ||
13378 | /* Hostname capability */ | |
13379 | vty_out(vty, " Hostname Capability:"); | |
13380 | ||
13381 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13382 | vty_out(vty, | |
13383 | " advertised (name: %s,domain name: %s)", | |
13384 | bgp->peer_self->hostname | |
13385 | ? bgp->peer_self->hostname | |
13386 | : "n/a", | |
13387 | bgp->peer_self->domainname | |
13388 | ? bgp->peer_self->domainname | |
13389 | : "n/a"); | |
13390 | } else { | |
13391 | vty_out(vty, " not advertised"); | |
13392 | } | |
13393 | ||
13394 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13395 | vty_out(vty, | |
13396 | " received (name: %s,domain name: %s)", | |
13397 | p->hostname ? p->hostname : "n/a", | |
13398 | p->domainname ? p->domainname : "n/a"); | |
13399 | } else { | |
13400 | vty_out(vty, " not received"); | |
13401 | } | |
13402 | ||
13403 | vty_out(vty, "\n"); | |
13404 | ||
13405 | /* Graceful Restart */ | |
13406 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
13407 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13408 | vty_out(vty, | |
13409 | " Graceful Restart Capability:"); | |
13410 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
13411 | vty_out(vty, " advertised"); | |
13412 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
13413 | vty_out(vty, " %sreceived", | |
13414 | CHECK_FLAG(p->cap, | |
13415 | PEER_CAP_RESTART_ADV) | |
13416 | ? "and " | |
13417 | : ""); | |
13418 | vty_out(vty, "\n"); | |
13419 | ||
13420 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13421 | int restart_af_count = 0; | |
13422 | ||
13423 | vty_out(vty, | |
13424 | " Remote Restart timer is %d seconds\n", | |
13425 | p->v_gr_restart); | |
13426 | vty_out(vty, | |
13427 | " Address families by peer:\n "); | |
13428 | ||
13429 | FOREACH_AFI_SAFI (afi, safi) | |
13430 | if (CHECK_FLAG( | |
13431 | p->af_cap[afi] | |
13432 | [safi], | |
13433 | PEER_CAP_RESTART_AF_RCV)) { | |
13434 | vty_out(vty, "%s%s(%s)", | |
13435 | restart_af_count | |
13436 | ? ", " | |
13437 | : "", | |
13438 | get_afi_safi_str( | |
13439 | afi, | |
13440 | safi, | |
13441 | false), | |
13442 | CHECK_FLAG( | |
13443 | p->af_cap | |
13444 | [afi] | |
13445 | [safi], | |
13446 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13447 | ? "preserved" | |
13448 | : "not preserved"); | |
13449 | restart_af_count++; | |
13450 | } | |
13451 | if (!restart_af_count) | |
13452 | vty_out(vty, "none"); | |
13453 | vty_out(vty, "\n"); | |
13454 | } | |
13455 | } /* Gracefull Restart */ | |
13456 | } | |
13457 | } | |
13458 | ||
13459 | /* graceful restart information */ | |
13460 | json_object *json_grace = NULL; | |
13461 | json_object *json_grace_send = NULL; | |
13462 | json_object *json_grace_recv = NULL; | |
13463 | int eor_send_af_count = 0; | |
13464 | int eor_receive_af_count = 0; | |
13465 | ||
13466 | if (use_json) { | |
13467 | json_grace = json_object_new_object(); | |
13468 | json_grace_send = json_object_new_object(); | |
13469 | json_grace_recv = json_object_new_object(); | |
13470 | ||
13471 | if ((peer_established(p)) && | |
13472 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13473 | FOREACH_AFI_SAFI (afi, safi) { | |
13474 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13475 | PEER_STATUS_EOR_SEND)) { | |
13476 | json_object_boolean_true_add( | |
13477 | json_grace_send, | |
13478 | get_afi_safi_str(afi, safi, | |
13479 | true)); | |
13480 | eor_send_af_count++; | |
13481 | } | |
13482 | } | |
13483 | FOREACH_AFI_SAFI (afi, safi) { | |
13484 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13485 | PEER_STATUS_EOR_RECEIVED)) { | |
13486 | json_object_boolean_true_add( | |
13487 | json_grace_recv, | |
13488 | get_afi_safi_str(afi, safi, | |
13489 | true)); | |
13490 | eor_receive_af_count++; | |
13491 | } | |
13492 | } | |
13493 | } | |
13494 | json_object_object_add(json_grace, "endOfRibSend", | |
13495 | json_grace_send); | |
13496 | json_object_object_add(json_grace, "endOfRibRecv", | |
13497 | json_grace_recv); | |
13498 | ||
13499 | ||
13500 | if (p->t_gr_restart) | |
13501 | json_object_int_add( | |
13502 | json_grace, "gracefulRestartTimerMsecs", | |
13503 | thread_timer_remain_second(p->t_gr_restart) * | |
13504 | 1000); | |
13505 | ||
13506 | if (p->t_gr_stale) | |
13507 | json_object_int_add( | |
13508 | json_grace, "gracefulStalepathTimerMsecs", | |
13509 | thread_timer_remain_second(p->t_gr_stale) * | |
13510 | 1000); | |
13511 | /* more gr info in new format */ | |
13512 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json_grace); | |
13513 | json_object_object_add(json_neigh, "gracefulRestartInfo", | |
13514 | json_grace); | |
13515 | } else { | |
13516 | vty_out(vty, " Graceful restart information:\n"); | |
13517 | if ((peer_established(p)) && | |
13518 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13519 | ||
13520 | vty_out(vty, " End-of-RIB send: "); | |
13521 | FOREACH_AFI_SAFI (afi, safi) { | |
13522 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13523 | PEER_STATUS_EOR_SEND)) { | |
13524 | vty_out(vty, "%s%s", | |
13525 | eor_send_af_count ? ", " : "", | |
13526 | get_afi_safi_str(afi, safi, | |
13527 | false)); | |
13528 | eor_send_af_count++; | |
13529 | } | |
13530 | } | |
13531 | vty_out(vty, "\n"); | |
13532 | vty_out(vty, " End-of-RIB received: "); | |
13533 | FOREACH_AFI_SAFI (afi, safi) { | |
13534 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13535 | PEER_STATUS_EOR_RECEIVED)) { | |
13536 | vty_out(vty, "%s%s", | |
13537 | eor_receive_af_count ? ", " | |
13538 | : "", | |
13539 | get_afi_safi_str(afi, safi, | |
13540 | false)); | |
13541 | eor_receive_af_count++; | |
13542 | } | |
13543 | } | |
13544 | vty_out(vty, "\n"); | |
13545 | } | |
13546 | ||
13547 | if (p->t_gr_restart) | |
13548 | vty_out(vty, | |
13549 | " The remaining time of restart timer is %ld\n", | |
13550 | thread_timer_remain_second(p->t_gr_restart)); | |
13551 | ||
13552 | if (p->t_gr_stale) | |
13553 | vty_out(vty, | |
13554 | " The remaining time of stalepath timer is %ld\n", | |
13555 | thread_timer_remain_second(p->t_gr_stale)); | |
13556 | ||
13557 | /* more gr info in new format */ | |
13558 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
13559 | } | |
13560 | ||
13561 | if (use_json) { | |
13562 | json_object *json_stat = NULL; | |
13563 | json_stat = json_object_new_object(); | |
13564 | /* Packet counts. */ | |
13565 | ||
13566 | atomic_size_t outq_count, inq_count; | |
13567 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13568 | memory_order_relaxed); | |
13569 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13570 | memory_order_relaxed); | |
13571 | ||
13572 | json_object_int_add(json_stat, "depthInq", | |
13573 | (unsigned long)inq_count); | |
13574 | json_object_int_add(json_stat, "depthOutq", | |
13575 | (unsigned long)outq_count); | |
13576 | json_object_int_add(json_stat, "opensSent", | |
13577 | atomic_load_explicit(&p->open_out, | |
13578 | memory_order_relaxed)); | |
13579 | json_object_int_add(json_stat, "opensRecv", | |
13580 | atomic_load_explicit(&p->open_in, | |
13581 | memory_order_relaxed)); | |
13582 | json_object_int_add(json_stat, "notificationsSent", | |
13583 | atomic_load_explicit(&p->notify_out, | |
13584 | memory_order_relaxed)); | |
13585 | json_object_int_add(json_stat, "notificationsRecv", | |
13586 | atomic_load_explicit(&p->notify_in, | |
13587 | memory_order_relaxed)); | |
13588 | json_object_int_add(json_stat, "updatesSent", | |
13589 | atomic_load_explicit(&p->update_out, | |
13590 | memory_order_relaxed)); | |
13591 | json_object_int_add(json_stat, "updatesRecv", | |
13592 | atomic_load_explicit(&p->update_in, | |
13593 | memory_order_relaxed)); | |
13594 | json_object_int_add(json_stat, "keepalivesSent", | |
13595 | atomic_load_explicit(&p->keepalive_out, | |
13596 | memory_order_relaxed)); | |
13597 | json_object_int_add(json_stat, "keepalivesRecv", | |
13598 | atomic_load_explicit(&p->keepalive_in, | |
13599 | memory_order_relaxed)); | |
13600 | json_object_int_add(json_stat, "routeRefreshSent", | |
13601 | atomic_load_explicit(&p->refresh_out, | |
13602 | memory_order_relaxed)); | |
13603 | json_object_int_add(json_stat, "routeRefreshRecv", | |
13604 | atomic_load_explicit(&p->refresh_in, | |
13605 | memory_order_relaxed)); | |
13606 | json_object_int_add(json_stat, "capabilitySent", | |
13607 | atomic_load_explicit(&p->dynamic_cap_out, | |
13608 | memory_order_relaxed)); | |
13609 | json_object_int_add(json_stat, "capabilityRecv", | |
13610 | atomic_load_explicit(&p->dynamic_cap_in, | |
13611 | memory_order_relaxed)); | |
13612 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13613 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
13614 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
13615 | } else { | |
13616 | atomic_size_t outq_count, inq_count, open_out, open_in, | |
13617 | notify_out, notify_in, update_out, update_in, | |
13618 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
13619 | dynamic_cap_out, dynamic_cap_in; | |
13620 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13621 | memory_order_relaxed); | |
13622 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13623 | memory_order_relaxed); | |
13624 | open_out = atomic_load_explicit(&p->open_out, | |
13625 | memory_order_relaxed); | |
13626 | open_in = | |
13627 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
13628 | notify_out = atomic_load_explicit(&p->notify_out, | |
13629 | memory_order_relaxed); | |
13630 | notify_in = atomic_load_explicit(&p->notify_in, | |
13631 | memory_order_relaxed); | |
13632 | update_out = atomic_load_explicit(&p->update_out, | |
13633 | memory_order_relaxed); | |
13634 | update_in = atomic_load_explicit(&p->update_in, | |
13635 | memory_order_relaxed); | |
13636 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
13637 | memory_order_relaxed); | |
13638 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
13639 | memory_order_relaxed); | |
13640 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
13641 | memory_order_relaxed); | |
13642 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
13643 | memory_order_relaxed); | |
13644 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
13645 | memory_order_relaxed); | |
13646 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
13647 | memory_order_relaxed); | |
13648 | ||
13649 | /* Packet counts. */ | |
13650 | vty_out(vty, " Message statistics:\n"); | |
13651 | vty_out(vty, " Inq depth is %zu\n", inq_count); | |
13652 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
13653 | vty_out(vty, " Sent Rcvd\n"); | |
13654 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, | |
13655 | open_in); | |
13656 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
13657 | notify_in); | |
13658 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
13659 | update_in); | |
13660 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
13661 | keepalive_in); | |
13662 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
13663 | refresh_in); | |
13664 | vty_out(vty, " Capability: %10zu %10zu\n", | |
13665 | dynamic_cap_out, dynamic_cap_in); | |
13666 | vty_out(vty, " Total: %10u %10u\n", | |
13667 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
13668 | } | |
13669 | ||
13670 | if (use_json) { | |
13671 | /* advertisement-interval */ | |
13672 | json_object_int_add(json_neigh, | |
13673 | "minBtwnAdvertisementRunsTimerMsecs", | |
13674 | p->v_routeadv * 1000); | |
13675 | ||
13676 | /* Update-source. */ | |
13677 | if (p->update_if || p->update_source) { | |
13678 | if (p->update_if) | |
13679 | json_object_string_add(json_neigh, | |
13680 | "updateSource", | |
13681 | p->update_if); | |
13682 | else if (p->update_source) | |
13683 | json_object_string_add( | |
13684 | json_neigh, "updateSource", | |
13685 | sockunion2str(p->update_source, buf1, | |
13686 | SU_ADDRSTRLEN)); | |
13687 | } | |
13688 | } else { | |
13689 | /* advertisement-interval */ | |
13690 | vty_out(vty, | |
13691 | " Minimum time between advertisement runs is %d seconds\n", | |
13692 | p->v_routeadv); | |
13693 | ||
13694 | /* Update-source. */ | |
13695 | if (p->update_if || p->update_source) { | |
13696 | vty_out(vty, " Update source is "); | |
13697 | if (p->update_if) | |
13698 | vty_out(vty, "%s", p->update_if); | |
13699 | else if (p->update_source) | |
13700 | vty_out(vty, "%s", | |
13701 | sockunion2str(p->update_source, buf1, | |
13702 | SU_ADDRSTRLEN)); | |
13703 | vty_out(vty, "\n"); | |
13704 | } | |
13705 | ||
13706 | vty_out(vty, "\n"); | |
13707 | } | |
13708 | ||
13709 | /* Address Family Information */ | |
13710 | json_object *json_hold = NULL; | |
13711 | ||
13712 | if (use_json) | |
13713 | json_hold = json_object_new_object(); | |
13714 | ||
13715 | FOREACH_AFI_SAFI (afi, safi) | |
13716 | if (p->afc[afi][safi]) | |
13717 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13718 | json_hold); | |
13719 | ||
13720 | if (use_json) { | |
13721 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13722 | json_hold); | |
13723 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13724 | p->established); | |
13725 | json_object_int_add(json_neigh, "connectionsDropped", | |
13726 | p->dropped); | |
13727 | } else | |
13728 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13729 | p->established, p->dropped); | |
13730 | ||
13731 | if (!p->last_reset) { | |
13732 | if (use_json) | |
13733 | json_object_string_add(json_neigh, "lastReset", | |
13734 | "never"); | |
13735 | else | |
13736 | vty_out(vty, " Last reset never\n"); | |
13737 | } else { | |
13738 | if (use_json) { | |
13739 | time_t uptime; | |
13740 | struct tm tm; | |
13741 | ||
13742 | uptime = bgp_clock(); | |
13743 | uptime -= p->resettime; | |
13744 | gmtime_r(&uptime, &tm); | |
13745 | ||
13746 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
13747 | (tm.tm_sec * 1000) | |
13748 | + (tm.tm_min * 60000) | |
13749 | + (tm.tm_hour * 3600000)); | |
13750 | bgp_show_peer_reset(NULL, p, json_neigh, true); | |
13751 | } else { | |
13752 | vty_out(vty, " Last reset %s, ", | |
13753 | peer_uptime(p->resettime, timebuf, | |
13754 | BGP_UPTIME_LEN, 0, NULL)); | |
13755 | ||
13756 | bgp_show_peer_reset(vty, p, NULL, false); | |
13757 | if (p->last_reset_cause_size) { | |
13758 | msg = p->last_reset_cause; | |
13759 | vty_out(vty, | |
13760 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13761 | for (i = 1; i <= p->last_reset_cause_size; | |
13762 | i++) { | |
13763 | vty_out(vty, "%02X", *msg++); | |
13764 | ||
13765 | if (i != p->last_reset_cause_size) { | |
13766 | if (i % 16 == 0) { | |
13767 | vty_out(vty, "\n "); | |
13768 | } else if (i % 4 == 0) { | |
13769 | vty_out(vty, " "); | |
13770 | } | |
13771 | } | |
13772 | } | |
13773 | vty_out(vty, "\n"); | |
13774 | } | |
13775 | } | |
13776 | } | |
13777 | ||
13778 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13779 | if (use_json) | |
13780 | json_object_boolean_true_add(json_neigh, | |
13781 | "prefixesConfigExceedMax"); | |
13782 | else | |
13783 | vty_out(vty, | |
13784 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13785 | ||
13786 | if (p->t_pmax_restart) { | |
13787 | if (use_json) { | |
13788 | json_object_boolean_true_add( | |
13789 | json_neigh, "reducePrefixNumFrom"); | |
13790 | json_object_int_add(json_neigh, | |
13791 | "restartInTimerMsec", | |
13792 | thread_timer_remain_second( | |
13793 | p->t_pmax_restart) | |
13794 | * 1000); | |
13795 | } else | |
13796 | vty_out(vty, | |
13797 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
13798 | p->host, thread_timer_remain_second( | |
13799 | p->t_pmax_restart)); | |
13800 | } else { | |
13801 | if (use_json) | |
13802 | json_object_boolean_true_add( | |
13803 | json_neigh, | |
13804 | "reducePrefixNumAndClearIpBgp"); | |
13805 | else | |
13806 | vty_out(vty, | |
13807 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13808 | p->host); | |
13809 | } | |
13810 | } | |
13811 | ||
13812 | /* EBGP Multihop and GTSM */ | |
13813 | if (p->sort != BGP_PEER_IBGP) { | |
13814 | if (use_json) { | |
13815 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
13816 | json_object_int_add(json_neigh, | |
13817 | "externalBgpNbrMaxHopsAway", | |
13818 | p->gtsm_hops); | |
13819 | else if (p->ttl > BGP_DEFAULT_TTL) | |
13820 | json_object_int_add(json_neigh, | |
13821 | "externalBgpNbrMaxHopsAway", | |
13822 | p->ttl); | |
13823 | } else { | |
13824 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
13825 | vty_out(vty, | |
13826 | " External BGP neighbor may be up to %d hops away.\n", | |
13827 | p->gtsm_hops); | |
13828 | else if (p->ttl > BGP_DEFAULT_TTL) | |
13829 | vty_out(vty, | |
13830 | " External BGP neighbor may be up to %d hops away.\n", | |
13831 | p->ttl); | |
13832 | } | |
13833 | } else { | |
13834 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { | |
13835 | if (use_json) | |
13836 | json_object_int_add(json_neigh, | |
13837 | "internalBgpNbrMaxHopsAway", | |
13838 | p->gtsm_hops); | |
13839 | else | |
13840 | vty_out(vty, | |
13841 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13842 | p->gtsm_hops); | |
13843 | } | |
13844 | } | |
13845 | ||
13846 | /* Local address. */ | |
13847 | if (p->su_local) { | |
13848 | if (use_json) { | |
13849 | json_object_string_add(json_neigh, "hostLocal", | |
13850 | sockunion2str(p->su_local, buf1, | |
13851 | SU_ADDRSTRLEN)); | |
13852 | json_object_int_add(json_neigh, "portLocal", | |
13853 | ntohs(p->su_local->sin.sin_port)); | |
13854 | } else | |
13855 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13856 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13857 | ntohs(p->su_local->sin.sin_port)); | |
13858 | } | |
13859 | ||
13860 | /* Remote address. */ | |
13861 | if (p->su_remote) { | |
13862 | if (use_json) { | |
13863 | json_object_string_add(json_neigh, "hostForeign", | |
13864 | sockunion2str(p->su_remote, buf1, | |
13865 | SU_ADDRSTRLEN)); | |
13866 | json_object_int_add(json_neigh, "portForeign", | |
13867 | ntohs(p->su_remote->sin.sin_port)); | |
13868 | } else | |
13869 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13870 | sockunion2str(p->su_remote, buf1, | |
13871 | SU_ADDRSTRLEN), | |
13872 | ntohs(p->su_remote->sin.sin_port)); | |
13873 | } | |
13874 | ||
13875 | /* Nexthop display. */ | |
13876 | if (p->su_local) { | |
13877 | if (use_json) { | |
13878 | json_object_string_addf(json_neigh, "nexthop", "%pI4", | |
13879 | &p->nexthop.v4); | |
13880 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
13881 | "%pI6", &p->nexthop.v6_global); | |
13882 | json_object_string_addf(json_neigh, "nexthopLocal", | |
13883 | "%pI6", &p->nexthop.v6_local); | |
13884 | if (p->shared_network) | |
13885 | json_object_string_add(json_neigh, | |
13886 | "bgpConnection", | |
13887 | "sharedNetwork"); | |
13888 | else | |
13889 | json_object_string_add(json_neigh, | |
13890 | "bgpConnection", | |
13891 | "nonSharedNetwork"); | |
13892 | } else { | |
13893 | vty_out(vty, "Nexthop: %s\n", | |
13894 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13895 | sizeof(buf1))); | |
13896 | vty_out(vty, "Nexthop global: %s\n", | |
13897 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13898 | sizeof(buf1))); | |
13899 | vty_out(vty, "Nexthop local: %s\n", | |
13900 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13901 | sizeof(buf1))); | |
13902 | vty_out(vty, "BGP connection: %s\n", | |
13903 | p->shared_network ? "shared network" | |
13904 | : "non shared network"); | |
13905 | } | |
13906 | } | |
13907 | ||
13908 | /* Timer information. */ | |
13909 | if (use_json) { | |
13910 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13911 | p->v_connect); | |
13912 | if (peer_established(p) && p->rtt) | |
13913 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13914 | p->rtt); | |
13915 | if (p->t_start) | |
13916 | json_object_int_add( | |
13917 | json_neigh, "nextStartTimerDueInMsecs", | |
13918 | thread_timer_remain_second(p->t_start) * 1000); | |
13919 | if (p->t_connect) | |
13920 | json_object_int_add( | |
13921 | json_neigh, "nextConnectTimerDueInMsecs", | |
13922 | thread_timer_remain_second(p->t_connect) | |
13923 | * 1000); | |
13924 | if (p->t_routeadv) { | |
13925 | json_object_int_add(json_neigh, "mraiInterval", | |
13926 | p->v_routeadv); | |
13927 | json_object_int_add( | |
13928 | json_neigh, "mraiTimerExpireInMsecs", | |
13929 | thread_timer_remain_second(p->t_routeadv) | |
13930 | * 1000); | |
13931 | } | |
13932 | if (p->password) | |
13933 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13934 | 1); | |
13935 | ||
13936 | if (p->t_read) | |
13937 | json_object_string_add(json_neigh, "readThread", "on"); | |
13938 | else | |
13939 | json_object_string_add(json_neigh, "readThread", "off"); | |
13940 | ||
13941 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
13942 | json_object_string_add(json_neigh, "writeThread", "on"); | |
13943 | else | |
13944 | json_object_string_add(json_neigh, "writeThread", | |
13945 | "off"); | |
13946 | } else { | |
13947 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13948 | p->v_connect); | |
13949 | if (peer_established(p) && p->rtt) | |
13950 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13951 | p->rtt); | |
13952 | if (p->t_start) | |
13953 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13954 | thread_timer_remain_second(p->t_start)); | |
13955 | if (p->t_connect) | |
13956 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13957 | thread_timer_remain_second(p->t_connect)); | |
13958 | if (p->t_routeadv) | |
13959 | vty_out(vty, | |
13960 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13961 | p->v_routeadv, | |
13962 | thread_timer_remain_second(p->t_routeadv)); | |
13963 | if (p->password) | |
13964 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13965 | ||
13966 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", | |
13967 | p->t_read ? "on" : "off", | |
13968 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13969 | ? "on" | |
13970 | : "off", p->fd); | |
13971 | } | |
13972 | ||
13973 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13974 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13975 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13976 | ||
13977 | if (!use_json) | |
13978 | vty_out(vty, "\n"); | |
13979 | ||
13980 | /* BFD information. */ | |
13981 | if (p->bfd_config) | |
13982 | bgp_bfd_show_info(vty, p, json_neigh); | |
13983 | ||
13984 | if (use_json) { | |
13985 | if (p->conf_if) /* Configured interface name. */ | |
13986 | json_object_object_add(json, p->conf_if, json_neigh); | |
13987 | else /* Configured IP address. */ | |
13988 | json_object_object_add(json, p->host, json_neigh); | |
13989 | } | |
13990 | } | |
13991 | ||
13992 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, | |
13993 | enum show_type type, | |
13994 | union sockunion *su, | |
13995 | const char *conf_if, afi_t afi, | |
13996 | bool use_json) | |
13997 | { | |
13998 | struct listnode *node, *nnode; | |
13999 | struct peer *peer; | |
14000 | int find = 0; | |
14001 | safi_t safi = SAFI_UNICAST; | |
14002 | json_object *json = NULL; | |
14003 | json_object *json_neighbor = NULL; | |
14004 | ||
14005 | if (use_json) { | |
14006 | json = json_object_new_object(); | |
14007 | json_neighbor = json_object_new_object(); | |
14008 | } | |
14009 | ||
14010 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14011 | ||
14012 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14013 | continue; | |
14014 | ||
14015 | if ((peer->afc[afi][safi]) == 0) | |
14016 | continue; | |
14017 | ||
14018 | if (type == show_all) { | |
14019 | bgp_show_peer_gr_status(vty, peer, use_json, | |
14020 | json_neighbor); | |
14021 | ||
14022 | if (use_json) { | |
14023 | json_object_object_add(json, peer->host, | |
14024 | json_neighbor); | |
14025 | json_neighbor = NULL; | |
14026 | } | |
14027 | ||
14028 | } else if (type == show_peer) { | |
14029 | if (conf_if) { | |
14030 | if ((peer->conf_if | |
14031 | && !strcmp(peer->conf_if, conf_if)) | |
14032 | || (peer->hostname | |
14033 | && !strcmp(peer->hostname, conf_if))) { | |
14034 | find = 1; | |
14035 | bgp_show_peer_gr_status(vty, peer, | |
14036 | use_json, | |
14037 | json_neighbor); | |
14038 | } | |
14039 | } else { | |
14040 | if (sockunion_same(&peer->su, su)) { | |
14041 | find = 1; | |
14042 | bgp_show_peer_gr_status(vty, peer, | |
14043 | use_json, | |
14044 | json_neighbor); | |
14045 | } | |
14046 | } | |
14047 | if (use_json && find) | |
14048 | json_object_object_add(json, peer->host, | |
14049 | json_neighbor); | |
14050 | } | |
14051 | ||
14052 | if (find) { | |
14053 | json_neighbor = NULL; | |
14054 | break; | |
14055 | } | |
14056 | } | |
14057 | ||
14058 | if (type == show_peer && !find) { | |
14059 | if (use_json) | |
14060 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14061 | else | |
14062 | vty_out(vty, "%% No such neighbor\n"); | |
14063 | } | |
14064 | if (use_json) { | |
14065 | if (json_neighbor) | |
14066 | json_object_free(json_neighbor); | |
14067 | vty_json(vty, json); | |
14068 | } else { | |
14069 | vty_out(vty, "\n"); | |
14070 | } | |
14071 | ||
14072 | return CMD_SUCCESS; | |
14073 | } | |
14074 | ||
14075 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
14076 | enum show_type type, union sockunion *su, | |
14077 | const char *conf_if, bool use_json, | |
14078 | json_object *json) | |
14079 | { | |
14080 | struct listnode *node, *nnode; | |
14081 | struct peer *peer; | |
14082 | int find = 0; | |
14083 | bool nbr_output = false; | |
14084 | afi_t afi = AFI_MAX; | |
14085 | safi_t safi = SAFI_MAX; | |
14086 | ||
14087 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14088 | afi = AFI_IP; | |
14089 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14090 | afi = AFI_IP6; | |
14091 | } | |
14092 | ||
14093 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14094 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14095 | continue; | |
14096 | ||
14097 | switch (type) { | |
14098 | case show_all: | |
14099 | bgp_show_peer(vty, peer, use_json, json); | |
14100 | nbr_output = true; | |
14101 | break; | |
14102 | case show_peer: | |
14103 | if (conf_if) { | |
14104 | if ((peer->conf_if | |
14105 | && !strcmp(peer->conf_if, conf_if)) | |
14106 | || (peer->hostname | |
14107 | && !strcmp(peer->hostname, conf_if))) { | |
14108 | find = 1; | |
14109 | bgp_show_peer(vty, peer, use_json, | |
14110 | json); | |
14111 | } | |
14112 | } else { | |
14113 | if (sockunion_same(&peer->su, su)) { | |
14114 | find = 1; | |
14115 | bgp_show_peer(vty, peer, use_json, | |
14116 | json); | |
14117 | } | |
14118 | } | |
14119 | break; | |
14120 | case show_ipv4_peer: | |
14121 | case show_ipv6_peer: | |
14122 | FOREACH_SAFI (safi) { | |
14123 | if (peer->afc[afi][safi]) { | |
14124 | if (conf_if) { | |
14125 | if ((peer->conf_if | |
14126 | && !strcmp(peer->conf_if, conf_if)) | |
14127 | || (peer->hostname | |
14128 | && !strcmp(peer->hostname, conf_if))) { | |
14129 | find = 1; | |
14130 | bgp_show_peer(vty, peer, use_json, | |
14131 | json); | |
14132 | break; | |
14133 | } | |
14134 | } else { | |
14135 | if (sockunion_same(&peer->su, su)) { | |
14136 | find = 1; | |
14137 | bgp_show_peer(vty, peer, use_json, | |
14138 | json); | |
14139 | break; | |
14140 | } | |
14141 | } | |
14142 | } | |
14143 | } | |
14144 | break; | |
14145 | case show_ipv4_all: | |
14146 | case show_ipv6_all: | |
14147 | FOREACH_SAFI (safi) { | |
14148 | if (peer->afc[afi][safi]) { | |
14149 | bgp_show_peer(vty, peer, use_json, json); | |
14150 | nbr_output = true; | |
14151 | break; | |
14152 | } | |
14153 | } | |
14154 | break; | |
14155 | } | |
14156 | } | |
14157 | ||
14158 | if ((type == show_peer || type == show_ipv4_peer || | |
14159 | type == show_ipv6_peer) && !find) { | |
14160 | if (use_json) | |
14161 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14162 | else | |
14163 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); | |
14164 | } | |
14165 | ||
14166 | if (type != show_peer && type != show_ipv4_peer && | |
14167 | type != show_ipv6_peer && !nbr_output && !use_json) | |
14168 | vty_out(vty, "%% No BGP neighbors found\n"); | |
14169 | ||
14170 | if (use_json) { | |
14171 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
14172 | json, JSON_C_TO_STRING_PRETTY)); | |
14173 | } else { | |
14174 | vty_out(vty, "\n"); | |
14175 | } | |
14176 | ||
14177 | return CMD_SUCCESS; | |
14178 | } | |
14179 | ||
14180 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, | |
14181 | enum show_type type, | |
14182 | const char *ip_str, | |
14183 | afi_t afi, bool use_json) | |
14184 | { | |
14185 | ||
14186 | int ret; | |
14187 | struct bgp *bgp; | |
14188 | union sockunion su; | |
14189 | ||
14190 | bgp = bgp_get_default(); | |
14191 | ||
14192 | if (!bgp) | |
14193 | return; | |
14194 | ||
14195 | if (!use_json) | |
14196 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14197 | NULL); | |
14198 | ||
14199 | if (ip_str) { | |
14200 | ret = str2sockunion(ip_str, &su); | |
14201 | if (ret < 0) | |
14202 | bgp_show_neighbor_graceful_restart( | |
14203 | vty, bgp, type, NULL, ip_str, afi, use_json); | |
14204 | else | |
14205 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14206 | NULL, afi, use_json); | |
14207 | } else | |
14208 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
14209 | afi, use_json); | |
14210 | } | |
14211 | ||
14212 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
14213 | enum show_type type, | |
14214 | const char *ip_str, | |
14215 | bool use_json) | |
14216 | { | |
14217 | struct listnode *node, *nnode; | |
14218 | struct bgp *bgp; | |
14219 | union sockunion su; | |
14220 | json_object *json = NULL; | |
14221 | int ret, is_first = 1; | |
14222 | bool nbr_output = false; | |
14223 | ||
14224 | if (use_json) | |
14225 | vty_out(vty, "{\n"); | |
14226 | ||
14227 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14228 | nbr_output = true; | |
14229 | if (use_json) { | |
14230 | if (!(json = json_object_new_object())) { | |
14231 | flog_err( | |
14232 | EC_BGP_JSON_MEM_ERROR, | |
14233 | "Unable to allocate memory for JSON object"); | |
14234 | vty_out(vty, | |
14235 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14236 | return; | |
14237 | } | |
14238 | ||
14239 | json_object_int_add(json, "vrfId", | |
14240 | (bgp->vrf_id == VRF_UNKNOWN) | |
14241 | ? -1 | |
14242 | : (int64_t)bgp->vrf_id); | |
14243 | json_object_string_add( | |
14244 | json, "vrfName", | |
14245 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14246 | ? VRF_DEFAULT_NAME | |
14247 | : bgp->name); | |
14248 | ||
14249 | if (!is_first) | |
14250 | vty_out(vty, ",\n"); | |
14251 | else | |
14252 | is_first = 0; | |
14253 | ||
14254 | vty_out(vty, "\"%s\":", | |
14255 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14256 | ? VRF_DEFAULT_NAME | |
14257 | : bgp->name); | |
14258 | } else { | |
14259 | vty_out(vty, "\nInstance %s:\n", | |
14260 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14261 | ? VRF_DEFAULT_NAME | |
14262 | : bgp->name); | |
14263 | } | |
14264 | ||
14265 | if (type == show_peer || type == show_ipv4_peer || | |
14266 | type == show_ipv6_peer) { | |
14267 | ret = str2sockunion(ip_str, &su); | |
14268 | if (ret < 0) | |
14269 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14270 | use_json, json); | |
14271 | else | |
14272 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14273 | use_json, json); | |
14274 | } else { | |
14275 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, | |
14276 | use_json, json); | |
14277 | } | |
14278 | json_object_free(json); | |
14279 | json = NULL; | |
14280 | } | |
14281 | ||
14282 | if (use_json) | |
14283 | vty_out(vty, "}\n"); | |
14284 | else if (!nbr_output) | |
14285 | vty_out(vty, "%% BGP instance not found\n"); | |
14286 | } | |
14287 | ||
14288 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14289 | enum show_type type, const char *ip_str, | |
14290 | bool use_json) | |
14291 | { | |
14292 | int ret; | |
14293 | struct bgp *bgp; | |
14294 | union sockunion su; | |
14295 | json_object *json = NULL; | |
14296 | ||
14297 | if (name) { | |
14298 | if (strmatch(name, "all")) { | |
14299 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, | |
14300 | use_json); | |
14301 | return CMD_SUCCESS; | |
14302 | } else { | |
14303 | bgp = bgp_lookup_by_name(name); | |
14304 | if (!bgp) { | |
14305 | if (use_json) { | |
14306 | json = json_object_new_object(); | |
14307 | vty_json(vty, json); | |
14308 | } else | |
14309 | vty_out(vty, | |
14310 | "%% BGP instance not found\n"); | |
14311 | ||
14312 | return CMD_WARNING; | |
14313 | } | |
14314 | } | |
14315 | } else { | |
14316 | bgp = bgp_get_default(); | |
14317 | } | |
14318 | ||
14319 | if (bgp) { | |
14320 | json = json_object_new_object(); | |
14321 | if (ip_str) { | |
14322 | ret = str2sockunion(ip_str, &su); | |
14323 | if (ret < 0) | |
14324 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14325 | use_json, json); | |
14326 | else | |
14327 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14328 | use_json, json); | |
14329 | } else { | |
14330 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14331 | json); | |
14332 | } | |
14333 | json_object_free(json); | |
14334 | } else { | |
14335 | if (use_json) | |
14336 | vty_out(vty, "{}\n"); | |
14337 | else | |
14338 | vty_out(vty, "%% BGP instance not found\n"); | |
14339 | } | |
14340 | ||
14341 | return CMD_SUCCESS; | |
14342 | } | |
14343 | ||
14344 | ||
14345 | ||
14346 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14347 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14348 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14349 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14350 | SHOW_STR | |
14351 | BGP_STR | |
14352 | IP_STR | |
14353 | IPV6_STR | |
14354 | NEIGHBOR_STR | |
14355 | "Neighbor to display information about\n" | |
14356 | "Neighbor to display information about\n" | |
14357 | "Neighbor on BGP configured interface\n" | |
14358 | GR_SHOW | |
14359 | JSON_STR) | |
14360 | { | |
14361 | char *sh_arg = NULL; | |
14362 | enum show_type sh_type; | |
14363 | int idx = 0; | |
14364 | afi_t afi = AFI_MAX; | |
14365 | bool uj = use_json(argc, argv); | |
14366 | ||
14367 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
14368 | afi = AFI_MAX; | |
14369 | ||
14370 | idx++; | |
14371 | ||
14372 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14373 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14374 | || argv_find(argv, argc, "WORD", &idx)) { | |
14375 | sh_type = show_peer; | |
14376 | sh_arg = argv[idx]->arg; | |
14377 | } else | |
14378 | sh_type = show_all; | |
14379 | ||
14380 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14381 | return CMD_SUCCESS; | |
14382 | ||
14383 | ||
14384 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, | |
14385 | afi, uj); | |
14386 | } | |
14387 | ||
14388 | /* "show [ip] bgp neighbors" commands. */ | |
14389 | DEFUN (show_ip_bgp_neighbors, | |
14390 | show_ip_bgp_neighbors_cmd, | |
14391 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", | |
14392 | SHOW_STR | |
14393 | IP_STR | |
14394 | BGP_STR | |
14395 | BGP_INSTANCE_HELP_STR | |
14396 | "Address Family\n" | |
14397 | "Address Family\n" | |
14398 | "Detailed information on TCP and BGP neighbor connections\n" | |
14399 | "Neighbor to display information about\n" | |
14400 | "Neighbor to display information about\n" | |
14401 | "Neighbor on BGP configured interface\n" | |
14402 | JSON_STR) | |
14403 | { | |
14404 | char *vrf = NULL; | |
14405 | char *sh_arg = NULL; | |
14406 | enum show_type sh_type; | |
14407 | afi_t afi = AFI_MAX; | |
14408 | ||
14409 | bool uj = use_json(argc, argv); | |
14410 | ||
14411 | int idx = 0; | |
14412 | ||
14413 | /* [<vrf> VIEWVRFNAME] */ | |
14414 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14415 | vrf = argv[idx + 1]->arg; | |
14416 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14417 | vrf = NULL; | |
14418 | } else if (argv_find(argv, argc, "view", &idx)) | |
14419 | /* [<view> VIEWVRFNAME] */ | |
14420 | vrf = argv[idx + 1]->arg; | |
14421 | ||
14422 | idx++; | |
14423 | ||
14424 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14425 | sh_type = show_ipv4_all; | |
14426 | afi = AFI_IP; | |
14427 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14428 | sh_type = show_ipv6_all; | |
14429 | afi = AFI_IP6; | |
14430 | } else { | |
14431 | sh_type = show_all; | |
14432 | } | |
14433 | ||
14434 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14435 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14436 | || argv_find(argv, argc, "WORD", &idx)) { | |
14437 | sh_type = show_peer; | |
14438 | sh_arg = argv[idx]->arg; | |
14439 | } | |
14440 | ||
14441 | if (sh_type == show_peer && afi == AFI_IP) { | |
14442 | sh_type = show_ipv4_peer; | |
14443 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14444 | sh_type = show_ipv6_peer; | |
14445 | } | |
14446 | ||
14447 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); | |
14448 | } | |
14449 | ||
14450 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp | |
14451 | paths' and `show ip mbgp paths'. Those functions results are the | |
14452 | same.*/ | |
14453 | DEFUN (show_ip_bgp_paths, | |
14454 | show_ip_bgp_paths_cmd, | |
14455 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", | |
14456 | SHOW_STR | |
14457 | IP_STR | |
14458 | BGP_STR | |
14459 | BGP_SAFI_HELP_STR | |
14460 | "Path information\n") | |
14461 | { | |
14462 | vty_out(vty, "Address Refcnt Path\n"); | |
14463 | aspath_print_all_vty(vty); | |
14464 | return CMD_SUCCESS; | |
14465 | } | |
14466 | ||
14467 | #include "hash.h" | |
14468 | ||
14469 | static void community_show_all_iterator(struct hash_bucket *bucket, | |
14470 | struct vty *vty) | |
14471 | { | |
14472 | struct community *com; | |
14473 | ||
14474 | com = (struct community *)bucket->data; | |
14475 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, | |
14476 | community_str(com, false)); | |
14477 | } | |
14478 | ||
14479 | /* Show BGP's community internal data. */ | |
14480 | DEFUN (show_ip_bgp_community_info, | |
14481 | show_ip_bgp_community_info_cmd, | |
14482 | "show [ip] bgp community-info", | |
14483 | SHOW_STR | |
14484 | IP_STR | |
14485 | BGP_STR | |
14486 | "List all bgp community information\n") | |
14487 | { | |
14488 | vty_out(vty, "Address Refcnt Community\n"); | |
14489 | ||
14490 | hash_iterate(community_hash(), | |
14491 | (void (*)(struct hash_bucket *, | |
14492 | void *))community_show_all_iterator, | |
14493 | vty); | |
14494 | ||
14495 | return CMD_SUCCESS; | |
14496 | } | |
14497 | ||
14498 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, | |
14499 | struct vty *vty) | |
14500 | { | |
14501 | struct lcommunity *lcom; | |
14502 | ||
14503 | lcom = (struct lcommunity *)bucket->data; | |
14504 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, | |
14505 | lcommunity_str(lcom, false)); | |
14506 | } | |
14507 | ||
14508 | /* Show BGP's community internal data. */ | |
14509 | DEFUN (show_ip_bgp_lcommunity_info, | |
14510 | show_ip_bgp_lcommunity_info_cmd, | |
14511 | "show ip bgp large-community-info", | |
14512 | SHOW_STR | |
14513 | IP_STR | |
14514 | BGP_STR | |
14515 | "List all bgp large-community information\n") | |
14516 | { | |
14517 | vty_out(vty, "Address Refcnt Large-community\n"); | |
14518 | ||
14519 | hash_iterate(lcommunity_hash(), | |
14520 | (void (*)(struct hash_bucket *, | |
14521 | void *))lcommunity_show_all_iterator, | |
14522 | vty); | |
14523 | ||
14524 | return CMD_SUCCESS; | |
14525 | } | |
14526 | /* Graceful Restart */ | |
14527 | ||
14528 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
14529 | struct bgp *bgp, | |
14530 | bool use_json, | |
14531 | json_object *json) | |
14532 | { | |
14533 | ||
14534 | ||
14535 | vty_out(vty, "\n%s", SHOW_GR_HEADER); | |
14536 | ||
14537 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); | |
14538 | ||
14539 | switch (bgp_global_gr_mode) { | |
14540 | ||
14541 | case GLOBAL_HELPER: | |
14542 | vty_out(vty, "Global BGP GR Mode : Helper\n"); | |
14543 | break; | |
14544 | ||
14545 | case GLOBAL_GR: | |
14546 | vty_out(vty, "Global BGP GR Mode : Restart\n"); | |
14547 | break; | |
14548 | ||
14549 | case GLOBAL_DISABLE: | |
14550 | vty_out(vty, "Global BGP GR Mode : Disable\n"); | |
14551 | break; | |
14552 | ||
14553 | case GLOBAL_INVALID: | |
14554 | vty_out(vty, | |
14555 | "Global BGP GR Mode Invalid\n"); | |
14556 | break; | |
14557 | } | |
14558 | vty_out(vty, "\n"); | |
14559 | } | |
14560 | ||
14561 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, | |
14562 | enum show_type type, | |
14563 | const char *ip_str, | |
14564 | afi_t afi, bool use_json) | |
14565 | { | |
14566 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14567 | afi = AFI_IP; | |
14568 | ||
14569 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14570 | ||
14571 | bgp_show_neighbor_graceful_restart_vty( | |
14572 | vty, type, ip_str, afi, use_json); | |
14573 | afi++; | |
14574 | } | |
14575 | } else if (afi != AFI_MAX) { | |
14576 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, | |
14577 | use_json); | |
14578 | } else { | |
14579 | return CMD_ERR_INCOMPLETE; | |
14580 | } | |
14581 | ||
14582 | return CMD_SUCCESS; | |
14583 | } | |
14584 | /* Graceful Restart */ | |
14585 | ||
14586 | DEFUN (show_ip_bgp_attr_info, | |
14587 | show_ip_bgp_attr_info_cmd, | |
14588 | "show [ip] bgp attribute-info", | |
14589 | SHOW_STR | |
14590 | IP_STR | |
14591 | BGP_STR | |
14592 | "List all bgp attribute information\n") | |
14593 | { | |
14594 | attr_show_all(vty); | |
14595 | return CMD_SUCCESS; | |
14596 | } | |
14597 | ||
14598 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, | |
14599 | afi_t afi, safi_t safi, | |
14600 | bool use_json, json_object *json) | |
14601 | { | |
14602 | struct bgp *bgp; | |
14603 | struct listnode *node; | |
14604 | char *vname; | |
14605 | char buf1[INET6_ADDRSTRLEN]; | |
14606 | char *ecom_str; | |
14607 | vpn_policy_direction_t dir; | |
14608 | ||
14609 | if (json) { | |
14610 | json_object *json_import_vrfs = NULL; | |
14611 | json_object *json_export_vrfs = NULL; | |
14612 | ||
14613 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
14614 | ||
14615 | if (!bgp) { | |
14616 | vty_json(vty, json); | |
14617 | ||
14618 | return CMD_WARNING; | |
14619 | } | |
14620 | ||
14621 | /* Provide context for the block */ | |
14622 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14623 | json_object_string_add(json, "afiSafi", | |
14624 | get_afi_safi_str(afi, safi, true)); | |
14625 | ||
14626 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14627 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14628 | json_object_string_add(json, "importFromVrfs", "none"); | |
14629 | json_object_string_add(json, "importRts", "none"); | |
14630 | } else { | |
14631 | json_import_vrfs = json_object_new_array(); | |
14632 | ||
14633 | for (ALL_LIST_ELEMENTS_RO( | |
14634 | bgp->vpn_policy[afi].import_vrf, | |
14635 | node, vname)) | |
14636 | json_object_array_add(json_import_vrfs, | |
14637 | json_object_new_string(vname)); | |
14638 | ||
14639 | json_object_object_add(json, "importFromVrfs", | |
14640 | json_import_vrfs); | |
14641 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
14642 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14643 | ecom_str = ecommunity_ecom2str( | |
14644 | bgp->vpn_policy[afi].rtlist[dir], | |
14645 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
14646 | json_object_string_add(json, "importRts", | |
14647 | ecom_str); | |
14648 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14649 | } else | |
14650 | json_object_string_add(json, "importRts", | |
14651 | "none"); | |
14652 | } | |
14653 | ||
14654 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14655 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14656 | json_object_string_add(json, "exportToVrfs", "none"); | |
14657 | json_object_string_add(json, "routeDistinguisher", | |
14658 | "none"); | |
14659 | json_object_string_add(json, "exportRts", "none"); | |
14660 | } else { | |
14661 | json_export_vrfs = json_object_new_array(); | |
14662 | ||
14663 | for (ALL_LIST_ELEMENTS_RO( | |
14664 | bgp->vpn_policy[afi].export_vrf, | |
14665 | node, vname)) | |
14666 | json_object_array_add(json_export_vrfs, | |
14667 | json_object_new_string(vname)); | |
14668 | json_object_object_add(json, "exportToVrfs", | |
14669 | json_export_vrfs); | |
14670 | json_object_string_add(json, "routeDistinguisher", | |
14671 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14672 | buf1, RD_ADDRSTRLEN)); | |
14673 | ||
14674 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
14675 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14676 | ecom_str = ecommunity_ecom2str( | |
14677 | bgp->vpn_policy[afi].rtlist[dir], | |
14678 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
14679 | json_object_string_add(json, "exportRts", | |
14680 | ecom_str); | |
14681 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14682 | } else | |
14683 | json_object_string_add(json, "exportRts", | |
14684 | "none"); | |
14685 | } | |
14686 | ||
14687 | if (use_json) { | |
14688 | vty_json(vty, json); | |
14689 | } | |
14690 | } else { | |
14691 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
14692 | ||
14693 | if (!bgp) { | |
14694 | vty_out(vty, "%% No such BGP instance exist\n"); | |
14695 | return CMD_WARNING; | |
14696 | } | |
14697 | ||
14698 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14699 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14700 | vty_out(vty, | |
14701 | "This VRF is not importing %s routes from any other VRF\n", | |
14702 | get_afi_safi_str(afi, safi, false)); | |
14703 | else { | |
14704 | vty_out(vty, | |
14705 | "This VRF is importing %s routes from the following VRFs:\n", | |
14706 | get_afi_safi_str(afi, safi, false)); | |
14707 | ||
14708 | for (ALL_LIST_ELEMENTS_RO( | |
14709 | bgp->vpn_policy[afi].import_vrf, | |
14710 | node, vname)) | |
14711 | vty_out(vty, " %s\n", vname); | |
14712 | ||
14713 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
14714 | ecom_str = NULL; | |
14715 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14716 | ecom_str = ecommunity_ecom2str( | |
14717 | bgp->vpn_policy[afi].rtlist[dir], | |
14718 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
14719 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
14720 | ||
14721 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14722 | } else | |
14723 | vty_out(vty, "Import RT(s):\n"); | |
14724 | } | |
14725 | ||
14726 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14727 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14728 | vty_out(vty, | |
14729 | "This VRF is not exporting %s routes to any other VRF\n", | |
14730 | get_afi_safi_str(afi, safi, false)); | |
14731 | else { | |
14732 | vty_out(vty, | |
14733 | "This VRF is exporting %s routes to the following VRFs:\n", | |
14734 | get_afi_safi_str(afi, safi, false)); | |
14735 | ||
14736 | for (ALL_LIST_ELEMENTS_RO( | |
14737 | bgp->vpn_policy[afi].export_vrf, | |
14738 | node, vname)) | |
14739 | vty_out(vty, " %s\n", vname); | |
14740 | ||
14741 | vty_out(vty, "RD: %s\n", | |
14742 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14743 | buf1, RD_ADDRSTRLEN)); | |
14744 | ||
14745 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
14746 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14747 | ecom_str = ecommunity_ecom2str( | |
14748 | bgp->vpn_policy[afi].rtlist[dir], | |
14749 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
14750 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
14751 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14752 | } else | |
14753 | vty_out(vty, "Import RT(s):\n"); | |
14754 | } | |
14755 | } | |
14756 | ||
14757 | return CMD_SUCCESS; | |
14758 | } | |
14759 | ||
14760 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, | |
14761 | safi_t safi, bool use_json) | |
14762 | { | |
14763 | struct listnode *node, *nnode; | |
14764 | struct bgp *bgp; | |
14765 | char *vrf_name = NULL; | |
14766 | json_object *json = NULL; | |
14767 | json_object *json_vrf = NULL; | |
14768 | json_object *json_vrfs = NULL; | |
14769 | ||
14770 | if (use_json) { | |
14771 | json = json_object_new_object(); | |
14772 | json_vrfs = json_object_new_object(); | |
14773 | } | |
14774 | ||
14775 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14776 | ||
14777 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14778 | vrf_name = bgp->name; | |
14779 | ||
14780 | if (use_json) { | |
14781 | json_vrf = json_object_new_object(); | |
14782 | } else { | |
14783 | vty_out(vty, "\nInstance %s:\n", | |
14784 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14785 | ? VRF_DEFAULT_NAME : bgp->name); | |
14786 | } | |
14787 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14788 | if (use_json) { | |
14789 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14790 | json_object_object_add(json_vrfs, | |
14791 | VRF_DEFAULT_NAME, json_vrf); | |
14792 | else | |
14793 | json_object_object_add(json_vrfs, vrf_name, | |
14794 | json_vrf); | |
14795 | } | |
14796 | } | |
14797 | ||
14798 | if (use_json) { | |
14799 | json_object_object_add(json, "vrfs", json_vrfs); | |
14800 | vty_json(vty, json); | |
14801 | } | |
14802 | ||
14803 | return CMD_SUCCESS; | |
14804 | } | |
14805 | ||
14806 | /* "show [ip] bgp route-leak" command. */ | |
14807 | DEFUN (show_ip_bgp_route_leak, | |
14808 | show_ip_bgp_route_leak_cmd, | |
14809 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
14810 | SHOW_STR | |
14811 | IP_STR | |
14812 | BGP_STR | |
14813 | BGP_INSTANCE_HELP_STR | |
14814 | BGP_AFI_HELP_STR | |
14815 | BGP_SAFI_HELP_STR | |
14816 | "Route leaking information\n" | |
14817 | JSON_STR) | |
14818 | { | |
14819 | char *vrf = NULL; | |
14820 | afi_t afi = AFI_MAX; | |
14821 | safi_t safi = SAFI_MAX; | |
14822 | ||
14823 | bool uj = use_json(argc, argv); | |
14824 | int idx = 0; | |
14825 | json_object *json = NULL; | |
14826 | ||
14827 | /* show [ip] bgp */ | |
14828 | if (argv_find(argv, argc, "ip", &idx)) { | |
14829 | afi = AFI_IP; | |
14830 | safi = SAFI_UNICAST; | |
14831 | } | |
14832 | /* [vrf VIEWVRFNAME] */ | |
14833 | if (argv_find(argv, argc, "view", &idx)) { | |
14834 | vty_out(vty, | |
14835 | "%% This command is not applicable to BGP views\n"); | |
14836 | return CMD_WARNING; | |
14837 | } | |
14838 | ||
14839 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14840 | vrf = argv[idx + 1]->arg; | |
14841 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14842 | vrf = NULL; | |
14843 | } | |
14844 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
14845 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
14846 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14847 | ||
14848 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
14849 | vty_out(vty, | |
14850 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
14851 | return CMD_WARNING; | |
14852 | } | |
14853 | ||
14854 | if (vrf && strmatch(vrf, "all")) | |
14855 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14856 | ||
14857 | if (uj) | |
14858 | json = json_object_new_object(); | |
14859 | ||
14860 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
14861 | } | |
14862 | ||
14863 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, | |
14864 | safi_t safi) | |
14865 | { | |
14866 | struct listnode *node, *nnode; | |
14867 | struct bgp *bgp; | |
14868 | ||
14869 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14870 | vty_out(vty, "\nInstance %s:\n", | |
14871 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14872 | ? VRF_DEFAULT_NAME | |
14873 | : bgp->name); | |
14874 | update_group_show(bgp, afi, safi, vty, 0); | |
14875 | } | |
14876 | } | |
14877 | ||
14878 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, | |
14879 | int safi, uint64_t subgrp_id) | |
14880 | { | |
14881 | struct bgp *bgp; | |
14882 | ||
14883 | if (name) { | |
14884 | if (strmatch(name, "all")) { | |
14885 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14886 | return CMD_SUCCESS; | |
14887 | } else { | |
14888 | bgp = bgp_lookup_by_name(name); | |
14889 | } | |
14890 | } else { | |
14891 | bgp = bgp_get_default(); | |
14892 | } | |
14893 | ||
14894 | if (bgp) | |
14895 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14896 | return CMD_SUCCESS; | |
14897 | } | |
14898 | ||
14899 | DEFUN (show_ip_bgp_updgrps, | |
14900 | show_ip_bgp_updgrps_cmd, | |
14901 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", | |
14902 | SHOW_STR | |
14903 | IP_STR | |
14904 | BGP_STR | |
14905 | BGP_INSTANCE_HELP_STR | |
14906 | BGP_AFI_HELP_STR | |
14907 | BGP_SAFI_WITH_LABEL_HELP_STR | |
14908 | "Detailed info about dynamic update groups\n" | |
14909 | "Specific subgroup to display detailed info for\n") | |
14910 | { | |
14911 | char *vrf = NULL; | |
14912 | afi_t afi = AFI_IP6; | |
14913 | safi_t safi = SAFI_UNICAST; | |
14914 | uint64_t subgrp_id = 0; | |
14915 | ||
14916 | int idx = 0; | |
14917 | ||
14918 | /* show [ip] bgp */ | |
14919 | if (argv_find(argv, argc, "ip", &idx)) | |
14920 | afi = AFI_IP; | |
14921 | /* [<vrf> VIEWVRFNAME] */ | |
14922 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14923 | vrf = argv[idx + 1]->arg; | |
14924 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14925 | vrf = NULL; | |
14926 | } else if (argv_find(argv, argc, "view", &idx)) | |
14927 | /* [<view> VIEWVRFNAME] */ | |
14928 | vrf = argv[idx + 1]->arg; | |
14929 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
14930 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14931 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14932 | } | |
14933 | ||
14934 | /* get subgroup id, if provided */ | |
14935 | idx = argc - 1; | |
14936 | if (argv[idx]->type == VARIABLE_TKN) | |
14937 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
14938 | ||
14939 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
14940 | } | |
14941 | ||
14942 | DEFUN (show_bgp_instance_all_ipv6_updgrps, | |
14943 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
14944 | "show [ip] bgp <view|vrf> all update-groups", | |
14945 | SHOW_STR | |
14946 | IP_STR | |
14947 | BGP_STR | |
14948 | BGP_INSTANCE_ALL_HELP_STR | |
14949 | "Detailed info about dynamic update groups\n") | |
14950 | { | |
14951 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); | |
14952 | return CMD_SUCCESS; | |
14953 | } | |
14954 | ||
14955 | DEFUN (show_bgp_l2vpn_evpn_updgrps, | |
14956 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14957 | "show [ip] bgp l2vpn evpn update-groups", | |
14958 | SHOW_STR | |
14959 | IP_STR | |
14960 | BGP_STR | |
14961 | "l2vpn address family\n" | |
14962 | "evpn sub-address family\n" | |
14963 | "Detailed info about dynamic update groups\n") | |
14964 | { | |
14965 | char *vrf = NULL; | |
14966 | uint64_t subgrp_id = 0; | |
14967 | ||
14968 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14969 | return CMD_SUCCESS; | |
14970 | } | |
14971 | ||
14972 | DEFUN (show_bgp_updgrps_stats, | |
14973 | show_bgp_updgrps_stats_cmd, | |
14974 | "show [ip] bgp update-groups statistics", | |
14975 | SHOW_STR | |
14976 | IP_STR | |
14977 | BGP_STR | |
14978 | "Detailed info about dynamic update groups\n" | |
14979 | "Statistics\n") | |
14980 | { | |
14981 | struct bgp *bgp; | |
14982 | ||
14983 | bgp = bgp_get_default(); | |
14984 | if (bgp) | |
14985 | update_group_show_stats(bgp, vty); | |
14986 | ||
14987 | return CMD_SUCCESS; | |
14988 | } | |
14989 | ||
14990 | DEFUN (show_bgp_instance_updgrps_stats, | |
14991 | show_bgp_instance_updgrps_stats_cmd, | |
14992 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", | |
14993 | SHOW_STR | |
14994 | IP_STR | |
14995 | BGP_STR | |
14996 | BGP_INSTANCE_HELP_STR | |
14997 | "Detailed info about dynamic update groups\n" | |
14998 | "Statistics\n") | |
14999 | { | |
15000 | int idx_word = 3; | |
15001 | struct bgp *bgp; | |
15002 | ||
15003 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); | |
15004 | if (bgp) | |
15005 | update_group_show_stats(bgp, vty); | |
15006 | ||
15007 | return CMD_SUCCESS; | |
15008 | } | |
15009 | ||
15010 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, | |
15011 | afi_t afi, safi_t safi, | |
15012 | const char *what, uint64_t subgrp_id) | |
15013 | { | |
15014 | struct bgp *bgp; | |
15015 | ||
15016 | if (name) | |
15017 | bgp = bgp_lookup_by_name(name); | |
15018 | else | |
15019 | bgp = bgp_get_default(); | |
15020 | ||
15021 | if (bgp) { | |
15022 | if (!strcmp(what, "advertise-queue")) | |
15023 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15024 | subgrp_id); | |
15025 | else if (!strcmp(what, "advertised-routes")) | |
15026 | update_group_show_advertised(bgp, afi, safi, vty, | |
15027 | subgrp_id); | |
15028 | else if (!strcmp(what, "packet-queue")) | |
15029 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15030 | subgrp_id); | |
15031 | } | |
15032 | } | |
15033 | ||
15034 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, | |
15035 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15036 | "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", | |
15037 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15038 | BGP_SAFI_HELP_STR | |
15039 | "Detailed info about dynamic update groups\n" | |
15040 | "Specific subgroup to display info for\n" | |
15041 | "Advertisement queue\n" | |
15042 | "Announced routes\n" | |
15043 | "Packet queue\n") | |
15044 | { | |
15045 | uint64_t subgrp_id = 0; | |
15046 | afi_t afiz; | |
15047 | safi_t safiz; | |
15048 | if (sgid) | |
15049 | subgrp_id = strtoull(sgid, NULL, 10); | |
15050 | ||
15051 | if (!ip && !afi) | |
15052 | afiz = AFI_IP6; | |
15053 | if (!ip && afi) | |
15054 | afiz = bgp_vty_afi_from_str(afi); | |
15055 | if (ip && !afi) | |
15056 | afiz = AFI_IP; | |
15057 | if (ip && afi) { | |
15058 | afiz = bgp_vty_afi_from_str(afi); | |
15059 | if (afiz != AFI_IP) | |
15060 | vty_out(vty, | |
15061 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15062 | return CMD_WARNING; | |
15063 | } | |
15064 | ||
15065 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; | |
15066 | ||
15067 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); | |
15068 | return CMD_SUCCESS; | |
15069 | } | |
15070 | ||
15071 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, | |
15072 | json_object *json) | |
15073 | { | |
15074 | struct listnode *node, *nnode; | |
15075 | struct prefix *range; | |
15076 | struct peer *conf; | |
15077 | struct peer *peer; | |
15078 | afi_t afi; | |
15079 | safi_t safi; | |
15080 | const char *peer_status; | |
15081 | int lr_count; | |
15082 | int dynamic; | |
15083 | bool af_cfgd; | |
15084 | json_object *json_peer_group = NULL; | |
15085 | json_object *json_peer_group_afc = NULL; | |
15086 | json_object *json_peer_group_members = NULL; | |
15087 | json_object *json_peer_group_dynamic = NULL; | |
15088 | json_object *json_peer_group_dynamic_af = NULL; | |
15089 | json_object *json_peer_group_ranges = NULL; | |
15090 | ||
15091 | conf = group->conf; | |
15092 | ||
15093 | if (json) { | |
15094 | json_peer_group = json_object_new_object(); | |
15095 | json_peer_group_afc = json_object_new_array(); | |
15096 | } | |
15097 | ||
15098 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
15099 | if (json) | |
15100 | json_object_int_add(json_peer_group, "remoteAs", | |
15101 | conf->as); | |
15102 | else | |
15103 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15104 | group->name, conf->as); | |
15105 | } else if (conf->as_type == AS_INTERNAL) { | |
15106 | if (json) | |
15107 | json_object_int_add(json_peer_group, "remoteAs", | |
15108 | group->bgp->as); | |
15109 | else | |
15110 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15111 | group->name, group->bgp->as); | |
15112 | } else { | |
15113 | if (!json) | |
15114 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
15115 | } | |
15116 | ||
15117 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { | |
15118 | if (json) | |
15119 | json_object_string_add(json_peer_group, "type", | |
15120 | "internal"); | |
15121 | else | |
15122 | vty_out(vty, " Peer-group type is internal\n"); | |
15123 | } else { | |
15124 | if (json) | |
15125 | json_object_string_add(json_peer_group, "type", | |
15126 | "external"); | |
15127 | else | |
15128 | vty_out(vty, " Peer-group type is external\n"); | |
15129 | } | |
15130 | ||
15131 | /* Display AFs configured. */ | |
15132 | if (!json) | |
15133 | vty_out(vty, " Configured address-families:"); | |
15134 | ||
15135 | FOREACH_AFI_SAFI (afi, safi) { | |
15136 | if (conf->afc[afi][safi]) { | |
15137 | af_cfgd = true; | |
15138 | if (json) | |
15139 | json_object_array_add( | |
15140 | json_peer_group_afc, | |
15141 | json_object_new_string(get_afi_safi_str( | |
15142 | afi, safi, false))); | |
15143 | else | |
15144 | vty_out(vty, " %s;", | |
15145 | get_afi_safi_str(afi, safi, false)); | |
15146 | } | |
15147 | } | |
15148 | ||
15149 | if (json) { | |
15150 | json_object_object_add(json_peer_group, | |
15151 | "addressFamiliesConfigured", | |
15152 | json_peer_group_afc); | |
15153 | } else { | |
15154 | if (!af_cfgd) | |
15155 | vty_out(vty, " none\n"); | |
15156 | else | |
15157 | vty_out(vty, "\n"); | |
15158 | } | |
15159 | ||
15160 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15161 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
15162 | lr_count = listcount(group->listen_range[afi]); | |
15163 | if (lr_count) { | |
15164 | if (json) { | |
15165 | if (!json_peer_group_dynamic) | |
15166 | json_peer_group_dynamic = | |
15167 | json_object_new_object(); | |
15168 | ||
15169 | json_peer_group_dynamic_af = | |
15170 | json_object_new_object(); | |
15171 | json_peer_group_ranges = | |
15172 | json_object_new_array(); | |
15173 | json_object_int_add(json_peer_group_dynamic_af, | |
15174 | "count", lr_count); | |
15175 | } else { | |
15176 | vty_out(vty, " %d %s listen range(s)\n", | |
15177 | lr_count, afi2str(afi)); | |
15178 | } | |
15179 | ||
15180 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
15181 | nnode, range)) { | |
15182 | if (json) { | |
15183 | char buf[BUFSIZ]; | |
15184 | ||
15185 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15186 | range); | |
15187 | ||
15188 | json_object_array_add( | |
15189 | json_peer_group_ranges, | |
15190 | json_object_new_string(buf)); | |
15191 | } else { | |
15192 | vty_out(vty, " %pFX\n", range); | |
15193 | } | |
15194 | } | |
15195 | ||
15196 | if (json) { | |
15197 | json_object_object_add( | |
15198 | json_peer_group_dynamic_af, "ranges", | |
15199 | json_peer_group_ranges); | |
15200 | ||
15201 | json_object_object_add( | |
15202 | json_peer_group_dynamic, afi2str(afi), | |
15203 | json_peer_group_dynamic_af); | |
15204 | } | |
15205 | } | |
15206 | } | |
15207 | ||
15208 | if (json_peer_group_dynamic) | |
15209 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15210 | json_peer_group_dynamic); | |
15211 | ||
15212 | /* Display group members and their status */ | |
15213 | if (listcount(group->peer)) { | |
15214 | if (json) | |
15215 | json_peer_group_members = json_object_new_object(); | |
15216 | else | |
15217 | vty_out(vty, " Peer-group members:\n"); | |
15218 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
15219 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
15220 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
15221 | peer_status = "Idle (Admin)"; | |
15222 | else if (CHECK_FLAG(peer->sflags, | |
15223 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15224 | peer_status = "Idle (PfxCt)"; | |
15225 | else | |
15226 | peer_status = lookup_msg(bgp_status_msg, | |
15227 | peer->status, NULL); | |
15228 | ||
15229 | dynamic = peer_dynamic_neighbor(peer); | |
15230 | ||
15231 | if (json) { | |
15232 | json_object *json_peer_group_member = | |
15233 | json_object_new_object(); | |
15234 | ||
15235 | json_object_string_add(json_peer_group_member, | |
15236 | "status", peer_status); | |
15237 | ||
15238 | if (dynamic) | |
15239 | json_object_boolean_true_add( | |
15240 | json_peer_group_member, | |
15241 | "dynamic"); | |
15242 | ||
15243 | json_object_object_add(json_peer_group_members, | |
15244 | peer->host, | |
15245 | json_peer_group_member); | |
15246 | } else { | |
15247 | vty_out(vty, " %s %s %s \n", peer->host, | |
15248 | dynamic ? "(dynamic)" : "", | |
15249 | peer_status); | |
15250 | } | |
15251 | } | |
15252 | if (json) | |
15253 | json_object_object_add(json_peer_group, "members", | |
15254 | json_peer_group_members); | |
15255 | } | |
15256 | ||
15257 | if (json) | |
15258 | json_object_object_add(json, group->name, json_peer_group); | |
15259 | ||
15260 | return CMD_SUCCESS; | |
15261 | } | |
15262 | ||
15263 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, | |
15264 | const char *group_name, bool uj) | |
15265 | { | |
15266 | struct bgp *bgp; | |
15267 | struct listnode *node, *nnode; | |
15268 | struct peer_group *group; | |
15269 | bool found = false; | |
15270 | json_object *json = NULL; | |
15271 | ||
15272 | if (uj) | |
15273 | json = json_object_new_object(); | |
15274 | ||
15275 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15276 | ||
15277 | if (!bgp) { | |
15278 | if (uj) | |
15279 | vty_json(vty, json); | |
15280 | else | |
15281 | vty_out(vty, "%% BGP instance not found\n"); | |
15282 | ||
15283 | return CMD_WARNING; | |
15284 | } | |
15285 | ||
15286 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15287 | if (group_name) { | |
15288 | if (strmatch(group->name, group_name)) { | |
15289 | bgp_show_one_peer_group(vty, group, json); | |
15290 | found = true; | |
15291 | break; | |
15292 | } | |
15293 | } else { | |
15294 | bgp_show_one_peer_group(vty, group, json); | |
15295 | } | |
15296 | } | |
15297 | ||
15298 | if (group_name && !found && !uj) | |
15299 | vty_out(vty, "%% No such peer-group\n"); | |
15300 | ||
15301 | if (uj) | |
15302 | vty_json(vty, json); | |
15303 | ||
15304 | return CMD_SUCCESS; | |
15305 | } | |
15306 | ||
15307 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, | |
15308 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15309 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15310 | "Detailed information on BGP peer groups\n" | |
15311 | "Peer group name\n" JSON_STR) | |
15312 | { | |
15313 | char *vrf, *pg; | |
15314 | int idx = 0; | |
15315 | bool uj = use_json(argc, argv); | |
15316 | ||
15317 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg | |
15318 | : NULL; | |
15319 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
15320 | ||
15321 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); | |
15322 | } | |
15323 | ||
15324 | ||
15325 | /* Redistribute VTY commands. */ | |
15326 | ||
15327 | DEFUN (bgp_redistribute_ipv4, | |
15328 | bgp_redistribute_ipv4_cmd, | |
15329 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15330 | "Redistribute information from another routing protocol\n" | |
15331 | FRR_IP_REDIST_HELP_STR_BGPD) | |
15332 | { | |
15333 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15334 | int idx_protocol = 1; | |
15335 | int type; | |
15336 | ||
15337 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15338 | if (type < 0) { | |
15339 | vty_out(vty, "%% Invalid route type\n"); | |
15340 | return CMD_WARNING_CONFIG_FAILED; | |
15341 | } | |
15342 | ||
15343 | bgp_redist_add(bgp, AFI_IP, type, 0); | |
15344 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
15345 | } | |
15346 | ||
15347 | ALIAS_HIDDEN( | |
15348 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15349 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15350 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
15351 | ||
15352 | DEFUN (bgp_redistribute_ipv4_rmap, | |
15353 | bgp_redistribute_ipv4_rmap_cmd, | |
15354 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15355 | "Redistribute information from another routing protocol\n" | |
15356 | FRR_IP_REDIST_HELP_STR_BGPD | |
15357 | "Route map reference\n" | |
15358 | "Pointer to route-map entries\n") | |
15359 | { | |
15360 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15361 | int idx_protocol = 1; | |
15362 | int idx_word = 3; | |
15363 | int type; | |
15364 | struct bgp_redist *red; | |
15365 | bool changed; | |
15366 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15367 | vty, argv[idx_word]->arg); | |
15368 | ||
15369 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15370 | if (type < 0) { | |
15371 | vty_out(vty, "%% Invalid route type\n"); | |
15372 | return CMD_WARNING_CONFIG_FAILED; | |
15373 | } | |
15374 | ||
15375 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
15376 | changed = | |
15377 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15378 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
15379 | } | |
15380 | ||
15381 | ALIAS_HIDDEN( | |
15382 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15383 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15384 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15385 | "Route map reference\n" | |
15386 | "Pointer to route-map entries\n") | |
15387 | ||
15388 | DEFUN (bgp_redistribute_ipv4_metric, | |
15389 | bgp_redistribute_ipv4_metric_cmd, | |
15390 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15391 | "Redistribute information from another routing protocol\n" | |
15392 | FRR_IP_REDIST_HELP_STR_BGPD | |
15393 | "Metric for redistributed routes\n" | |
15394 | "Default metric\n") | |
15395 | { | |
15396 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15397 | int idx_protocol = 1; | |
15398 | int idx_number = 3; | |
15399 | int type; | |
15400 | uint32_t metric; | |
15401 | struct bgp_redist *red; | |
15402 | bool changed; | |
15403 | ||
15404 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15405 | if (type < 0) { | |
15406 | vty_out(vty, "%% Invalid route type\n"); | |
15407 | return CMD_WARNING_CONFIG_FAILED; | |
15408 | } | |
15409 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15410 | ||
15411 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
15412 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15413 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
15414 | } | |
15415 | ||
15416 | ALIAS_HIDDEN( | |
15417 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15418 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15419 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15420 | "Metric for redistributed routes\n" | |
15421 | "Default metric\n") | |
15422 | ||
15423 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
15424 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15425 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15426 | "Redistribute information from another routing protocol\n" | |
15427 | FRR_IP_REDIST_HELP_STR_BGPD | |
15428 | "Route map reference\n" | |
15429 | "Pointer to route-map entries\n" | |
15430 | "Metric for redistributed routes\n" | |
15431 | "Default metric\n") | |
15432 | { | |
15433 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15434 | int idx_protocol = 1; | |
15435 | int idx_word = 3; | |
15436 | int idx_number = 5; | |
15437 | int type; | |
15438 | uint32_t metric; | |
15439 | struct bgp_redist *red; | |
15440 | bool changed; | |
15441 | struct route_map *route_map = | |
15442 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15443 | ||
15444 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15445 | if (type < 0) { | |
15446 | vty_out(vty, "%% Invalid route type\n"); | |
15447 | return CMD_WARNING_CONFIG_FAILED; | |
15448 | } | |
15449 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15450 | ||
15451 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
15452 | changed = | |
15453 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15454 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15455 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
15456 | } | |
15457 | ||
15458 | ALIAS_HIDDEN( | |
15459 | bgp_redistribute_ipv4_rmap_metric, | |
15460 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15461 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15462 | " route-map WORD metric (0-4294967295)", | |
15463 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15464 | "Route map reference\n" | |
15465 | "Pointer to route-map entries\n" | |
15466 | "Metric for redistributed routes\n" | |
15467 | "Default metric\n") | |
15468 | ||
15469 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
15470 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15471 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15472 | "Redistribute information from another routing protocol\n" | |
15473 | FRR_IP_REDIST_HELP_STR_BGPD | |
15474 | "Metric for redistributed routes\n" | |
15475 | "Default metric\n" | |
15476 | "Route map reference\n" | |
15477 | "Pointer to route-map entries\n") | |
15478 | { | |
15479 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15480 | int idx_protocol = 1; | |
15481 | int idx_number = 3; | |
15482 | int idx_word = 5; | |
15483 | int type; | |
15484 | uint32_t metric; | |
15485 | struct bgp_redist *red; | |
15486 | bool changed; | |
15487 | struct route_map *route_map = | |
15488 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15489 | ||
15490 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15491 | if (type < 0) { | |
15492 | vty_out(vty, "%% Invalid route type\n"); | |
15493 | return CMD_WARNING_CONFIG_FAILED; | |
15494 | } | |
15495 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15496 | ||
15497 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
15498 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15499 | changed |= | |
15500 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15501 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
15502 | } | |
15503 | ||
15504 | ALIAS_HIDDEN( | |
15505 | bgp_redistribute_ipv4_metric_rmap, | |
15506 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15507 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15508 | " metric (0-4294967295) route-map WORD", | |
15509 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15510 | "Metric for redistributed routes\n" | |
15511 | "Default metric\n" | |
15512 | "Route map reference\n" | |
15513 | "Pointer to route-map entries\n") | |
15514 | ||
15515 | DEFUN (bgp_redistribute_ipv4_ospf, | |
15516 | bgp_redistribute_ipv4_ospf_cmd, | |
15517 | "redistribute <ospf|table> (1-65535)", | |
15518 | "Redistribute information from another routing protocol\n" | |
15519 | "Open Shortest Path First (OSPFv2)\n" | |
15520 | "Non-main Kernel Routing Table\n" | |
15521 | "Instance ID/Table ID\n") | |
15522 | { | |
15523 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15524 | int idx_ospf_table = 1; | |
15525 | int idx_number = 2; | |
15526 | unsigned short instance; | |
15527 | unsigned short protocol; | |
15528 | ||
15529 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15530 | ||
15531 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15532 | protocol = ZEBRA_ROUTE_OSPF; | |
15533 | else | |
15534 | protocol = ZEBRA_ROUTE_TABLE; | |
15535 | ||
15536 | bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15537 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
15538 | } | |
15539 | ||
15540 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, | |
15541 | "redistribute <ospf|table> (1-65535)", | |
15542 | "Redistribute information from another routing protocol\n" | |
15543 | "Open Shortest Path First (OSPFv2)\n" | |
15544 | "Non-main Kernel Routing Table\n" | |
15545 | "Instance ID/Table ID\n") | |
15546 | ||
15547 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
15548 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15549 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15550 | "Redistribute information from another routing protocol\n" | |
15551 | "Open Shortest Path First (OSPFv2)\n" | |
15552 | "Non-main Kernel Routing Table\n" | |
15553 | "Instance ID/Table ID\n" | |
15554 | "Route map reference\n" | |
15555 | "Pointer to route-map entries\n") | |
15556 | { | |
15557 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15558 | int idx_ospf_table = 1; | |
15559 | int idx_number = 2; | |
15560 | int idx_word = 4; | |
15561 | struct bgp_redist *red; | |
15562 | unsigned short instance; | |
15563 | int protocol; | |
15564 | bool changed; | |
15565 | struct route_map *route_map = | |
15566 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15567 | ||
15568 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15569 | protocol = ZEBRA_ROUTE_OSPF; | |
15570 | else | |
15571 | protocol = ZEBRA_ROUTE_TABLE; | |
15572 | ||
15573 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15574 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15575 | changed = | |
15576 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15577 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
15578 | } | |
15579 | ||
15580 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15581 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15582 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15583 | "Redistribute information from another routing protocol\n" | |
15584 | "Open Shortest Path First (OSPFv2)\n" | |
15585 | "Non-main Kernel Routing Table\n" | |
15586 | "Instance ID/Table ID\n" | |
15587 | "Route map reference\n" | |
15588 | "Pointer to route-map entries\n") | |
15589 | ||
15590 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
15591 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15592 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15593 | "Redistribute information from another routing protocol\n" | |
15594 | "Open Shortest Path First (OSPFv2)\n" | |
15595 | "Non-main Kernel Routing Table\n" | |
15596 | "Instance ID/Table ID\n" | |
15597 | "Metric for redistributed routes\n" | |
15598 | "Default metric\n") | |
15599 | { | |
15600 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15601 | int idx_ospf_table = 1; | |
15602 | int idx_number = 2; | |
15603 | int idx_number_2 = 4; | |
15604 | uint32_t metric; | |
15605 | struct bgp_redist *red; | |
15606 | unsigned short instance; | |
15607 | int protocol; | |
15608 | bool changed; | |
15609 | ||
15610 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15611 | protocol = ZEBRA_ROUTE_OSPF; | |
15612 | else | |
15613 | protocol = ZEBRA_ROUTE_TABLE; | |
15614 | ||
15615 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15616 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
15617 | ||
15618 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15619 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15620 | metric); | |
15621 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
15622 | } | |
15623 | ||
15624 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15625 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15626 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15627 | "Redistribute information from another routing protocol\n" | |
15628 | "Open Shortest Path First (OSPFv2)\n" | |
15629 | "Non-main Kernel Routing Table\n" | |
15630 | "Instance ID/Table ID\n" | |
15631 | "Metric for redistributed routes\n" | |
15632 | "Default metric\n") | |
15633 | ||
15634 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
15635 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15636 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15637 | "Redistribute information from another routing protocol\n" | |
15638 | "Open Shortest Path First (OSPFv2)\n" | |
15639 | "Non-main Kernel Routing Table\n" | |
15640 | "Instance ID/Table ID\n" | |
15641 | "Route map reference\n" | |
15642 | "Pointer to route-map entries\n" | |
15643 | "Metric for redistributed routes\n" | |
15644 | "Default metric\n") | |
15645 | { | |
15646 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15647 | int idx_ospf_table = 1; | |
15648 | int idx_number = 2; | |
15649 | int idx_word = 4; | |
15650 | int idx_number_2 = 6; | |
15651 | uint32_t metric; | |
15652 | struct bgp_redist *red; | |
15653 | unsigned short instance; | |
15654 | int protocol; | |
15655 | bool changed; | |
15656 | struct route_map *route_map = | |
15657 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15658 | ||
15659 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15660 | protocol = ZEBRA_ROUTE_OSPF; | |
15661 | else | |
15662 | protocol = ZEBRA_ROUTE_TABLE; | |
15663 | ||
15664 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15665 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
15666 | ||
15667 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15668 | changed = | |
15669 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15670 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15671 | metric); | |
15672 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
15673 | } | |
15674 | ||
15675 | ALIAS_HIDDEN( | |
15676 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15677 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15678 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15679 | "Redistribute information from another routing protocol\n" | |
15680 | "Open Shortest Path First (OSPFv2)\n" | |
15681 | "Non-main Kernel Routing Table\n" | |
15682 | "Instance ID/Table ID\n" | |
15683 | "Route map reference\n" | |
15684 | "Pointer to route-map entries\n" | |
15685 | "Metric for redistributed routes\n" | |
15686 | "Default metric\n") | |
15687 | ||
15688 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
15689 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15690 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15691 | "Redistribute information from another routing protocol\n" | |
15692 | "Open Shortest Path First (OSPFv2)\n" | |
15693 | "Non-main Kernel Routing Table\n" | |
15694 | "Instance ID/Table ID\n" | |
15695 | "Metric for redistributed routes\n" | |
15696 | "Default metric\n" | |
15697 | "Route map reference\n" | |
15698 | "Pointer to route-map entries\n") | |
15699 | { | |
15700 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15701 | int idx_ospf_table = 1; | |
15702 | int idx_number = 2; | |
15703 | int idx_number_2 = 4; | |
15704 | int idx_word = 6; | |
15705 | uint32_t metric; | |
15706 | struct bgp_redist *red; | |
15707 | unsigned short instance; | |
15708 | int protocol; | |
15709 | bool changed; | |
15710 | struct route_map *route_map = | |
15711 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15712 | ||
15713 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15714 | protocol = ZEBRA_ROUTE_OSPF; | |
15715 | else | |
15716 | protocol = ZEBRA_ROUTE_TABLE; | |
15717 | ||
15718 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15719 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
15720 | ||
15721 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15722 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15723 | metric); | |
15724 | changed |= | |
15725 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15726 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
15727 | } | |
15728 | ||
15729 | ALIAS_HIDDEN( | |
15730 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15731 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15732 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15733 | "Redistribute information from another routing protocol\n" | |
15734 | "Open Shortest Path First (OSPFv2)\n" | |
15735 | "Non-main Kernel Routing Table\n" | |
15736 | "Instance ID/Table ID\n" | |
15737 | "Metric for redistributed routes\n" | |
15738 | "Default metric\n" | |
15739 | "Route map reference\n" | |
15740 | "Pointer to route-map entries\n") | |
15741 | ||
15742 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
15743 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15744 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15745 | NO_STR | |
15746 | "Redistribute information from another routing protocol\n" | |
15747 | "Open Shortest Path First (OSPFv2)\n" | |
15748 | "Non-main Kernel Routing Table\n" | |
15749 | "Instance ID/Table ID\n" | |
15750 | "Metric for redistributed routes\n" | |
15751 | "Default metric\n" | |
15752 | "Route map reference\n" | |
15753 | "Pointer to route-map entries\n") | |
15754 | { | |
15755 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15756 | int idx_ospf_table = 2; | |
15757 | int idx_number = 3; | |
15758 | unsigned short instance; | |
15759 | int protocol; | |
15760 | ||
15761 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15762 | protocol = ZEBRA_ROUTE_OSPF; | |
15763 | else | |
15764 | protocol = ZEBRA_ROUTE_TABLE; | |
15765 | ||
15766 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
15767 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
15768 | } | |
15769 | ||
15770 | ALIAS_HIDDEN( | |
15771 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
15772 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15773 | NO_STR | |
15774 | "Redistribute information from another routing protocol\n" | |
15775 | "Open Shortest Path First (OSPFv2)\n" | |
15776 | "Non-main Kernel Routing Table\n" | |
15777 | "Instance ID/Table ID\n" | |
15778 | "Metric for redistributed routes\n" | |
15779 | "Default metric\n" | |
15780 | "Route map reference\n" | |
15781 | "Pointer to route-map entries\n") | |
15782 | ||
15783 | DEFUN (no_bgp_redistribute_ipv4, | |
15784 | no_bgp_redistribute_ipv4_cmd, | |
15785 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15786 | NO_STR | |
15787 | "Redistribute information from another routing protocol\n" | |
15788 | FRR_IP_REDIST_HELP_STR_BGPD | |
15789 | "Metric for redistributed routes\n" | |
15790 | "Default metric\n" | |
15791 | "Route map reference\n" | |
15792 | "Pointer to route-map entries\n") | |
15793 | { | |
15794 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15795 | int idx_protocol = 2; | |
15796 | int type; | |
15797 | ||
15798 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15799 | if (type < 0) { | |
15800 | vty_out(vty, "%% Invalid route type\n"); | |
15801 | return CMD_WARNING_CONFIG_FAILED; | |
15802 | } | |
15803 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
15804 | } | |
15805 | ||
15806 | ALIAS_HIDDEN( | |
15807 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15808 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
15809 | " [{metric (0-4294967295)|route-map WORD}]", | |
15810 | NO_STR | |
15811 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15812 | "Metric for redistributed routes\n" | |
15813 | "Default metric\n" | |
15814 | "Route map reference\n" | |
15815 | "Pointer to route-map entries\n") | |
15816 | ||
15817 | DEFUN (bgp_redistribute_ipv6, | |
15818 | bgp_redistribute_ipv6_cmd, | |
15819 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15820 | "Redistribute information from another routing protocol\n" | |
15821 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
15822 | { | |
15823 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15824 | int idx_protocol = 1; | |
15825 | int type; | |
15826 | ||
15827 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15828 | if (type < 0) { | |
15829 | vty_out(vty, "%% Invalid route type\n"); | |
15830 | return CMD_WARNING_CONFIG_FAILED; | |
15831 | } | |
15832 | ||
15833 | bgp_redist_add(bgp, AFI_IP6, type, 0); | |
15834 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
15835 | } | |
15836 | ||
15837 | DEFUN (bgp_redistribute_ipv6_rmap, | |
15838 | bgp_redistribute_ipv6_rmap_cmd, | |
15839 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15840 | "Redistribute information from another routing protocol\n" | |
15841 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15842 | "Route map reference\n" | |
15843 | "Pointer to route-map entries\n") | |
15844 | { | |
15845 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15846 | int idx_protocol = 1; | |
15847 | int idx_word = 3; | |
15848 | int type; | |
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 | ||
15860 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); | |
15861 | changed = | |
15862 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15863 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
15864 | } | |
15865 | ||
15866 | DEFUN (bgp_redistribute_ipv6_metric, | |
15867 | bgp_redistribute_ipv6_metric_cmd, | |
15868 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", | |
15869 | "Redistribute information from another routing protocol\n" | |
15870 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15871 | "Metric for redistributed routes\n" | |
15872 | "Default metric\n") | |
15873 | { | |
15874 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15875 | int idx_protocol = 1; | |
15876 | int idx_number = 3; | |
15877 | int type; | |
15878 | uint32_t metric; | |
15879 | struct bgp_redist *red; | |
15880 | bool changed; | |
15881 | ||
15882 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15883 | if (type < 0) { | |
15884 | vty_out(vty, "%% Invalid route type\n"); | |
15885 | return CMD_WARNING_CONFIG_FAILED; | |
15886 | } | |
15887 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15888 | ||
15889 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); | |
15890 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
15891 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
15892 | } | |
15893 | ||
15894 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
15895 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15896 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15897 | "Redistribute information from another routing protocol\n" | |
15898 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15899 | "Route map reference\n" | |
15900 | "Pointer to route-map entries\n" | |
15901 | "Metric for redistributed routes\n" | |
15902 | "Default metric\n") | |
15903 | { | |
15904 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15905 | int idx_protocol = 1; | |
15906 | int idx_word = 3; | |
15907 | int idx_number = 5; | |
15908 | int type; | |
15909 | uint32_t metric; | |
15910 | struct bgp_redist *red; | |
15911 | bool changed; | |
15912 | struct route_map *route_map = | |
15913 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15914 | ||
15915 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15916 | if (type < 0) { | |
15917 | vty_out(vty, "%% Invalid route type\n"); | |
15918 | return CMD_WARNING_CONFIG_FAILED; | |
15919 | } | |
15920 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15921 | ||
15922 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); | |
15923 | changed = | |
15924 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15925 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
15926 | metric); | |
15927 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
15928 | } | |
15929 | ||
15930 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
15931 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15932 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15933 | "Redistribute information from another routing protocol\n" | |
15934 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15935 | "Metric for redistributed routes\n" | |
15936 | "Default metric\n" | |
15937 | "Route map reference\n" | |
15938 | "Pointer to route-map entries\n") | |
15939 | { | |
15940 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15941 | int idx_protocol = 1; | |
15942 | int idx_number = 3; | |
15943 | int idx_word = 5; | |
15944 | int type; | |
15945 | uint32_t metric; | |
15946 | struct bgp_redist *red; | |
15947 | bool changed; | |
15948 | struct route_map *route_map = | |
15949 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15950 | ||
15951 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15952 | if (type < 0) { | |
15953 | vty_out(vty, "%% Invalid route type\n"); | |
15954 | return CMD_WARNING_CONFIG_FAILED; | |
15955 | } | |
15956 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
15957 | ||
15958 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); | |
15959 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
15960 | metric); | |
15961 | changed |= | |
15962 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15963 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
15964 | } | |
15965 | ||
15966 | DEFUN (no_bgp_redistribute_ipv6, | |
15967 | no_bgp_redistribute_ipv6_cmd, | |
15968 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15969 | NO_STR | |
15970 | "Redistribute information from another routing protocol\n" | |
15971 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15972 | "Metric for redistributed routes\n" | |
15973 | "Default metric\n" | |
15974 | "Route map reference\n" | |
15975 | "Pointer to route-map entries\n") | |
15976 | { | |
15977 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
15978 | int idx_protocol = 2; | |
15979 | int type; | |
15980 | ||
15981 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15982 | if (type < 0) { | |
15983 | vty_out(vty, "%% Invalid route type\n"); | |
15984 | return CMD_WARNING_CONFIG_FAILED; | |
15985 | } | |
15986 | ||
15987 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); | |
15988 | } | |
15989 | ||
15990 | /* Neighbor update tcp-mss. */ | |
15991 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
15992 | const char *tcp_mss_str) | |
15993 | { | |
15994 | struct peer *peer; | |
15995 | uint32_t tcp_mss_val = 0; | |
15996 | ||
15997 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
15998 | if (!peer) | |
15999 | return CMD_WARNING_CONFIG_FAILED; | |
16000 | ||
16001 | if (tcp_mss_str) { | |
16002 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16003 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16004 | } else { | |
16005 | peer_tcp_mss_unset(peer); | |
16006 | } | |
16007 | ||
16008 | return CMD_SUCCESS; | |
16009 | } | |
16010 | ||
16011 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16012 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16013 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16014 | "TCP max segment size\n" | |
16015 | "TCP MSS value\n") | |
16016 | { | |
16017 | int peer_index = 1; | |
16018 | int mss_index = 3; | |
16019 | ||
16020 | vty_out(vty, | |
16021 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16022 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16023 | argv[mss_index]->arg); | |
16024 | } | |
16025 | ||
16026 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16027 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16028 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16029 | "TCP max segment size\n" | |
16030 | "TCP MSS value\n") | |
16031 | { | |
16032 | int peer_index = 2; | |
16033 | ||
16034 | vty_out(vty, | |
16035 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16036 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16037 | } | |
16038 | ||
16039 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, | |
16040 | afi_t afi, safi_t safi) | |
16041 | { | |
16042 | int i; | |
16043 | ||
16044 | /* Unicast redistribution only. */ | |
16045 | if (safi != SAFI_UNICAST) | |
16046 | return; | |
16047 | ||
16048 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16049 | /* Redistribute BGP does not make sense. */ | |
16050 | if (i != ZEBRA_ROUTE_BGP) { | |
16051 | struct list *red_list; | |
16052 | struct listnode *node; | |
16053 | struct bgp_redist *red; | |
16054 | ||
16055 | red_list = bgp->redist[afi][i]; | |
16056 | if (!red_list) | |
16057 | continue; | |
16058 | ||
16059 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
16060 | /* "redistribute" configuration. */ | |
16061 | vty_out(vty, " redistribute %s", | |
16062 | zebra_route_string(i)); | |
16063 | if (red->instance) | |
16064 | vty_out(vty, " %d", red->instance); | |
16065 | if (red->redist_metric_flag) | |
16066 | vty_out(vty, " metric %u", | |
16067 | red->redist_metric); | |
16068 | if (red->rmap.name) | |
16069 | vty_out(vty, " route-map %s", | |
16070 | red->rmap.name); | |
16071 | vty_out(vty, "\n"); | |
16072 | } | |
16073 | } | |
16074 | } | |
16075 | } | |
16076 | ||
16077 | /* peer-group helpers for config-write */ | |
16078 | ||
16079 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16080 | { | |
16081 | if (!peer_group_active(peer)) { | |
16082 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16083 | return !CHECK_FLAG(peer->flags, flag); | |
16084 | else | |
16085 | return !!CHECK_FLAG(peer->flags, flag); | |
16086 | } | |
16087 | ||
16088 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16089 | } | |
16090 | ||
16091 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16092 | uint32_t flag) | |
16093 | { | |
16094 | if (!peer_group_active(peer)) { | |
16095 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16096 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16097 | else | |
16098 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16099 | } | |
16100 | ||
16101 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16102 | } | |
16103 | ||
16104 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16105 | uint8_t type, int direct) | |
16106 | { | |
16107 | struct bgp_filter *filter; | |
16108 | ||
16109 | if (peer_group_active(peer)) | |
16110 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16111 | type); | |
16112 | ||
16113 | filter = &peer->filter[afi][safi]; | |
16114 | switch (type) { | |
16115 | case PEER_FT_DISTRIBUTE_LIST: | |
16116 | return !!(filter->dlist[direct].name); | |
16117 | case PEER_FT_FILTER_LIST: | |
16118 | return !!(filter->aslist[direct].name); | |
16119 | case PEER_FT_PREFIX_LIST: | |
16120 | return !!(filter->plist[direct].name); | |
16121 | case PEER_FT_ROUTE_MAP: | |
16122 | return !!(filter->map[direct].name); | |
16123 | case PEER_FT_UNSUPPRESS_MAP: | |
16124 | return !!(filter->usmap.name); | |
16125 | case PEER_FT_ADVERTISE_MAP: | |
16126 | return !!(filter->advmap.aname | |
16127 | && ((filter->advmap.condition == direct) | |
16128 | && filter->advmap.cname)); | |
16129 | default: | |
16130 | return false; | |
16131 | } | |
16132 | } | |
16133 | ||
16134 | /* Return true if the addpath type is set for peer and different from | |
16135 | * peer-group. | |
16136 | */ | |
16137 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, | |
16138 | safi_t safi) | |
16139 | { | |
16140 | enum bgp_addpath_strat type, g_type; | |
16141 | ||
16142 | type = peer->addpath_type[afi][safi]; | |
16143 | ||
16144 | if (type != BGP_ADDPATH_NONE) { | |
16145 | if (peer_group_active(peer)) { | |
16146 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16147 | ||
16148 | if (type != g_type) | |
16149 | return true; | |
16150 | else | |
16151 | return false; | |
16152 | } | |
16153 | ||
16154 | return true; | |
16155 | } | |
16156 | ||
16157 | return false; | |
16158 | } | |
16159 | ||
16160 | /* This is part of the address-family block (unicast only) */ | |
16161 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
16162 | afi_t afi) | |
16163 | { | |
16164 | int indent = 2; | |
16165 | uint32_t tovpn_sid_index = 0; | |
16166 | ||
16167 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16168 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16169 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
16170 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
16171 | bgp->vpn_policy[afi] | |
16172 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16173 | else | |
16174 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16175 | bgp->vpn_policy[afi] | |
16176 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16177 | } | |
16178 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16179 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16180 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16181 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16182 | return; | |
16183 | ||
16184 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16185 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16186 | ||
16187 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16188 | ||
16189 | } else { | |
16190 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16191 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16192 | bgp->vpn_policy[afi].tovpn_label); | |
16193 | } | |
16194 | } | |
16195 | ||
16196 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16197 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16198 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16199 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16200 | } else if (tovpn_sid_index != 0) { | |
16201 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16202 | tovpn_sid_index); | |
16203 | } | |
16204 | ||
16205 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16206 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16207 | char buf[RD_ADDRSTRLEN]; | |
16208 | vty_out(vty, "%*srd vpn export %s\n", indent, "", | |
16209 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, | |
16210 | sizeof(buf))); | |
16211 | } | |
16212 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16213 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16214 | ||
16215 | char buf[PREFIX_STRLEN]; | |
16216 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16217 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16218 | sizeof(buf))) { | |
16219 | ||
16220 | vty_out(vty, "%*snexthop vpn export %s\n", | |
16221 | indent, "", buf); | |
16222 | } | |
16223 | } | |
16224 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16225 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16226 | && ecommunity_cmp( | |
16227 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16228 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16229 | ||
16230 | char *b = ecommunity_ecom2str( | |
16231 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16232 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
16233 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); | |
16234 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
16235 | } else { | |
16236 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16237 | char *b = ecommunity_ecom2str( | |
16238 | bgp->vpn_policy[afi] | |
16239 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16240 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16241 | ECOMMUNITY_ROUTE_TARGET); | |
16242 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); | |
16243 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
16244 | } | |
16245 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16246 | char *b = ecommunity_ecom2str( | |
16247 | bgp->vpn_policy[afi] | |
16248 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16249 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16250 | ECOMMUNITY_ROUTE_TARGET); | |
16251 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); | |
16252 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
16253 | } | |
16254 | } | |
16255 | ||
16256 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
16257 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", | |
16258 | bgp->vpn_policy[afi] | |
16259 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
16260 | ||
16261 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { | |
16262 | char *b = ecommunity_ecom2str( | |
16263 | bgp->vpn_policy[afi] | |
16264 | .import_redirect_rtlist, | |
16265 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16266 | ECOMMUNITY_ROUTE_TARGET); | |
16267 | ||
16268 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size | |
16269 | != ECOMMUNITY_SIZE) | |
16270 | vty_out(vty, "%*srt6 redirect import %s\n", | |
16271 | indent, "", b); | |
16272 | else | |
16273 | vty_out(vty, "%*srt redirect import %s\n", | |
16274 | indent, "", b); | |
16275 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
16276 | } | |
16277 | } | |
16278 | ||
16279 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, | |
16280 | afi_t afi, safi_t safi) | |
16281 | { | |
16282 | struct bgp_filter *filter; | |
16283 | char *addr; | |
16284 | ||
16285 | addr = peer->host; | |
16286 | filter = &peer->filter[afi][safi]; | |
16287 | ||
16288 | /* distribute-list. */ | |
16289 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16290 | FILTER_IN)) | |
16291 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16292 | filter->dlist[FILTER_IN].name); | |
16293 | ||
16294 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16295 | FILTER_OUT)) | |
16296 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16297 | filter->dlist[FILTER_OUT].name); | |
16298 | ||
16299 | /* prefix-list. */ | |
16300 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16301 | FILTER_IN)) | |
16302 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16303 | filter->plist[FILTER_IN].name); | |
16304 | ||
16305 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16306 | FILTER_OUT)) | |
16307 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16308 | filter->plist[FILTER_OUT].name); | |
16309 | ||
16310 | /* route-map. */ | |
16311 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16312 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16313 | filter->map[RMAP_IN].name); | |
16314 | ||
16315 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16316 | RMAP_OUT)) | |
16317 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16318 | filter->map[RMAP_OUT].name); | |
16319 | ||
16320 | /* unsuppress-map */ | |
16321 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16322 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16323 | filter->usmap.name); | |
16324 | ||
16325 | /* advertise-map : always applied in OUT direction*/ | |
16326 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16327 | CONDITION_NON_EXIST)) | |
16328 | vty_out(vty, | |
16329 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16330 | addr, filter->advmap.aname, filter->advmap.cname); | |
16331 | ||
16332 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16333 | CONDITION_EXIST)) | |
16334 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16335 | addr, filter->advmap.aname, filter->advmap.cname); | |
16336 | ||
16337 | /* filter-list. */ | |
16338 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16339 | FILTER_IN)) | |
16340 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16341 | filter->aslist[FILTER_IN].name); | |
16342 | ||
16343 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16344 | FILTER_OUT)) | |
16345 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16346 | filter->aslist[FILTER_OUT].name); | |
16347 | } | |
16348 | ||
16349 | /* BGP peer configuration display function. */ | |
16350 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16351 | struct peer *peer) | |
16352 | { | |
16353 | struct peer *g_peer = NULL; | |
16354 | char buf[SU_ADDRSTRLEN]; | |
16355 | char *addr; | |
16356 | int if_pg_printed = false; | |
16357 | int if_ras_printed = false; | |
16358 | ||
16359 | /* Skip dynamic neighbors. */ | |
16360 | if (peer_dynamic_neighbor(peer)) | |
16361 | return; | |
16362 | ||
16363 | if (peer->conf_if) | |
16364 | addr = peer->conf_if; | |
16365 | else | |
16366 | addr = peer->host; | |
16367 | ||
16368 | /************************************ | |
16369 | ****** Global to the neighbor ****** | |
16370 | ************************************/ | |
16371 | if (peer->conf_if) { | |
16372 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16373 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16374 | else | |
16375 | vty_out(vty, " neighbor %s interface", addr); | |
16376 | ||
16377 | if (peer_group_active(peer)) { | |
16378 | vty_out(vty, " peer-group %s", peer->group->name); | |
16379 | if_pg_printed = true; | |
16380 | } else if (peer->as_type == AS_SPECIFIED) { | |
16381 | vty_out(vty, " remote-as %u", peer->as); | |
16382 | if_ras_printed = true; | |
16383 | } else if (peer->as_type == AS_INTERNAL) { | |
16384 | vty_out(vty, " remote-as internal"); | |
16385 | if_ras_printed = true; | |
16386 | } else if (peer->as_type == AS_EXTERNAL) { | |
16387 | vty_out(vty, " remote-as external"); | |
16388 | if_ras_printed = true; | |
16389 | } | |
16390 | ||
16391 | vty_out(vty, "\n"); | |
16392 | } | |
16393 | ||
16394 | /* remote-as and peer-group */ | |
16395 | /* peer is a member of a peer-group */ | |
16396 | if (peer_group_active(peer)) { | |
16397 | g_peer = peer->group->conf; | |
16398 | ||
16399 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16400 | if (peer->as_type == AS_SPECIFIED) { | |
16401 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16402 | addr, peer->as); | |
16403 | } else if (peer->as_type == AS_INTERNAL) { | |
16404 | vty_out(vty, | |
16405 | " neighbor %s remote-as internal\n", | |
16406 | addr); | |
16407 | } else if (peer->as_type == AS_EXTERNAL) { | |
16408 | vty_out(vty, | |
16409 | " neighbor %s remote-as external\n", | |
16410 | addr); | |
16411 | } | |
16412 | } | |
16413 | ||
16414 | /* For swpX peers we displayed the peer-group | |
16415 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16416 | if (!if_pg_printed) | |
16417 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16418 | peer->group->name); | |
16419 | } | |
16420 | ||
16421 | /* peer is NOT a member of a peer-group */ | |
16422 | else { | |
16423 | /* peer is a peer-group, declare the peer-group */ | |
16424 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16425 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16426 | } | |
16427 | ||
16428 | if (!if_ras_printed) { | |
16429 | if (peer->as_type == AS_SPECIFIED) { | |
16430 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16431 | addr, peer->as); | |
16432 | } else if (peer->as_type == AS_INTERNAL) { | |
16433 | vty_out(vty, | |
16434 | " neighbor %s remote-as internal\n", | |
16435 | addr); | |
16436 | } else if (peer->as_type == AS_EXTERNAL) { | |
16437 | vty_out(vty, | |
16438 | " neighbor %s remote-as external\n", | |
16439 | addr); | |
16440 | } | |
16441 | } | |
16442 | } | |
16443 | ||
16444 | /* local-as */ | |
16445 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16446 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16447 | peer->change_local_as); | |
16448 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16449 | vty_out(vty, " no-prepend"); | |
16450 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16451 | vty_out(vty, " replace-as"); | |
16452 | vty_out(vty, "\n"); | |
16453 | } | |
16454 | ||
16455 | /* description */ | |
16456 | if (peer->desc) { | |
16457 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16458 | } | |
16459 | ||
16460 | /* shutdown */ | |
16461 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16462 | if (peer->tx_shutdown_message) | |
16463 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16464 | peer->tx_shutdown_message); | |
16465 | else | |
16466 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16467 | } | |
16468 | ||
16469 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) | |
16470 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16471 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16472 | ||
16473 | /* bfd */ | |
16474 | if (peer->bfd_config) | |
16475 | bgp_bfd_peer_config_write(vty, peer, addr); | |
16476 | ||
16477 | /* password */ | |
16478 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16479 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16480 | peer->password); | |
16481 | ||
16482 | /* neighbor solo */ | |
16483 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16484 | if (!peer_group_active(peer)) { | |
16485 | vty_out(vty, " neighbor %s solo\n", addr); | |
16486 | } | |
16487 | } | |
16488 | ||
16489 | /* BGP port */ | |
16490 | if (peer->port != BGP_PORT_DEFAULT) { | |
16491 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16492 | } | |
16493 | ||
16494 | /* Local interface name */ | |
16495 | if (peer->ifname) { | |
16496 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16497 | } | |
16498 | ||
16499 | /* TCP max segment size */ | |
16500 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16501 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16502 | ||
16503 | /* passive */ | |
16504 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16505 | vty_out(vty, " neighbor %s passive\n", addr); | |
16506 | ||
16507 | /* ebgp-multihop */ | |
16508 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
16509 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED | |
16510 | && peer->ttl == MAXTTL)) { | |
16511 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { | |
16512 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16513 | peer->ttl); | |
16514 | } | |
16515 | } | |
16516 | ||
16517 | /* ttl-security hops */ | |
16518 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { | |
16519 | if (!peer_group_active(peer) | |
16520 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16521 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16522 | addr, peer->gtsm_hops); | |
16523 | } | |
16524 | } | |
16525 | ||
16526 | /* disable-connected-check */ | |
16527 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16528 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16529 | ||
16530 | /* link-bw-encoding-ieee */ | |
16531 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16532 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16533 | addr); | |
16534 | ||
16535 | /* extended-optional-parameters */ | |
16536 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
16537 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
16538 | addr); | |
16539 | ||
16540 | /* enforce-first-as */ | |
16541 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16542 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16543 | ||
16544 | /* update-source */ | |
16545 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16546 | if (peer->update_source) | |
16547 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16548 | sockunion2str(peer->update_source, buf, | |
16549 | SU_ADDRSTRLEN)); | |
16550 | else if (peer->update_if) | |
16551 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16552 | peer->update_if); | |
16553 | } | |
16554 | ||
16555 | /* advertisement-interval */ | |
16556 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16557 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16558 | peer->routeadv); | |
16559 | ||
16560 | /* timers */ | |
16561 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16562 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16563 | peer->keepalive, peer->holdtime); | |
16564 | ||
16565 | /* timers connect */ | |
16566 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16567 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16568 | peer->connect); | |
16569 | /* need special-case handling for changed default values due to | |
16570 | * config profile / version (because there is no "timers bgp connect" | |
16571 | * command, we need to save this per-peer :/) | |
16572 | */ | |
16573 | else if (!peer_group_active(peer) && !peer->connect && | |
16574 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16575 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16576 | peer->bgp->default_connect_retry); | |
16577 | ||
16578 | /* timers delayopen */ | |
16579 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16580 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16581 | peer->delayopen); | |
16582 | /* Save config even though flag is not set if default values have been | |
16583 | * changed | |
16584 | */ | |
16585 | else if (!peer_group_active(peer) && !peer->delayopen | |
16586 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16587 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16588 | peer->bgp->default_delayopen); | |
16589 | ||
16590 | /* capability dynamic */ | |
16591 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16592 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16593 | ||
16594 | /* capability extended-nexthop */ | |
16595 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16596 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) | |
16597 | vty_out(vty, | |
16598 | " no neighbor %s capability extended-nexthop\n", | |
16599 | addr); | |
16600 | else if (!peer->conf_if) | |
16601 | vty_out(vty, | |
16602 | " neighbor %s capability extended-nexthop\n", | |
16603 | addr); | |
16604 | } | |
16605 | ||
16606 | /* dont-capability-negotiation */ | |
16607 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16608 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16609 | ||
16610 | /* override-capability */ | |
16611 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16612 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16613 | ||
16614 | /* strict-capability-match */ | |
16615 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16616 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16617 | ||
16618 | /* Sender side AS path loop detection. */ | |
16619 | if (peer->as_path_loop_detection) | |
16620 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16621 | addr); | |
16622 | ||
16623 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16624 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { | |
16625 | ||
16626 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16627 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { | |
16628 | vty_out(vty, | |
16629 | " neighbor %s graceful-restart-helper\n", addr); | |
16630 | } else if (CHECK_FLAG( | |
16631 | peer->peer_gr_new_status_flag, | |
16632 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
16633 | vty_out(vty, | |
16634 | " neighbor %s graceful-restart\n", addr); | |
16635 | } else if ( | |
16636 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16637 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16638 | && !(CHECK_FLAG( | |
16639 | peer->peer_gr_new_status_flag, | |
16640 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16641 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16642 | addr); | |
16643 | } | |
16644 | } | |
16645 | } | |
16646 | ||
16647 | /* BGP peer configuration display function. */ | |
16648 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16649 | struct peer *peer, afi_t afi, safi_t safi) | |
16650 | { | |
16651 | struct peer *g_peer = NULL; | |
16652 | char *addr; | |
16653 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16654 | ||
16655 | /* Skip dynamic neighbors. */ | |
16656 | if (peer_dynamic_neighbor(peer)) | |
16657 | return; | |
16658 | ||
16659 | if (peer->conf_if) | |
16660 | addr = peer->conf_if; | |
16661 | else | |
16662 | addr = peer->host; | |
16663 | ||
16664 | /************************************ | |
16665 | ****** Per AF to the neighbor ****** | |
16666 | ************************************/ | |
16667 | if (peer_group_active(peer)) { | |
16668 | g_peer = peer->group->conf; | |
16669 | ||
16670 | /* If the peer-group is active but peer is not, print a 'no | |
16671 | * activate' */ | |
16672 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16673 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16674 | } | |
16675 | ||
16676 | /* If the peer-group is not active but peer is, print an | |
16677 | 'activate' */ | |
16678 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16679 | vty_out(vty, " neighbor %s activate\n", addr); | |
16680 | } | |
16681 | } else { | |
16682 | if (peer->afc[afi][safi]) { | |
16683 | if (safi == SAFI_ENCAP) | |
16684 | vty_out(vty, " neighbor %s activate\n", addr); | |
16685 | else if (!bgp->default_af[afi][safi]) | |
16686 | vty_out(vty, " neighbor %s activate\n", addr); | |
16687 | } else { | |
16688 | if (bgp->default_af[afi][safi]) | |
16689 | vty_out(vty, " no neighbor %s activate\n", | |
16690 | addr); | |
16691 | } | |
16692 | } | |
16693 | ||
16694 | /* addpath TX knobs */ | |
16695 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16696 | switch (peer->addpath_type[afi][safi]) { | |
16697 | case BGP_ADDPATH_ALL: | |
16698 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16699 | addr); | |
16700 | break; | |
16701 | case BGP_ADDPATH_BEST_PER_AS: | |
16702 | vty_out(vty, | |
16703 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16704 | addr); | |
16705 | break; | |
16706 | case BGP_ADDPATH_MAX: | |
16707 | case BGP_ADDPATH_NONE: | |
16708 | break; | |
16709 | } | |
16710 | } | |
16711 | ||
16712 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) | |
16713 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16714 | ||
16715 | /* ORF capability. */ | |
16716 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16717 | || peergroup_af_flag_check(peer, afi, safi, | |
16718 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16719 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16720 | ||
16721 | if (peergroup_af_flag_check(peer, afi, safi, | |
16722 | PEER_FLAG_ORF_PREFIX_SM) | |
16723 | && peergroup_af_flag_check(peer, afi, safi, | |
16724 | PEER_FLAG_ORF_PREFIX_RM)) | |
16725 | vty_out(vty, " both"); | |
16726 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16727 | PEER_FLAG_ORF_PREFIX_SM)) | |
16728 | vty_out(vty, " send"); | |
16729 | else | |
16730 | vty_out(vty, " receive"); | |
16731 | vty_out(vty, "\n"); | |
16732 | } | |
16733 | ||
16734 | /* Route reflector client. */ | |
16735 | if (peergroup_af_flag_check(peer, afi, safi, | |
16736 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16737 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16738 | } | |
16739 | ||
16740 | /* next-hop-self force */ | |
16741 | if (peergroup_af_flag_check(peer, afi, safi, | |
16742 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16743 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16744 | } | |
16745 | ||
16746 | /* next-hop-self */ | |
16747 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16748 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16749 | } | |
16750 | ||
16751 | /* remove-private-AS */ | |
16752 | if (peergroup_af_flag_check(peer, afi, safi, | |
16753 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16754 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16755 | addr); | |
16756 | } | |
16757 | ||
16758 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16759 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16760 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16761 | addr); | |
16762 | } | |
16763 | ||
16764 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16765 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16766 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16767 | } | |
16768 | ||
16769 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16770 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16771 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16772 | } | |
16773 | ||
16774 | /* as-override */ | |
16775 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16776 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16777 | } | |
16778 | ||
16779 | /* send-community print. */ | |
16780 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16781 | PEER_FLAG_SEND_COMMUNITY); | |
16782 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16783 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16784 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16785 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16786 | ||
16787 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16788 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16789 | } else { | |
16790 | if (flag_scomm) | |
16791 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16792 | if (flag_secomm) | |
16793 | vty_out(vty, | |
16794 | " no neighbor %s send-community extended\n", | |
16795 | addr); | |
16796 | ||
16797 | if (flag_slcomm) | |
16798 | vty_out(vty, " no neighbor %s send-community large\n", | |
16799 | addr); | |
16800 | } | |
16801 | ||
16802 | /* Default information */ | |
16803 | if (peergroup_af_flag_check(peer, afi, safi, | |
16804 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16805 | vty_out(vty, " neighbor %s default-originate", addr); | |
16806 | ||
16807 | if (peer->default_rmap[afi][safi].name) | |
16808 | vty_out(vty, " route-map %s", | |
16809 | peer->default_rmap[afi][safi].name); | |
16810 | ||
16811 | vty_out(vty, "\n"); | |
16812 | } | |
16813 | ||
16814 | /* Soft reconfiguration inbound. */ | |
16815 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16816 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16817 | addr); | |
16818 | } | |
16819 | ||
16820 | /* maximum-prefix. */ | |
16821 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
16822 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, | |
16823 | peer->pmax[afi][safi]); | |
16824 | ||
16825 | if (peer->pmax_threshold[afi][safi] | |
16826 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16827 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16828 | if (peer_af_flag_check(peer, afi, safi, | |
16829 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16830 | vty_out(vty, " warning-only"); | |
16831 | if (peer->pmax_restart[afi][safi]) | |
16832 | vty_out(vty, " restart %u", | |
16833 | peer->pmax_restart[afi][safi]); | |
16834 | if (peer_af_flag_check(peer, afi, safi, | |
16835 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16836 | vty_out(vty, " force"); | |
16837 | ||
16838 | vty_out(vty, "\n"); | |
16839 | } | |
16840 | ||
16841 | /* maximum-prefix-out */ | |
16842 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
16843 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", | |
16844 | addr, peer->pmax_out[afi][safi]); | |
16845 | ||
16846 | /* Route server client. */ | |
16847 | if (peergroup_af_flag_check(peer, afi, safi, | |
16848 | PEER_FLAG_RSERVER_CLIENT)) { | |
16849 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16850 | } | |
16851 | ||
16852 | /* Nexthop-local unchanged. */ | |
16853 | if (peergroup_af_flag_check(peer, afi, safi, | |
16854 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16855 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16856 | } | |
16857 | ||
16858 | /* allowas-in <1-10> */ | |
16859 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16860 | if (peer_af_flag_check(peer, afi, safi, | |
16861 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16862 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16863 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16864 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16865 | } else { | |
16866 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16867 | peer->allowas_in[afi][safi]); | |
16868 | } | |
16869 | } | |
16870 | ||
16871 | /* weight */ | |
16872 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16873 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16874 | peer->weight[afi][safi]); | |
16875 | ||
16876 | /* Filter. */ | |
16877 | bgp_config_write_filter(vty, peer, afi, safi); | |
16878 | ||
16879 | /* atribute-unchanged. */ | |
16880 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16881 | || (safi != SAFI_EVPN | |
16882 | && peer_af_flag_check(peer, afi, safi, | |
16883 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16884 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16885 | ||
16886 | if (!peer_group_active(peer) | |
16887 | || peergroup_af_flag_check(peer, afi, safi, | |
16888 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16889 | || peergroup_af_flag_check(peer, afi, safi, | |
16890 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16891 | || peergroup_af_flag_check(peer, afi, safi, | |
16892 | PEER_FLAG_MED_UNCHANGED)) { | |
16893 | ||
16894 | vty_out(vty, | |
16895 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16896 | addr, | |
16897 | peer_af_flag_check(peer, afi, safi, | |
16898 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16899 | ? " as-path" | |
16900 | : "", | |
16901 | peer_af_flag_check(peer, afi, safi, | |
16902 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16903 | ? " next-hop" | |
16904 | : "", | |
16905 | peer_af_flag_check(peer, afi, safi, | |
16906 | PEER_FLAG_MED_UNCHANGED) | |
16907 | ? " med" | |
16908 | : ""); | |
16909 | } | |
16910 | } | |
16911 | } | |
16912 | ||
16913 | /* Address family based peer configuration display. */ | |
16914 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16915 | safi_t safi) | |
16916 | { | |
16917 | struct peer *peer; | |
16918 | struct peer_group *group; | |
16919 | struct listnode *node, *nnode; | |
16920 | ||
16921 | ||
16922 | vty_frame(vty, " !\n address-family "); | |
16923 | if (afi == AFI_IP) { | |
16924 | if (safi == SAFI_UNICAST) | |
16925 | vty_frame(vty, "ipv4 unicast"); | |
16926 | else if (safi == SAFI_LABELED_UNICAST) | |
16927 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16928 | else if (safi == SAFI_MULTICAST) | |
16929 | vty_frame(vty, "ipv4 multicast"); | |
16930 | else if (safi == SAFI_MPLS_VPN) | |
16931 | vty_frame(vty, "ipv4 vpn"); | |
16932 | else if (safi == SAFI_ENCAP) | |
16933 | vty_frame(vty, "ipv4 encap"); | |
16934 | else if (safi == SAFI_FLOWSPEC) | |
16935 | vty_frame(vty, "ipv4 flowspec"); | |
16936 | } else if (afi == AFI_IP6) { | |
16937 | if (safi == SAFI_UNICAST) | |
16938 | vty_frame(vty, "ipv6 unicast"); | |
16939 | else if (safi == SAFI_LABELED_UNICAST) | |
16940 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16941 | else if (safi == SAFI_MULTICAST) | |
16942 | vty_frame(vty, "ipv6 multicast"); | |
16943 | else if (safi == SAFI_MPLS_VPN) | |
16944 | vty_frame(vty, "ipv6 vpn"); | |
16945 | else if (safi == SAFI_ENCAP) | |
16946 | vty_frame(vty, "ipv6 encap"); | |
16947 | else if (safi == SAFI_FLOWSPEC) | |
16948 | vty_frame(vty, "ipv6 flowspec"); | |
16949 | } else if (afi == AFI_L2VPN) { | |
16950 | if (safi == SAFI_EVPN) | |
16951 | vty_frame(vty, "l2vpn evpn"); | |
16952 | } | |
16953 | vty_frame(vty, "\n"); | |
16954 | ||
16955 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16956 | ||
16957 | bgp_config_write_network(vty, bgp, afi, safi); | |
16958 | ||
16959 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16960 | ||
16961 | /* BGP flag dampening. */ | |
16962 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
16963 | bgp_config_write_damp(vty, afi, safi); | |
16964 | ||
16965 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
16966 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16967 | ||
16968 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16969 | /* Do not display doppelganger peers */ | |
16970 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16971 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16972 | } | |
16973 | ||
16974 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16975 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16976 | ||
16977 | if (safi == SAFI_EVPN) | |
16978 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16979 | ||
16980 | if (safi == SAFI_FLOWSPEC) | |
16981 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16982 | ||
16983 | if (safi == SAFI_UNICAST) { | |
16984 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16985 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16986 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16987 | ||
16988 | vty_out(vty, " export vpn\n"); | |
16989 | } | |
16990 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16991 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16992 | ||
16993 | vty_out(vty, " import vpn\n"); | |
16994 | } | |
16995 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16996 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16997 | char *name; | |
16998 | ||
16999 | for (ALL_LIST_ELEMENTS_RO( | |
17000 | bgp->vpn_policy[afi].import_vrf, node, | |
17001 | name)) | |
17002 | vty_out(vty, " import vrf %s\n", name); | |
17003 | } | |
17004 | } | |
17005 | ||
17006 | vty_endframe(vty, " exit-address-family\n"); | |
17007 | } | |
17008 | ||
17009 | int bgp_config_write(struct vty *vty) | |
17010 | { | |
17011 | struct bgp *bgp; | |
17012 | struct peer_group *group; | |
17013 | struct peer *peer; | |
17014 | struct listnode *node, *nnode; | |
17015 | struct listnode *mnode, *mnnode; | |
17016 | afi_t afi; | |
17017 | safi_t safi; | |
17018 | ||
17019 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17020 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17021 | bm->rmap_update_timer); | |
17022 | ||
17023 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
17024 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17025 | if (bm->v_update_delay != bm->v_establish_wait) | |
17026 | vty_out(vty, " %d", bm->v_establish_wait); | |
17027 | vty_out(vty, "\n"); | |
17028 | } | |
17029 | ||
17030 | if (bm->wait_for_fib) | |
17031 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17032 | ||
17033 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17034 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17035 | ||
17036 | /* No-RIB (Zebra) option flag configuration */ | |
17037 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17038 | vty_out(vty, "bgp no-rib\n"); | |
17039 | ||
17040 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) | |
17041 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
17042 | ||
17043 | /* BGP configuration. */ | |
17044 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17045 | ||
17046 | /* skip all auto created vrf as they dont have user config */ | |
17047 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17048 | continue; | |
17049 | ||
17050 | /* Router bgp ASN */ | |
17051 | vty_out(vty, "router bgp %u", bgp->as); | |
17052 | ||
17053 | if (bgp->name) | |
17054 | vty_out(vty, " %s %s", | |
17055 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17056 | ? "view" : "vrf", bgp->name); | |
17057 | vty_out(vty, "\n"); | |
17058 | ||
17059 | /* BGP fast-external-failover. */ | |
17060 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17061 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17062 | ||
17063 | /* BGP router ID. */ | |
17064 | if (bgp->router_id_static.s_addr != INADDR_ANY) | |
17065 | vty_out(vty, " bgp router-id %pI4\n", | |
17066 | &bgp->router_id_static); | |
17067 | ||
17068 | /* Suppress fib pending */ | |
17069 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17070 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17071 | ||
17072 | /* BGP log-neighbor-changes. */ | |
17073 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
17074 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) | |
17075 | vty_out(vty, " %sbgp log-neighbor-changes\n", | |
17076 | CHECK_FLAG(bgp->flags, | |
17077 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
17078 | ? "" | |
17079 | : "no "); | |
17080 | ||
17081 | /* BGP configuration. */ | |
17082 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) | |
17083 | vty_out(vty, " bgp always-compare-med\n"); | |
17084 | ||
17085 | /* RFC8212 default eBGP policy. */ | |
17086 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17087 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17088 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17089 | CHECK_FLAG(bgp->flags, | |
17090 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17091 | ? "" | |
17092 | : "no "); | |
17093 | ||
17094 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
17095 | if (bgp->reject_as_sets) | |
17096 | vty_out(vty, " bgp reject-as-sets\n"); | |
17097 | ||
17098 | /* Suppress duplicate updates if the route actually not changed | |
17099 | */ | |
17100 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17101 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17102 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17103 | CHECK_FLAG(bgp->flags, | |
17104 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17105 | ? "" | |
17106 | : "no "); | |
17107 | ||
17108 | /* BGP default <afi>-<safi> */ | |
17109 | FOREACH_AFI_SAFI (afi, safi) { | |
17110 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17111 | if (!bgp->default_af[afi][safi]) | |
17112 | vty_out(vty, " no bgp default %s\n", | |
17113 | get_bgp_default_af_flag(afi, | |
17114 | safi)); | |
17115 | } else if (bgp->default_af[afi][safi]) | |
17116 | vty_out(vty, " bgp default %s\n", | |
17117 | get_bgp_default_af_flag(afi, safi)); | |
17118 | } | |
17119 | ||
17120 | /* BGP default local-preference. */ | |
17121 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17122 | vty_out(vty, " bgp default local-preference %u\n", | |
17123 | bgp->default_local_pref); | |
17124 | ||
17125 | /* BGP default show-hostname */ | |
17126 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) | |
17127 | != SAVE_BGP_SHOW_HOSTNAME) | |
17128 | vty_out(vty, " %sbgp default show-hostname\n", | |
17129 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) | |
17130 | ? "" | |
17131 | : "no "); | |
17132 | ||
17133 | /* BGP default show-nexthop-hostname */ | |
17134 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17135 | != SAVE_BGP_SHOW_HOSTNAME) | |
17136 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17137 | CHECK_FLAG(bgp->flags, | |
17138 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17139 | ? "" | |
17140 | : "no "); | |
17141 | ||
17142 | /* BGP default subgroup-pkt-queue-max. */ | |
17143 | if (bgp->default_subgroup_pkt_queue_max | |
17144 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17145 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17146 | bgp->default_subgroup_pkt_queue_max); | |
17147 | ||
17148 | /* BGP client-to-client reflection. */ | |
17149 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
17150 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
17151 | ||
17152 | /* BGP cluster ID. */ | |
17153 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
17154 | vty_out(vty, " bgp cluster-id %pI4\n", | |
17155 | &bgp->cluster_id); | |
17156 | ||
17157 | /* Disable ebgp connected nexthop check */ | |
17158 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
17159 | vty_out(vty, | |
17160 | " bgp disable-ebgp-connected-route-check\n"); | |
17161 | ||
17162 | /* Confederation identifier*/ | |
17163 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17164 | vty_out(vty, " bgp confederation identifier %u\n", | |
17165 | bgp->confed_id); | |
17166 | ||
17167 | /* Confederation peer */ | |
17168 | if (bgp->confed_peers_cnt > 0) { | |
17169 | int i; | |
17170 | ||
17171 | vty_out(vty, " bgp confederation peers"); | |
17172 | ||
17173 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17174 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17175 | ||
17176 | vty_out(vty, "\n"); | |
17177 | } | |
17178 | ||
17179 | /* BGP deterministic-med. */ | |
17180 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) | |
17181 | != SAVE_BGP_DETERMINISTIC_MED) | |
17182 | vty_out(vty, " %sbgp deterministic-med\n", | |
17183 | CHECK_FLAG(bgp->flags, | |
17184 | BGP_FLAG_DETERMINISTIC_MED) | |
17185 | ? "" | |
17186 | : "no "); | |
17187 | ||
17188 | /* BGP update-delay. */ | |
17189 | bgp_config_write_update_delay(vty, bgp); | |
17190 | ||
17191 | if (bgp->v_maxmed_onstartup | |
17192 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17193 | vty_out(vty, " bgp max-med on-startup %u", | |
17194 | bgp->v_maxmed_onstartup); | |
17195 | if (bgp->maxmed_onstartup_value | |
17196 | != BGP_MAXMED_VALUE_DEFAULT) | |
17197 | vty_out(vty, " %u", | |
17198 | bgp->maxmed_onstartup_value); | |
17199 | vty_out(vty, "\n"); | |
17200 | } | |
17201 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17202 | vty_out(vty, " bgp max-med administrative"); | |
17203 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17204 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17205 | vty_out(vty, "\n"); | |
17206 | } | |
17207 | ||
17208 | /* write quanta */ | |
17209 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17210 | /* read quanta */ | |
17211 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17212 | ||
17213 | /* coalesce time */ | |
17214 | bgp_config_write_coalesce_time(vty, bgp); | |
17215 | ||
17216 | /* BGP per-instance graceful-shutdown */ | |
17217 | /* BGP-wide settings and per-instance settings are mutually | |
17218 | * exclusive. | |
17219 | */ | |
17220 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17221 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17222 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17223 | ||
17224 | /* Long-lived Graceful Restart */ | |
17225 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
17226 | vty_out(vty, | |
17227 | " bgp long-lived-graceful-restart stale-time %u\n", | |
17228 | bgp->llgr_stale_time); | |
17229 | ||
17230 | /* BGP graceful-restart. */ | |
17231 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17232 | vty_out(vty, | |
17233 | " bgp graceful-restart stalepath-time %u\n", | |
17234 | bgp->stalepath_time); | |
17235 | ||
17236 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) | |
17237 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17238 | bgp->restart_time); | |
17239 | ||
17240 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17241 | vty_out(vty, | |
17242 | " bgp graceful-restart select-defer-time %u\n", | |
17243 | bgp->select_defer_time); | |
17244 | ||
17245 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
17246 | vty_out(vty, " bgp graceful-restart\n"); | |
17247 | ||
17248 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) | |
17249 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17250 | ||
17251 | /* BGP graceful-restart Preserve State F bit. */ | |
17252 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) | |
17253 | vty_out(vty, | |
17254 | " bgp graceful-restart preserve-fw-state\n"); | |
17255 | ||
17256 | /* Stale timer for RIB */ | |
17257 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17258 | vty_out(vty, | |
17259 | " bgp graceful-restart rib-stale-time %u\n", | |
17260 | bgp->rib_stale_time); | |
17261 | ||
17262 | /* BGP bestpath method. */ | |
17263 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) | |
17264 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
17265 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) | |
17266 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
17267 | ||
17268 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
17269 | if (CHECK_FLAG(bgp->flags, | |
17270 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
17271 | vty_out(vty, | |
17272 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17273 | } else { | |
17274 | vty_out(vty, | |
17275 | " bgp bestpath as-path multipath-relax\n"); | |
17276 | } | |
17277 | } | |
17278 | ||
17279 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
17280 | vty_out(vty, | |
17281 | " bgp route-reflector allow-outbound-policy\n"); | |
17282 | } | |
17283 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) | |
17284 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
17285 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) | |
17286 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
17287 | vty_out(vty, " bgp bestpath med"); | |
17288 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
17289 | vty_out(vty, " confed"); | |
17290 | if (CHECK_FLAG(bgp->flags, | |
17291 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
17292 | vty_out(vty, " missing-as-worst"); | |
17293 | vty_out(vty, "\n"); | |
17294 | } | |
17295 | ||
17296 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) | |
17297 | vty_out(vty, | |
17298 | " bgp bestpath peer-type multipath-relax\n"); | |
17299 | ||
17300 | /* Link bandwidth handling. */ | |
17301 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17302 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17303 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17304 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17305 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17306 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17307 | ||
17308 | /* BGP network import check. */ | |
17309 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) | |
17310 | != SAVE_BGP_IMPORT_CHECK) | |
17311 | vty_out(vty, " %sbgp network import-check\n", | |
17312 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) | |
17313 | ? "" | |
17314 | : "no "); | |
17315 | ||
17316 | /* BGP timers configuration. */ | |
17317 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE | |
17318 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
17319 | vty_out(vty, " timers bgp %u %u\n", | |
17320 | bgp->default_keepalive, bgp->default_holdtime); | |
17321 | ||
17322 | /* BGP minimum holdtime configuration. */ | |
17323 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17324 | && bgp->default_min_holdtime != 0) | |
17325 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17326 | bgp->default_min_holdtime); | |
17327 | ||
17328 | /* Conditional advertisement timer configuration */ | |
17329 | if (bgp->condition_check_period | |
17330 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17331 | vty_out(vty, | |
17332 | " bgp conditional-advertisement timer %u\n", | |
17333 | bgp->condition_check_period); | |
17334 | ||
17335 | /* peer-group */ | |
17336 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17337 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17338 | } | |
17339 | ||
17340 | /* Normal neighbor configuration. */ | |
17341 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17342 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17343 | bgp_config_write_peer_global(vty, bgp, peer); | |
17344 | } | |
17345 | ||
17346 | /* listen range and limit for dynamic BGP neighbors */ | |
17347 | bgp_config_write_listen(vty, bgp); | |
17348 | ||
17349 | /* | |
17350 | * BGP default autoshutdown neighbors | |
17351 | * | |
17352 | * This must be placed after any peer and peer-group | |
17353 | * configuration, to avoid setting all peers to shutdown after | |
17354 | * a daemon restart, which is undesired behavior. (see #2286) | |
17355 | */ | |
17356 | if (bgp->autoshutdown) | |
17357 | vty_out(vty, " bgp default shutdown\n"); | |
17358 | ||
17359 | /* BGP instance administrative shutdown */ | |
17360 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17361 | vty_out(vty, " bgp shutdown\n"); | |
17362 | ||
17363 | if (bgp->fast_convergence) | |
17364 | vty_out(vty, " bgp fast-convergence\n"); | |
17365 | ||
17366 | if (bgp->srv6_enabled) { | |
17367 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
17368 | if (strlen(bgp->srv6_locator_name)) | |
17369 | vty_out(vty, " locator %s\n", | |
17370 | bgp->srv6_locator_name); | |
17371 | vty_endframe(vty, " exit\n"); | |
17372 | } | |
17373 | ||
17374 | ||
17375 | /* IPv4 unicast configuration. */ | |
17376 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17377 | ||
17378 | /* IPv4 multicast configuration. */ | |
17379 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17380 | ||
17381 | /* IPv4 labeled-unicast configuration. */ | |
17382 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17383 | ||
17384 | /* IPv4 VPN configuration. */ | |
17385 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17386 | ||
17387 | /* ENCAPv4 configuration. */ | |
17388 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17389 | ||
17390 | /* FLOWSPEC v4 configuration. */ | |
17391 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17392 | ||
17393 | /* IPv6 unicast configuration. */ | |
17394 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17395 | ||
17396 | /* IPv6 multicast configuration. */ | |
17397 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17398 | ||
17399 | /* IPv6 labeled-unicast configuration. */ | |
17400 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17401 | SAFI_LABELED_UNICAST); | |
17402 | ||
17403 | /* IPv6 VPN configuration. */ | |
17404 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17405 | ||
17406 | /* ENCAPv6 configuration. */ | |
17407 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17408 | ||
17409 | /* FLOWSPEC v6 configuration. */ | |
17410 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17411 | ||
17412 | /* EVPN configuration. */ | |
17413 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17414 | ||
17415 | hook_call(bgp_inst_config_write, bgp, vty); | |
17416 | ||
17417 | #ifdef ENABLE_BGP_VNC | |
17418 | bgp_rfapi_cfg_write(vty, bgp); | |
17419 | #endif | |
17420 | ||
17421 | vty_out(vty, "exit\n"); | |
17422 | vty_out(vty, "!\n"); | |
17423 | } | |
17424 | return 0; | |
17425 | } | |
17426 | ||
17427 | ||
17428 | /* BGP node structure. */ | |
17429 | static struct cmd_node bgp_node = { | |
17430 | .name = "bgp", | |
17431 | .node = BGP_NODE, | |
17432 | .parent_node = CONFIG_NODE, | |
17433 | .prompt = "%s(config-router)# ", | |
17434 | .config_write = bgp_config_write, | |
17435 | }; | |
17436 | ||
17437 | static struct cmd_node bgp_ipv4_unicast_node = { | |
17438 | .name = "bgp ipv4 unicast", | |
17439 | .node = BGP_IPV4_NODE, | |
17440 | .parent_node = BGP_NODE, | |
17441 | .prompt = "%s(config-router-af)# ", | |
17442 | .no_xpath = true, | |
17443 | }; | |
17444 | ||
17445 | static struct cmd_node bgp_ipv4_multicast_node = { | |
17446 | .name = "bgp ipv4 multicast", | |
17447 | .node = BGP_IPV4M_NODE, | |
17448 | .parent_node = BGP_NODE, | |
17449 | .prompt = "%s(config-router-af)# ", | |
17450 | .no_xpath = true, | |
17451 | }; | |
17452 | ||
17453 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { | |
17454 | .name = "bgp ipv4 labeled unicast", | |
17455 | .node = BGP_IPV4L_NODE, | |
17456 | .parent_node = BGP_NODE, | |
17457 | .prompt = "%s(config-router-af)# ", | |
17458 | .no_xpath = true, | |
17459 | }; | |
17460 | ||
17461 | static struct cmd_node bgp_ipv6_unicast_node = { | |
17462 | .name = "bgp ipv6 unicast", | |
17463 | .node = BGP_IPV6_NODE, | |
17464 | .parent_node = BGP_NODE, | |
17465 | .prompt = "%s(config-router-af)# ", | |
17466 | .no_xpath = true, | |
17467 | }; | |
17468 | ||
17469 | static struct cmd_node bgp_ipv6_multicast_node = { | |
17470 | .name = "bgp ipv6 multicast", | |
17471 | .node = BGP_IPV6M_NODE, | |
17472 | .parent_node = BGP_NODE, | |
17473 | .prompt = "%s(config-router-af)# ", | |
17474 | .no_xpath = true, | |
17475 | }; | |
17476 | ||
17477 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { | |
17478 | .name = "bgp ipv6 labeled unicast", | |
17479 | .node = BGP_IPV6L_NODE, | |
17480 | .parent_node = BGP_NODE, | |
17481 | .prompt = "%s(config-router-af)# ", | |
17482 | .no_xpath = true, | |
17483 | }; | |
17484 | ||
17485 | static struct cmd_node bgp_vpnv4_node = { | |
17486 | .name = "bgp vpnv4", | |
17487 | .node = BGP_VPNV4_NODE, | |
17488 | .parent_node = BGP_NODE, | |
17489 | .prompt = "%s(config-router-af)# ", | |
17490 | .no_xpath = true, | |
17491 | }; | |
17492 | ||
17493 | static struct cmd_node bgp_vpnv6_node = { | |
17494 | .name = "bgp vpnv6", | |
17495 | .node = BGP_VPNV6_NODE, | |
17496 | .parent_node = BGP_NODE, | |
17497 | .prompt = "%s(config-router-af-vpnv6)# ", | |
17498 | .no_xpath = true, | |
17499 | }; | |
17500 | ||
17501 | static struct cmd_node bgp_evpn_node = { | |
17502 | .name = "bgp evpn", | |
17503 | .node = BGP_EVPN_NODE, | |
17504 | .parent_node = BGP_NODE, | |
17505 | .prompt = "%s(config-router-evpn)# ", | |
17506 | .no_xpath = true, | |
17507 | }; | |
17508 | ||
17509 | static struct cmd_node bgp_evpn_vni_node = { | |
17510 | .name = "bgp evpn vni", | |
17511 | .node = BGP_EVPN_VNI_NODE, | |
17512 | .parent_node = BGP_EVPN_NODE, | |
17513 | .prompt = "%s(config-router-af-vni)# ", | |
17514 | }; | |
17515 | ||
17516 | static struct cmd_node bgp_flowspecv4_node = { | |
17517 | .name = "bgp ipv4 flowspec", | |
17518 | .node = BGP_FLOWSPECV4_NODE, | |
17519 | .parent_node = BGP_NODE, | |
17520 | .prompt = "%s(config-router-af)# ", | |
17521 | .no_xpath = true, | |
17522 | }; | |
17523 | ||
17524 | static struct cmd_node bgp_flowspecv6_node = { | |
17525 | .name = "bgp ipv6 flowspec", | |
17526 | .node = BGP_FLOWSPECV6_NODE, | |
17527 | .parent_node = BGP_NODE, | |
17528 | .prompt = "%s(config-router-af-vpnv6)# ", | |
17529 | .no_xpath = true, | |
17530 | }; | |
17531 | ||
17532 | static struct cmd_node bgp_srv6_node = { | |
17533 | .name = "bgp srv6", | |
17534 | .node = BGP_SRV6_NODE, | |
17535 | .parent_node = BGP_NODE, | |
17536 | .prompt = "%s(config-router-srv6)# ", | |
17537 | }; | |
17538 | ||
17539 | static void community_list_vty(void); | |
17540 | ||
17541 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) | |
17542 | { | |
17543 | struct bgp *bgp; | |
17544 | struct peer_group *group; | |
17545 | struct listnode *lnbgp, *lnpeer; | |
17546 | ||
17547 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17548 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17549 | vector_set(comps, | |
17550 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
17551 | } | |
17552 | } | |
17553 | ||
17554 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
17555 | { | |
17556 | struct bgp *bgp; | |
17557 | struct peer *peer; | |
17558 | struct listnode *lnbgp, *lnpeer; | |
17559 | ||
17560 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17561 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17562 | /* only provide suggestions on the appropriate input | |
17563 | * token type, | |
17564 | * they'll otherwise show up multiple times */ | |
17565 | enum cmd_token_type match_type; | |
17566 | char *name = peer->host; | |
17567 | ||
17568 | if (peer->conf_if) { | |
17569 | match_type = VARIABLE_TKN; | |
17570 | name = peer->conf_if; | |
17571 | } else if (strchr(peer->host, ':')) | |
17572 | match_type = IPV6_TKN; | |
17573 | else | |
17574 | match_type = IPV4_TKN; | |
17575 | ||
17576 | if (token->type != match_type) | |
17577 | continue; | |
17578 | ||
17579 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); | |
17580 | } | |
17581 | } | |
17582 | } | |
17583 | ||
17584 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) | |
17585 | { | |
17586 | bgp_ac_peer(comps, token); | |
17587 | ||
17588 | if (token->type == VARIABLE_TKN) | |
17589 | bgp_ac_peergroup(comps, token); | |
17590 | } | |
17591 | ||
17592 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
17593 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, | |
17594 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
17595 | {.varname = "peer", .completions = bgp_ac_neighbor}, | |
17596 | {.completions = NULL}}; | |
17597 | ||
17598 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17599 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17600 | {.completions = NULL} }; | |
17601 | ||
17602 | void bgp_vty_init(void) | |
17603 | { | |
17604 | cmd_variable_handler_register(bgp_var_neighbor); | |
17605 | cmd_variable_handler_register(bgp_var_peergroup); | |
17606 | ||
17607 | /* Install bgp top node. */ | |
17608 | install_node(&bgp_node); | |
17609 | install_node(&bgp_ipv4_unicast_node); | |
17610 | install_node(&bgp_ipv4_multicast_node); | |
17611 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17612 | install_node(&bgp_ipv6_unicast_node); | |
17613 | install_node(&bgp_ipv6_multicast_node); | |
17614 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17615 | install_node(&bgp_vpnv4_node); | |
17616 | install_node(&bgp_vpnv6_node); | |
17617 | install_node(&bgp_evpn_node); | |
17618 | install_node(&bgp_evpn_vni_node); | |
17619 | install_node(&bgp_flowspecv4_node); | |
17620 | install_node(&bgp_flowspecv6_node); | |
17621 | install_node(&bgp_srv6_node); | |
17622 | ||
17623 | /* Install default VTY commands to new nodes. */ | |
17624 | install_default(BGP_NODE); | |
17625 | install_default(BGP_IPV4_NODE); | |
17626 | install_default(BGP_IPV4M_NODE); | |
17627 | install_default(BGP_IPV4L_NODE); | |
17628 | install_default(BGP_IPV6_NODE); | |
17629 | install_default(BGP_IPV6M_NODE); | |
17630 | install_default(BGP_IPV6L_NODE); | |
17631 | install_default(BGP_VPNV4_NODE); | |
17632 | install_default(BGP_VPNV6_NODE); | |
17633 | install_default(BGP_FLOWSPECV4_NODE); | |
17634 | install_default(BGP_FLOWSPECV6_NODE); | |
17635 | install_default(BGP_EVPN_NODE); | |
17636 | install_default(BGP_EVPN_VNI_NODE); | |
17637 | install_default(BGP_SRV6_NODE); | |
17638 | ||
17639 | /* "bgp local-mac" hidden commands. */ | |
17640 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17641 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17642 | ||
17643 | /* "bgp suppress-fib-pending" global */ | |
17644 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17645 | ||
17646 | /* bgp route-map delay-timer commands. */ | |
17647 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17648 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17649 | ||
17650 | /* bgp fast-convergence command */ | |
17651 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17652 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17653 | ||
17654 | /* global bgp update-delay command */ | |
17655 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17656 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17657 | ||
17658 | /* global bgp graceful-shutdown command */ | |
17659 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17660 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17661 | ||
17662 | /* Dummy commands (Currently not supported) */ | |
17663 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17664 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17665 | ||
17666 | /* "router bgp" commands. */ | |
17667 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17668 | ||
17669 | /* "no router bgp" commands. */ | |
17670 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17671 | ||
17672 | /* "bgp router-id" commands. */ | |
17673 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17674 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17675 | ||
17676 | /* "bgp suppress-fib-pending" command */ | |
17677 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17678 | ||
17679 | /* "bgp cluster-id" commands. */ | |
17680 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17681 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17682 | ||
17683 | /* "bgp no-rib" commands. */ | |
17684 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17685 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17686 | ||
17687 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); | |
17688 | ||
17689 | /* "bgp confederation" commands. */ | |
17690 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17691 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17692 | ||
17693 | /* "bgp confederation peers" commands. */ | |
17694 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17695 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17696 | ||
17697 | /* bgp max-med command */ | |
17698 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17699 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17700 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17701 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17702 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17703 | ||
17704 | /* bgp disable-ebgp-connected-nh-check */ | |
17705 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17706 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17707 | ||
17708 | /* bgp update-delay command */ | |
17709 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17710 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
17711 | ||
17712 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
17713 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); | |
17714 | ||
17715 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17716 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17717 | ||
17718 | /* "maximum-paths" commands. */ | |
17719 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17720 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17721 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17722 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17723 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17724 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17725 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17726 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17727 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17728 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17729 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17730 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17731 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17732 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17733 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17734 | ||
17735 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); | |
17736 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17737 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17738 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17739 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17740 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
17741 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17742 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17743 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17744 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17745 | ||
17746 | /* "timers bgp" commands. */ | |
17747 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17748 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17749 | ||
17750 | /* "minimum-holdtime" commands. */ | |
17751 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17752 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17753 | ||
17754 | /* route-map delay-timer commands - per instance for backwards compat. | |
17755 | */ | |
17756 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17757 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17758 | ||
17759 | /* "bgp client-to-client reflection" commands */ | |
17760 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17761 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17762 | ||
17763 | /* "bgp always-compare-med" commands */ | |
17764 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17765 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17766 | ||
17767 | /* bgp ebgp-requires-policy */ | |
17768 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17769 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17770 | ||
17771 | /* bgp suppress-duplicates */ | |
17772 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17773 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17774 | ||
17775 | /* bgp reject-as-sets */ | |
17776 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17777 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17778 | ||
17779 | /* "bgp deterministic-med" commands */ | |
17780 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17781 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17782 | ||
17783 | /* "bgp graceful-restart" command */ | |
17784 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
17785 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
17786 | ||
17787 | /* "bgp graceful-restart-disable" command */ | |
17788 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); | |
17789 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
17790 | ||
17791 | /* "neighbor a:b:c:d graceful-restart" command */ | |
17792 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); | |
17793 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
17794 | ||
17795 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17796 | install_element(BGP_NODE, | |
17797 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17798 | install_element(BGP_NODE, | |
17799 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17800 | ||
17801 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17802 | install_element(BGP_NODE, | |
17803 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17804 | install_element(BGP_NODE, | |
17805 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17806 | ||
17807 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
17808 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17809 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17810 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
17811 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); | |
17812 | install_element(BGP_NODE, | |
17813 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
17814 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
17815 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17816 | ||
17817 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); | |
17818 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
17819 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); | |
17820 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
17821 | ||
17822 | /* "bgp graceful-shutdown" commands */ | |
17823 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17824 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17825 | ||
17826 | /* "bgp long-lived-graceful-restart" commands */ | |
17827 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
17828 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
17829 | ||
17830 | /* "bgp fast-external-failover" commands */ | |
17831 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17832 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17833 | ||
17834 | /* "bgp bestpath compare-routerid" commands */ | |
17835 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17836 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17837 | ||
17838 | /* "bgp bestpath as-path ignore" commands */ | |
17839 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17840 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17841 | ||
17842 | /* "bgp bestpath as-path confed" commands */ | |
17843 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17844 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17845 | ||
17846 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17847 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17848 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17849 | ||
17850 | /* "bgp bestpath peer-type multipath-relax" commands */ | |
17851 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
17852 | install_element(BGP_NODE, | |
17853 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
17854 | ||
17855 | /* "bgp log-neighbor-changes" commands */ | |
17856 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17857 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17858 | ||
17859 | /* "bgp bestpath med" commands */ | |
17860 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17861 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17862 | ||
17863 | /* "bgp bestpath bandwidth" commands */ | |
17864 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
17865 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); | |
17866 | ||
17867 | /* "no bgp default <afi>-<safi>" commands. */ | |
17868 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
17869 | ||
17870 | /* "bgp network import-check" commands. */ | |
17871 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17872 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17873 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17874 | ||
17875 | /* "bgp default local-preference" commands. */ | |
17876 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17877 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17878 | ||
17879 | /* bgp default show-hostname */ | |
17880 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17881 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17882 | ||
17883 | /* bgp default show-nexthop-hostname */ | |
17884 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17885 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17886 | ||
17887 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
17888 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17889 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17890 | ||
17891 | /* bgp ibgp-allow-policy-mods command */ | |
17892 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17893 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17894 | ||
17895 | /* "bgp listen limit" commands. */ | |
17896 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17897 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17898 | ||
17899 | /* "bgp listen range" commands. */ | |
17900 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17901 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17902 | ||
17903 | /* "bgp default shutdown" command */ | |
17904 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); | |
17905 | ||
17906 | /* "bgp shutdown" commands */ | |
17907 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
17908 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); | |
17909 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); | |
17910 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); | |
17911 | ||
17912 | /* "neighbor remote-as" commands. */ | |
17913 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17914 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17915 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17916 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17917 | install_element(BGP_NODE, | |
17918 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17919 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17920 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17921 | ||
17922 | /* "neighbor peer-group" commands. */ | |
17923 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17924 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17925 | install_element(BGP_NODE, | |
17926 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17927 | ||
17928 | /* "neighbor local-as" commands. */ | |
17929 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17930 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17931 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17932 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17933 | ||
17934 | /* "neighbor solo" commands. */ | |
17935 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17936 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17937 | ||
17938 | /* "neighbor password" commands. */ | |
17939 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17940 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17941 | ||
17942 | /* "neighbor activate" commands. */ | |
17943 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17944 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17945 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17946 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17947 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17948 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17949 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17950 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17951 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
17952 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); | |
17953 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
17954 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
17955 | ||
17956 | /* "no neighbor activate" commands. */ | |
17957 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17958 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17959 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17960 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17961 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17962 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17963 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17964 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17965 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
17966 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); | |
17967 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
17968 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
17969 | ||
17970 | /* "neighbor peer-group" set commands. */ | |
17971 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17972 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17973 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17974 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17975 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17976 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17977 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17978 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17979 | install_element(BGP_FLOWSPECV4_NODE, | |
17980 | &neighbor_set_peer_group_hidden_cmd); | |
17981 | install_element(BGP_FLOWSPECV6_NODE, | |
17982 | &neighbor_set_peer_group_hidden_cmd); | |
17983 | ||
17984 | /* "no neighbor peer-group unset" commands. */ | |
17985 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17986 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17987 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17988 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17989 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17990 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17991 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17992 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17993 | install_element(BGP_FLOWSPECV4_NODE, | |
17994 | &no_neighbor_set_peer_group_hidden_cmd); | |
17995 | install_element(BGP_FLOWSPECV6_NODE, | |
17996 | &no_neighbor_set_peer_group_hidden_cmd); | |
17997 | ||
17998 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17999 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18000 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18001 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18002 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18003 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18004 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18005 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18006 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18007 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18008 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18009 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18010 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18011 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18012 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18013 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18014 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18015 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18016 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18017 | install_element(BGP_FLOWSPECV4_NODE, | |
18018 | &neighbor_soft_reconfiguration_cmd); | |
18019 | install_element(BGP_FLOWSPECV4_NODE, | |
18020 | &no_neighbor_soft_reconfiguration_cmd); | |
18021 | install_element(BGP_FLOWSPECV6_NODE, | |
18022 | &neighbor_soft_reconfiguration_cmd); | |
18023 | install_element(BGP_FLOWSPECV6_NODE, | |
18024 | &no_neighbor_soft_reconfiguration_cmd); | |
18025 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); | |
18026 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18027 | ||
18028 | /* "neighbor attribute-unchanged" commands. */ | |
18029 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18030 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18031 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18032 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18033 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18034 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18035 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18036 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18037 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18038 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18039 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18040 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18041 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18042 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18043 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18044 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18045 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18046 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18047 | ||
18048 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18049 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18050 | ||
18051 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); | |
18052 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18053 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18054 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18055 | ||
18056 | /* "nexthop-local unchanged" commands */ | |
18057 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18058 | install_element(BGP_IPV6_NODE, | |
18059 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18060 | ||
18061 | /* "neighbor next-hop-self" commands. */ | |
18062 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18063 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18064 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18065 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18066 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18067 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18068 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18069 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18070 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18071 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18072 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18073 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18074 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18075 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18076 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18077 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18078 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18079 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18080 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); | |
18081 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
18082 | ||
18083 | /* "neighbor next-hop-self force" commands. */ | |
18084 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18085 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
18086 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18087 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
18088 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
18089 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18090 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18091 | install_element(BGP_IPV4_NODE, | |
18092 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18093 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
18094 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18095 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18096 | install_element(BGP_IPV4M_NODE, | |
18097 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18098 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
18099 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18100 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18101 | install_element(BGP_IPV4L_NODE, | |
18102 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18103 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
18104 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18105 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18106 | install_element(BGP_IPV6_NODE, | |
18107 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18108 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
18109 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18110 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18111 | install_element(BGP_IPV6M_NODE, | |
18112 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18113 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
18114 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18115 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18116 | install_element(BGP_IPV6L_NODE, | |
18117 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18118 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
18119 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18120 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18121 | install_element(BGP_VPNV4_NODE, | |
18122 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18123 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
18124 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18125 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); | |
18126 | install_element(BGP_VPNV6_NODE, | |
18127 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
18128 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); | |
18129 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
18130 | ||
18131 | /* "neighbor as-override" commands. */ | |
18132 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18133 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18134 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18135 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18136 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18137 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18138 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18139 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18140 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18141 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18142 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18143 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18144 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18145 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18146 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18147 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18148 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18149 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18150 | ||
18151 | /* "neighbor remove-private-AS" commands. */ | |
18152 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18153 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18154 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18155 | install_element(BGP_NODE, | |
18156 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18157 | install_element(BGP_NODE, | |
18158 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18159 | install_element(BGP_NODE, | |
18160 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18161 | install_element(BGP_NODE, | |
18162 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18163 | install_element( | |
18164 | BGP_NODE, | |
18165 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18166 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18167 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18168 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18169 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18170 | install_element(BGP_IPV4_NODE, | |
18171 | &neighbor_remove_private_as_replace_as_cmd); | |
18172 | install_element(BGP_IPV4_NODE, | |
18173 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18174 | install_element(BGP_IPV4_NODE, | |
18175 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18176 | install_element(BGP_IPV4_NODE, | |
18177 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18178 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18179 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18180 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18181 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18182 | install_element(BGP_IPV4M_NODE, | |
18183 | &neighbor_remove_private_as_replace_as_cmd); | |
18184 | install_element(BGP_IPV4M_NODE, | |
18185 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18186 | install_element(BGP_IPV4M_NODE, | |
18187 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18188 | install_element(BGP_IPV4M_NODE, | |
18189 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18190 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18191 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18192 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18193 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18194 | install_element(BGP_IPV4L_NODE, | |
18195 | &neighbor_remove_private_as_replace_as_cmd); | |
18196 | install_element(BGP_IPV4L_NODE, | |
18197 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18198 | install_element(BGP_IPV4L_NODE, | |
18199 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18200 | install_element(BGP_IPV4L_NODE, | |
18201 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18202 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18203 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18204 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18205 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18206 | install_element(BGP_IPV6_NODE, | |
18207 | &neighbor_remove_private_as_replace_as_cmd); | |
18208 | install_element(BGP_IPV6_NODE, | |
18209 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18210 | install_element(BGP_IPV6_NODE, | |
18211 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18212 | install_element(BGP_IPV6_NODE, | |
18213 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18214 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18215 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18216 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18217 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18218 | install_element(BGP_IPV6M_NODE, | |
18219 | &neighbor_remove_private_as_replace_as_cmd); | |
18220 | install_element(BGP_IPV6M_NODE, | |
18221 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18222 | install_element(BGP_IPV6M_NODE, | |
18223 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18224 | install_element(BGP_IPV6M_NODE, | |
18225 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18226 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18227 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18228 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18229 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18230 | install_element(BGP_IPV6L_NODE, | |
18231 | &neighbor_remove_private_as_replace_as_cmd); | |
18232 | install_element(BGP_IPV6L_NODE, | |
18233 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18234 | install_element(BGP_IPV6L_NODE, | |
18235 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18236 | install_element(BGP_IPV6L_NODE, | |
18237 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18238 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18239 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18240 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18241 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18242 | install_element(BGP_VPNV4_NODE, | |
18243 | &neighbor_remove_private_as_replace_as_cmd); | |
18244 | install_element(BGP_VPNV4_NODE, | |
18245 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18246 | install_element(BGP_VPNV4_NODE, | |
18247 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18248 | install_element(BGP_VPNV4_NODE, | |
18249 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18250 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18251 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18252 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18253 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18254 | install_element(BGP_VPNV6_NODE, | |
18255 | &neighbor_remove_private_as_replace_as_cmd); | |
18256 | install_element(BGP_VPNV6_NODE, | |
18257 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18258 | install_element(BGP_VPNV6_NODE, | |
18259 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18260 | install_element(BGP_VPNV6_NODE, | |
18261 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18262 | ||
18263 | /* "neighbor send-community" commands.*/ | |
18264 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18265 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18266 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18267 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18268 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18269 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18270 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18271 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18272 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18273 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18274 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18275 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18276 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18277 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18278 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18279 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18280 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18281 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18282 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18283 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18284 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18285 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18286 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18287 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18288 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18289 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18290 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18291 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18292 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18293 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18294 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18295 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18296 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18297 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18298 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18299 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18300 | ||
18301 | /* "neighbor route-reflector" commands.*/ | |
18302 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18303 | install_element(BGP_NODE, | |
18304 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18305 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18306 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18307 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18308 | install_element(BGP_IPV4M_NODE, | |
18309 | &no_neighbor_route_reflector_client_cmd); | |
18310 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18311 | install_element(BGP_IPV4L_NODE, | |
18312 | &no_neighbor_route_reflector_client_cmd); | |
18313 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18314 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18315 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18316 | install_element(BGP_IPV6M_NODE, | |
18317 | &no_neighbor_route_reflector_client_cmd); | |
18318 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18319 | install_element(BGP_IPV6L_NODE, | |
18320 | &no_neighbor_route_reflector_client_cmd); | |
18321 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18322 | install_element(BGP_VPNV4_NODE, | |
18323 | &no_neighbor_route_reflector_client_cmd); | |
18324 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18325 | install_element(BGP_VPNV6_NODE, | |
18326 | &no_neighbor_route_reflector_client_cmd); | |
18327 | install_element(BGP_FLOWSPECV4_NODE, | |
18328 | &neighbor_route_reflector_client_cmd); | |
18329 | install_element(BGP_FLOWSPECV4_NODE, | |
18330 | &no_neighbor_route_reflector_client_cmd); | |
18331 | install_element(BGP_FLOWSPECV6_NODE, | |
18332 | &neighbor_route_reflector_client_cmd); | |
18333 | install_element(BGP_FLOWSPECV6_NODE, | |
18334 | &no_neighbor_route_reflector_client_cmd); | |
18335 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
18336 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18337 | ||
18338 | /* "neighbor route-server" commands.*/ | |
18339 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18340 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18341 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18342 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18343 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18344 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18345 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18346 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18347 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18348 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18349 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18350 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18351 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18352 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18353 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18354 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18355 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18356 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
18357 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); | |
18358 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
18359 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); | |
18360 | install_element(BGP_FLOWSPECV4_NODE, | |
18361 | &no_neighbor_route_server_client_cmd); | |
18362 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18363 | install_element(BGP_FLOWSPECV6_NODE, | |
18364 | &no_neighbor_route_server_client_cmd); | |
18365 | ||
18366 | /* "neighbor disable-addpath-rx" commands. */ | |
18367 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18368 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18369 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18370 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18371 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18372 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18373 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18374 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18375 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18376 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18377 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18378 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18379 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18380 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18381 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18382 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18383 | ||
18384 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
18385 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18386 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18387 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18388 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18389 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18390 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18391 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18392 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18393 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18394 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18395 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18396 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18397 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18398 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18399 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18400 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18401 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18402 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18403 | ||
18404 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18405 | install_element(BGP_NODE, | |
18406 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18407 | install_element(BGP_NODE, | |
18408 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18409 | install_element(BGP_IPV4_NODE, | |
18410 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18411 | install_element(BGP_IPV4_NODE, | |
18412 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18413 | install_element(BGP_IPV4M_NODE, | |
18414 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18415 | install_element(BGP_IPV4M_NODE, | |
18416 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18417 | install_element(BGP_IPV4L_NODE, | |
18418 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18419 | install_element(BGP_IPV4L_NODE, | |
18420 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18421 | install_element(BGP_IPV6_NODE, | |
18422 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18423 | install_element(BGP_IPV6_NODE, | |
18424 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18425 | install_element(BGP_IPV6M_NODE, | |
18426 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18427 | install_element(BGP_IPV6M_NODE, | |
18428 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18429 | install_element(BGP_IPV6L_NODE, | |
18430 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18431 | install_element(BGP_IPV6L_NODE, | |
18432 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18433 | install_element(BGP_VPNV4_NODE, | |
18434 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18435 | install_element(BGP_VPNV4_NODE, | |
18436 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18437 | install_element(BGP_VPNV6_NODE, | |
18438 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18439 | install_element(BGP_VPNV6_NODE, | |
18440 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18441 | ||
18442 | /* "neighbor sender-as-path-loop-detection" commands. */ | |
18443 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18444 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18445 | ||
18446 | /* "neighbor passive" commands. */ | |
18447 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18448 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18449 | ||
18450 | ||
18451 | /* "neighbor shutdown" commands. */ | |
18452 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18453 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18454 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18455 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
18456 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); | |
18457 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
18458 | ||
18459 | /* "neighbor capability extended-nexthop" commands.*/ | |
18460 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18461 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18462 | ||
18463 | /* "neighbor capability orf prefix-list" commands.*/ | |
18464 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18465 | install_element(BGP_NODE, | |
18466 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18467 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18468 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18469 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18470 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18471 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18472 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18473 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18474 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18475 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18476 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18477 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18478 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18479 | ||
18480 | /* "neighbor capability dynamic" commands.*/ | |
18481 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18482 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18483 | ||
18484 | /* "neighbor dont-capability-negotiate" commands. */ | |
18485 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18486 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18487 | ||
18488 | /* "neighbor ebgp-multihop" commands. */ | |
18489 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18490 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18491 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18492 | ||
18493 | /* "neighbor disable-connected-check" commands. */ | |
18494 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18495 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18496 | ||
18497 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ | |
18498 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18499 | install_element(BGP_NODE, | |
18500 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
18501 | ||
18502 | /* "neighbor extended-optional-parameters" commands. */ | |
18503 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
18504 | install_element(BGP_NODE, | |
18505 | &no_neighbor_extended_optional_parameters_cmd); | |
18506 | ||
18507 | /* "neighbor enforce-first-as" commands. */ | |
18508 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18509 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18510 | ||
18511 | /* "neighbor description" commands. */ | |
18512 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18513 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
18514 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); | |
18515 | ||
18516 | /* "neighbor update-source" commands. "*/ | |
18517 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18518 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18519 | ||
18520 | /* "neighbor default-originate" commands. */ | |
18521 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18522 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18523 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18524 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18525 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18526 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18527 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18528 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18529 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18530 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18531 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18532 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18533 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18534 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18535 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18536 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18537 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18538 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18539 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18540 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18541 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18542 | ||
18543 | /* "neighbor port" commands. */ | |
18544 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18545 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18546 | ||
18547 | /* "neighbor weight" commands. */ | |
18548 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18549 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18550 | ||
18551 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18552 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18553 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18554 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18555 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18556 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18557 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18558 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18559 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18560 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18561 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18562 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18563 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18564 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18565 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18566 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18567 | ||
18568 | /* "neighbor override-capability" commands. */ | |
18569 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18570 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18571 | ||
18572 | /* "neighbor strict-capability-match" commands. */ | |
18573 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18574 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18575 | ||
18576 | /* "neighbor timers" commands. */ | |
18577 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18578 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18579 | ||
18580 | /* "neighbor timers connect" commands. */ | |
18581 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18582 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18583 | ||
18584 | /* "neighbor timers delayopen" commands. */ | |
18585 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18586 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18587 | ||
18588 | /* "neighbor advertisement-interval" commands. */ | |
18589 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18590 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18591 | ||
18592 | /* "neighbor interface" commands. */ | |
18593 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18594 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18595 | ||
18596 | /* "neighbor distribute" commands. */ | |
18597 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18598 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18599 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18600 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18601 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18602 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18603 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18604 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18605 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18606 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18607 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18608 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18609 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18610 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18611 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18612 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18613 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18614 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18615 | ||
18616 | /* "neighbor prefix-list" commands. */ | |
18617 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
18618 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
18619 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
18620 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
18621 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
18622 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
18623 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
18624 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
18625 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
18626 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
18627 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
18628 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
18629 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
18630 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
18631 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
18632 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
18633 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
18634 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
18635 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); | |
18636 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
18637 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
18638 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
18639 | ||
18640 | /* "neighbor filter-list" commands. */ | |
18641 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18642 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18643 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18644 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18645 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18646 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18647 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18648 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18649 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18650 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18651 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18652 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18653 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18654 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18655 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18656 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18657 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18658 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
18659 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); | |
18660 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18661 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18662 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
18663 | ||
18664 | /* "neighbor route-map" commands. */ | |
18665 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
18666 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
18667 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
18668 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
18669 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
18670 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
18671 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
18672 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
18673 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
18674 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
18675 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
18676 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
18677 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
18678 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
18679 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
18680 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
18681 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
18682 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
18683 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); | |
18684 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
18685 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
18686 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
18687 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); | |
18688 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
18689 | ||
18690 | /* "neighbor unsuppress-map" commands. */ | |
18691 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18692 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18693 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18694 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18695 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18696 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18697 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18698 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18699 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18700 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18701 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18702 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18703 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18704 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18705 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18706 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18707 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18708 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18709 | ||
18710 | /* "neighbor advertise-map" commands. */ | |
18711 | install_element(BGP_NODE, &bgp_condadv_period_cmd); | |
18712 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
18713 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); | |
18714 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); | |
18715 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); | |
18716 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); | |
18717 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); | |
18718 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); | |
18719 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); | |
18720 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); | |
18721 | ||
18722 | /* neighbor maximum-prefix-out commands. */ | |
18723 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18724 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18725 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18726 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18727 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18728 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18729 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18730 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18731 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18732 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18733 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18734 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18735 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18736 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18737 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18738 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18739 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18740 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18741 | ||
18742 | /* "neighbor maximum-prefix" commands. */ | |
18743 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18744 | install_element(BGP_NODE, | |
18745 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18746 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18747 | install_element(BGP_NODE, | |
18748 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18749 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18750 | install_element(BGP_NODE, | |
18751 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18752 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18753 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18754 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18755 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18756 | install_element(BGP_IPV4_NODE, | |
18757 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18758 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18759 | install_element(BGP_IPV4_NODE, | |
18760 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18761 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18762 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18763 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18764 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18765 | install_element(BGP_IPV4M_NODE, | |
18766 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18767 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18768 | install_element(BGP_IPV4M_NODE, | |
18769 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18770 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18771 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18772 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18773 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18774 | install_element(BGP_IPV4L_NODE, | |
18775 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18776 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18777 | install_element(BGP_IPV4L_NODE, | |
18778 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18779 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18780 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18781 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18782 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18783 | install_element(BGP_IPV6_NODE, | |
18784 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18785 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18786 | install_element(BGP_IPV6_NODE, | |
18787 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18788 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18789 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18790 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18791 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18792 | install_element(BGP_IPV6M_NODE, | |
18793 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18794 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18795 | install_element(BGP_IPV6M_NODE, | |
18796 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18797 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18798 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18799 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18800 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18801 | install_element(BGP_IPV6L_NODE, | |
18802 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18803 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18804 | install_element(BGP_IPV6L_NODE, | |
18805 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18806 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18807 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18808 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18809 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18810 | install_element(BGP_VPNV4_NODE, | |
18811 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18812 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18813 | install_element(BGP_VPNV4_NODE, | |
18814 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18815 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18816 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18817 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18818 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18819 | install_element(BGP_VPNV6_NODE, | |
18820 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18821 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18822 | install_element(BGP_VPNV6_NODE, | |
18823 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18824 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18825 | ||
18826 | /* "neighbor allowas-in" */ | |
18827 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18828 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18829 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18830 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18831 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18832 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18833 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18834 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18835 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18836 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18837 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18838 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18839 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18840 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18841 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18842 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18843 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18844 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18845 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18846 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18847 | ||
18848 | /* address-family commands. */ | |
18849 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18850 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
18851 | #ifdef KEEP_OLD_VPN_COMMANDS | |
18852 | install_element(BGP_NODE, &address_family_vpnv4_cmd); | |
18853 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
18854 | #endif /* KEEP_OLD_VPN_COMMANDS */ | |
18855 | ||
18856 | install_element(BGP_NODE, &address_family_evpn_cmd); | |
18857 | ||
18858 | /* "exit-address-family" command. */ | |
18859 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18860 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18861 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18862 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18863 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18864 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18865 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18866 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
18867 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); | |
18868 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
18869 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
18870 | ||
18871 | /* "clear ip bgp commands" */ | |
18872 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18873 | ||
18874 | /* clear ip bgp prefix */ | |
18875 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18876 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18877 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18878 | ||
18879 | /* "show [ip] bgp summary" commands. */ | |
18880 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
18881 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); | |
18882 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
18883 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
18884 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
18885 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
18886 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
18887 | ||
18888 | /* "show [ip] bgp neighbors" commands. */ | |
18889 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18890 | ||
18891 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); | |
18892 | ||
18893 | /* "show [ip] bgp peer-group" commands. */ | |
18894 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18895 | ||
18896 | /* "show [ip] bgp paths" commands. */ | |
18897 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18898 | ||
18899 | /* "show [ip] bgp community" commands. */ | |
18900 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18901 | ||
18902 | /* "show ip bgp large-community" commands. */ | |
18903 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18904 | /* "show [ip] bgp attribute-info" commands. */ | |
18905 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
18906 | /* "show [ip] bgp route-leak" command */ | |
18907 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
18908 | ||
18909 | /* "redistribute" commands. */ | |
18910 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18911 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18912 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18913 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18914 | install_element(BGP_NODE, | |
18915 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18916 | install_element(BGP_NODE, | |
18917 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18918 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18919 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18920 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18921 | install_element(BGP_NODE, | |
18922 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18923 | install_element(BGP_NODE, | |
18924 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18925 | install_element(BGP_NODE, | |
18926 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18927 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18928 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18929 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18930 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18931 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18932 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18933 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18934 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18935 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18936 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18937 | install_element(BGP_IPV4_NODE, | |
18938 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18939 | install_element(BGP_IPV4_NODE, | |
18940 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18941 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18942 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18943 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18944 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18945 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18946 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18947 | ||
18948 | /* import|export vpn [route-map WORD] */ | |
18949 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18950 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
18951 | ||
18952 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); | |
18953 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18954 | ||
18955 | /* ttl_security commands */ | |
18956 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18957 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18958 | ||
18959 | /* "show [ip] bgp memory" commands. */ | |
18960 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18961 | ||
18962 | /* "show bgp martian next-hop" */ | |
18963 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18964 | ||
18965 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); | |
18966 | ||
18967 | /* "show [ip] bgp views" commands. */ | |
18968 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18969 | ||
18970 | /* "show [ip] bgp vrfs" commands. */ | |
18971 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18972 | ||
18973 | /* Community-list. */ | |
18974 | community_list_vty(); | |
18975 | ||
18976 | community_alias_vty(); | |
18977 | ||
18978 | /* vpn-policy commands */ | |
18979 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); | |
18980 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18981 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18982 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18983 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18984 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18985 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18986 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18987 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18988 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
18989 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); | |
18990 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
18991 | ||
18992 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); | |
18993 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18994 | ||
18995 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); | |
18996 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18997 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18998 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
18999 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
19000 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
19001 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19002 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19003 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); | |
19004 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
19005 | ||
19006 | /* tcp-mss command */ | |
19007 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
19008 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
19009 | ||
19010 | /* srv6 commands */ | |
19011 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); | |
19012 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); | |
19013 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); | |
19014 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); | |
19015 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); | |
19016 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); | |
19017 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
19018 | } | |
19019 | ||
19020 | #include "memory.h" | |
19021 | #include "bgp_regex.h" | |
19022 | #include "bgp_clist.h" | |
19023 | #include "bgp_ecommunity.h" | |
19024 | ||
19025 | /* VTY functions. */ | |
19026 | ||
19027 | /* Direction value to string conversion. */ | |
19028 | static const char *community_direct_str(int direct) | |
19029 | { | |
19030 | switch (direct) { | |
19031 | case COMMUNITY_DENY: | |
19032 | return "deny"; | |
19033 | case COMMUNITY_PERMIT: | |
19034 | return "permit"; | |
19035 | default: | |
19036 | return "unknown"; | |
19037 | } | |
19038 | } | |
19039 | ||
19040 | /* Display error string. */ | |
19041 | static void community_list_perror(struct vty *vty, int ret) | |
19042 | { | |
19043 | switch (ret) { | |
19044 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19045 | vty_out(vty, "%% Can't find community-list\n"); | |
19046 | break; | |
19047 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19048 | vty_out(vty, "%% Malformed community-list value\n"); | |
19049 | break; | |
19050 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19051 | vty_out(vty, | |
19052 | "%% Community name conflict, previously defined as standard community\n"); | |
19053 | break; | |
19054 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19055 | vty_out(vty, | |
19056 | "%% Community name conflict, previously defined as expanded community\n"); | |
19057 | break; | |
19058 | } | |
19059 | } | |
19060 | ||
19061 | /* "community-list" keyword help string. */ | |
19062 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19063 | ||
19064 | /*community-list standard */ | |
19065 | DEFUN (community_list_standard, | |
19066 | bgp_community_list_standard_cmd, | |
19067 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19068 | BGP_STR | |
19069 | COMMUNITY_LIST_STR | |
19070 | "Community list number (standard)\n" | |
19071 | "Add an standard community-list entry\n" | |
19072 | "Community list name\n" | |
19073 | "Sequence number of an entry\n" | |
19074 | "Sequence number\n" | |
19075 | "Specify community to reject\n" | |
19076 | "Specify community to accept\n" | |
19077 | COMMUNITY_VAL_STR) | |
19078 | { | |
19079 | char *cl_name_or_number = NULL; | |
19080 | char *seq = NULL; | |
19081 | int direct = 0; | |
19082 | int style = COMMUNITY_LIST_STANDARD; | |
19083 | int idx = 0; | |
19084 | ||
19085 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
19086 | if (idx) | |
19087 | seq = argv[idx]->arg; | |
19088 | ||
19089 | idx = 0; | |
19090 | argv_find(argv, argc, "(1-99)", &idx); | |
19091 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); | |
19092 | cl_name_or_number = argv[idx]->arg; | |
19093 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19094 | : COMMUNITY_DENY; | |
19095 | argv_find(argv, argc, "AA:NN", &idx); | |
19096 | char *str = argv_concat(argv, argc, idx); | |
19097 | ||
19098 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, | |
19099 | direct, style); | |
19100 | ||
19101 | XFREE(MTYPE_TMP, str); | |
19102 | ||
19103 | if (ret < 0) { | |
19104 | /* Display error string. */ | |
19105 | community_list_perror(vty, ret); | |
19106 | return CMD_WARNING_CONFIG_FAILED; | |
19107 | } | |
19108 | ||
19109 | return CMD_SUCCESS; | |
19110 | } | |
19111 | ||
19112 | DEFUN (no_community_list_standard_all, | |
19113 | no_bgp_community_list_standard_all_cmd, | |
19114 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19115 | NO_STR | |
19116 | BGP_STR | |
19117 | COMMUNITY_LIST_STR | |
19118 | "Community list number (standard)\n" | |
19119 | "Add an standard community-list entry\n" | |
19120 | "Community list name\n" | |
19121 | "Sequence number of an entry\n" | |
19122 | "Sequence number\n" | |
19123 | "Specify community to reject\n" | |
19124 | "Specify community to accept\n" | |
19125 | COMMUNITY_VAL_STR) | |
19126 | { | |
19127 | char *cl_name_or_number = NULL; | |
19128 | char *str = NULL; | |
19129 | int direct = 0; | |
19130 | int style = COMMUNITY_LIST_STANDARD; | |
19131 | char *seq = NULL; | |
19132 | int idx = 0; | |
19133 | ||
19134 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
19135 | if (idx) | |
19136 | seq = argv[idx]->arg; | |
19137 | ||
19138 | idx = 0; | |
19139 | argv_find(argv, argc, "permit", &idx); | |
19140 | argv_find(argv, argc, "deny", &idx); | |
19141 | ||
19142 | if (idx) { | |
19143 | direct = argv_find(argv, argc, "permit", &idx) | |
19144 | ? COMMUNITY_PERMIT | |
19145 | : COMMUNITY_DENY; | |
19146 | ||
19147 | idx = 0; | |
19148 | argv_find(argv, argc, "AA:NN", &idx); | |
19149 | str = argv_concat(argv, argc, idx); | |
19150 | } | |
19151 | ||
19152 | idx = 0; | |
19153 | argv_find(argv, argc, "(1-99)", &idx); | |
19154 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); | |
19155 | cl_name_or_number = argv[idx]->arg; | |
19156 | ||
19157 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, | |
19158 | direct, style); | |
19159 | ||
19160 | XFREE(MTYPE_TMP, str); | |
19161 | ||
19162 | if (ret < 0) { | |
19163 | community_list_perror(vty, ret); | |
19164 | return CMD_WARNING_CONFIG_FAILED; | |
19165 | } | |
19166 | ||
19167 | return CMD_SUCCESS; | |
19168 | } | |
19169 | ||
19170 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, | |
19171 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", | |
19172 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19173 | "Community list number (standard)\n" | |
19174 | "Add an standard community-list entry\n" | |
19175 | "Community list name\n") | |
19176 | ||
19177 | /*community-list expanded */ | |
19178 | DEFUN (community_list_expanded_all, | |
19179 | bgp_community_list_expanded_all_cmd, | |
19180 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19181 | BGP_STR | |
19182 | COMMUNITY_LIST_STR | |
19183 | "Community list number (expanded)\n" | |
19184 | "Add an expanded community-list entry\n" | |
19185 | "Community list name\n" | |
19186 | "Sequence number of an entry\n" | |
19187 | "Sequence number\n" | |
19188 | "Specify community to reject\n" | |
19189 | "Specify community to accept\n" | |
19190 | COMMUNITY_VAL_STR) | |
19191 | { | |
19192 | char *cl_name_or_number = NULL; | |
19193 | char *seq = NULL; | |
19194 | int direct = 0; | |
19195 | int style = COMMUNITY_LIST_EXPANDED; | |
19196 | int idx = 0; | |
19197 | ||
19198 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
19199 | if (idx) | |
19200 | seq = argv[idx]->arg; | |
19201 | ||
19202 | idx = 0; | |
19203 | ||
19204 | argv_find(argv, argc, "(100-500)", &idx); | |
19205 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); | |
19206 | cl_name_or_number = argv[idx]->arg; | |
19207 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19208 | : COMMUNITY_DENY; | |
19209 | argv_find(argv, argc, "AA:NN", &idx); | |
19210 | char *str = argv_concat(argv, argc, idx); | |
19211 | ||
19212 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, | |
19213 | direct, style); | |
19214 | ||
19215 | XFREE(MTYPE_TMP, str); | |
19216 | ||
19217 | if (ret < 0) { | |
19218 | /* Display error string. */ | |
19219 | community_list_perror(vty, ret); | |
19220 | return CMD_WARNING_CONFIG_FAILED; | |
19221 | } | |
19222 | ||
19223 | return CMD_SUCCESS; | |
19224 | } | |
19225 | ||
19226 | DEFUN (no_community_list_expanded_all, | |
19227 | no_bgp_community_list_expanded_all_cmd, | |
19228 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19229 | NO_STR | |
19230 | BGP_STR | |
19231 | COMMUNITY_LIST_STR | |
19232 | "Community list number (expanded)\n" | |
19233 | "Add an expanded community-list entry\n" | |
19234 | "Community list name\n" | |
19235 | "Sequence number of an entry\n" | |
19236 | "Sequence number\n" | |
19237 | "Specify community to reject\n" | |
19238 | "Specify community to accept\n" | |
19239 | COMMUNITY_VAL_STR) | |
19240 | { | |
19241 | char *cl_name_or_number = NULL; | |
19242 | char *seq = NULL; | |
19243 | char *str = NULL; | |
19244 | int direct = 0; | |
19245 | int style = COMMUNITY_LIST_EXPANDED; | |
19246 | int idx = 0; | |
19247 | ||
19248 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
19249 | if (idx) | |
19250 | seq = argv[idx]->arg; | |
19251 | ||
19252 | idx = 0; | |
19253 | argv_find(argv, argc, "permit", &idx); | |
19254 | argv_find(argv, argc, "deny", &idx); | |
19255 | ||
19256 | if (idx) { | |
19257 | direct = argv_find(argv, argc, "permit", &idx) | |
19258 | ? COMMUNITY_PERMIT | |
19259 | : COMMUNITY_DENY; | |
19260 | ||
19261 | idx = 0; | |
19262 | argv_find(argv, argc, "AA:NN", &idx); | |
19263 | str = argv_concat(argv, argc, idx); | |
19264 | } | |
19265 | ||
19266 | idx = 0; | |
19267 | argv_find(argv, argc, "(100-500)", &idx); | |
19268 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); | |
19269 | cl_name_or_number = argv[idx]->arg; | |
19270 | ||
19271 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, | |
19272 | direct, style); | |
19273 | ||
19274 | XFREE(MTYPE_TMP, str); | |
19275 | ||
19276 | if (ret < 0) { | |
19277 | community_list_perror(vty, ret); | |
19278 | return CMD_WARNING_CONFIG_FAILED; | |
19279 | } | |
19280 | ||
19281 | return CMD_SUCCESS; | |
19282 | } | |
19283 | ||
19284 | ALIAS(no_community_list_expanded_all, | |
19285 | no_bgp_community_list_expanded_all_list_cmd, | |
19286 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", | |
19287 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19288 | "Community list number (expanded)\n" | |
19289 | "Add an expanded community-list entry\n" | |
19290 | "Community list name\n") | |
19291 | ||
19292 | /* Return configuration string of community-list entry. */ | |
19293 | static const char *community_list_config_str(struct community_entry *entry) | |
19294 | { | |
19295 | const char *str; | |
19296 | ||
19297 | if (entry->any) | |
19298 | str = ""; | |
19299 | else { | |
19300 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19301 | str = community_str(entry->u.com, false); | |
19302 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19303 | str = lcommunity_str(entry->u.lcom, false); | |
19304 | else | |
19305 | str = entry->config; | |
19306 | } | |
19307 | return str; | |
19308 | } | |
19309 | ||
19310 | static void community_list_show(struct vty *vty, struct community_list *list) | |
19311 | { | |
19312 | struct community_entry *entry; | |
19313 | ||
19314 | for (entry = list->head; entry; entry = entry->next) { | |
19315 | if (entry == list->head) { | |
19316 | if (all_digit(list->name)) | |
19317 | vty_out(vty, "Community %s list %s\n", | |
19318 | entry->style == COMMUNITY_LIST_STANDARD | |
19319 | ? "standard" | |
19320 | : "(expanded) access", | |
19321 | list->name); | |
19322 | else | |
19323 | vty_out(vty, "Named Community %s list %s\n", | |
19324 | entry->style == COMMUNITY_LIST_STANDARD | |
19325 | ? "standard" | |
19326 | : "expanded", | |
19327 | list->name); | |
19328 | } | |
19329 | if (entry->any) | |
19330 | vty_out(vty, " %s\n", | |
19331 | community_direct_str(entry->direct)); | |
19332 | else | |
19333 | vty_out(vty, " %s %s\n", | |
19334 | community_direct_str(entry->direct), | |
19335 | community_list_config_str(entry)); | |
19336 | } | |
19337 | } | |
19338 | ||
19339 | DEFUN (show_community_list, | |
19340 | show_bgp_community_list_cmd, | |
19341 | "show bgp community-list", | |
19342 | SHOW_STR | |
19343 | BGP_STR | |
19344 | "List community-list\n") | |
19345 | { | |
19346 | struct community_list *list; | |
19347 | struct community_list_master *cm; | |
19348 | ||
19349 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
19350 | if (!cm) | |
19351 | return CMD_SUCCESS; | |
19352 | ||
19353 | for (list = cm->num.head; list; list = list->next) | |
19354 | community_list_show(vty, list); | |
19355 | ||
19356 | for (list = cm->str.head; list; list = list->next) | |
19357 | community_list_show(vty, list); | |
19358 | ||
19359 | return CMD_SUCCESS; | |
19360 | } | |
19361 | ||
19362 | DEFUN (show_community_list_arg, | |
19363 | show_bgp_community_list_arg_cmd, | |
19364 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", | |
19365 | SHOW_STR | |
19366 | BGP_STR | |
19367 | "List community-list\n" | |
19368 | "Community-list number\n" | |
19369 | "Community-list name\n" | |
19370 | "Detailed information on community-list\n") | |
19371 | { | |
19372 | int idx_comm_list = 3; | |
19373 | struct community_list *list; | |
19374 | ||
19375 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, | |
19376 | COMMUNITY_LIST_MASTER); | |
19377 | if (!list) { | |
19378 | vty_out(vty, "%% Can't find community-list\n"); | |
19379 | return CMD_WARNING; | |
19380 | } | |
19381 | ||
19382 | community_list_show(vty, list); | |
19383 | ||
19384 | return CMD_SUCCESS; | |
19385 | } | |
19386 | ||
19387 | /* | |
19388 | * Large Community code. | |
19389 | */ | |
19390 | static int lcommunity_list_set_vty(struct vty *vty, int argc, | |
19391 | struct cmd_token **argv, int style, | |
19392 | int reject_all_digit_name) | |
19393 | { | |
19394 | int ret; | |
19395 | int direct; | |
19396 | char *str; | |
19397 | int idx = 0; | |
19398 | char *cl_name; | |
19399 | char *seq = NULL; | |
19400 | ||
19401 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19402 | seq = argv[idx]->arg; | |
19403 | ||
19404 | idx = 0; | |
19405 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19406 | : COMMUNITY_DENY; | |
19407 | ||
19408 | /* All digit name check. */ | |
19409 | idx = 0; | |
19410 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); | |
19411 | argv_find(argv, argc, "(1-99)", &idx); | |
19412 | argv_find(argv, argc, "(100-500)", &idx); | |
19413 | cl_name = argv[idx]->arg; | |
19414 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19415 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19416 | return CMD_WARNING_CONFIG_FAILED; | |
19417 | } | |
19418 | ||
19419 | idx = 0; | |
19420 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19421 | argv_find(argv, argc, "LINE", &idx); | |
19422 | /* Concat community string argument. */ | |
19423 | if (idx) | |
19424 | str = argv_concat(argv, argc, idx); | |
19425 | else | |
19426 | str = NULL; | |
19427 | ||
19428 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); | |
19429 | ||
19430 | /* Free temporary community list string allocated by | |
19431 | argv_concat(). */ | |
19432 | XFREE(MTYPE_TMP, str); | |
19433 | ||
19434 | if (ret < 0) { | |
19435 | community_list_perror(vty, ret); | |
19436 | return CMD_WARNING_CONFIG_FAILED; | |
19437 | } | |
19438 | return CMD_SUCCESS; | |
19439 | } | |
19440 | ||
19441 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19442 | struct cmd_token **argv, int style) | |
19443 | { | |
19444 | int ret; | |
19445 | int direct = 0; | |
19446 | char *str = NULL; | |
19447 | int idx = 0; | |
19448 | char *seq = NULL; | |
19449 | ||
19450 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19451 | seq = argv[idx]->arg; | |
19452 | ||
19453 | idx = 0; | |
19454 | argv_find(argv, argc, "permit", &idx); | |
19455 | argv_find(argv, argc, "deny", &idx); | |
19456 | ||
19457 | if (idx) { | |
19458 | /* Check the list direct. */ | |
19459 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19460 | direct = COMMUNITY_PERMIT; | |
19461 | else | |
19462 | direct = COMMUNITY_DENY; | |
19463 | ||
19464 | idx = 0; | |
19465 | argv_find(argv, argc, "LINE", &idx); | |
19466 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19467 | /* Concat community string argument. */ | |
19468 | str = argv_concat(argv, argc, idx); | |
19469 | } | |
19470 | ||
19471 | idx = 0; | |
19472 | argv_find(argv, argc, "(1-99)", &idx); | |
19473 | argv_find(argv, argc, "(100-500)", &idx); | |
19474 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); | |
19475 | ||
19476 | /* Unset community list. */ | |
19477 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, | |
19478 | style); | |
19479 | ||
19480 | /* Free temporary community list string allocated by | |
19481 | argv_concat(). */ | |
19482 | XFREE(MTYPE_TMP, str); | |
19483 | ||
19484 | if (ret < 0) { | |
19485 | community_list_perror(vty, ret); | |
19486 | return CMD_WARNING_CONFIG_FAILED; | |
19487 | } | |
19488 | ||
19489 | return CMD_SUCCESS; | |
19490 | } | |
19491 | ||
19492 | /* "large-community-list" keyword help string. */ | |
19493 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19494 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19495 | ||
19496 | DEFUN (lcommunity_list_standard, | |
19497 | bgp_lcommunity_list_standard_cmd, | |
19498 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", | |
19499 | BGP_STR | |
19500 | LCOMMUNITY_LIST_STR | |
19501 | "Large Community list number (standard)\n" | |
19502 | "Sequence number of an entry\n" | |
19503 | "Sequence number\n" | |
19504 | "Specify large community to reject\n" | |
19505 | "Specify large community to accept\n" | |
19506 | LCOMMUNITY_VAL_STR) | |
19507 | { | |
19508 | return lcommunity_list_set_vty(vty, argc, argv, | |
19509 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
19510 | } | |
19511 | ||
19512 | DEFUN (lcommunity_list_expanded, | |
19513 | bgp_lcommunity_list_expanded_cmd, | |
19514 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", | |
19515 | BGP_STR | |
19516 | LCOMMUNITY_LIST_STR | |
19517 | "Large Community list number (expanded)\n" | |
19518 | "Sequence number of an entry\n" | |
19519 | "Sequence number\n" | |
19520 | "Specify large community to reject\n" | |
19521 | "Specify large community to accept\n" | |
19522 | "An ordered list as a regular-expression\n") | |
19523 | { | |
19524 | return lcommunity_list_set_vty(vty, argc, argv, | |
19525 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
19526 | } | |
19527 | ||
19528 | DEFUN (lcommunity_list_name_standard, | |
19529 | bgp_lcommunity_list_name_standard_cmd, | |
19530 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", | |
19531 | BGP_STR | |
19532 | LCOMMUNITY_LIST_STR | |
19533 | "Specify standard large-community-list\n" | |
19534 | "Large Community list name\n" | |
19535 | "Sequence number of an entry\n" | |
19536 | "Sequence number\n" | |
19537 | "Specify large community to reject\n" | |
19538 | "Specify large community to accept\n" | |
19539 | LCOMMUNITY_VAL_STR) | |
19540 | { | |
19541 | return lcommunity_list_set_vty(vty, argc, argv, | |
19542 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
19543 | } | |
19544 | ||
19545 | DEFUN (lcommunity_list_name_expanded, | |
19546 | bgp_lcommunity_list_name_expanded_cmd, | |
19547 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", | |
19548 | BGP_STR | |
19549 | LCOMMUNITY_LIST_STR | |
19550 | "Specify expanded large-community-list\n" | |
19551 | "Large Community list name\n" | |
19552 | "Sequence number of an entry\n" | |
19553 | "Sequence number\n" | |
19554 | "Specify large community to reject\n" | |
19555 | "Specify large community to accept\n" | |
19556 | "An ordered list as a regular-expression\n") | |
19557 | { | |
19558 | return lcommunity_list_set_vty(vty, argc, argv, | |
19559 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
19560 | } | |
19561 | ||
19562 | DEFUN (no_lcommunity_list_all, | |
19563 | no_bgp_lcommunity_list_all_cmd, | |
19564 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", | |
19565 | NO_STR | |
19566 | BGP_STR | |
19567 | LCOMMUNITY_LIST_STR | |
19568 | "Large Community list number (standard)\n" | |
19569 | "Large Community list number (expanded)\n" | |
19570 | "Large Community list name\n") | |
19571 | { | |
19572 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19573 | LARGE_COMMUNITY_LIST_STANDARD); | |
19574 | } | |
19575 | ||
19576 | DEFUN (no_lcommunity_list_name_standard_all, | |
19577 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19578 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", | |
19579 | NO_STR | |
19580 | BGP_STR | |
19581 | LCOMMUNITY_LIST_STR | |
19582 | "Specify standard large-community-list\n" | |
19583 | "Large Community list name\n") | |
19584 | { | |
19585 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19586 | LARGE_COMMUNITY_LIST_STANDARD); | |
19587 | } | |
19588 | ||
19589 | DEFUN (no_lcommunity_list_name_expanded_all, | |
19590 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19591 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", | |
19592 | NO_STR | |
19593 | BGP_STR | |
19594 | LCOMMUNITY_LIST_STR | |
19595 | "Specify expanded large-community-list\n" | |
19596 | "Large Community list name\n") | |
19597 | { | |
19598 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19599 | LARGE_COMMUNITY_LIST_EXPANDED); | |
19600 | } | |
19601 | ||
19602 | DEFUN (no_lcommunity_list_standard, | |
19603 | no_bgp_lcommunity_list_standard_cmd, | |
19604 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", | |
19605 | NO_STR | |
19606 | BGP_STR | |
19607 | LCOMMUNITY_LIST_STR | |
19608 | "Large Community list number (standard)\n" | |
19609 | "Sequence number of an entry\n" | |
19610 | "Sequence number\n" | |
19611 | "Specify large community to reject\n" | |
19612 | "Specify large community to accept\n" | |
19613 | LCOMMUNITY_VAL_STR) | |
19614 | { | |
19615 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19616 | LARGE_COMMUNITY_LIST_STANDARD); | |
19617 | } | |
19618 | ||
19619 | DEFUN (no_lcommunity_list_expanded, | |
19620 | no_bgp_lcommunity_list_expanded_cmd, | |
19621 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", | |
19622 | NO_STR | |
19623 | BGP_STR | |
19624 | LCOMMUNITY_LIST_STR | |
19625 | "Large Community list number (expanded)\n" | |
19626 | "Sequence number of an entry\n" | |
19627 | "Sequence number\n" | |
19628 | "Specify large community to reject\n" | |
19629 | "Specify large community to accept\n" | |
19630 | "An ordered list as a regular-expression\n") | |
19631 | { | |
19632 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19633 | LARGE_COMMUNITY_LIST_EXPANDED); | |
19634 | } | |
19635 | ||
19636 | DEFUN (no_lcommunity_list_name_standard, | |
19637 | no_bgp_lcommunity_list_name_standard_cmd, | |
19638 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", | |
19639 | NO_STR | |
19640 | BGP_STR | |
19641 | LCOMMUNITY_LIST_STR | |
19642 | "Specify standard large-community-list\n" | |
19643 | "Large Community list name\n" | |
19644 | "Sequence number of an entry\n" | |
19645 | "Sequence number\n" | |
19646 | "Specify large community to reject\n" | |
19647 | "Specify large community to accept\n" | |
19648 | LCOMMUNITY_VAL_STR) | |
19649 | { | |
19650 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19651 | LARGE_COMMUNITY_LIST_STANDARD); | |
19652 | } | |
19653 | ||
19654 | DEFUN (no_lcommunity_list_name_expanded, | |
19655 | no_bgp_lcommunity_list_name_expanded_cmd, | |
19656 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", | |
19657 | NO_STR | |
19658 | BGP_STR | |
19659 | LCOMMUNITY_LIST_STR | |
19660 | "Specify expanded large-community-list\n" | |
19661 | "Large community list name\n" | |
19662 | "Sequence number of an entry\n" | |
19663 | "Sequence number\n" | |
19664 | "Specify large community to reject\n" | |
19665 | "Specify large community to accept\n" | |
19666 | "An ordered list as a regular-expression\n") | |
19667 | { | |
19668 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19669 | LARGE_COMMUNITY_LIST_EXPANDED); | |
19670 | } | |
19671 | ||
19672 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
19673 | { | |
19674 | struct community_entry *entry; | |
19675 | ||
19676 | for (entry = list->head; entry; entry = entry->next) { | |
19677 | if (entry == list->head) { | |
19678 | if (all_digit(list->name)) | |
19679 | vty_out(vty, "Large community %s list %s\n", | |
19680 | entry->style == | |
19681 | LARGE_COMMUNITY_LIST_STANDARD | |
19682 | ? "standard" | |
19683 | : "(expanded) access", | |
19684 | list->name); | |
19685 | else | |
19686 | vty_out(vty, | |
19687 | "Named large community %s list %s\n", | |
19688 | entry->style == | |
19689 | LARGE_COMMUNITY_LIST_STANDARD | |
19690 | ? "standard" | |
19691 | : "expanded", | |
19692 | list->name); | |
19693 | } | |
19694 | if (entry->any) | |
19695 | vty_out(vty, " %s\n", | |
19696 | community_direct_str(entry->direct)); | |
19697 | else | |
19698 | vty_out(vty, " %s %s\n", | |
19699 | community_direct_str(entry->direct), | |
19700 | community_list_config_str(entry)); | |
19701 | } | |
19702 | } | |
19703 | ||
19704 | DEFUN (show_lcommunity_list, | |
19705 | show_bgp_lcommunity_list_cmd, | |
19706 | "show bgp large-community-list", | |
19707 | SHOW_STR | |
19708 | BGP_STR | |
19709 | "List large-community list\n") | |
19710 | { | |
19711 | struct community_list *list; | |
19712 | struct community_list_master *cm; | |
19713 | ||
19714 | cm = community_list_master_lookup(bgp_clist, | |
19715 | LARGE_COMMUNITY_LIST_MASTER); | |
19716 | if (!cm) | |
19717 | return CMD_SUCCESS; | |
19718 | ||
19719 | for (list = cm->num.head; list; list = list->next) | |
19720 | lcommunity_list_show(vty, list); | |
19721 | ||
19722 | for (list = cm->str.head; list; list = list->next) | |
19723 | lcommunity_list_show(vty, list); | |
19724 | ||
19725 | return CMD_SUCCESS; | |
19726 | } | |
19727 | ||
19728 | DEFUN (show_lcommunity_list_arg, | |
19729 | show_bgp_lcommunity_list_arg_cmd, | |
19730 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", | |
19731 | SHOW_STR | |
19732 | BGP_STR | |
19733 | "List large-community list\n" | |
19734 | "Large-community-list number\n" | |
19735 | "Large-community-list name\n" | |
19736 | "Detailed information on large-community-list\n") | |
19737 | { | |
19738 | struct community_list *list; | |
19739 | ||
19740 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, | |
19741 | LARGE_COMMUNITY_LIST_MASTER); | |
19742 | if (!list) { | |
19743 | vty_out(vty, "%% Can't find large-community-list\n"); | |
19744 | return CMD_WARNING; | |
19745 | } | |
19746 | ||
19747 | lcommunity_list_show(vty, list); | |
19748 | ||
19749 | return CMD_SUCCESS; | |
19750 | } | |
19751 | ||
19752 | /* "extcommunity-list" keyword help string. */ | |
19753 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19754 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19755 | ||
19756 | DEFUN (extcommunity_list_standard, | |
19757 | bgp_extcommunity_list_standard_cmd, | |
19758 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19759 | BGP_STR | |
19760 | EXTCOMMUNITY_LIST_STR | |
19761 | "Extended Community list number (standard)\n" | |
19762 | "Specify standard extcommunity-list\n" | |
19763 | "Community list name\n" | |
19764 | "Sequence number of an entry\n" | |
19765 | "Sequence number\n" | |
19766 | "Specify community to reject\n" | |
19767 | "Specify community to accept\n" | |
19768 | EXTCOMMUNITY_VAL_STR) | |
19769 | { | |
19770 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
19771 | int direct = 0; | |
19772 | char *cl_number_or_name = NULL; | |
19773 | char *seq = NULL; | |
19774 | ||
19775 | int idx = 0; | |
19776 | ||
19777 | argv_find(argv, argc, "(1-99)", &idx); | |
19778 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); | |
19779 | cl_number_or_name = argv[idx]->arg; | |
19780 | ||
19781 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19782 | seq = argv[idx]->arg; | |
19783 | ||
19784 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19785 | : COMMUNITY_DENY; | |
19786 | argv_find(argv, argc, "AA:NN", &idx); | |
19787 | char *str = argv_concat(argv, argc, idx); | |
19788 | ||
19789 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, | |
19790 | direct, style); | |
19791 | ||
19792 | XFREE(MTYPE_TMP, str); | |
19793 | ||
19794 | if (ret < 0) { | |
19795 | community_list_perror(vty, ret); | |
19796 | return CMD_WARNING_CONFIG_FAILED; | |
19797 | } | |
19798 | ||
19799 | return CMD_SUCCESS; | |
19800 | } | |
19801 | ||
19802 | DEFUN (extcommunity_list_name_expanded, | |
19803 | bgp_extcommunity_list_name_expanded_cmd, | |
19804 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", | |
19805 | BGP_STR | |
19806 | EXTCOMMUNITY_LIST_STR | |
19807 | "Extended Community list number (expanded)\n" | |
19808 | "Specify expanded extcommunity-list\n" | |
19809 | "Extended Community list name\n" | |
19810 | "Sequence number of an entry\n" | |
19811 | "Sequence number\n" | |
19812 | "Specify community to reject\n" | |
19813 | "Specify community to accept\n" | |
19814 | "An ordered list as a regular-expression\n") | |
19815 | { | |
19816 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
19817 | int direct = 0; | |
19818 | char *cl_number_or_name = NULL; | |
19819 | char *seq = NULL; | |
19820 | int idx = 0; | |
19821 | ||
19822 | argv_find(argv, argc, "(100-500)", &idx); | |
19823 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); | |
19824 | cl_number_or_name = argv[idx]->arg; | |
19825 | ||
19826 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19827 | seq = argv[idx]->arg; | |
19828 | ||
19829 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19830 | : COMMUNITY_DENY; | |
19831 | argv_find(argv, argc, "LINE", &idx); | |
19832 | char *str = argv_concat(argv, argc, idx); | |
19833 | ||
19834 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, | |
19835 | direct, style); | |
19836 | ||
19837 | XFREE(MTYPE_TMP, str); | |
19838 | ||
19839 | if (ret < 0) { | |
19840 | community_list_perror(vty, ret); | |
19841 | return CMD_WARNING_CONFIG_FAILED; | |
19842 | } | |
19843 | ||
19844 | return CMD_SUCCESS; | |
19845 | } | |
19846 | ||
19847 | DEFUN (no_extcommunity_list_standard_all, | |
19848 | no_bgp_extcommunity_list_standard_all_cmd, | |
19849 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", | |
19850 | NO_STR | |
19851 | BGP_STR | |
19852 | EXTCOMMUNITY_LIST_STR | |
19853 | "Extended Community list number (standard)\n" | |
19854 | "Specify standard extcommunity-list\n" | |
19855 | "Community list name\n" | |
19856 | "Sequence number of an entry\n" | |
19857 | "Sequence number\n" | |
19858 | "Specify community to reject\n" | |
19859 | "Specify community to accept\n" | |
19860 | EXTCOMMUNITY_VAL_STR) | |
19861 | { | |
19862 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
19863 | int direct = 0; | |
19864 | char *cl_number_or_name = NULL; | |
19865 | char *str = NULL; | |
19866 | char *seq = NULL; | |
19867 | int idx = 0; | |
19868 | ||
19869 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19870 | seq = argv[idx]->arg; | |
19871 | ||
19872 | idx = 0; | |
19873 | argv_find(argv, argc, "permit", &idx); | |
19874 | argv_find(argv, argc, "deny", &idx); | |
19875 | if (idx) { | |
19876 | direct = argv_find(argv, argc, "permit", &idx) | |
19877 | ? COMMUNITY_PERMIT | |
19878 | : COMMUNITY_DENY; | |
19879 | ||
19880 | idx = 0; | |
19881 | argv_find(argv, argc, "AA:NN", &idx); | |
19882 | str = argv_concat(argv, argc, idx); | |
19883 | } | |
19884 | ||
19885 | idx = 0; | |
19886 | argv_find(argv, argc, "(1-99)", &idx); | |
19887 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); | |
19888 | cl_number_or_name = argv[idx]->arg; | |
19889 | ||
19890 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, | |
19891 | seq, direct, style); | |
19892 | ||
19893 | XFREE(MTYPE_TMP, str); | |
19894 | ||
19895 | if (ret < 0) { | |
19896 | community_list_perror(vty, ret); | |
19897 | return CMD_WARNING_CONFIG_FAILED; | |
19898 | } | |
19899 | ||
19900 | return CMD_SUCCESS; | |
19901 | } | |
19902 | ||
19903 | ALIAS(no_extcommunity_list_standard_all, | |
19904 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19905 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", | |
19906 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR | |
19907 | "Extended Community list number (standard)\n" | |
19908 | "Specify standard extcommunity-list\n" | |
19909 | "Community list name\n") | |
19910 | ||
19911 | DEFUN (no_extcommunity_list_expanded_all, | |
19912 | no_bgp_extcommunity_list_expanded_all_cmd, | |
19913 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", | |
19914 | NO_STR | |
19915 | BGP_STR | |
19916 | EXTCOMMUNITY_LIST_STR | |
19917 | "Extended Community list number (expanded)\n" | |
19918 | "Specify expanded extcommunity-list\n" | |
19919 | "Extended Community list name\n" | |
19920 | "Sequence number of an entry\n" | |
19921 | "Sequence number\n" | |
19922 | "Specify community to reject\n" | |
19923 | "Specify community to accept\n" | |
19924 | "An ordered list as a regular-expression\n") | |
19925 | { | |
19926 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
19927 | int direct = 0; | |
19928 | char *cl_number_or_name = NULL; | |
19929 | char *str = NULL; | |
19930 | char *seq = NULL; | |
19931 | int idx = 0; | |
19932 | ||
19933 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
19934 | seq = argv[idx]->arg; | |
19935 | ||
19936 | idx = 0; | |
19937 | argv_find(argv, argc, "permit", &idx); | |
19938 | argv_find(argv, argc, "deny", &idx); | |
19939 | ||
19940 | if (idx) { | |
19941 | direct = argv_find(argv, argc, "permit", &idx) | |
19942 | ? COMMUNITY_PERMIT | |
19943 | : COMMUNITY_DENY; | |
19944 | ||
19945 | idx = 0; | |
19946 | argv_find(argv, argc, "LINE", &idx); | |
19947 | str = argv_concat(argv, argc, idx); | |
19948 | } | |
19949 | ||
19950 | idx = 0; | |
19951 | argv_find(argv, argc, "(100-500)", &idx); | |
19952 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); | |
19953 | cl_number_or_name = argv[idx]->arg; | |
19954 | ||
19955 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, | |
19956 | seq, direct, style); | |
19957 | ||
19958 | XFREE(MTYPE_TMP, str); | |
19959 | ||
19960 | if (ret < 0) { | |
19961 | community_list_perror(vty, ret); | |
19962 | return CMD_WARNING_CONFIG_FAILED; | |
19963 | } | |
19964 | ||
19965 | return CMD_SUCCESS; | |
19966 | } | |
19967 | ||
19968 | ALIAS(no_extcommunity_list_expanded_all, | |
19969 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19970 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", | |
19971 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR | |
19972 | "Extended Community list number (expanded)\n" | |
19973 | "Specify expanded extcommunity-list\n" | |
19974 | "Extended Community list name\n") | |
19975 | ||
19976 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) | |
19977 | { | |
19978 | struct community_entry *entry; | |
19979 | ||
19980 | for (entry = list->head; entry; entry = entry->next) { | |
19981 | if (entry == list->head) { | |
19982 | if (all_digit(list->name)) | |
19983 | vty_out(vty, "Extended community %s list %s\n", | |
19984 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19985 | ? "standard" | |
19986 | : "(expanded) access", | |
19987 | list->name); | |
19988 | else | |
19989 | vty_out(vty, | |
19990 | "Named extended community %s list %s\n", | |
19991 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19992 | ? "standard" | |
19993 | : "expanded", | |
19994 | list->name); | |
19995 | } | |
19996 | if (entry->any) | |
19997 | vty_out(vty, " %s\n", | |
19998 | community_direct_str(entry->direct)); | |
19999 | else | |
20000 | vty_out(vty, " %s %s\n", | |
20001 | community_direct_str(entry->direct), | |
20002 | community_list_config_str(entry)); | |
20003 | } | |
20004 | } | |
20005 | ||
20006 | DEFUN (show_extcommunity_list, | |
20007 | show_bgp_extcommunity_list_cmd, | |
20008 | "show bgp extcommunity-list", | |
20009 | SHOW_STR | |
20010 | BGP_STR | |
20011 | "List extended-community list\n") | |
20012 | { | |
20013 | struct community_list *list; | |
20014 | struct community_list_master *cm; | |
20015 | ||
20016 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20017 | if (!cm) | |
20018 | return CMD_SUCCESS; | |
20019 | ||
20020 | for (list = cm->num.head; list; list = list->next) | |
20021 | extcommunity_list_show(vty, list); | |
20022 | ||
20023 | for (list = cm->str.head; list; list = list->next) | |
20024 | extcommunity_list_show(vty, list); | |
20025 | ||
20026 | return CMD_SUCCESS; | |
20027 | } | |
20028 | ||
20029 | DEFUN (show_extcommunity_list_arg, | |
20030 | show_bgp_extcommunity_list_arg_cmd, | |
20031 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", | |
20032 | SHOW_STR | |
20033 | BGP_STR | |
20034 | "List extended-community list\n" | |
20035 | "Extcommunity-list number\n" | |
20036 | "Extcommunity-list name\n" | |
20037 | "Detailed information on extcommunity-list\n") | |
20038 | { | |
20039 | int idx_comm_list = 3; | |
20040 | struct community_list *list; | |
20041 | ||
20042 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, | |
20043 | EXTCOMMUNITY_LIST_MASTER); | |
20044 | if (!list) { | |
20045 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20046 | return CMD_WARNING; | |
20047 | } | |
20048 | ||
20049 | extcommunity_list_show(vty, list); | |
20050 | ||
20051 | return CMD_SUCCESS; | |
20052 | } | |
20053 | ||
20054 | /* Display community-list and extcommunity-list configuration. */ | |
20055 | static int community_list_config_write(struct vty *vty) | |
20056 | { | |
20057 | struct community_list *list; | |
20058 | struct community_entry *entry; | |
20059 | struct community_list_master *cm; | |
20060 | int write = 0; | |
20061 | ||
20062 | /* Community-list. */ | |
20063 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20064 | ||
20065 | for (list = cm->num.head; list; list = list->next) | |
20066 | for (entry = list->head; entry; entry = entry->next) { | |
20067 | vty_out(vty, | |
20068 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20069 | list->name, entry->seq, | |
20070 | community_direct_str(entry->direct), | |
20071 | community_list_config_str(entry)); | |
20072 | write++; | |
20073 | } | |
20074 | for (list = cm->str.head; list; list = list->next) | |
20075 | for (entry = list->head; entry; entry = entry->next) { | |
20076 | vty_out(vty, | |
20077 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
20078 | entry->style == COMMUNITY_LIST_STANDARD | |
20079 | ? "standard" | |
20080 | : "expanded", | |
20081 | list->name, entry->seq, | |
20082 | community_direct_str(entry->direct), | |
20083 | community_list_config_str(entry)); | |
20084 | write++; | |
20085 | } | |
20086 | ||
20087 | /* Extcommunity-list. */ | |
20088 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20089 | ||
20090 | for (list = cm->num.head; list; list = list->next) | |
20091 | for (entry = list->head; entry; entry = entry->next) { | |
20092 | vty_out(vty, | |
20093 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20094 | list->name, entry->seq, | |
20095 | community_direct_str(entry->direct), | |
20096 | community_list_config_str(entry)); | |
20097 | write++; | |
20098 | } | |
20099 | for (list = cm->str.head; list; list = list->next) | |
20100 | for (entry = list->head; entry; entry = entry->next) { | |
20101 | vty_out(vty, | |
20102 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", | |
20103 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20104 | ? "standard" | |
20105 | : "expanded", | |
20106 | list->name, entry->seq, | |
20107 | community_direct_str(entry->direct), | |
20108 | community_list_config_str(entry)); | |
20109 | write++; | |
20110 | } | |
20111 | ||
20112 | ||
20113 | /* lcommunity-list. */ | |
20114 | cm = community_list_master_lookup(bgp_clist, | |
20115 | LARGE_COMMUNITY_LIST_MASTER); | |
20116 | ||
20117 | for (list = cm->num.head; list; list = list->next) | |
20118 | for (entry = list->head; entry; entry = entry->next) { | |
20119 | vty_out(vty, | |
20120 | "bgp large-community-list %s seq %" PRId64" %s %s\n", | |
20121 | list->name, entry->seq, | |
20122 | community_direct_str(entry->direct), | |
20123 | community_list_config_str(entry)); | |
20124 | write++; | |
20125 | } | |
20126 | for (list = cm->str.head; list; list = list->next) | |
20127 | for (entry = list->head; entry; entry = entry->next) { | |
20128 | vty_out(vty, | |
20129 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", | |
20130 | ||
20131 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
20132 | ? "standard" | |
20133 | : "expanded", | |
20134 | list->name, entry->seq, community_direct_str(entry->direct), | |
20135 | community_list_config_str(entry)); | |
20136 | write++; | |
20137 | } | |
20138 | ||
20139 | return write; | |
20140 | } | |
20141 | ||
20142 | static int community_list_config_write(struct vty *vty); | |
20143 | static struct cmd_node community_list_node = { | |
20144 | .name = "community list", | |
20145 | .node = COMMUNITY_LIST_NODE, | |
20146 | .prompt = "", | |
20147 | .config_write = community_list_config_write, | |
20148 | }; | |
20149 | ||
20150 | static void community_list_vty(void) | |
20151 | { | |
20152 | install_node(&community_list_node); | |
20153 | ||
20154 | /* Community-list. */ | |
20155 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); | |
20156 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20157 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
20158 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); | |
20159 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); | |
20160 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); | |
20161 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); | |
20162 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
20163 | ||
20164 | /* Extcommunity-list. */ | |
20165 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); | |
20166 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20167 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
20168 | install_element(CONFIG_NODE, | |
20169 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
20170 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); | |
20171 | install_element(CONFIG_NODE, | |
20172 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
20173 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); | |
20174 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
20175 | ||
20176 | /* Large Community List */ | |
20177 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); | |
20178 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
20179 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
20180 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
20181 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); | |
20182 | install_element(CONFIG_NODE, | |
20183 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
20184 | install_element(CONFIG_NODE, | |
20185 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20186 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20187 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20188 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20189 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20190 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20191 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
20192 | ||
20193 | bgp_community_list_command_completion_setup(); | |
20194 | } | |
20195 | ||
20196 | static struct cmd_node community_alias_node = { | |
20197 | .name = "community alias", | |
20198 | .node = COMMUNITY_ALIAS_NODE, | |
20199 | .prompt = "", | |
20200 | .config_write = bgp_community_alias_write, | |
20201 | }; | |
20202 | ||
20203 | void community_alias_vty(void) | |
20204 | { | |
20205 | install_node(&community_alias_node); | |
20206 | ||
20207 | /* Community-list. */ | |
20208 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
20209 | ||
20210 | bgp_community_alias_command_completion_setup(); | |
20211 | } |