]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
5d5ba018 | 37 | #include "frrstr.h" |
718e3744 | 38 | |
39 | #include "bgpd/bgpd.h" | |
4bf6a362 | 40 | #include "bgpd/bgp_advertise.h" |
718e3744 | 41 | #include "bgpd/bgp_attr.h" |
42 | #include "bgpd/bgp_aspath.h" | |
43 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 44 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 45 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 46 | #include "bgpd/bgp_damp.h" |
718e3744 | 47 | #include "bgpd/bgp_debug.h" |
14454c9f | 48 | #include "bgpd/bgp_errors.h" |
e0701b79 | 49 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 50 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 51 | #include "bgpd/bgp_open.h" |
4bf6a362 | 52 | #include "bgpd/bgp_regex.h" |
718e3744 | 53 | #include "bgpd/bgp_route.h" |
c016b6c7 | 54 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 55 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 56 | #include "bgpd/bgp_table.h" |
94f2b392 | 57 | #include "bgpd/bgp_vty.h" |
165b5fff | 58 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 59 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 60 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 61 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 62 | #include "bgpd/bgp_io.h" |
94c2f693 | 63 | #include "bgpd/bgp_evpn.h" |
dcc68b5e | 64 | #include "bgpd/bgp_addpath.h" |
718e3744 | 65 | |
d62a17ae | 66 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
67 | struct prefix *range, int exact); | |
68 | ||
69 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
70 | { | |
71 | switch (afi) { | |
72 | case AFI_IP: | |
73 | switch (safi) { | |
74 | case SAFI_UNICAST: | |
75 | return BGP_IPV4_NODE; | |
76 | break; | |
77 | case SAFI_MULTICAST: | |
78 | return BGP_IPV4M_NODE; | |
79 | break; | |
80 | case SAFI_LABELED_UNICAST: | |
81 | return BGP_IPV4L_NODE; | |
82 | break; | |
83 | case SAFI_MPLS_VPN: | |
84 | return BGP_VPNV4_NODE; | |
85 | break; | |
7c40bf39 | 86 | case SAFI_FLOWSPEC: |
87 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
88 | default: |
89 | /* not expected */ | |
90 | return BGP_IPV4_NODE; | |
91 | break; | |
d62a17ae | 92 | } |
93 | break; | |
94 | case AFI_IP6: | |
95 | switch (safi) { | |
96 | case SAFI_UNICAST: | |
97 | return BGP_IPV6_NODE; | |
98 | break; | |
99 | case SAFI_MULTICAST: | |
100 | return BGP_IPV6M_NODE; | |
101 | break; | |
102 | case SAFI_LABELED_UNICAST: | |
103 | return BGP_IPV6L_NODE; | |
104 | break; | |
105 | case SAFI_MPLS_VPN: | |
106 | return BGP_VPNV6_NODE; | |
107 | break; | |
7c40bf39 | 108 | case SAFI_FLOWSPEC: |
109 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
110 | default: |
111 | /* not expected */ | |
112 | return BGP_IPV4_NODE; | |
113 | break; | |
d62a17ae | 114 | } |
115 | break; | |
116 | case AFI_L2VPN: | |
117 | return BGP_EVPN_NODE; | |
118 | break; | |
119 | case AFI_MAX: | |
120 | // We should never be here but to clarify the switch statement.. | |
121 | return BGP_IPV4_NODE; | |
122 | break; | |
123 | } | |
124 | ||
125 | // Impossible to happen | |
126 | return BGP_IPV4_NODE; | |
f51bae9c | 127 | } |
20eb8864 | 128 | |
718e3744 | 129 | /* Utility function to get address family from current node. */ |
d62a17ae | 130 | afi_t bgp_node_afi(struct vty *vty) |
131 | { | |
132 | afi_t afi; | |
133 | switch (vty->node) { | |
134 | case BGP_IPV6_NODE: | |
135 | case BGP_IPV6M_NODE: | |
136 | case BGP_IPV6L_NODE: | |
137 | case BGP_VPNV6_NODE: | |
7c40bf39 | 138 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 139 | afi = AFI_IP6; |
140 | break; | |
141 | case BGP_EVPN_NODE: | |
142 | afi = AFI_L2VPN; | |
143 | break; | |
144 | default: | |
145 | afi = AFI_IP; | |
146 | break; | |
147 | } | |
148 | return afi; | |
718e3744 | 149 | } |
150 | ||
151 | /* Utility function to get subsequent address family from current | |
152 | node. */ | |
d62a17ae | 153 | safi_t bgp_node_safi(struct vty *vty) |
154 | { | |
155 | safi_t safi; | |
156 | switch (vty->node) { | |
157 | case BGP_VPNV4_NODE: | |
158 | case BGP_VPNV6_NODE: | |
159 | safi = SAFI_MPLS_VPN; | |
160 | break; | |
161 | case BGP_IPV4M_NODE: | |
162 | case BGP_IPV6M_NODE: | |
163 | safi = SAFI_MULTICAST; | |
164 | break; | |
165 | case BGP_EVPN_NODE: | |
166 | safi = SAFI_EVPN; | |
167 | break; | |
168 | case BGP_IPV4L_NODE: | |
169 | case BGP_IPV6L_NODE: | |
170 | safi = SAFI_LABELED_UNICAST; | |
171 | break; | |
7c40bf39 | 172 | case BGP_FLOWSPECV4_NODE: |
173 | case BGP_FLOWSPECV6_NODE: | |
174 | safi = SAFI_FLOWSPEC; | |
175 | break; | |
d62a17ae | 176 | default: |
177 | safi = SAFI_UNICAST; | |
178 | break; | |
179 | } | |
180 | return safi; | |
718e3744 | 181 | } |
182 | ||
55f91488 QY |
183 | /** |
184 | * Converts an AFI in string form to afi_t | |
185 | * | |
186 | * @param afi string, one of | |
187 | * - "ipv4" | |
188 | * - "ipv6" | |
81cf0de5 | 189 | * - "l2vpn" |
55f91488 QY |
190 | * @return the corresponding afi_t |
191 | */ | |
d62a17ae | 192 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
193 | { | |
194 | afi_t afi = AFI_MAX; /* unknown */ | |
195 | if (strmatch(afi_str, "ipv4")) | |
196 | afi = AFI_IP; | |
197 | else if (strmatch(afi_str, "ipv6")) | |
198 | afi = AFI_IP6; | |
81cf0de5 CS |
199 | else if (strmatch(afi_str, "l2vpn")) |
200 | afi = AFI_L2VPN; | |
d62a17ae | 201 | return afi; |
202 | } | |
203 | ||
204 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
205 | afi_t *afi) | |
206 | { | |
207 | int ret = 0; | |
208 | if (argv_find(argv, argc, "ipv4", index)) { | |
209 | ret = 1; | |
210 | if (afi) | |
211 | *afi = AFI_IP; | |
212 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
213 | ret = 1; | |
214 | if (afi) | |
215 | *afi = AFI_IP6; | |
216 | } | |
217 | return ret; | |
46f296b4 LB |
218 | } |
219 | ||
375a2e67 | 220 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 221 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
222 | { | |
223 | safi_t safi = SAFI_MAX; /* unknown */ | |
224 | if (strmatch(safi_str, "multicast")) | |
225 | safi = SAFI_MULTICAST; | |
226 | else if (strmatch(safi_str, "unicast")) | |
227 | safi = SAFI_UNICAST; | |
228 | else if (strmatch(safi_str, "vpn")) | |
229 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
230 | else if (strmatch(safi_str, "evpn")) |
231 | safi = SAFI_EVPN; | |
d62a17ae | 232 | else if (strmatch(safi_str, "labeled-unicast")) |
233 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 234 | else if (strmatch(safi_str, "flowspec")) |
235 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 236 | return safi; |
237 | } | |
238 | ||
239 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
240 | safi_t *safi) | |
241 | { | |
242 | int ret = 0; | |
243 | if (argv_find(argv, argc, "unicast", index)) { | |
244 | ret = 1; | |
245 | if (safi) | |
246 | *safi = SAFI_UNICAST; | |
247 | } else if (argv_find(argv, argc, "multicast", index)) { | |
248 | ret = 1; | |
249 | if (safi) | |
250 | *safi = SAFI_MULTICAST; | |
251 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
252 | ret = 1; | |
253 | if (safi) | |
254 | *safi = SAFI_LABELED_UNICAST; | |
255 | } else if (argv_find(argv, argc, "vpn", index)) { | |
256 | ret = 1; | |
257 | if (safi) | |
258 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 259 | } else if (argv_find(argv, argc, "flowspec", index)) { |
260 | ret = 1; | |
261 | if (safi) | |
262 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 263 | } |
264 | return ret; | |
46f296b4 LB |
265 | } |
266 | ||
7eeee51e | 267 | /* |
f212a857 | 268 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 269 | * |
f212a857 DS |
270 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
271 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
272 | * to appropriate values for the calling function. This is to allow the |
273 | * calling function to make decisions appropriate for the show command | |
274 | * that is being parsed. | |
275 | * | |
276 | * The show commands are generally of the form: | |
d62a17ae | 277 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
278 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
279 | * |
280 | * Since we use argv_find if the show command in particular doesn't have: | |
281 | * [ip] | |
18c57037 | 282 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 283 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
284 | * The command parsing should still be ok. |
285 | * | |
286 | * vty -> The vty for the command so we can output some useful data in | |
287 | * the event of a parse error in the vrf. | |
288 | * argv -> The command tokens | |
289 | * argc -> How many command tokens we have | |
d62a17ae | 290 | * idx -> The current place in the command, generally should be 0 for this |
291 | * function | |
7eeee51e DS |
292 | * afi -> The parsed afi if it was included in the show command, returned here |
293 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 294 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
295 | * |
296 | * The function returns the correct location in the parse tree for the | |
297 | * last token found. | |
0e37c258 DS |
298 | * |
299 | * Returns 0 for failure to parse correctly, else the idx position of where | |
300 | * it found the last token. | |
7eeee51e | 301 | */ |
d62a17ae | 302 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
303 | struct cmd_token **argv, int argc, | |
304 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 305 | struct bgp **bgp, bool use_json) |
d62a17ae | 306 | { |
307 | char *vrf_name = NULL; | |
308 | ||
309 | assert(afi); | |
310 | assert(safi); | |
311 | assert(bgp); | |
312 | ||
313 | if (argv_find(argv, argc, "ip", idx)) | |
314 | *afi = AFI_IP; | |
315 | ||
9a8bdf1c | 316 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 317 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
318 | else if (argv_find(argv, argc, "vrf", idx)) { |
319 | vrf_name = argv[*idx + 1]->arg; | |
320 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
321 | vrf_name = NULL; | |
322 | } | |
323 | if (vrf_name) { | |
d62a17ae | 324 | if (strmatch(vrf_name, "all")) |
325 | *bgp = NULL; | |
326 | else { | |
327 | *bgp = bgp_lookup_by_name(vrf_name); | |
328 | if (!*bgp) { | |
ca61fd25 DS |
329 | if (use_json) |
330 | vty_out(vty, "{}\n"); | |
331 | else | |
332 | vty_out(vty, "View/Vrf %s is unknown\n", | |
333 | vrf_name); | |
d62a17ae | 334 | *idx = 0; |
335 | return 0; | |
336 | } | |
337 | } | |
338 | } else { | |
339 | *bgp = bgp_get_default(); | |
340 | if (!*bgp) { | |
ca61fd25 DS |
341 | if (use_json) |
342 | vty_out(vty, "{}\n"); | |
343 | else | |
344 | vty_out(vty, | |
345 | "Default BGP instance not found\n"); | |
d62a17ae | 346 | *idx = 0; |
347 | return 0; | |
348 | } | |
349 | } | |
350 | ||
351 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
352 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
353 | ||
354 | *idx += 1; | |
355 | return *idx; | |
356 | } | |
357 | ||
358 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
359 | { | |
360 | struct interface *ifp = NULL; | |
361 | ||
362 | if (su->sa.sa_family == AF_INET) | |
363 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
364 | else if (su->sa.sa_family == AF_INET6) | |
365 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
366 | su->sin6.sin6_scope_id, | |
367 | bgp->vrf_id); | |
368 | ||
369 | if (ifp) | |
370 | return 1; | |
371 | ||
372 | return 0; | |
718e3744 | 373 | } |
374 | ||
375 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
376 | /* This is used only for configuration, so disallow if attempted on |
377 | * a dynamic neighbor. | |
378 | */ | |
d62a17ae | 379 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
380 | { | |
381 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
382 | int ret; | |
383 | union sockunion su; | |
384 | struct peer *peer; | |
385 | ||
386 | if (!bgp) { | |
387 | return NULL; | |
388 | } | |
389 | ||
390 | ret = str2sockunion(ip_str, &su); | |
391 | if (ret < 0) { | |
392 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
393 | if (!peer) { | |
394 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
395 | == NULL) { | |
396 | vty_out(vty, | |
397 | "%% Malformed address or name: %s\n", | |
398 | ip_str); | |
399 | return NULL; | |
400 | } | |
401 | } | |
402 | } else { | |
403 | peer = peer_lookup(bgp, &su); | |
404 | if (!peer) { | |
405 | vty_out(vty, | |
406 | "%% Specify remote-as or peer-group commands first\n"); | |
407 | return NULL; | |
408 | } | |
409 | if (peer_dynamic_neighbor(peer)) { | |
410 | vty_out(vty, | |
411 | "%% Operation not allowed on a dynamic neighbor\n"); | |
412 | return NULL; | |
413 | } | |
414 | } | |
415 | return peer; | |
718e3744 | 416 | } |
417 | ||
418 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
419 | /* This is used only for configuration, so disallow if attempted on |
420 | * a dynamic neighbor. | |
421 | */ | |
d62a17ae | 422 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
423 | { | |
424 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
425 | int ret; | |
426 | union sockunion su; | |
427 | struct peer *peer = NULL; | |
428 | struct peer_group *group = NULL; | |
429 | ||
430 | if (!bgp) { | |
431 | return NULL; | |
432 | } | |
433 | ||
434 | ret = str2sockunion(peer_str, &su); | |
435 | if (ret == 0) { | |
436 | /* IP address, locate peer. */ | |
437 | peer = peer_lookup(bgp, &su); | |
438 | } else { | |
439 | /* Not IP, could match either peer configured on interface or a | |
440 | * group. */ | |
441 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
442 | if (!peer) | |
443 | group = peer_group_lookup(bgp, peer_str); | |
444 | } | |
445 | ||
446 | if (peer) { | |
447 | if (peer_dynamic_neighbor(peer)) { | |
448 | vty_out(vty, | |
449 | "%% Operation not allowed on a dynamic neighbor\n"); | |
450 | return NULL; | |
451 | } | |
452 | ||
453 | return peer; | |
454 | } | |
455 | ||
456 | if (group) | |
457 | return group->conf; | |
458 | ||
459 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
460 | ||
461 | return NULL; | |
462 | } | |
463 | ||
464 | int bgp_vty_return(struct vty *vty, int ret) | |
465 | { | |
466 | const char *str = NULL; | |
467 | ||
468 | switch (ret) { | |
469 | case BGP_ERR_INVALID_VALUE: | |
470 | str = "Invalid value"; | |
471 | break; | |
472 | case BGP_ERR_INVALID_FLAG: | |
473 | str = "Invalid flag"; | |
474 | break; | |
475 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
476 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
477 | break; | |
478 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
479 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
480 | break; | |
481 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
482 | str = "Specify remote-as or peer-group remote AS first"; | |
483 | break; | |
484 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
485 | str = "Cannot change the peer-group. Deconfigure first"; | |
486 | break; | |
487 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
488 | str = "Peer is not a member of this peer-group"; | |
489 | break; | |
490 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
491 | str = "Prefix/distribute list can not co-exist"; | |
492 | break; | |
493 | case BGP_ERR_NOT_INTERNAL_PEER: | |
494 | str = "Invalid command. Not an internal neighbor"; | |
495 | break; | |
496 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
497 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
498 | break; | |
499 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
500 | str = "Local-AS allowed only for EBGP peers"; | |
501 | break; | |
502 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
503 | str = "Cannot have local-as same as BGP AS number"; | |
504 | break; | |
505 | case BGP_ERR_TCPSIG_FAILED: | |
506 | str = "Error while applying TCP-Sig to session(s)"; | |
507 | break; | |
508 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
509 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
510 | break; | |
511 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
512 | str = "ttl-security only allowed for EBGP peers"; | |
513 | break; | |
514 | case BGP_ERR_AS_OVERRIDE: | |
515 | str = "as-override cannot be configured for IBGP peers"; | |
516 | break; | |
517 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
518 | str = "Invalid limit for number of dynamic neighbors"; | |
519 | break; | |
520 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
521 | str = "Dynamic neighbor listen range already exists"; | |
522 | break; | |
523 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
524 | str = "Operation not allowed on a dynamic neighbor"; | |
525 | break; | |
526 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
527 | str = "Operation not allowed on a directly connected neighbor"; | |
528 | break; | |
529 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
530 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
531 | break; | |
532 | } | |
533 | if (str) { | |
534 | vty_out(vty, "%% %s\n", str); | |
535 | return CMD_WARNING_CONFIG_FAILED; | |
536 | } | |
537 | return CMD_SUCCESS; | |
718e3744 | 538 | } |
539 | ||
7aafcaca | 540 | /* BGP clear sort. */ |
d62a17ae | 541 | enum clear_sort { |
542 | clear_all, | |
543 | clear_peer, | |
544 | clear_group, | |
545 | clear_external, | |
546 | clear_as | |
7aafcaca DS |
547 | }; |
548 | ||
d62a17ae | 549 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
550 | safi_t safi, int error) | |
551 | { | |
552 | switch (error) { | |
553 | case BGP_ERR_AF_UNCONFIGURED: | |
554 | vty_out(vty, | |
555 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
556 | afi_safi_print(afi, safi), peer->host); | |
557 | break; | |
558 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
559 | vty_out(vty, | |
560 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
561 | peer->host); | |
562 | break; | |
563 | default: | |
564 | break; | |
565 | } | |
7aafcaca DS |
566 | } |
567 | ||
568 | /* `clear ip bgp' functions. */ | |
d62a17ae | 569 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
570 | enum clear_sort sort, enum bgp_clear_type stype, | |
571 | const char *arg) | |
572 | { | |
573 | int ret; | |
3ae8bfa5 | 574 | bool found = false; |
d62a17ae | 575 | struct peer *peer; |
576 | struct listnode *node, *nnode; | |
577 | ||
578 | /* Clear all neighbors. */ | |
579 | /* | |
580 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
581 | * nodes on the BGP instance as that may get freed if it is a |
582 | * doppelganger | |
d62a17ae | 583 | */ |
584 | if (sort == clear_all) { | |
585 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
586 | if (!peer->afc[afi][safi]) |
587 | continue; | |
588 | ||
d62a17ae | 589 | if (stype == BGP_CLEAR_SOFT_NONE) |
590 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 591 | else |
3ae8bfa5 | 592 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 593 | |
594 | if (ret < 0) | |
595 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
596 | else |
597 | found = true; | |
04b6bdc0 | 598 | } |
d62a17ae | 599 | |
600 | /* This is to apply read-only mode on this clear. */ | |
601 | if (stype == BGP_CLEAR_SOFT_NONE) | |
602 | bgp->update_delay_over = 0; | |
603 | ||
3ae8bfa5 | 604 | if (!found) |
3702f84d | 605 | vty_out(vty, "%%BGP: No %s peer configured\n", |
3ae8bfa5 PM |
606 | afi_safi_print(afi, safi)); |
607 | ||
d62a17ae | 608 | return CMD_SUCCESS; |
7aafcaca DS |
609 | } |
610 | ||
3ae8bfa5 | 611 | /* Clear specified neighbor. */ |
d62a17ae | 612 | if (sort == clear_peer) { |
613 | union sockunion su; | |
d62a17ae | 614 | |
615 | /* Make sockunion for lookup. */ | |
616 | ret = str2sockunion(arg, &su); | |
617 | if (ret < 0) { | |
618 | peer = peer_lookup_by_conf_if(bgp, arg); | |
619 | if (!peer) { | |
620 | peer = peer_lookup_by_hostname(bgp, arg); | |
621 | if (!peer) { | |
622 | vty_out(vty, | |
623 | "Malformed address or name: %s\n", | |
624 | arg); | |
625 | return CMD_WARNING; | |
626 | } | |
627 | } | |
628 | } else { | |
629 | peer = peer_lookup(bgp, &su); | |
630 | if (!peer) { | |
631 | vty_out(vty, | |
632 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
633 | arg); | |
634 | return CMD_WARNING; | |
635 | } | |
636 | } | |
7aafcaca | 637 | |
3ae8bfa5 PM |
638 | if (!peer->afc[afi][safi]) |
639 | ret = BGP_ERR_AF_UNCONFIGURED; | |
640 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 641 | ret = peer_clear(peer, NULL); |
642 | else | |
643 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 644 | |
d62a17ae | 645 | if (ret < 0) |
646 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 647 | |
d62a17ae | 648 | return CMD_SUCCESS; |
7aafcaca | 649 | } |
7aafcaca | 650 | |
3ae8bfa5 | 651 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 652 | if (sort == clear_group) { |
653 | struct peer_group *group; | |
7aafcaca | 654 | |
d62a17ae | 655 | group = peer_group_lookup(bgp, arg); |
656 | if (!group) { | |
657 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
658 | return CMD_WARNING; | |
659 | } | |
660 | ||
661 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 662 | if (!peer->afc[afi][safi]) |
663 | continue; | |
664 | ||
3ae8bfa5 PM |
665 | if (stype == BGP_CLEAR_SOFT_NONE) |
666 | ret = peer_clear(peer, NULL); | |
667 | else | |
668 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 669 | |
d62a17ae | 670 | if (ret < 0) |
671 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
672 | else |
673 | found = true; | |
d62a17ae | 674 | } |
3ae8bfa5 PM |
675 | |
676 | if (!found) | |
677 | vty_out(vty, | |
678 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
679 | afi_safi_print(afi, safi), arg); | |
680 | ||
d62a17ae | 681 | return CMD_SUCCESS; |
7aafcaca | 682 | } |
7aafcaca | 683 | |
3ae8bfa5 | 684 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 685 | if (sort == clear_external) { |
686 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
687 | if (peer->sort == BGP_PEER_IBGP) | |
688 | continue; | |
7aafcaca | 689 | |
3ae8bfa5 PM |
690 | if (!peer->afc[afi][safi]) |
691 | continue; | |
692 | ||
d62a17ae | 693 | if (stype == BGP_CLEAR_SOFT_NONE) |
694 | ret = peer_clear(peer, &nnode); | |
695 | else | |
696 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 697 | |
d62a17ae | 698 | if (ret < 0) |
699 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
700 | else |
701 | found = true; | |
d62a17ae | 702 | } |
3ae8bfa5 PM |
703 | |
704 | if (!found) | |
705 | vty_out(vty, | |
706 | "%%BGP: No external %s peer is configured\n", | |
707 | afi_safi_print(afi, safi)); | |
708 | ||
d62a17ae | 709 | return CMD_SUCCESS; |
710 | } | |
711 | ||
3ae8bfa5 | 712 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 713 | if (sort == clear_as) { |
3ae8bfa5 | 714 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 715 | |
716 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
717 | if (peer->as != as) | |
718 | continue; | |
719 | ||
3ae8bfa5 PM |
720 | if (!peer->afc[afi][safi]) |
721 | ret = BGP_ERR_AF_UNCONFIGURED; | |
722 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 723 | ret = peer_clear(peer, &nnode); |
724 | else | |
725 | ret = peer_clear_soft(peer, afi, safi, stype); | |
726 | ||
727 | if (ret < 0) | |
728 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
729 | else |
730 | found = true; | |
d62a17ae | 731 | } |
3ae8bfa5 PM |
732 | |
733 | if (!found) | |
d62a17ae | 734 | vty_out(vty, |
3ae8bfa5 PM |
735 | "%%BGP: No %s peer is configured with AS %s\n", |
736 | afi_safi_print(afi, safi), arg); | |
737 | ||
d62a17ae | 738 | return CMD_SUCCESS; |
739 | } | |
740 | ||
741 | return CMD_SUCCESS; | |
742 | } | |
743 | ||
744 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
745 | safi_t safi, enum clear_sort sort, | |
746 | enum bgp_clear_type stype, const char *arg) | |
747 | { | |
748 | struct bgp *bgp; | |
749 | ||
750 | /* BGP structure lookup. */ | |
751 | if (name) { | |
752 | bgp = bgp_lookup_by_name(name); | |
753 | if (bgp == NULL) { | |
754 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
755 | return CMD_WARNING; | |
756 | } | |
757 | } else { | |
758 | bgp = bgp_get_default(); | |
759 | if (bgp == NULL) { | |
760 | vty_out(vty, "No BGP process is configured\n"); | |
761 | return CMD_WARNING; | |
762 | } | |
763 | } | |
764 | ||
765 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
766 | } |
767 | ||
768 | /* clear soft inbound */ | |
d62a17ae | 769 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 770 | { |
d62a17ae | 771 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
772 | BGP_CLEAR_SOFT_IN, NULL); | |
773 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
774 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
775 | } |
776 | ||
777 | /* clear soft outbound */ | |
d62a17ae | 778 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 779 | { |
d62a17ae | 780 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
781 | BGP_CLEAR_SOFT_OUT, NULL); | |
782 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
783 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
784 | } |
785 | ||
786 | ||
f787d7a0 | 787 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 788 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
789 | #endif |
790 | ||
718e3744 | 791 | /* BGP global configuration. */ |
bee57a7a | 792 | #if (CONFDATE > 20190601) |
1cc40660 DS |
793 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
794 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
795 | #endif | |
796 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
797 | bgp_multiple_instance_cmd, | |
798 | "bgp multiple-instance", | |
799 | BGP_STR | |
800 | "Enable bgp multiple instance\n") | |
718e3744 | 801 | { |
d62a17ae | 802 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
803 | return CMD_SUCCESS; | |
718e3744 | 804 | } |
805 | ||
1cc40660 | 806 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 807 | no_bgp_multiple_instance_cmd, |
808 | "no bgp multiple-instance", | |
809 | NO_STR | |
810 | BGP_STR | |
811 | "BGP multiple instance\n") | |
812 | { | |
d62a17ae | 813 | int ret; |
718e3744 | 814 | |
1cc40660 DS |
815 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
816 | vty_out(vty, "if you are using this please let the developers know\n"); | |
b7cd3069 | 817 | zlog_info("Deprecated option: `bgp multiple-instance` being used"); |
d62a17ae | 818 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
819 | if (ret < 0) { | |
820 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
821 | return CMD_WARNING_CONFIG_FAILED; | |
822 | } | |
823 | return CMD_SUCCESS; | |
718e3744 | 824 | } |
825 | ||
8029b216 AK |
826 | DEFUN_HIDDEN (bgp_local_mac, |
827 | bgp_local_mac_cmd, | |
093e3f23 | 828 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
829 | BGP_STR |
830 | "Local MAC config\n" | |
831 | "VxLAN Network Identifier\n" | |
832 | "VNI number\n" | |
833 | "local mac\n" | |
834 | "mac address\n" | |
835 | "mac-mobility sequence\n" | |
836 | "seq number\n") | |
837 | { | |
838 | int rv; | |
839 | vni_t vni; | |
840 | struct ethaddr mac; | |
841 | struct ipaddr ip; | |
842 | uint32_t seq; | |
843 | struct bgp *bgp; | |
844 | ||
845 | vni = strtoul(argv[3]->arg, NULL, 10); | |
846 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
847 | vty_out(vty, "%% Malformed MAC address\n"); | |
848 | return CMD_WARNING; | |
849 | } | |
850 | memset(&ip, 0, sizeof(ip)); | |
851 | seq = strtoul(argv[7]->arg, NULL, 10); | |
852 | ||
853 | bgp = bgp_get_default(); | |
854 | if (!bgp) { | |
855 | vty_out(vty, "Default BGP instance is not there\n"); | |
856 | return CMD_WARNING; | |
857 | } | |
858 | ||
859 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
860 | if (rv < 0) { | |
861 | vty_out(vty, "Internal error\n"); | |
862 | return CMD_WARNING; | |
863 | } | |
864 | ||
865 | return CMD_SUCCESS; | |
866 | } | |
867 | ||
868 | DEFUN_HIDDEN (no_bgp_local_mac, | |
869 | no_bgp_local_mac_cmd, | |
093e3f23 | 870 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
871 | NO_STR |
872 | BGP_STR | |
873 | "Local MAC config\n" | |
874 | "VxLAN Network Identifier\n" | |
875 | "VNI number\n" | |
876 | "local mac\n" | |
877 | "mac address\n") | |
878 | { | |
879 | int rv; | |
880 | vni_t vni; | |
881 | struct ethaddr mac; | |
882 | struct ipaddr ip; | |
883 | struct bgp *bgp; | |
884 | ||
885 | vni = strtoul(argv[4]->arg, NULL, 10); | |
886 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
887 | vty_out(vty, "%% Malformed MAC address\n"); | |
888 | return CMD_WARNING; | |
889 | } | |
890 | memset(&ip, 0, sizeof(ip)); | |
891 | ||
892 | bgp = bgp_get_default(); | |
893 | if (!bgp) { | |
894 | vty_out(vty, "Default BGP instance is not there\n"); | |
895 | return CMD_WARNING; | |
896 | } | |
897 | ||
898 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip); | |
899 | if (rv < 0) { | |
900 | vty_out(vty, "Internal error\n"); | |
901 | return CMD_WARNING; | |
902 | } | |
903 | ||
904 | return CMD_SUCCESS; | |
905 | } | |
906 | ||
bee57a7a | 907 | #if (CONFDATE > 20190601) |
798467a2 DS |
908 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
909 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
910 | #endif | |
911 | DEFUN_HIDDEN (bgp_config_type, | |
912 | bgp_config_type_cmd, | |
913 | "bgp config-type <cisco|zebra>", | |
914 | BGP_STR | |
915 | "Configuration type\n" | |
916 | "cisco\n" | |
917 | "zebra\n") | |
718e3744 | 918 | { |
d62a17ae | 919 | int idx = 0; |
798467a2 DS |
920 | if (argv_find(argv, argc, "cisco", &idx)) { |
921 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
922 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
b7cd3069 | 923 | zlog_info("Deprecated option: `bgp config-type cisco` being used"); |
d62a17ae | 924 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 925 | } else |
d62a17ae | 926 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 927 | |
d62a17ae | 928 | return CMD_SUCCESS; |
718e3744 | 929 | } |
930 | ||
798467a2 DS |
931 | DEFUN_HIDDEN (no_bgp_config_type, |
932 | no_bgp_config_type_cmd, | |
933 | "no bgp config-type [<cisco|zebra>]", | |
934 | NO_STR | |
935 | BGP_STR | |
936 | "Display configuration type\n" | |
937 | "cisco\n" | |
938 | "zebra\n") | |
718e3744 | 939 | { |
d62a17ae | 940 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
941 | return CMD_SUCCESS; | |
718e3744 | 942 | } |
943 | ||
813d4307 | 944 | |
718e3744 | 945 | DEFUN (no_synchronization, |
946 | no_synchronization_cmd, | |
947 | "no synchronization", | |
948 | NO_STR | |
949 | "Perform IGP synchronization\n") | |
950 | { | |
d62a17ae | 951 | return CMD_SUCCESS; |
718e3744 | 952 | } |
953 | ||
954 | DEFUN (no_auto_summary, | |
955 | no_auto_summary_cmd, | |
956 | "no auto-summary", | |
957 | NO_STR | |
958 | "Enable automatic network number summarization\n") | |
959 | { | |
d62a17ae | 960 | return CMD_SUCCESS; |
718e3744 | 961 | } |
3d515fd9 | 962 | |
718e3744 | 963 | /* "router bgp" commands. */ |
505e5056 | 964 | DEFUN_NOSH (router_bgp, |
f412b39a | 965 | router_bgp_cmd, |
18c57037 | 966 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 967 | ROUTER_STR |
968 | BGP_STR | |
31500417 DW |
969 | AS_STR |
970 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 971 | { |
d62a17ae | 972 | int idx_asn = 2; |
973 | int idx_view_vrf = 3; | |
974 | int idx_vrf = 4; | |
ecec9495 | 975 | int is_new_bgp = 0; |
d62a17ae | 976 | int ret; |
977 | as_t as; | |
978 | struct bgp *bgp; | |
979 | const char *name = NULL; | |
980 | enum bgp_instance_type inst_type; | |
981 | ||
982 | // "router bgp" without an ASN | |
983 | if (argc == 2) { | |
984 | // Pending: Make VRF option available for ASN less config | |
985 | bgp = bgp_get_default(); | |
986 | ||
987 | if (bgp == NULL) { | |
988 | vty_out(vty, "%% No BGP process is configured\n"); | |
989 | return CMD_WARNING_CONFIG_FAILED; | |
990 | } | |
991 | ||
992 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 993 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 994 | return CMD_WARNING_CONFIG_FAILED; |
995 | } | |
996 | } | |
997 | ||
998 | // "router bgp X" | |
999 | else { | |
1000 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1001 | ||
1002 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1003 | if (argc > 3) { | |
1004 | name = argv[idx_vrf]->arg; | |
1005 | ||
9a8bdf1c PG |
1006 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1007 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1008 | name = NULL; | |
1009 | else | |
1010 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1011 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1012 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1013 | } | |
1014 | ||
ecec9495 AD |
1015 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1016 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1017 | ||
d62a17ae | 1018 | ret = bgp_get(&bgp, &as, name, inst_type); |
1019 | switch (ret) { | |
1020 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
1021 | vty_out(vty, | |
1022 | "Please specify 'bgp multiple-instance' first\n"); | |
1023 | return CMD_WARNING_CONFIG_FAILED; | |
1024 | case BGP_ERR_AS_MISMATCH: | |
1025 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1026 | return CMD_WARNING_CONFIG_FAILED; | |
1027 | case BGP_ERR_INSTANCE_MISMATCH: | |
1028 | vty_out(vty, | |
1029 | "BGP instance name and AS number mismatch\n"); | |
1030 | vty_out(vty, | |
1031 | "BGP instance is already running; AS is %u\n", | |
1032 | as); | |
1033 | return CMD_WARNING_CONFIG_FAILED; | |
1034 | } | |
1035 | ||
3bd70bf8 PZ |
1036 | /* |
1037 | * If we just instantiated the default instance, complete | |
1038 | * any pending VRF-VPN leaking that was configured via | |
1039 | * earlier "router bgp X vrf FOO" blocks. | |
1040 | */ | |
ecec9495 | 1041 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1042 | vpn_leak_postchange_all(); |
1043 | ||
d62a17ae | 1044 | /* Pending: handle when user tries to change a view to vrf n vv. |
1045 | */ | |
1046 | } | |
1047 | ||
0b5131c9 MK |
1048 | /* unset the auto created flag as the user config is now present */ |
1049 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1050 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1051 | ||
1052 | return CMD_SUCCESS; | |
718e3744 | 1053 | } |
1054 | ||
718e3744 | 1055 | /* "no router bgp" commands. */ |
1056 | DEFUN (no_router_bgp, | |
1057 | no_router_bgp_cmd, | |
18c57037 | 1058 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1059 | NO_STR |
1060 | ROUTER_STR | |
1061 | BGP_STR | |
31500417 DW |
1062 | AS_STR |
1063 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1064 | { |
d62a17ae | 1065 | int idx_asn = 3; |
1066 | int idx_vrf = 5; | |
1067 | as_t as; | |
1068 | struct bgp *bgp; | |
1069 | const char *name = NULL; | |
718e3744 | 1070 | |
d62a17ae | 1071 | // "no router bgp" without an ASN |
1072 | if (argc == 3) { | |
1073 | // Pending: Make VRF option available for ASN less config | |
1074 | bgp = bgp_get_default(); | |
718e3744 | 1075 | |
d62a17ae | 1076 | if (bgp == NULL) { |
1077 | vty_out(vty, "%% No BGP process is configured\n"); | |
1078 | return CMD_WARNING_CONFIG_FAILED; | |
1079 | } | |
7fb21a9f | 1080 | |
d62a17ae | 1081 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1082 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1083 | return CMD_WARNING_CONFIG_FAILED; |
1084 | } | |
0b5131c9 MK |
1085 | |
1086 | if (bgp->l3vni) { | |
1087 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1088 | bgp->l3vni); | |
1089 | return CMD_WARNING_CONFIG_FAILED; | |
1090 | } | |
d62a17ae | 1091 | } else { |
1092 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1093 | |
d62a17ae | 1094 | if (argc > 4) |
1095 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1096 | |
d62a17ae | 1097 | /* Lookup bgp structure. */ |
1098 | bgp = bgp_lookup(as, name); | |
1099 | if (!bgp) { | |
1100 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1101 | return CMD_WARNING_CONFIG_FAILED; | |
1102 | } | |
0b5131c9 MK |
1103 | |
1104 | if (bgp->l3vni) { | |
1105 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1106 | bgp->l3vni); | |
1107 | return CMD_WARNING_CONFIG_FAILED; | |
1108 | } | |
d62a17ae | 1109 | } |
718e3744 | 1110 | |
d62a17ae | 1111 | bgp_delete(bgp); |
718e3744 | 1112 | |
d62a17ae | 1113 | return CMD_SUCCESS; |
718e3744 | 1114 | } |
1115 | ||
6b0655a2 | 1116 | |
718e3744 | 1117 | /* BGP router-id. */ |
1118 | ||
f787d7a0 | 1119 | DEFPY (bgp_router_id, |
718e3744 | 1120 | bgp_router_id_cmd, |
1121 | "bgp router-id A.B.C.D", | |
1122 | BGP_STR | |
1123 | "Override configured router identifier\n" | |
1124 | "Manually configured router identifier\n") | |
1125 | { | |
d62a17ae | 1126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1127 | bgp_router_id_static_set(bgp, router_id); | |
1128 | return CMD_SUCCESS; | |
718e3744 | 1129 | } |
1130 | ||
f787d7a0 | 1131 | DEFPY (no_bgp_router_id, |
718e3744 | 1132 | no_bgp_router_id_cmd, |
31500417 | 1133 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1134 | NO_STR |
1135 | BGP_STR | |
31500417 DW |
1136 | "Override configured router identifier\n" |
1137 | "Manually configured router identifier\n") | |
718e3744 | 1138 | { |
d62a17ae | 1139 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1140 | |
d62a17ae | 1141 | if (router_id_str) { |
1142 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1143 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1144 | return CMD_WARNING_CONFIG_FAILED; | |
1145 | } | |
e018c7cc | 1146 | } |
718e3744 | 1147 | |
d62a17ae | 1148 | router_id.s_addr = 0; |
1149 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1150 | |
d62a17ae | 1151 | return CMD_SUCCESS; |
718e3744 | 1152 | } |
1153 | ||
6b0655a2 | 1154 | |
718e3744 | 1155 | /* BGP Cluster ID. */ |
718e3744 | 1156 | DEFUN (bgp_cluster_id, |
1157 | bgp_cluster_id_cmd, | |
838758ac | 1158 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1159 | BGP_STR |
1160 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1161 | "Route-Reflector Cluster-id in IP address format\n" |
1162 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1163 | { |
d62a17ae | 1164 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1165 | int idx_ipv4 = 2; | |
1166 | int ret; | |
1167 | struct in_addr cluster; | |
718e3744 | 1168 | |
d62a17ae | 1169 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1170 | if (!ret) { | |
1171 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1172 | return CMD_WARNING_CONFIG_FAILED; | |
1173 | } | |
718e3744 | 1174 | |
d62a17ae | 1175 | bgp_cluster_id_set(bgp, &cluster); |
1176 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1177 | |
d62a17ae | 1178 | return CMD_SUCCESS; |
718e3744 | 1179 | } |
1180 | ||
718e3744 | 1181 | DEFUN (no_bgp_cluster_id, |
1182 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1183 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1184 | NO_STR |
1185 | BGP_STR | |
838758ac DW |
1186 | "Configure Route-Reflector Cluster-id\n" |
1187 | "Route-Reflector Cluster-id in IP address format\n" | |
1188 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1189 | { |
d62a17ae | 1190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1191 | bgp_cluster_id_unset(bgp); | |
1192 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1193 | |
d62a17ae | 1194 | return CMD_SUCCESS; |
718e3744 | 1195 | } |
1196 | ||
718e3744 | 1197 | DEFUN (bgp_confederation_identifier, |
1198 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1199 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1200 | "BGP specific commands\n" |
1201 | "AS confederation parameters\n" | |
1202 | "AS number\n" | |
1203 | "Set routing domain confederation AS\n") | |
1204 | { | |
d62a17ae | 1205 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1206 | int idx_number = 3; | |
1207 | as_t as; | |
718e3744 | 1208 | |
d62a17ae | 1209 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1210 | |
d62a17ae | 1211 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1212 | |
d62a17ae | 1213 | return CMD_SUCCESS; |
718e3744 | 1214 | } |
1215 | ||
1216 | DEFUN (no_bgp_confederation_identifier, | |
1217 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1218 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1219 | NO_STR |
1220 | "BGP specific commands\n" | |
1221 | "AS confederation parameters\n" | |
3a2d747c QY |
1222 | "AS number\n" |
1223 | "Set routing domain confederation AS\n") | |
718e3744 | 1224 | { |
d62a17ae | 1225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1226 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1227 | |
d62a17ae | 1228 | return CMD_SUCCESS; |
718e3744 | 1229 | } |
1230 | ||
718e3744 | 1231 | DEFUN (bgp_confederation_peers, |
1232 | bgp_confederation_peers_cmd, | |
12dcf78e | 1233 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1234 | "BGP specific commands\n" |
1235 | "AS confederation parameters\n" | |
1236 | "Peer ASs in BGP confederation\n" | |
1237 | AS_STR) | |
1238 | { | |
d62a17ae | 1239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1240 | int idx_asn = 3; | |
1241 | as_t as; | |
1242 | int i; | |
718e3744 | 1243 | |
d62a17ae | 1244 | for (i = idx_asn; i < argc; i++) { |
1245 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1246 | |
d62a17ae | 1247 | if (bgp->as == as) { |
1248 | vty_out(vty, | |
1249 | "%% Local member-AS not allowed in confed peer list\n"); | |
1250 | continue; | |
1251 | } | |
718e3744 | 1252 | |
d62a17ae | 1253 | bgp_confederation_peers_add(bgp, as); |
1254 | } | |
1255 | return CMD_SUCCESS; | |
718e3744 | 1256 | } |
1257 | ||
1258 | DEFUN (no_bgp_confederation_peers, | |
1259 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1260 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1261 | NO_STR |
1262 | "BGP specific commands\n" | |
1263 | "AS confederation parameters\n" | |
1264 | "Peer ASs in BGP confederation\n" | |
1265 | AS_STR) | |
1266 | { | |
d62a17ae | 1267 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1268 | int idx_asn = 4; | |
1269 | as_t as; | |
1270 | int i; | |
718e3744 | 1271 | |
d62a17ae | 1272 | for (i = idx_asn; i < argc; i++) { |
1273 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1274 | |
d62a17ae | 1275 | bgp_confederation_peers_remove(bgp, as); |
1276 | } | |
1277 | return CMD_SUCCESS; | |
718e3744 | 1278 | } |
6b0655a2 | 1279 | |
5e242b0d DS |
1280 | /** |
1281 | * Central routine for maximum-paths configuration. | |
1282 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1283 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1284 | */ | |
d62a17ae | 1285 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1286 | const char *mpaths, uint16_t options, |
d62a17ae | 1287 | int set) |
1288 | { | |
1289 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1290 | uint16_t maxpaths = 0; |
d62a17ae | 1291 | int ret; |
1292 | afi_t afi; | |
1293 | safi_t safi; | |
1294 | ||
1295 | afi = bgp_node_afi(vty); | |
1296 | safi = bgp_node_safi(vty); | |
1297 | ||
1298 | if (set) { | |
1299 | maxpaths = strtol(mpaths, NULL, 10); | |
1300 | if (maxpaths > multipath_num) { | |
1301 | vty_out(vty, | |
1302 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1303 | maxpaths, multipath_num); | |
1304 | return CMD_WARNING_CONFIG_FAILED; | |
1305 | } | |
1306 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1307 | options); | |
1308 | } else | |
1309 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1310 | ||
1311 | if (ret < 0) { | |
1312 | vty_out(vty, | |
1313 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1314 | (set == 1) ? "" : "un", | |
1315 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1316 | maxpaths, afi, safi); | |
1317 | return CMD_WARNING_CONFIG_FAILED; | |
1318 | } | |
1319 | ||
1320 | bgp_recalculate_all_bestpaths(bgp); | |
1321 | ||
1322 | return CMD_SUCCESS; | |
165b5fff JB |
1323 | } |
1324 | ||
abc920f8 DS |
1325 | DEFUN (bgp_maxmed_admin, |
1326 | bgp_maxmed_admin_cmd, | |
1327 | "bgp max-med administrative ", | |
1328 | BGP_STR | |
1329 | "Advertise routes with max-med\n" | |
1330 | "Administratively applied, for an indefinite period\n") | |
1331 | { | |
d62a17ae | 1332 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1333 | |
d62a17ae | 1334 | bgp->v_maxmed_admin = 1; |
1335 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1336 | |
d62a17ae | 1337 | bgp_maxmed_update(bgp); |
abc920f8 | 1338 | |
d62a17ae | 1339 | return CMD_SUCCESS; |
abc920f8 DS |
1340 | } |
1341 | ||
1342 | DEFUN (bgp_maxmed_admin_medv, | |
1343 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1344 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1345 | BGP_STR |
1346 | "Advertise routes with max-med\n" | |
1347 | "Administratively applied, for an indefinite period\n" | |
1348 | "Max MED value to be used\n") | |
1349 | { | |
d62a17ae | 1350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1351 | int idx_number = 3; | |
abc920f8 | 1352 | |
d62a17ae | 1353 | bgp->v_maxmed_admin = 1; |
1354 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1355 | |
d62a17ae | 1356 | bgp_maxmed_update(bgp); |
abc920f8 | 1357 | |
d62a17ae | 1358 | return CMD_SUCCESS; |
abc920f8 DS |
1359 | } |
1360 | ||
1361 | DEFUN (no_bgp_maxmed_admin, | |
1362 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1363 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1364 | NO_STR |
1365 | BGP_STR | |
1366 | "Advertise routes with max-med\n" | |
838758ac DW |
1367 | "Administratively applied, for an indefinite period\n" |
1368 | "Max MED value to be used\n") | |
abc920f8 | 1369 | { |
d62a17ae | 1370 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1371 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1372 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1373 | bgp_maxmed_update(bgp); | |
abc920f8 | 1374 | |
d62a17ae | 1375 | return CMD_SUCCESS; |
abc920f8 DS |
1376 | } |
1377 | ||
abc920f8 DS |
1378 | DEFUN (bgp_maxmed_onstartup, |
1379 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1380 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1381 | BGP_STR |
1382 | "Advertise routes with max-med\n" | |
1383 | "Effective on a startup\n" | |
1384 | "Time (seconds) period for max-med\n" | |
1385 | "Max MED value to be used\n") | |
1386 | { | |
d62a17ae | 1387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1388 | int idx = 0; | |
4668a151 | 1389 | |
d62a17ae | 1390 | argv_find(argv, argc, "(5-86400)", &idx); |
1391 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1392 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1393 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1394 | else | |
1395 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1396 | |
d62a17ae | 1397 | bgp_maxmed_update(bgp); |
abc920f8 | 1398 | |
d62a17ae | 1399 | return CMD_SUCCESS; |
abc920f8 DS |
1400 | } |
1401 | ||
1402 | DEFUN (no_bgp_maxmed_onstartup, | |
1403 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1404 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1405 | NO_STR |
1406 | BGP_STR | |
1407 | "Advertise routes with max-med\n" | |
838758ac DW |
1408 | "Effective on a startup\n" |
1409 | "Time (seconds) period for max-med\n" | |
1410 | "Max MED value to be used\n") | |
abc920f8 | 1411 | { |
d62a17ae | 1412 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1413 | |
d62a17ae | 1414 | /* Cancel max-med onstartup if its on */ |
1415 | if (bgp->t_maxmed_onstartup) { | |
1416 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1417 | bgp->maxmed_onstartup_over = 1; | |
1418 | } | |
abc920f8 | 1419 | |
d62a17ae | 1420 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1421 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1422 | |
d62a17ae | 1423 | bgp_maxmed_update(bgp); |
abc920f8 | 1424 | |
d62a17ae | 1425 | return CMD_SUCCESS; |
abc920f8 DS |
1426 | } |
1427 | ||
d62a17ae | 1428 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1429 | const char *wait) | |
f188f2c4 | 1430 | { |
d62a17ae | 1431 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1432 | uint16_t update_delay; |
1433 | uint16_t establish_wait; | |
f188f2c4 | 1434 | |
d62a17ae | 1435 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1436 | |
d62a17ae | 1437 | if (!wait) /* update-delay <delay> */ |
1438 | { | |
1439 | bgp->v_update_delay = update_delay; | |
1440 | bgp->v_establish_wait = bgp->v_update_delay; | |
1441 | return CMD_SUCCESS; | |
1442 | } | |
f188f2c4 | 1443 | |
d62a17ae | 1444 | /* update-delay <delay> <establish-wait> */ |
1445 | establish_wait = atoi(wait); | |
1446 | if (update_delay < establish_wait) { | |
1447 | vty_out(vty, | |
1448 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1449 | return CMD_WARNING_CONFIG_FAILED; | |
1450 | } | |
f188f2c4 | 1451 | |
d62a17ae | 1452 | bgp->v_update_delay = update_delay; |
1453 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1454 | |
d62a17ae | 1455 | return CMD_SUCCESS; |
f188f2c4 DS |
1456 | } |
1457 | ||
d62a17ae | 1458 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1459 | { |
d62a17ae | 1460 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1461 | |
d62a17ae | 1462 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1463 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1464 | |
d62a17ae | 1465 | return CMD_SUCCESS; |
f188f2c4 DS |
1466 | } |
1467 | ||
2b791107 | 1468 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1469 | { |
d62a17ae | 1470 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1471 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1472 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1473 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1474 | vty_out(vty, "\n"); | |
1475 | } | |
f188f2c4 DS |
1476 | } |
1477 | ||
1478 | ||
1479 | /* Update-delay configuration */ | |
1480 | DEFUN (bgp_update_delay, | |
1481 | bgp_update_delay_cmd, | |
6147e2c6 | 1482 | "update-delay (0-3600)", |
f188f2c4 DS |
1483 | "Force initial delay for best-path and updates\n" |
1484 | "Seconds\n") | |
1485 | { | |
d62a17ae | 1486 | int idx_number = 1; |
1487 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1488 | } |
1489 | ||
1490 | DEFUN (bgp_update_delay_establish_wait, | |
1491 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1492 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1493 | "Force initial delay for best-path and updates\n" |
1494 | "Seconds\n" | |
f188f2c4 DS |
1495 | "Seconds\n") |
1496 | { | |
d62a17ae | 1497 | int idx_number = 1; |
1498 | int idx_number_2 = 2; | |
1499 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1500 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1501 | } |
1502 | ||
1503 | /* Update-delay deconfiguration */ | |
1504 | DEFUN (no_bgp_update_delay, | |
1505 | no_bgp_update_delay_cmd, | |
838758ac DW |
1506 | "no update-delay [(0-3600) [(1-3600)]]", |
1507 | NO_STR | |
f188f2c4 | 1508 | "Force initial delay for best-path and updates\n" |
838758ac | 1509 | "Seconds\n" |
7111c1a0 | 1510 | "Seconds\n") |
f188f2c4 | 1511 | { |
d62a17ae | 1512 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1513 | } |
1514 | ||
5e242b0d | 1515 | |
d62a17ae | 1516 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1517 | char set) | |
cb1faec9 | 1518 | { |
d62a17ae | 1519 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1520 | |
555e09d4 QY |
1521 | if (set) { |
1522 | uint32_t quanta = strtoul(num, NULL, 10); | |
1523 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1524 | memory_order_relaxed); | |
1525 | } else { | |
1526 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1527 | memory_order_relaxed); | |
1528 | } | |
1529 | ||
1530 | return CMD_SUCCESS; | |
1531 | } | |
1532 | ||
1533 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1534 | char set) | |
1535 | { | |
1536 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1537 | ||
1538 | if (set) { | |
1539 | uint32_t quanta = strtoul(num, NULL, 10); | |
1540 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1541 | memory_order_relaxed); | |
1542 | } else { | |
1543 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1544 | memory_order_relaxed); | |
1545 | } | |
cb1faec9 | 1546 | |
d62a17ae | 1547 | return CMD_SUCCESS; |
cb1faec9 DS |
1548 | } |
1549 | ||
2b791107 | 1550 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1551 | { |
555e09d4 QY |
1552 | uint32_t quanta = |
1553 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1554 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1555 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1556 | } |
1557 | ||
555e09d4 QY |
1558 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1559 | { | |
1560 | uint32_t quanta = | |
1561 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1562 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1563 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1564 | } |
cb1faec9 | 1565 | |
555e09d4 | 1566 | /* Packet quanta configuration */ |
cb1faec9 DS |
1567 | DEFUN (bgp_wpkt_quanta, |
1568 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1569 | "write-quanta (1-10)", |
cb1faec9 DS |
1570 | "How many packets to write to peer socket per run\n" |
1571 | "Number of packets\n") | |
1572 | { | |
d62a17ae | 1573 | int idx_number = 1; |
1574 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1575 | } |
1576 | ||
cb1faec9 DS |
1577 | DEFUN (no_bgp_wpkt_quanta, |
1578 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1579 | "no write-quanta (1-10)", |
d7fa34c1 | 1580 | NO_STR |
555e09d4 | 1581 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1582 | "Number of packets\n") |
1583 | { | |
d62a17ae | 1584 | int idx_number = 2; |
1585 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1586 | } |
1587 | ||
555e09d4 QY |
1588 | DEFUN (bgp_rpkt_quanta, |
1589 | bgp_rpkt_quanta_cmd, | |
1590 | "read-quanta (1-10)", | |
1591 | "How many packets to read from peer socket per I/O cycle\n" | |
1592 | "Number of packets\n") | |
1593 | { | |
1594 | int idx_number = 1; | |
1595 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1596 | } | |
1597 | ||
1598 | DEFUN (no_bgp_rpkt_quanta, | |
1599 | no_bgp_rpkt_quanta_cmd, | |
1600 | "no read-quanta (1-10)", | |
1601 | NO_STR | |
1602 | "How many packets to read from peer socket per I/O cycle\n" | |
1603 | "Number of packets\n") | |
1604 | { | |
1605 | int idx_number = 2; | |
1606 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1607 | } | |
1608 | ||
2b791107 | 1609 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1610 | { |
37a333fe | 1611 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1612 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1613 | } |
1614 | ||
1615 | ||
1616 | DEFUN (bgp_coalesce_time, | |
1617 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1618 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1619 | "Subgroup coalesce timer\n" |
1620 | "Subgroup coalesce timer value (in ms)\n") | |
1621 | { | |
d62a17ae | 1622 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1623 | |
d62a17ae | 1624 | int idx = 0; |
1625 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1626 | bgp->heuristic_coalesce = false; |
d62a17ae | 1627 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1628 | return CMD_SUCCESS; | |
3f9c7369 DS |
1629 | } |
1630 | ||
1631 | DEFUN (no_bgp_coalesce_time, | |
1632 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1633 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1634 | NO_STR |
3f9c7369 DS |
1635 | "Subgroup coalesce timer\n" |
1636 | "Subgroup coalesce timer value (in ms)\n") | |
1637 | { | |
d62a17ae | 1638 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1639 | |
37a333fe | 1640 | bgp->heuristic_coalesce = true; |
d62a17ae | 1641 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1642 | return CMD_SUCCESS; | |
3f9c7369 DS |
1643 | } |
1644 | ||
5e242b0d DS |
1645 | /* Maximum-paths configuration */ |
1646 | DEFUN (bgp_maxpaths, | |
1647 | bgp_maxpaths_cmd, | |
6319fd63 | 1648 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1649 | "Forward packets over multiple paths\n" |
1650 | "Number of paths\n") | |
1651 | { | |
d62a17ae | 1652 | int idx_number = 1; |
1653 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1654 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1655 | } |
1656 | ||
d62a17ae | 1657 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1658 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1659 | "Forward packets over multiple paths\n" | |
1660 | "Number of paths\n") | |
596c17ba | 1661 | |
165b5fff JB |
1662 | DEFUN (bgp_maxpaths_ibgp, |
1663 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1664 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1665 | "Forward packets over multiple paths\n" |
1666 | "iBGP-multipath\n" | |
1667 | "Number of paths\n") | |
1668 | { | |
d62a17ae | 1669 | int idx_number = 2; |
1670 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1671 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1672 | } |
165b5fff | 1673 | |
d62a17ae | 1674 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1675 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1676 | "Forward packets over multiple paths\n" | |
1677 | "iBGP-multipath\n" | |
1678 | "Number of paths\n") | |
596c17ba | 1679 | |
5e242b0d DS |
1680 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1681 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1682 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1683 | "Forward packets over multiple paths\n" |
1684 | "iBGP-multipath\n" | |
1685 | "Number of paths\n" | |
1686 | "Match the cluster length\n") | |
1687 | { | |
d62a17ae | 1688 | int idx_number = 2; |
1689 | return bgp_maxpaths_config_vty( | |
1690 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1691 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1692 | } |
1693 | ||
d62a17ae | 1694 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1695 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1696 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1697 | "Forward packets over multiple paths\n" | |
1698 | "iBGP-multipath\n" | |
1699 | "Number of paths\n" | |
1700 | "Match the cluster length\n") | |
596c17ba | 1701 | |
165b5fff JB |
1702 | DEFUN (no_bgp_maxpaths, |
1703 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1704 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1705 | NO_STR |
1706 | "Forward packets over multiple paths\n" | |
1707 | "Number of paths\n") | |
1708 | { | |
d62a17ae | 1709 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1710 | } |
1711 | ||
d62a17ae | 1712 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1713 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1714 | "Forward packets over multiple paths\n" |
1715 | "Number of paths\n") | |
596c17ba | 1716 | |
165b5fff JB |
1717 | DEFUN (no_bgp_maxpaths_ibgp, |
1718 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1719 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1720 | NO_STR |
1721 | "Forward packets over multiple paths\n" | |
1722 | "iBGP-multipath\n" | |
838758ac DW |
1723 | "Number of paths\n" |
1724 | "Match the cluster length\n") | |
165b5fff | 1725 | { |
d62a17ae | 1726 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1727 | } |
1728 | ||
d62a17ae | 1729 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1730 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1731 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1732 | NO_STR | |
1733 | "Forward packets over multiple paths\n" | |
1734 | "iBGP-multipath\n" | |
1735 | "Number of paths\n" | |
1736 | "Match the cluster length\n") | |
596c17ba | 1737 | |
2b791107 | 1738 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1739 | safi_t safi) |
165b5fff | 1740 | { |
d62a17ae | 1741 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1742 | vty_out(vty, " maximum-paths %d\n", |
1743 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1744 | } | |
165b5fff | 1745 | |
d62a17ae | 1746 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1747 | vty_out(vty, " maximum-paths ibgp %d", |
1748 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1749 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1750 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1751 | vty_out(vty, " equal-cluster-length"); | |
1752 | vty_out(vty, "\n"); | |
1753 | } | |
165b5fff | 1754 | } |
6b0655a2 | 1755 | |
718e3744 | 1756 | /* BGP timers. */ |
1757 | ||
1758 | DEFUN (bgp_timers, | |
1759 | bgp_timers_cmd, | |
6147e2c6 | 1760 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1761 | "Adjust routing timers\n" |
1762 | "BGP timers\n" | |
1763 | "Keepalive interval\n" | |
1764 | "Holdtime\n") | |
1765 | { | |
d62a17ae | 1766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1767 | int idx_number = 2; | |
1768 | int idx_number_2 = 3; | |
1769 | unsigned long keepalive = 0; | |
1770 | unsigned long holdtime = 0; | |
718e3744 | 1771 | |
d62a17ae | 1772 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1773 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1774 | |
d62a17ae | 1775 | /* Holdtime value check. */ |
1776 | if (holdtime < 3 && holdtime != 0) { | |
1777 | vty_out(vty, | |
1778 | "%% hold time value must be either 0 or greater than 3\n"); | |
1779 | return CMD_WARNING_CONFIG_FAILED; | |
1780 | } | |
718e3744 | 1781 | |
d62a17ae | 1782 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1783 | |
d62a17ae | 1784 | return CMD_SUCCESS; |
718e3744 | 1785 | } |
1786 | ||
1787 | DEFUN (no_bgp_timers, | |
1788 | no_bgp_timers_cmd, | |
838758ac | 1789 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1790 | NO_STR |
1791 | "Adjust routing timers\n" | |
838758ac DW |
1792 | "BGP timers\n" |
1793 | "Keepalive interval\n" | |
1794 | "Holdtime\n") | |
718e3744 | 1795 | { |
d62a17ae | 1796 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1797 | bgp_timers_unset(bgp); | |
718e3744 | 1798 | |
d62a17ae | 1799 | return CMD_SUCCESS; |
718e3744 | 1800 | } |
1801 | ||
6b0655a2 | 1802 | |
718e3744 | 1803 | DEFUN (bgp_client_to_client_reflection, |
1804 | bgp_client_to_client_reflection_cmd, | |
1805 | "bgp client-to-client reflection", | |
1806 | "BGP specific commands\n" | |
1807 | "Configure client to client route reflection\n" | |
1808 | "reflection of routes allowed\n") | |
1809 | { | |
d62a17ae | 1810 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1811 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1812 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1813 | |
d62a17ae | 1814 | return CMD_SUCCESS; |
718e3744 | 1815 | } |
1816 | ||
1817 | DEFUN (no_bgp_client_to_client_reflection, | |
1818 | no_bgp_client_to_client_reflection_cmd, | |
1819 | "no bgp client-to-client reflection", | |
1820 | NO_STR | |
1821 | "BGP specific commands\n" | |
1822 | "Configure client to client route reflection\n" | |
1823 | "reflection of routes allowed\n") | |
1824 | { | |
d62a17ae | 1825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1826 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1827 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1828 | |
d62a17ae | 1829 | return CMD_SUCCESS; |
718e3744 | 1830 | } |
1831 | ||
1832 | /* "bgp always-compare-med" configuration. */ | |
1833 | DEFUN (bgp_always_compare_med, | |
1834 | bgp_always_compare_med_cmd, | |
1835 | "bgp always-compare-med", | |
1836 | "BGP specific commands\n" | |
1837 | "Allow comparing MED from different neighbors\n") | |
1838 | { | |
d62a17ae | 1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1840 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1841 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1842 | |
d62a17ae | 1843 | return CMD_SUCCESS; |
718e3744 | 1844 | } |
1845 | ||
1846 | DEFUN (no_bgp_always_compare_med, | |
1847 | no_bgp_always_compare_med_cmd, | |
1848 | "no bgp always-compare-med", | |
1849 | NO_STR | |
1850 | "BGP specific commands\n" | |
1851 | "Allow comparing MED from different neighbors\n") | |
1852 | { | |
d62a17ae | 1853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1854 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1855 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1856 | |
d62a17ae | 1857 | return CMD_SUCCESS; |
718e3744 | 1858 | } |
6b0655a2 | 1859 | |
718e3744 | 1860 | /* "bgp deterministic-med" configuration. */ |
1861 | DEFUN (bgp_deterministic_med, | |
1862 | bgp_deterministic_med_cmd, | |
1863 | "bgp deterministic-med", | |
1864 | "BGP specific commands\n" | |
1865 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1866 | { | |
d62a17ae | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1868 | |
d62a17ae | 1869 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1870 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1871 | bgp_recalculate_all_bestpaths(bgp); | |
1872 | } | |
7aafcaca | 1873 | |
d62a17ae | 1874 | return CMD_SUCCESS; |
718e3744 | 1875 | } |
1876 | ||
1877 | DEFUN (no_bgp_deterministic_med, | |
1878 | no_bgp_deterministic_med_cmd, | |
1879 | "no bgp deterministic-med", | |
1880 | NO_STR | |
1881 | "BGP specific commands\n" | |
1882 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1883 | { | |
d62a17ae | 1884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1885 | int bestpath_per_as_used; | |
1886 | afi_t afi; | |
1887 | safi_t safi; | |
1888 | struct peer *peer; | |
1889 | struct listnode *node, *nnode; | |
1890 | ||
1891 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1892 | bestpath_per_as_used = 0; | |
1893 | ||
1894 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1895 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1896 | if (bgp_addpath_dmed_required( |
1897 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1898 | bestpath_per_as_used = 1; |
1899 | break; | |
1900 | } | |
d62a17ae | 1901 | |
1902 | if (bestpath_per_as_used) | |
1903 | break; | |
1904 | } | |
1905 | ||
1906 | if (bestpath_per_as_used) { | |
1907 | vty_out(vty, | |
1908 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1909 | return CMD_WARNING_CONFIG_FAILED; | |
1910 | } else { | |
1911 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1912 | bgp_recalculate_all_bestpaths(bgp); | |
1913 | } | |
1914 | } | |
1915 | ||
1916 | return CMD_SUCCESS; | |
718e3744 | 1917 | } |
538621f2 | 1918 | |
1919 | /* "bgp graceful-restart" configuration. */ | |
1920 | DEFUN (bgp_graceful_restart, | |
1921 | bgp_graceful_restart_cmd, | |
1922 | "bgp graceful-restart", | |
1923 | "BGP specific commands\n" | |
1924 | "Graceful restart capability parameters\n") | |
1925 | { | |
d62a17ae | 1926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1927 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1928 | return CMD_SUCCESS; | |
538621f2 | 1929 | } |
1930 | ||
1931 | DEFUN (no_bgp_graceful_restart, | |
1932 | no_bgp_graceful_restart_cmd, | |
1933 | "no bgp graceful-restart", | |
1934 | NO_STR | |
1935 | "BGP specific commands\n" | |
1936 | "Graceful restart capability parameters\n") | |
1937 | { | |
d62a17ae | 1938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1939 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1940 | return CMD_SUCCESS; | |
538621f2 | 1941 | } |
1942 | ||
93406d87 | 1943 | DEFUN (bgp_graceful_restart_stalepath_time, |
1944 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1945 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1946 | "BGP specific commands\n" |
1947 | "Graceful restart capability parameters\n" | |
1948 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1949 | "Delay value (seconds)\n") | |
1950 | { | |
d62a17ae | 1951 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1952 | int idx_number = 3; | |
d7c0a89a | 1953 | uint32_t stalepath; |
93406d87 | 1954 | |
d62a17ae | 1955 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1956 | bgp->stalepath_time = stalepath; | |
1957 | return CMD_SUCCESS; | |
93406d87 | 1958 | } |
1959 | ||
eb6f1b41 PG |
1960 | DEFUN (bgp_graceful_restart_restart_time, |
1961 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1962 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1963 | "BGP specific commands\n" |
1964 | "Graceful restart capability parameters\n" | |
1965 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1966 | "Delay value (seconds)\n") | |
1967 | { | |
d62a17ae | 1968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1969 | int idx_number = 3; | |
d7c0a89a | 1970 | uint32_t restart; |
eb6f1b41 | 1971 | |
d62a17ae | 1972 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1973 | bgp->restart_time = restart; | |
1974 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1975 | } |
1976 | ||
93406d87 | 1977 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1978 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1979 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1980 | NO_STR |
1981 | "BGP specific commands\n" | |
1982 | "Graceful restart capability parameters\n" | |
838758ac DW |
1983 | "Set the max time to hold onto restarting peer's stale paths\n" |
1984 | "Delay value (seconds)\n") | |
93406d87 | 1985 | { |
d62a17ae | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1987 | |
d62a17ae | 1988 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1989 | return CMD_SUCCESS; | |
93406d87 | 1990 | } |
1991 | ||
eb6f1b41 PG |
1992 | DEFUN (no_bgp_graceful_restart_restart_time, |
1993 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1994 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1995 | NO_STR |
1996 | "BGP specific commands\n" | |
1997 | "Graceful restart capability parameters\n" | |
838758ac DW |
1998 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1999 | "Delay value (seconds)\n") | |
eb6f1b41 | 2000 | { |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2002 | |
d62a17ae | 2003 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2004 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2005 | } |
2006 | ||
43fc21b3 JC |
2007 | DEFUN (bgp_graceful_restart_preserve_fw, |
2008 | bgp_graceful_restart_preserve_fw_cmd, | |
2009 | "bgp graceful-restart preserve-fw-state", | |
2010 | "BGP specific commands\n" | |
2011 | "Graceful restart capability parameters\n" | |
2012 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2013 | { | |
d62a17ae | 2014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2015 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2016 | return CMD_SUCCESS; | |
43fc21b3 JC |
2017 | } |
2018 | ||
2019 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2020 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2021 | "no bgp graceful-restart preserve-fw-state", | |
2022 | NO_STR | |
2023 | "BGP specific commands\n" | |
2024 | "Graceful restart capability parameters\n" | |
2025 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2026 | { | |
d62a17ae | 2027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2028 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2029 | return CMD_SUCCESS; | |
43fc21b3 JC |
2030 | } |
2031 | ||
7f323236 DW |
2032 | static void bgp_redistribute_redo(struct bgp *bgp) |
2033 | { | |
2034 | afi_t afi; | |
2035 | int i; | |
2036 | struct list *red_list; | |
2037 | struct listnode *node; | |
2038 | struct bgp_redist *red; | |
2039 | ||
a4d82a8a PZ |
2040 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
2041 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 2042 | |
a4d82a8a PZ |
2043 | red_list = bgp->redist[afi][i]; |
2044 | if (!red_list) | |
2045 | continue; | |
7f323236 | 2046 | |
a4d82a8a | 2047 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
2048 | bgp_redistribute_resend(bgp, afi, i, |
2049 | red->instance); | |
2050 | } | |
2051 | } | |
2052 | } | |
2053 | } | |
2054 | ||
2055 | /* "bgp graceful-shutdown" configuration */ | |
2056 | DEFUN (bgp_graceful_shutdown, | |
2057 | bgp_graceful_shutdown_cmd, | |
2058 | "bgp graceful-shutdown", | |
2059 | BGP_STR | |
2060 | "Graceful shutdown parameters\n") | |
2061 | { | |
2062 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2063 | ||
2064 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2065 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2066 | bgp_static_redo_import_check(bgp); | |
2067 | bgp_redistribute_redo(bgp); | |
2068 | bgp_clear_star_soft_out(vty, bgp->name); | |
2069 | bgp_clear_star_soft_in(vty, bgp->name); | |
2070 | } | |
2071 | ||
2072 | return CMD_SUCCESS; | |
2073 | } | |
2074 | ||
2075 | DEFUN (no_bgp_graceful_shutdown, | |
2076 | no_bgp_graceful_shutdown_cmd, | |
2077 | "no bgp graceful-shutdown", | |
2078 | NO_STR | |
2079 | BGP_STR | |
2080 | "Graceful shutdown parameters\n") | |
2081 | { | |
2082 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2083 | ||
2084 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2085 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2086 | bgp_static_redo_import_check(bgp); | |
2087 | bgp_redistribute_redo(bgp); | |
2088 | bgp_clear_star_soft_out(vty, bgp->name); | |
2089 | bgp_clear_star_soft_in(vty, bgp->name); | |
2090 | } | |
2091 | ||
2092 | return CMD_SUCCESS; | |
2093 | } | |
2094 | ||
718e3744 | 2095 | /* "bgp fast-external-failover" configuration. */ |
2096 | DEFUN (bgp_fast_external_failover, | |
2097 | bgp_fast_external_failover_cmd, | |
2098 | "bgp fast-external-failover", | |
2099 | BGP_STR | |
2100 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2101 | { | |
d62a17ae | 2102 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2103 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2104 | return CMD_SUCCESS; | |
718e3744 | 2105 | } |
2106 | ||
2107 | DEFUN (no_bgp_fast_external_failover, | |
2108 | no_bgp_fast_external_failover_cmd, | |
2109 | "no bgp fast-external-failover", | |
2110 | NO_STR | |
2111 | BGP_STR | |
2112 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2113 | { | |
d62a17ae | 2114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2115 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2116 | return CMD_SUCCESS; | |
718e3744 | 2117 | } |
6b0655a2 | 2118 | |
718e3744 | 2119 | /* "bgp enforce-first-as" configuration. */ |
ec4f0750 | 2120 | #if CONFDATE > 20190517 |
47cbc09b PM |
2121 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2122 | #endif | |
2123 | ||
f07e1c4f QY |
2124 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2125 | bgp_enforce_first_as_cmd, | |
2126 | "[no] bgp enforce-first-as", | |
2127 | NO_STR | |
2128 | BGP_STR | |
2129 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2130 | { |
d62a17ae | 2131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2132 | |
f07e1c4f QY |
2133 | if (strmatch(argv[0]->text, "no")) |
2134 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2135 | else | |
2136 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2137 | |
d62a17ae | 2138 | return CMD_SUCCESS; |
718e3744 | 2139 | } |
6b0655a2 | 2140 | |
718e3744 | 2141 | /* "bgp bestpath compare-routerid" configuration. */ |
2142 | DEFUN (bgp_bestpath_compare_router_id, | |
2143 | bgp_bestpath_compare_router_id_cmd, | |
2144 | "bgp bestpath compare-routerid", | |
2145 | "BGP specific commands\n" | |
2146 | "Change the default bestpath selection\n" | |
2147 | "Compare router-id for identical EBGP paths\n") | |
2148 | { | |
d62a17ae | 2149 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2150 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2151 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2152 | |
d62a17ae | 2153 | return CMD_SUCCESS; |
718e3744 | 2154 | } |
2155 | ||
2156 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2157 | no_bgp_bestpath_compare_router_id_cmd, | |
2158 | "no bgp bestpath compare-routerid", | |
2159 | NO_STR | |
2160 | "BGP specific commands\n" | |
2161 | "Change the default bestpath selection\n" | |
2162 | "Compare router-id for identical EBGP paths\n") | |
2163 | { | |
d62a17ae | 2164 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2165 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2166 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2167 | |
d62a17ae | 2168 | return CMD_SUCCESS; |
718e3744 | 2169 | } |
6b0655a2 | 2170 | |
718e3744 | 2171 | /* "bgp bestpath as-path ignore" configuration. */ |
2172 | DEFUN (bgp_bestpath_aspath_ignore, | |
2173 | bgp_bestpath_aspath_ignore_cmd, | |
2174 | "bgp bestpath as-path ignore", | |
2175 | "BGP specific commands\n" | |
2176 | "Change the default bestpath selection\n" | |
2177 | "AS-path attribute\n" | |
2178 | "Ignore as-path length in selecting a route\n") | |
2179 | { | |
d62a17ae | 2180 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2181 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2182 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2183 | |
d62a17ae | 2184 | return CMD_SUCCESS; |
718e3744 | 2185 | } |
2186 | ||
2187 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2188 | no_bgp_bestpath_aspath_ignore_cmd, | |
2189 | "no bgp bestpath as-path ignore", | |
2190 | NO_STR | |
2191 | "BGP specific commands\n" | |
2192 | "Change the default bestpath selection\n" | |
2193 | "AS-path attribute\n" | |
2194 | "Ignore as-path length in selecting a route\n") | |
2195 | { | |
d62a17ae | 2196 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2197 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2198 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2199 | |
d62a17ae | 2200 | return CMD_SUCCESS; |
718e3744 | 2201 | } |
6b0655a2 | 2202 | |
6811845b | 2203 | /* "bgp bestpath as-path confed" configuration. */ |
2204 | DEFUN (bgp_bestpath_aspath_confed, | |
2205 | bgp_bestpath_aspath_confed_cmd, | |
2206 | "bgp bestpath as-path confed", | |
2207 | "BGP specific commands\n" | |
2208 | "Change the default bestpath selection\n" | |
2209 | "AS-path attribute\n" | |
2210 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2211 | { | |
d62a17ae | 2212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2213 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2214 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2215 | |
d62a17ae | 2216 | return CMD_SUCCESS; |
6811845b | 2217 | } |
2218 | ||
2219 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2220 | no_bgp_bestpath_aspath_confed_cmd, | |
2221 | "no bgp bestpath as-path confed", | |
2222 | NO_STR | |
2223 | "BGP specific commands\n" | |
2224 | "Change the default bestpath selection\n" | |
2225 | "AS-path attribute\n" | |
2226 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2227 | { | |
d62a17ae | 2228 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2229 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2230 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2231 | |
d62a17ae | 2232 | return CMD_SUCCESS; |
6811845b | 2233 | } |
6b0655a2 | 2234 | |
2fdd455c PM |
2235 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2236 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2237 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2238 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2239 | "BGP specific commands\n" |
2240 | "Change the default bestpath selection\n" | |
2241 | "AS-path attribute\n" | |
2242 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2243 | "Generate an AS_SET\n" |
16fc1eec DS |
2244 | "Do not generate an AS_SET\n") |
2245 | { | |
d62a17ae | 2246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2247 | int idx = 0; | |
2248 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2249 | |
d62a17ae | 2250 | /* no-as-set is now the default behavior so we can silently |
2251 | * ignore it */ | |
2252 | if (argv_find(argv, argc, "as-set", &idx)) | |
2253 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2254 | else | |
2255 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2256 | |
d62a17ae | 2257 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2258 | |
d62a17ae | 2259 | return CMD_SUCCESS; |
16fc1eec DS |
2260 | } |
2261 | ||
219178b6 DW |
2262 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2263 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2264 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2265 | NO_STR |
2266 | "BGP specific commands\n" | |
2267 | "Change the default bestpath selection\n" | |
2268 | "AS-path attribute\n" | |
2269 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2270 | "Generate an AS_SET\n" |
16fc1eec DS |
2271 | "Do not generate an AS_SET\n") |
2272 | { | |
d62a17ae | 2273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2274 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2275 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2276 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2277 | |
d62a17ae | 2278 | return CMD_SUCCESS; |
2fdd455c | 2279 | } |
6b0655a2 | 2280 | |
848973c7 | 2281 | /* "bgp log-neighbor-changes" configuration. */ |
2282 | DEFUN (bgp_log_neighbor_changes, | |
2283 | bgp_log_neighbor_changes_cmd, | |
2284 | "bgp log-neighbor-changes", | |
2285 | "BGP specific commands\n" | |
2286 | "Log neighbor up/down and reset reason\n") | |
2287 | { | |
d62a17ae | 2288 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2289 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2290 | return CMD_SUCCESS; | |
848973c7 | 2291 | } |
2292 | ||
2293 | DEFUN (no_bgp_log_neighbor_changes, | |
2294 | no_bgp_log_neighbor_changes_cmd, | |
2295 | "no bgp log-neighbor-changes", | |
2296 | NO_STR | |
2297 | "BGP specific commands\n" | |
2298 | "Log neighbor up/down and reset reason\n") | |
2299 | { | |
d62a17ae | 2300 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2301 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2302 | return CMD_SUCCESS; | |
848973c7 | 2303 | } |
6b0655a2 | 2304 | |
718e3744 | 2305 | /* "bgp bestpath med" configuration. */ |
2306 | DEFUN (bgp_bestpath_med, | |
2307 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2308 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2309 | "BGP specific commands\n" |
2310 | "Change the default bestpath selection\n" | |
2311 | "MED attribute\n" | |
2312 | "Compare MED among confederation paths\n" | |
838758ac DW |
2313 | "Treat missing MED as the least preferred one\n" |
2314 | "Treat missing MED as the least preferred one\n" | |
2315 | "Compare MED among confederation paths\n") | |
718e3744 | 2316 | { |
d62a17ae | 2317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2318 | |
d62a17ae | 2319 | int idx = 0; |
2320 | if (argv_find(argv, argc, "confed", &idx)) | |
2321 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2322 | idx = 0; | |
2323 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2324 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2325 | |
d62a17ae | 2326 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2327 | |
d62a17ae | 2328 | return CMD_SUCCESS; |
718e3744 | 2329 | } |
2330 | ||
718e3744 | 2331 | DEFUN (no_bgp_bestpath_med, |
2332 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2333 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2334 | NO_STR |
2335 | "BGP specific commands\n" | |
2336 | "Change the default bestpath selection\n" | |
2337 | "MED attribute\n" | |
2338 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2339 | "Treat missing MED as the least preferred one\n" |
2340 | "Treat missing MED as the least preferred one\n" | |
2341 | "Compare MED among confederation paths\n") | |
718e3744 | 2342 | { |
d62a17ae | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2344 | |
d62a17ae | 2345 | int idx = 0; |
2346 | if (argv_find(argv, argc, "confed", &idx)) | |
2347 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2348 | idx = 0; | |
2349 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2350 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2351 | |
d62a17ae | 2352 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2353 | |
d62a17ae | 2354 | return CMD_SUCCESS; |
718e3744 | 2355 | } |
2356 | ||
718e3744 | 2357 | /* "no bgp default ipv4-unicast". */ |
2358 | DEFUN (no_bgp_default_ipv4_unicast, | |
2359 | no_bgp_default_ipv4_unicast_cmd, | |
2360 | "no bgp default ipv4-unicast", | |
2361 | NO_STR | |
2362 | "BGP specific commands\n" | |
2363 | "Configure BGP defaults\n" | |
2364 | "Activate ipv4-unicast for a peer by default\n") | |
2365 | { | |
d62a17ae | 2366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2367 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2368 | return CMD_SUCCESS; | |
718e3744 | 2369 | } |
2370 | ||
2371 | DEFUN (bgp_default_ipv4_unicast, | |
2372 | bgp_default_ipv4_unicast_cmd, | |
2373 | "bgp default ipv4-unicast", | |
2374 | "BGP specific commands\n" | |
2375 | "Configure BGP defaults\n" | |
2376 | "Activate ipv4-unicast for a peer by default\n") | |
2377 | { | |
d62a17ae | 2378 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2379 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2380 | return CMD_SUCCESS; | |
718e3744 | 2381 | } |
6b0655a2 | 2382 | |
04b6bdc0 DW |
2383 | /* Display hostname in certain command outputs */ |
2384 | DEFUN (bgp_default_show_hostname, | |
2385 | bgp_default_show_hostname_cmd, | |
2386 | "bgp default show-hostname", | |
2387 | "BGP specific commands\n" | |
2388 | "Configure BGP defaults\n" | |
0437e105 | 2389 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2390 | { |
d62a17ae | 2391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2392 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2393 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2394 | } |
2395 | ||
2396 | DEFUN (no_bgp_default_show_hostname, | |
2397 | no_bgp_default_show_hostname_cmd, | |
2398 | "no bgp default show-hostname", | |
2399 | NO_STR | |
2400 | "BGP specific commands\n" | |
2401 | "Configure BGP defaults\n" | |
0437e105 | 2402 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2403 | { |
d62a17ae | 2404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2405 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2406 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2407 | } |
2408 | ||
8233ef81 | 2409 | /* "bgp network import-check" configuration. */ |
718e3744 | 2410 | DEFUN (bgp_network_import_check, |
2411 | bgp_network_import_check_cmd, | |
5623e905 | 2412 | "bgp network import-check", |
718e3744 | 2413 | "BGP specific commands\n" |
2414 | "BGP network command\n" | |
5623e905 | 2415 | "Check BGP network route exists in IGP\n") |
718e3744 | 2416 | { |
d62a17ae | 2417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2418 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2419 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2420 | bgp_static_redo_import_check(bgp); | |
2421 | } | |
078430f6 | 2422 | |
d62a17ae | 2423 | return CMD_SUCCESS; |
718e3744 | 2424 | } |
2425 | ||
d62a17ae | 2426 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2427 | "bgp network import-check exact", | |
2428 | "BGP specific commands\n" | |
2429 | "BGP network command\n" | |
2430 | "Check BGP network route exists in IGP\n" | |
2431 | "Match route precisely\n") | |
8233ef81 | 2432 | |
718e3744 | 2433 | DEFUN (no_bgp_network_import_check, |
2434 | no_bgp_network_import_check_cmd, | |
5623e905 | 2435 | "no bgp network import-check", |
718e3744 | 2436 | NO_STR |
2437 | "BGP specific commands\n" | |
2438 | "BGP network command\n" | |
2439 | "Check BGP network route exists in IGP\n") | |
2440 | { | |
d62a17ae | 2441 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2442 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2443 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2444 | bgp_static_redo_import_check(bgp); | |
2445 | } | |
5623e905 | 2446 | |
d62a17ae | 2447 | return CMD_SUCCESS; |
718e3744 | 2448 | } |
6b0655a2 | 2449 | |
718e3744 | 2450 | DEFUN (bgp_default_local_preference, |
2451 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2452 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2453 | "BGP specific commands\n" |
2454 | "Configure BGP defaults\n" | |
2455 | "local preference (higher=more preferred)\n" | |
2456 | "Configure default local preference value\n") | |
2457 | { | |
d62a17ae | 2458 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2459 | int idx_number = 3; | |
d7c0a89a | 2460 | uint32_t local_pref; |
718e3744 | 2461 | |
d62a17ae | 2462 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2463 | |
d62a17ae | 2464 | bgp_default_local_preference_set(bgp, local_pref); |
2465 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2466 | |
d62a17ae | 2467 | return CMD_SUCCESS; |
718e3744 | 2468 | } |
2469 | ||
2470 | DEFUN (no_bgp_default_local_preference, | |
2471 | no_bgp_default_local_preference_cmd, | |
838758ac | 2472 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2473 | NO_STR |
2474 | "BGP specific commands\n" | |
2475 | "Configure BGP defaults\n" | |
838758ac DW |
2476 | "local preference (higher=more preferred)\n" |
2477 | "Configure default local preference value\n") | |
718e3744 | 2478 | { |
d62a17ae | 2479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2480 | bgp_default_local_preference_unset(bgp); | |
2481 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2482 | |
d62a17ae | 2483 | return CMD_SUCCESS; |
718e3744 | 2484 | } |
2485 | ||
6b0655a2 | 2486 | |
3f9c7369 DS |
2487 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2488 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2489 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2490 | "BGP specific commands\n" |
2491 | "Configure BGP defaults\n" | |
2492 | "subgroup-pkt-queue-max\n" | |
2493 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2494 | { |
d62a17ae | 2495 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2496 | int idx_number = 3; | |
d7c0a89a | 2497 | uint32_t max_size; |
8bd9d948 | 2498 | |
d62a17ae | 2499 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2500 | |
d62a17ae | 2501 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2502 | |
d62a17ae | 2503 | return CMD_SUCCESS; |
3f9c7369 DS |
2504 | } |
2505 | ||
2506 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2507 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2508 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2509 | NO_STR |
2510 | "BGP specific commands\n" | |
2511 | "Configure BGP defaults\n" | |
838758ac DW |
2512 | "subgroup-pkt-queue-max\n" |
2513 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2514 | { |
d62a17ae | 2515 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2516 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2517 | return CMD_SUCCESS; | |
8bd9d948 DS |
2518 | } |
2519 | ||
813d4307 | 2520 | |
8bd9d948 DS |
2521 | DEFUN (bgp_rr_allow_outbound_policy, |
2522 | bgp_rr_allow_outbound_policy_cmd, | |
2523 | "bgp route-reflector allow-outbound-policy", | |
2524 | "BGP specific commands\n" | |
2525 | "Allow modifications made by out route-map\n" | |
2526 | "on ibgp neighbors\n") | |
2527 | { | |
d62a17ae | 2528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2529 | |
d62a17ae | 2530 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2531 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2532 | update_group_announce_rrclients(bgp); | |
2533 | bgp_clear_star_soft_out(vty, bgp->name); | |
2534 | } | |
8bd9d948 | 2535 | |
d62a17ae | 2536 | return CMD_SUCCESS; |
8bd9d948 DS |
2537 | } |
2538 | ||
2539 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2540 | no_bgp_rr_allow_outbound_policy_cmd, | |
2541 | "no bgp route-reflector allow-outbound-policy", | |
2542 | NO_STR | |
2543 | "BGP specific commands\n" | |
2544 | "Allow modifications made by out route-map\n" | |
2545 | "on ibgp neighbors\n") | |
2546 | { | |
d62a17ae | 2547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2548 | |
d62a17ae | 2549 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2550 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2551 | update_group_announce_rrclients(bgp); | |
2552 | bgp_clear_star_soft_out(vty, bgp->name); | |
2553 | } | |
8bd9d948 | 2554 | |
d62a17ae | 2555 | return CMD_SUCCESS; |
8bd9d948 DS |
2556 | } |
2557 | ||
f14e6fdb DS |
2558 | DEFUN (bgp_listen_limit, |
2559 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2560 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2561 | "BGP specific commands\n" |
2562 | "Configure BGP defaults\n" | |
2563 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2564 | "Configure Dynamic Neighbors listen limit value\n") | |
2565 | { | |
d62a17ae | 2566 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2567 | int idx_number = 3; | |
2568 | int listen_limit; | |
f14e6fdb | 2569 | |
d62a17ae | 2570 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2571 | |
d62a17ae | 2572 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2573 | |
d62a17ae | 2574 | return CMD_SUCCESS; |
f14e6fdb DS |
2575 | } |
2576 | ||
2577 | DEFUN (no_bgp_listen_limit, | |
2578 | no_bgp_listen_limit_cmd, | |
838758ac | 2579 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2580 | "BGP specific commands\n" |
2581 | "Configure BGP defaults\n" | |
2582 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2583 | "Configure Dynamic Neighbors listen limit value to default\n" |
2584 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2585 | { |
d62a17ae | 2586 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2587 | bgp_listen_limit_unset(bgp); | |
2588 | return CMD_SUCCESS; | |
f14e6fdb DS |
2589 | } |
2590 | ||
2591 | ||
20eb8864 | 2592 | /* |
2593 | * Check if this listen range is already configured. Check for exact | |
2594 | * match or overlap based on input. | |
2595 | */ | |
d62a17ae | 2596 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2597 | struct prefix *range, int exact) | |
2598 | { | |
2599 | struct listnode *node, *nnode; | |
2600 | struct listnode *node1, *nnode1; | |
2601 | struct peer_group *group; | |
2602 | struct prefix *lr; | |
2603 | afi_t afi; | |
2604 | int match; | |
2605 | ||
2606 | afi = family2afi(range->family); | |
2607 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2608 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2609 | lr)) { | |
2610 | if (exact) | |
2611 | match = prefix_same(range, lr); | |
2612 | else | |
2613 | match = (prefix_match(range, lr) | |
2614 | || prefix_match(lr, range)); | |
2615 | if (match) | |
2616 | return group; | |
2617 | } | |
2618 | } | |
2619 | ||
2620 | return NULL; | |
20eb8864 | 2621 | } |
2622 | ||
f14e6fdb DS |
2623 | DEFUN (bgp_listen_range, |
2624 | bgp_listen_range_cmd, | |
9ccf14f7 | 2625 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2626 | "BGP specific commands\n" |
d7fa34c1 QY |
2627 | "Configure BGP dynamic neighbors listen range\n" |
2628 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2629 | NEIGHBOR_ADDR_STR |
2630 | "Member of the peer-group\n" | |
2631 | "Peer-group name\n") | |
f14e6fdb | 2632 | { |
d62a17ae | 2633 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2634 | struct prefix range; | |
2635 | struct peer_group *group, *existing_group; | |
2636 | afi_t afi; | |
2637 | int ret; | |
2638 | int idx = 0; | |
2639 | ||
2640 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2641 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2642 | char *prefix = argv[idx]->arg; | |
2643 | argv_find(argv, argc, "WORD", &idx); | |
2644 | char *peergroup = argv[idx]->arg; | |
2645 | ||
2646 | /* Convert IP prefix string to struct prefix. */ | |
2647 | ret = str2prefix(prefix, &range); | |
2648 | if (!ret) { | |
2649 | vty_out(vty, "%% Malformed listen range\n"); | |
2650 | return CMD_WARNING_CONFIG_FAILED; | |
2651 | } | |
2652 | ||
2653 | afi = family2afi(range.family); | |
2654 | ||
2655 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2656 | vty_out(vty, | |
2657 | "%% Malformed listen range (link-local address)\n"); | |
2658 | return CMD_WARNING_CONFIG_FAILED; | |
2659 | } | |
2660 | ||
2661 | apply_mask(&range); | |
2662 | ||
2663 | /* Check if same listen range is already configured. */ | |
2664 | existing_group = listen_range_exists(bgp, &range, 1); | |
2665 | if (existing_group) { | |
2666 | if (strcmp(existing_group->name, peergroup) == 0) | |
2667 | return CMD_SUCCESS; | |
2668 | else { | |
2669 | vty_out(vty, | |
2670 | "%% Same listen range is attached to peer-group %s\n", | |
2671 | existing_group->name); | |
2672 | return CMD_WARNING_CONFIG_FAILED; | |
2673 | } | |
2674 | } | |
2675 | ||
2676 | /* Check if an overlapping listen range exists. */ | |
2677 | if (listen_range_exists(bgp, &range, 0)) { | |
2678 | vty_out(vty, | |
2679 | "%% Listen range overlaps with existing listen range\n"); | |
2680 | return CMD_WARNING_CONFIG_FAILED; | |
2681 | } | |
2682 | ||
2683 | group = peer_group_lookup(bgp, peergroup); | |
2684 | if (!group) { | |
2685 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2686 | return CMD_WARNING_CONFIG_FAILED; | |
2687 | } | |
2688 | ||
2689 | ret = peer_group_listen_range_add(group, &range); | |
2690 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2691 | } |
2692 | ||
2693 | DEFUN (no_bgp_listen_range, | |
2694 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2695 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2696 | NO_STR | |
f14e6fdb | 2697 | "BGP specific commands\n" |
d7fa34c1 QY |
2698 | "Unconfigure BGP dynamic neighbors listen range\n" |
2699 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2700 | NEIGHBOR_ADDR_STR | |
2701 | "Member of the peer-group\n" | |
2702 | "Peer-group name\n") | |
f14e6fdb | 2703 | { |
d62a17ae | 2704 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2705 | struct prefix range; | |
2706 | struct peer_group *group; | |
2707 | afi_t afi; | |
2708 | int ret; | |
2709 | int idx = 0; | |
2710 | ||
2711 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2712 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2713 | char *prefix = argv[idx]->arg; | |
2714 | argv_find(argv, argc, "WORD", &idx); | |
2715 | char *peergroup = argv[idx]->arg; | |
2716 | ||
2717 | /* Convert IP prefix string to struct prefix. */ | |
2718 | ret = str2prefix(prefix, &range); | |
2719 | if (!ret) { | |
2720 | vty_out(vty, "%% Malformed listen range\n"); | |
2721 | return CMD_WARNING_CONFIG_FAILED; | |
2722 | } | |
2723 | ||
2724 | afi = family2afi(range.family); | |
2725 | ||
2726 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2727 | vty_out(vty, | |
2728 | "%% Malformed listen range (link-local address)\n"); | |
2729 | return CMD_WARNING_CONFIG_FAILED; | |
2730 | } | |
2731 | ||
2732 | apply_mask(&range); | |
2733 | ||
2734 | group = peer_group_lookup(bgp, peergroup); | |
2735 | if (!group) { | |
2736 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2737 | return CMD_WARNING_CONFIG_FAILED; | |
2738 | } | |
2739 | ||
2740 | ret = peer_group_listen_range_del(group, &range); | |
2741 | return bgp_vty_return(vty, ret); | |
2742 | } | |
2743 | ||
2b791107 | 2744 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2745 | { |
2746 | struct peer_group *group; | |
2747 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2748 | struct prefix *range; | |
2749 | afi_t afi; | |
2750 | char buf[PREFIX2STR_BUFFER]; | |
2751 | ||
2752 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2753 | vty_out(vty, " bgp listen limit %d\n", | |
2754 | bgp->dynamic_neighbors_limit); | |
2755 | ||
2756 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2757 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2758 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2759 | nrnode, range)) { | |
2760 | prefix2str(range, buf, sizeof(buf)); | |
2761 | vty_out(vty, | |
2762 | " bgp listen range %s peer-group %s\n", | |
2763 | buf, group->name); | |
2764 | } | |
2765 | } | |
2766 | } | |
f14e6fdb DS |
2767 | } |
2768 | ||
2769 | ||
907f92c8 DS |
2770 | DEFUN (bgp_disable_connected_route_check, |
2771 | bgp_disable_connected_route_check_cmd, | |
2772 | "bgp disable-ebgp-connected-route-check", | |
2773 | "BGP specific commands\n" | |
2774 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2775 | { | |
d62a17ae | 2776 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2777 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2778 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2779 | |
d62a17ae | 2780 | return CMD_SUCCESS; |
907f92c8 DS |
2781 | } |
2782 | ||
2783 | DEFUN (no_bgp_disable_connected_route_check, | |
2784 | no_bgp_disable_connected_route_check_cmd, | |
2785 | "no bgp disable-ebgp-connected-route-check", | |
2786 | NO_STR | |
2787 | "BGP specific commands\n" | |
2788 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2789 | { | |
d62a17ae | 2790 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2791 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2792 | bgp_clear_star_soft_in(vty, bgp->name); | |
2793 | ||
2794 | return CMD_SUCCESS; | |
2795 | } | |
2796 | ||
2797 | ||
2798 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2799 | const char *as_str, afi_t afi, safi_t safi) | |
2800 | { | |
2801 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2802 | int ret; | |
2803 | as_t as; | |
2804 | int as_type = AS_SPECIFIED; | |
2805 | union sockunion su; | |
2806 | ||
2807 | if (as_str[0] == 'i') { | |
2808 | as = 0; | |
2809 | as_type = AS_INTERNAL; | |
2810 | } else if (as_str[0] == 'e') { | |
2811 | as = 0; | |
2812 | as_type = AS_EXTERNAL; | |
2813 | } else { | |
2814 | /* Get AS number. */ | |
2815 | as = strtoul(as_str, NULL, 10); | |
2816 | } | |
2817 | ||
2818 | /* If peer is peer group, call proper function. */ | |
2819 | ret = str2sockunion(peer_str, &su); | |
2820 | if (ret < 0) { | |
2821 | /* Check for peer by interface */ | |
2822 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2823 | safi); | |
2824 | if (ret < 0) { | |
2825 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2826 | if (ret < 0) { | |
2827 | vty_out(vty, | |
d762bcc3 DS |
2828 | "%% Create the peer-group or interface first or specify \"interface\" keyword\n"); |
2829 | vty_out(vty, "%% if using an unnumbered interface neighbor\n"); | |
d62a17ae | 2830 | return CMD_WARNING_CONFIG_FAILED; |
2831 | } | |
2832 | return CMD_SUCCESS; | |
2833 | } | |
2834 | } else { | |
2835 | if (peer_address_self_check(bgp, &su)) { | |
2836 | vty_out(vty, | |
2837 | "%% Can not configure the local system as neighbor\n"); | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | } | |
2840 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2841 | } | |
2842 | ||
2843 | /* This peer belongs to peer group. */ | |
2844 | switch (ret) { | |
2845 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2846 | vty_out(vty, | |
2847 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2848 | as); | |
2849 | return CMD_WARNING_CONFIG_FAILED; | |
2850 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2851 | vty_out(vty, | |
2852 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2853 | as, as_str); | |
2854 | return CMD_WARNING_CONFIG_FAILED; | |
2855 | } | |
2856 | return bgp_vty_return(vty, ret); | |
718e3744 | 2857 | } |
2858 | ||
f26845f9 QY |
2859 | DEFUN (bgp_default_shutdown, |
2860 | bgp_default_shutdown_cmd, | |
2861 | "[no] bgp default shutdown", | |
2862 | NO_STR | |
2863 | BGP_STR | |
2864 | "Configure BGP defaults\n" | |
b012cbe2 | 2865 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2866 | { |
2867 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2868 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2869 | return CMD_SUCCESS; | |
2870 | } | |
2871 | ||
718e3744 | 2872 | DEFUN (neighbor_remote_as, |
2873 | neighbor_remote_as_cmd, | |
3a2d747c | 2874 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2875 | NEIGHBOR_STR |
2876 | NEIGHBOR_ADDR_STR2 | |
2877 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2878 | AS_STR |
3a2d747c QY |
2879 | "Internal BGP peer\n" |
2880 | "External BGP peer\n") | |
718e3744 | 2881 | { |
d62a17ae | 2882 | int idx_peer = 1; |
2883 | int idx_remote_as = 3; | |
2884 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2885 | argv[idx_remote_as]->arg, AFI_IP, | |
2886 | SAFI_UNICAST); | |
2887 | } | |
2888 | ||
2889 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2890 | afi_t afi, safi_t safi, int v6only, | |
2891 | const char *peer_group_name, | |
2892 | const char *as_str) | |
2893 | { | |
2894 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2895 | as_t as = 0; | |
2896 | int as_type = AS_UNSPECIFIED; | |
2897 | struct peer *peer; | |
2898 | struct peer_group *group; | |
2899 | int ret = 0; | |
2900 | union sockunion su; | |
2901 | ||
2902 | group = peer_group_lookup(bgp, conf_if); | |
2903 | ||
2904 | if (group) { | |
2905 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2906 | return CMD_WARNING_CONFIG_FAILED; | |
2907 | } | |
2908 | ||
2909 | if (as_str) { | |
2910 | if (as_str[0] == 'i') { | |
2911 | as_type = AS_INTERNAL; | |
2912 | } else if (as_str[0] == 'e') { | |
2913 | as_type = AS_EXTERNAL; | |
2914 | } else { | |
2915 | /* Get AS number. */ | |
2916 | as = strtoul(as_str, NULL, 10); | |
2917 | as_type = AS_SPECIFIED; | |
2918 | } | |
2919 | } | |
2920 | ||
2921 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2922 | if (peer) { | |
2923 | if (as_str) | |
cc4d4ce8 | 2924 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2925 | afi, safi); |
2926 | } else { | |
2927 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2928 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2929 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2930 | as_type, 0, 0, NULL); | |
2931 | else | |
2932 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2933 | as_type, afi, safi, NULL); | |
2934 | ||
2935 | if (!peer) { | |
2936 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2937 | return CMD_WARNING_CONFIG_FAILED; | |
2938 | } | |
2939 | ||
2940 | if (v6only) | |
527de3dc | 2941 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2942 | |
2943 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2944 | * this | |
2945 | * any unnumbered peer in order to not worry about run-time | |
2946 | * transitions | |
2947 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2948 | * address | |
2949 | * gets deleted later etc.) | |
2950 | */ | |
2951 | if (peer->ifp) | |
2952 | bgp_zebra_initiate_radv(bgp, peer); | |
2953 | } | |
2954 | ||
2955 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2956 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2957 | if (v6only) | |
527de3dc | 2958 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2959 | else |
527de3dc | 2960 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2961 | |
2962 | /* v6only flag changed. Reset bgp seesion */ | |
2963 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2964 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2965 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2966 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2967 | } else | |
2968 | bgp_session_reset(peer); | |
2969 | } | |
2970 | ||
9fb964de PM |
2971 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2972 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2973 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
2974 | UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
2975 | } | |
d62a17ae | 2976 | |
2977 | if (peer_group_name) { | |
2978 | group = peer_group_lookup(bgp, peer_group_name); | |
2979 | if (!group) { | |
2980 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2981 | return CMD_WARNING_CONFIG_FAILED; | |
2982 | } | |
2983 | ||
2984 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2985 | } | |
2986 | ||
2987 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2988 | } |
2989 | ||
4c48cf63 DW |
2990 | DEFUN (neighbor_interface_config, |
2991 | neighbor_interface_config_cmd, | |
31500417 | 2992 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2993 | NEIGHBOR_STR |
2994 | "Interface name or neighbor tag\n" | |
31500417 DW |
2995 | "Enable BGP on interface\n" |
2996 | "Member of the peer-group\n" | |
16cedbb0 | 2997 | "Peer-group name\n") |
4c48cf63 | 2998 | { |
d62a17ae | 2999 | int idx_word = 1; |
3000 | int idx_peer_group_word = 4; | |
31500417 | 3001 | |
d62a17ae | 3002 | if (argc > idx_peer_group_word) |
3003 | return peer_conf_interface_get( | |
3004 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3005 | argv[idx_peer_group_word]->arg, NULL); | |
3006 | else | |
3007 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3008 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3009 | } |
3010 | ||
4c48cf63 DW |
3011 | DEFUN (neighbor_interface_config_v6only, |
3012 | neighbor_interface_config_v6only_cmd, | |
31500417 | 3013 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
3014 | NEIGHBOR_STR |
3015 | "Interface name or neighbor tag\n" | |
3016 | "Enable BGP on interface\n" | |
31500417 DW |
3017 | "Enable BGP with v6 link-local only\n" |
3018 | "Member of the peer-group\n" | |
16cedbb0 | 3019 | "Peer-group name\n") |
4c48cf63 | 3020 | { |
d62a17ae | 3021 | int idx_word = 1; |
3022 | int idx_peer_group_word = 5; | |
31500417 | 3023 | |
d62a17ae | 3024 | if (argc > idx_peer_group_word) |
3025 | return peer_conf_interface_get( | |
3026 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3027 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3028 | |
d62a17ae | 3029 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3030 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3031 | } |
3032 | ||
a80beece | 3033 | |
b3a39dc5 DD |
3034 | DEFUN (neighbor_interface_config_remote_as, |
3035 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3036 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3037 | NEIGHBOR_STR |
3038 | "Interface name or neighbor tag\n" | |
3039 | "Enable BGP on interface\n" | |
3a2d747c | 3040 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3041 | AS_STR |
3a2d747c QY |
3042 | "Internal BGP peer\n" |
3043 | "External BGP peer\n") | |
b3a39dc5 | 3044 | { |
d62a17ae | 3045 | int idx_word = 1; |
3046 | int idx_remote_as = 4; | |
3047 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3048 | SAFI_UNICAST, 0, NULL, | |
3049 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3050 | } |
3051 | ||
3052 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3053 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3054 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3055 | NEIGHBOR_STR |
3056 | "Interface name or neighbor tag\n" | |
3a2d747c | 3057 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3058 | "Enable BGP on interface\n" |
3a2d747c | 3059 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3060 | AS_STR |
3a2d747c QY |
3061 | "Internal BGP peer\n" |
3062 | "External BGP peer\n") | |
b3a39dc5 | 3063 | { |
d62a17ae | 3064 | int idx_word = 1; |
3065 | int idx_remote_as = 5; | |
3066 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3067 | SAFI_UNICAST, 1, NULL, | |
3068 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3069 | } |
3070 | ||
718e3744 | 3071 | DEFUN (neighbor_peer_group, |
3072 | neighbor_peer_group_cmd, | |
3073 | "neighbor WORD peer-group", | |
3074 | NEIGHBOR_STR | |
a80beece | 3075 | "Interface name or neighbor tag\n" |
718e3744 | 3076 | "Configure peer-group\n") |
3077 | { | |
d62a17ae | 3078 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3079 | int idx_word = 1; | |
3080 | struct peer *peer; | |
3081 | struct peer_group *group; | |
718e3744 | 3082 | |
d62a17ae | 3083 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3084 | if (peer) { | |
3085 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3086 | return CMD_WARNING_CONFIG_FAILED; | |
3087 | } | |
718e3744 | 3088 | |
d62a17ae | 3089 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3090 | if (!group) { | |
3091 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3092 | return CMD_WARNING_CONFIG_FAILED; | |
3093 | } | |
718e3744 | 3094 | |
d62a17ae | 3095 | return CMD_SUCCESS; |
718e3744 | 3096 | } |
3097 | ||
3098 | DEFUN (no_neighbor, | |
3099 | no_neighbor_cmd, | |
dab8cd00 | 3100 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3101 | NO_STR |
3102 | NEIGHBOR_STR | |
3a2d747c QY |
3103 | NEIGHBOR_ADDR_STR2 |
3104 | "Specify a BGP neighbor\n" | |
3105 | AS_STR | |
3106 | "Internal BGP peer\n" | |
3107 | "External BGP peer\n") | |
718e3744 | 3108 | { |
d62a17ae | 3109 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3110 | int idx_peer = 2; | |
3111 | int ret; | |
3112 | union sockunion su; | |
3113 | struct peer_group *group; | |
3114 | struct peer *peer; | |
3115 | struct peer *other; | |
3116 | ||
3117 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3118 | if (ret < 0) { | |
3119 | /* look up for neighbor by interface name config. */ | |
3120 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3121 | if (peer) { | |
3122 | /* Request zebra to terminate IPv6 RAs on this | |
3123 | * interface. */ | |
3124 | if (peer->ifp) | |
3125 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3126 | peer_delete(peer); | |
3127 | return CMD_SUCCESS; | |
3128 | } | |
f14e6fdb | 3129 | |
d62a17ae | 3130 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3131 | if (group) | |
3132 | peer_group_delete(group); | |
3133 | else { | |
3134 | vty_out(vty, "%% Create the peer-group first\n"); | |
3135 | return CMD_WARNING_CONFIG_FAILED; | |
3136 | } | |
3137 | } else { | |
3138 | peer = peer_lookup(bgp, &su); | |
3139 | if (peer) { | |
3140 | if (peer_dynamic_neighbor(peer)) { | |
3141 | vty_out(vty, | |
3142 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3143 | return CMD_WARNING_CONFIG_FAILED; | |
3144 | } | |
3145 | ||
3146 | other = peer->doppelganger; | |
3147 | peer_delete(peer); | |
3148 | if (other && other->status != Deleted) | |
3149 | peer_delete(other); | |
3150 | } | |
1ff9a340 | 3151 | } |
718e3744 | 3152 | |
d62a17ae | 3153 | return CMD_SUCCESS; |
718e3744 | 3154 | } |
3155 | ||
a80beece DS |
3156 | DEFUN (no_neighbor_interface_config, |
3157 | no_neighbor_interface_config_cmd, | |
31500417 | 3158 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3159 | NO_STR |
3160 | NEIGHBOR_STR | |
3161 | "Interface name\n" | |
31500417 DW |
3162 | "Configure BGP on interface\n" |
3163 | "Enable BGP with v6 link-local only\n" | |
3164 | "Member of the peer-group\n" | |
16cedbb0 | 3165 | "Peer-group name\n" |
3a2d747c QY |
3166 | "Specify a BGP neighbor\n" |
3167 | AS_STR | |
3168 | "Internal BGP peer\n" | |
3169 | "External BGP peer\n") | |
a80beece | 3170 | { |
d62a17ae | 3171 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3172 | int idx_word = 2; | |
3173 | struct peer *peer; | |
3174 | ||
3175 | /* look up for neighbor by interface name config. */ | |
3176 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3177 | if (peer) { | |
3178 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3179 | if (peer->ifp) | |
3180 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3181 | peer_delete(peer); | |
3182 | } else { | |
3183 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3184 | return CMD_WARNING_CONFIG_FAILED; | |
3185 | } | |
3186 | return CMD_SUCCESS; | |
a80beece DS |
3187 | } |
3188 | ||
718e3744 | 3189 | DEFUN (no_neighbor_peer_group, |
3190 | no_neighbor_peer_group_cmd, | |
3191 | "no neighbor WORD peer-group", | |
3192 | NO_STR | |
3193 | NEIGHBOR_STR | |
3194 | "Neighbor tag\n" | |
3195 | "Configure peer-group\n") | |
3196 | { | |
d62a17ae | 3197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3198 | int idx_word = 2; | |
3199 | struct peer_group *group; | |
718e3744 | 3200 | |
d62a17ae | 3201 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3202 | if (group) | |
3203 | peer_group_delete(group); | |
3204 | else { | |
3205 | vty_out(vty, "%% Create the peer-group first\n"); | |
3206 | return CMD_WARNING_CONFIG_FAILED; | |
3207 | } | |
3208 | return CMD_SUCCESS; | |
718e3744 | 3209 | } |
3210 | ||
a80beece DS |
3211 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3212 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3213 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3214 | NO_STR |
3215 | NEIGHBOR_STR | |
a80beece | 3216 | "Interface name or neighbor tag\n" |
718e3744 | 3217 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3218 | AS_STR |
3219 | "Internal BGP peer\n" | |
3220 | "External BGP peer\n") | |
718e3744 | 3221 | { |
d62a17ae | 3222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3223 | int idx_word = 2; | |
3224 | struct peer_group *group; | |
3225 | struct peer *peer; | |
3226 | ||
3227 | /* look up for neighbor by interface name config. */ | |
3228 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3229 | if (peer) { | |
3230 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3231 | return CMD_SUCCESS; | |
3232 | } | |
3233 | ||
3234 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3235 | if (group) | |
3236 | peer_group_remote_as_delete(group); | |
3237 | else { | |
3238 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3239 | return CMD_WARNING_CONFIG_FAILED; | |
3240 | } | |
3241 | return CMD_SUCCESS; | |
718e3744 | 3242 | } |
6b0655a2 | 3243 | |
718e3744 | 3244 | DEFUN (neighbor_local_as, |
3245 | neighbor_local_as_cmd, | |
9ccf14f7 | 3246 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3247 | NEIGHBOR_STR |
3248 | NEIGHBOR_ADDR_STR2 | |
3249 | "Specify a local-as number\n" | |
3250 | "AS number used as local AS\n") | |
3251 | { | |
d62a17ae | 3252 | int idx_peer = 1; |
3253 | int idx_number = 3; | |
3254 | struct peer *peer; | |
3255 | int ret; | |
3256 | as_t as; | |
718e3744 | 3257 | |
d62a17ae | 3258 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3259 | if (!peer) | |
3260 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3261 | |
d62a17ae | 3262 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3263 | ret = peer_local_as_set(peer, as, 0, 0); | |
3264 | return bgp_vty_return(vty, ret); | |
718e3744 | 3265 | } |
3266 | ||
3267 | DEFUN (neighbor_local_as_no_prepend, | |
3268 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3269 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3270 | NEIGHBOR_STR |
3271 | NEIGHBOR_ADDR_STR2 | |
3272 | "Specify a local-as number\n" | |
3273 | "AS number used as local AS\n" | |
3274 | "Do not prepend local-as to updates from ebgp peers\n") | |
3275 | { | |
d62a17ae | 3276 | int idx_peer = 1; |
3277 | int idx_number = 3; | |
3278 | struct peer *peer; | |
3279 | int ret; | |
3280 | as_t as; | |
718e3744 | 3281 | |
d62a17ae | 3282 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3283 | if (!peer) | |
3284 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3285 | |
d62a17ae | 3286 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3287 | ret = peer_local_as_set(peer, as, 1, 0); | |
3288 | return bgp_vty_return(vty, ret); | |
718e3744 | 3289 | } |
3290 | ||
9d3f9705 AC |
3291 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3292 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3293 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3294 | NEIGHBOR_STR |
3295 | NEIGHBOR_ADDR_STR2 | |
3296 | "Specify a local-as number\n" | |
3297 | "AS number used as local AS\n" | |
3298 | "Do not prepend local-as to updates from ebgp peers\n" | |
3299 | "Do not prepend local-as to updates from ibgp peers\n") | |
3300 | { | |
d62a17ae | 3301 | int idx_peer = 1; |
3302 | int idx_number = 3; | |
3303 | struct peer *peer; | |
3304 | int ret; | |
3305 | as_t as; | |
9d3f9705 | 3306 | |
d62a17ae | 3307 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3308 | if (!peer) | |
3309 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3310 | |
d62a17ae | 3311 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3312 | ret = peer_local_as_set(peer, as, 1, 1); | |
3313 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3314 | } |
3315 | ||
718e3744 | 3316 | DEFUN (no_neighbor_local_as, |
3317 | no_neighbor_local_as_cmd, | |
a636c635 | 3318 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3319 | NO_STR |
3320 | NEIGHBOR_STR | |
3321 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3322 | "Specify a local-as number\n" |
3323 | "AS number used as local AS\n" | |
3324 | "Do not prepend local-as to updates from ebgp peers\n" | |
3325 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3326 | { |
d62a17ae | 3327 | int idx_peer = 2; |
3328 | struct peer *peer; | |
3329 | int ret; | |
718e3744 | 3330 | |
d62a17ae | 3331 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3332 | if (!peer) | |
3333 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3334 | |
d62a17ae | 3335 | ret = peer_local_as_unset(peer); |
3336 | return bgp_vty_return(vty, ret); | |
718e3744 | 3337 | } |
3338 | ||
718e3744 | 3339 | |
3f9c7369 DS |
3340 | DEFUN (neighbor_solo, |
3341 | neighbor_solo_cmd, | |
9ccf14f7 | 3342 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3343 | NEIGHBOR_STR |
3344 | NEIGHBOR_ADDR_STR2 | |
3345 | "Solo peer - part of its own update group\n") | |
3346 | { | |
d62a17ae | 3347 | int idx_peer = 1; |
3348 | struct peer *peer; | |
3349 | int ret; | |
3f9c7369 | 3350 | |
d62a17ae | 3351 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3352 | if (!peer) | |
3353 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3354 | |
d62a17ae | 3355 | ret = update_group_adjust_soloness(peer, 1); |
3356 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3357 | } |
3358 | ||
3359 | DEFUN (no_neighbor_solo, | |
3360 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3362 | NO_STR |
3363 | NEIGHBOR_STR | |
3364 | NEIGHBOR_ADDR_STR2 | |
3365 | "Solo peer - part of its own update group\n") | |
3366 | { | |
d62a17ae | 3367 | int idx_peer = 2; |
3368 | struct peer *peer; | |
3369 | int ret; | |
3f9c7369 | 3370 | |
d62a17ae | 3371 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3372 | if (!peer) | |
3373 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3374 | |
d62a17ae | 3375 | ret = update_group_adjust_soloness(peer, 0); |
3376 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3377 | } |
3378 | ||
0df7c91f PJ |
3379 | DEFUN (neighbor_password, |
3380 | neighbor_password_cmd, | |
9ccf14f7 | 3381 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3382 | NEIGHBOR_STR |
3383 | NEIGHBOR_ADDR_STR2 | |
3384 | "Set a password\n" | |
3385 | "The password\n") | |
3386 | { | |
d62a17ae | 3387 | int idx_peer = 1; |
3388 | int idx_line = 3; | |
3389 | struct peer *peer; | |
3390 | int ret; | |
0df7c91f | 3391 | |
d62a17ae | 3392 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3393 | if (!peer) | |
3394 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3395 | |
d62a17ae | 3396 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3397 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3398 | } |
3399 | ||
3400 | DEFUN (no_neighbor_password, | |
3401 | no_neighbor_password_cmd, | |
a636c635 | 3402 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3403 | NO_STR |
3404 | NEIGHBOR_STR | |
3405 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3406 | "Set a password\n" |
3407 | "The password\n") | |
0df7c91f | 3408 | { |
d62a17ae | 3409 | int idx_peer = 2; |
3410 | struct peer *peer; | |
3411 | int ret; | |
0df7c91f | 3412 | |
d62a17ae | 3413 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3414 | if (!peer) | |
3415 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3416 | |
d62a17ae | 3417 | ret = peer_password_unset(peer); |
3418 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3419 | } |
6b0655a2 | 3420 | |
718e3744 | 3421 | DEFUN (neighbor_activate, |
3422 | neighbor_activate_cmd, | |
9ccf14f7 | 3423 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3424 | NEIGHBOR_STR |
3425 | NEIGHBOR_ADDR_STR2 | |
3426 | "Enable the Address Family for this Neighbor\n") | |
3427 | { | |
d62a17ae | 3428 | int idx_peer = 1; |
3429 | int ret; | |
3430 | struct peer *peer; | |
718e3744 | 3431 | |
d62a17ae | 3432 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3433 | if (!peer) | |
3434 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3435 | |
d62a17ae | 3436 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3437 | return bgp_vty_return(vty, ret); | |
718e3744 | 3438 | } |
3439 | ||
d62a17ae | 3440 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3441 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3442 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3443 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3444 | |
718e3744 | 3445 | DEFUN (no_neighbor_activate, |
3446 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3447 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3448 | NO_STR |
3449 | NEIGHBOR_STR | |
3450 | NEIGHBOR_ADDR_STR2 | |
3451 | "Enable the Address Family for this Neighbor\n") | |
3452 | { | |
d62a17ae | 3453 | int idx_peer = 2; |
3454 | int ret; | |
3455 | struct peer *peer; | |
718e3744 | 3456 | |
d62a17ae | 3457 | /* Lookup peer. */ |
3458 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3459 | if (!peer) | |
3460 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3461 | |
d62a17ae | 3462 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3463 | return bgp_vty_return(vty, ret); | |
718e3744 | 3464 | } |
6b0655a2 | 3465 | |
d62a17ae | 3466 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3467 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3468 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3469 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3470 | |
718e3744 | 3471 | DEFUN (neighbor_set_peer_group, |
3472 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3473 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3474 | NEIGHBOR_STR |
a80beece | 3475 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3476 | "Member of the peer-group\n" |
16cedbb0 | 3477 | "Peer-group name\n") |
718e3744 | 3478 | { |
d62a17ae | 3479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3480 | int idx_peer = 1; | |
3481 | int idx_word = 3; | |
3482 | int ret; | |
3483 | as_t as; | |
3484 | union sockunion su; | |
3485 | struct peer *peer; | |
3486 | struct peer_group *group; | |
3487 | ||
d62a17ae | 3488 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3489 | if (ret < 0) { | |
3490 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3491 | if (!peer) { | |
3492 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3493 | argv[idx_peer]->arg); | |
3494 | return CMD_WARNING_CONFIG_FAILED; | |
3495 | } | |
3496 | } else { | |
3497 | if (peer_address_self_check(bgp, &su)) { | |
3498 | vty_out(vty, | |
3499 | "%% Can not configure the local system as neighbor\n"); | |
3500 | return CMD_WARNING_CONFIG_FAILED; | |
3501 | } | |
3502 | ||
3503 | /* Disallow for dynamic neighbor. */ | |
3504 | peer = peer_lookup(bgp, &su); | |
3505 | if (peer && peer_dynamic_neighbor(peer)) { | |
3506 | vty_out(vty, | |
3507 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3508 | return CMD_WARNING_CONFIG_FAILED; | |
3509 | } | |
3510 | } | |
3511 | ||
3512 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3513 | if (!group) { | |
3514 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3515 | return CMD_WARNING_CONFIG_FAILED; | |
3516 | } | |
3517 | ||
3518 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3519 | ||
3520 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3521 | vty_out(vty, | |
3522 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3523 | as); | |
3524 | return CMD_WARNING_CONFIG_FAILED; | |
3525 | } | |
3526 | ||
3527 | return bgp_vty_return(vty, ret); | |
3528 | } | |
3529 | ||
3530 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3531 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3532 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3533 | "Member of the peer-group\n" | |
3534 | "Peer-group name\n") | |
596c17ba | 3535 | |
718e3744 | 3536 | DEFUN (no_neighbor_set_peer_group, |
3537 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3538 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3539 | NO_STR |
3540 | NEIGHBOR_STR | |
a80beece | 3541 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3542 | "Member of the peer-group\n" |
16cedbb0 | 3543 | "Peer-group name\n") |
718e3744 | 3544 | { |
d62a17ae | 3545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3546 | int idx_peer = 2; | |
3547 | int idx_word = 4; | |
3548 | int ret; | |
3549 | struct peer *peer; | |
3550 | struct peer_group *group; | |
3551 | ||
3552 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3553 | if (!peer) | |
3554 | return CMD_WARNING_CONFIG_FAILED; | |
3555 | ||
3556 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3557 | if (!group) { | |
3558 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3559 | return CMD_WARNING_CONFIG_FAILED; | |
3560 | } | |
718e3744 | 3561 | |
827ed707 | 3562 | ret = peer_delete(peer); |
718e3744 | 3563 | |
d62a17ae | 3564 | return bgp_vty_return(vty, ret); |
718e3744 | 3565 | } |
6b0655a2 | 3566 | |
d62a17ae | 3567 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3568 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3569 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3570 | "Member of the peer-group\n" | |
3571 | "Peer-group name\n") | |
596c17ba | 3572 | |
d62a17ae | 3573 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3574 | uint32_t flag, int set) |
718e3744 | 3575 | { |
d62a17ae | 3576 | int ret; |
3577 | struct peer *peer; | |
718e3744 | 3578 | |
d62a17ae | 3579 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3580 | if (!peer) | |
3581 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3582 | |
7ebe625c QY |
3583 | /* |
3584 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3585 | * we should not accept disable-connected-check. | |
3586 | */ | |
3587 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3588 | vty_out(vty, | |
3589 | "%s is directly connected peer, cannot accept disable-" | |
3590 | "connected-check\n", | |
3591 | ip_str); | |
3592 | return CMD_WARNING_CONFIG_FAILED; | |
3593 | } | |
3594 | ||
d62a17ae | 3595 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3596 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3597 | |
d62a17ae | 3598 | if (set) |
3599 | ret = peer_flag_set(peer, flag); | |
3600 | else | |
3601 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3602 | |
d62a17ae | 3603 | return bgp_vty_return(vty, ret); |
718e3744 | 3604 | } |
3605 | ||
47cbc09b | 3606 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3607 | { |
d62a17ae | 3608 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3609 | } |
3610 | ||
d62a17ae | 3611 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3612 | uint32_t flag) |
718e3744 | 3613 | { |
d62a17ae | 3614 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3615 | } |
3616 | ||
3617 | /* neighbor passive. */ | |
3618 | DEFUN (neighbor_passive, | |
3619 | neighbor_passive_cmd, | |
9ccf14f7 | 3620 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3621 | NEIGHBOR_STR |
3622 | NEIGHBOR_ADDR_STR2 | |
3623 | "Don't send open messages to this neighbor\n") | |
3624 | { | |
d62a17ae | 3625 | int idx_peer = 1; |
3626 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3627 | } |
3628 | ||
3629 | DEFUN (no_neighbor_passive, | |
3630 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3631 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3632 | NO_STR |
3633 | NEIGHBOR_STR | |
3634 | NEIGHBOR_ADDR_STR2 | |
3635 | "Don't send open messages to this neighbor\n") | |
3636 | { | |
d62a17ae | 3637 | int idx_peer = 2; |
3638 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3639 | } |
6b0655a2 | 3640 | |
718e3744 | 3641 | /* neighbor shutdown. */ |
73d70fa6 DL |
3642 | DEFUN (neighbor_shutdown_msg, |
3643 | neighbor_shutdown_msg_cmd, | |
3644 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3645 | NEIGHBOR_STR |
3646 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3647 | "Administratively shut down this neighbor\n" |
3648 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3649 | "Shutdown message\n") | |
718e3744 | 3650 | { |
d62a17ae | 3651 | int idx_peer = 1; |
73d70fa6 | 3652 | |
d62a17ae | 3653 | if (argc >= 5) { |
3654 | struct peer *peer = | |
3655 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3656 | char *message; | |
73d70fa6 | 3657 | |
d62a17ae | 3658 | if (!peer) |
3659 | return CMD_WARNING_CONFIG_FAILED; | |
3660 | message = argv_concat(argv, argc, 4); | |
3661 | peer_tx_shutdown_message_set(peer, message); | |
3662 | XFREE(MTYPE_TMP, message); | |
3663 | } | |
73d70fa6 | 3664 | |
d62a17ae | 3665 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3666 | } |
3667 | ||
d62a17ae | 3668 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3669 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3670 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3671 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3672 | |
3673 | DEFUN (no_neighbor_shutdown_msg, | |
3674 | no_neighbor_shutdown_msg_cmd, | |
3675 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3676 | NO_STR | |
3677 | NEIGHBOR_STR | |
3678 | NEIGHBOR_ADDR_STR2 | |
3679 | "Administratively shut down this neighbor\n" | |
3680 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3681 | "Shutdown message\n") | |
718e3744 | 3682 | { |
d62a17ae | 3683 | int idx_peer = 2; |
73d70fa6 | 3684 | |
d62a17ae | 3685 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3686 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3687 | } |
6b0655a2 | 3688 | |
d62a17ae | 3689 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3691 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3692 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3693 | |
718e3744 | 3694 | /* neighbor capability dynamic. */ |
3695 | DEFUN (neighbor_capability_dynamic, | |
3696 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3697 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3698 | NEIGHBOR_STR |
3699 | NEIGHBOR_ADDR_STR2 | |
3700 | "Advertise capability to the peer\n" | |
3701 | "Advertise dynamic capability to this neighbor\n") | |
3702 | { | |
d62a17ae | 3703 | int idx_peer = 1; |
3704 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3705 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3706 | } |
3707 | ||
3708 | DEFUN (no_neighbor_capability_dynamic, | |
3709 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3710 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3711 | NO_STR |
3712 | NEIGHBOR_STR | |
3713 | NEIGHBOR_ADDR_STR2 | |
3714 | "Advertise capability to the peer\n" | |
3715 | "Advertise dynamic capability to this neighbor\n") | |
3716 | { | |
d62a17ae | 3717 | int idx_peer = 2; |
3718 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3719 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3720 | } |
6b0655a2 | 3721 | |
718e3744 | 3722 | /* neighbor dont-capability-negotiate */ |
3723 | DEFUN (neighbor_dont_capability_negotiate, | |
3724 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3725 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3726 | NEIGHBOR_STR |
3727 | NEIGHBOR_ADDR_STR2 | |
3728 | "Do not perform capability negotiation\n") | |
3729 | { | |
d62a17ae | 3730 | int idx_peer = 1; |
3731 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3732 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3733 | } |
3734 | ||
3735 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3736 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3737 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3738 | NO_STR |
3739 | NEIGHBOR_STR | |
3740 | NEIGHBOR_ADDR_STR2 | |
3741 | "Do not perform capability negotiation\n") | |
3742 | { | |
d62a17ae | 3743 | int idx_peer = 2; |
3744 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3745 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3746 | } |
6b0655a2 | 3747 | |
8a92a8a0 DS |
3748 | /* neighbor capability extended next hop encoding */ |
3749 | DEFUN (neighbor_capability_enhe, | |
3750 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3751 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3752 | NEIGHBOR_STR |
3753 | NEIGHBOR_ADDR_STR2 | |
3754 | "Advertise capability to the peer\n" | |
3755 | "Advertise extended next-hop capability to the peer\n") | |
3756 | { | |
d62a17ae | 3757 | int idx_peer = 1; |
3758 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3759 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3760 | } |
3761 | ||
3762 | DEFUN (no_neighbor_capability_enhe, | |
3763 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3765 | NO_STR |
3766 | NEIGHBOR_STR | |
3767 | NEIGHBOR_ADDR_STR2 | |
3768 | "Advertise capability to the peer\n" | |
3769 | "Advertise extended next-hop capability to the peer\n") | |
3770 | { | |
d62a17ae | 3771 | int idx_peer = 2; |
3772 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3773 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3774 | } |
3775 | ||
d62a17ae | 3776 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3777 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3778 | int set) |
718e3744 | 3779 | { |
d62a17ae | 3780 | int ret; |
3781 | struct peer *peer; | |
718e3744 | 3782 | |
d62a17ae | 3783 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3784 | if (!peer) | |
3785 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3786 | |
d62a17ae | 3787 | if (set) |
3788 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3789 | else | |
3790 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3791 | |
d62a17ae | 3792 | return bgp_vty_return(vty, ret); |
718e3744 | 3793 | } |
3794 | ||
d62a17ae | 3795 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3796 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3797 | { |
d62a17ae | 3798 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3799 | } |
3800 | ||
d62a17ae | 3801 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3802 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3803 | { |
d62a17ae | 3804 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3805 | } |
6b0655a2 | 3806 | |
718e3744 | 3807 | /* neighbor capability orf prefix-list. */ |
3808 | DEFUN (neighbor_capability_orf_prefix, | |
3809 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3810 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3811 | NEIGHBOR_STR |
3812 | NEIGHBOR_ADDR_STR2 | |
3813 | "Advertise capability to the peer\n" | |
3814 | "Advertise ORF capability to the peer\n" | |
3815 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3816 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3817 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3818 | "Capability to SEND the ORF to this neighbor\n") | |
3819 | { | |
d62a17ae | 3820 | int idx_peer = 1; |
3821 | int idx_send_recv = 5; | |
d7c0a89a | 3822 | uint16_t flag = 0; |
d62a17ae | 3823 | |
3824 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3825 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3826 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3827 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3828 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3829 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3830 | else { | |
3831 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3832 | return CMD_WARNING_CONFIG_FAILED; | |
3833 | } | |
3834 | ||
3835 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3836 | bgp_node_safi(vty), flag); | |
3837 | } | |
3838 | ||
3839 | ALIAS_HIDDEN( | |
3840 | neighbor_capability_orf_prefix, | |
3841 | neighbor_capability_orf_prefix_hidden_cmd, | |
3842 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3843 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3844 | "Advertise capability to the peer\n" | |
3845 | "Advertise ORF capability to the peer\n" | |
3846 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3847 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3848 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3849 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3850 | |
718e3744 | 3851 | DEFUN (no_neighbor_capability_orf_prefix, |
3852 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3853 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3854 | NO_STR |
3855 | NEIGHBOR_STR | |
3856 | NEIGHBOR_ADDR_STR2 | |
3857 | "Advertise capability to the peer\n" | |
3858 | "Advertise ORF capability to the peer\n" | |
3859 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3860 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3861 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3862 | "Capability to SEND the ORF to this neighbor\n") | |
3863 | { | |
d62a17ae | 3864 | int idx_peer = 2; |
3865 | int idx_send_recv = 6; | |
d7c0a89a | 3866 | uint16_t flag = 0; |
d62a17ae | 3867 | |
3868 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3869 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3870 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3871 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3872 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3873 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3874 | else { | |
3875 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3876 | return CMD_WARNING_CONFIG_FAILED; | |
3877 | } | |
3878 | ||
3879 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3880 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3881 | flag); | |
3882 | } | |
3883 | ||
3884 | ALIAS_HIDDEN( | |
3885 | no_neighbor_capability_orf_prefix, | |
3886 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3887 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3888 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3889 | "Advertise capability to the peer\n" | |
3890 | "Advertise ORF capability to the peer\n" | |
3891 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3892 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3893 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3894 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3895 | |
718e3744 | 3896 | /* neighbor next-hop-self. */ |
3897 | DEFUN (neighbor_nexthop_self, | |
3898 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3899 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3900 | NEIGHBOR_STR |
3901 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3902 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3903 | { |
d62a17ae | 3904 | int idx_peer = 1; |
3905 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3906 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3907 | } |
9e7a53c1 | 3908 | |
d62a17ae | 3909 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3910 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3911 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3912 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3913 | |
a538debe DS |
3914 | /* neighbor next-hop-self. */ |
3915 | DEFUN (neighbor_nexthop_self_force, | |
3916 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3917 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3918 | NEIGHBOR_STR |
3919 | NEIGHBOR_ADDR_STR2 | |
3920 | "Disable the next hop calculation for this neighbor\n" | |
3921 | "Set the next hop to self for reflected routes\n") | |
3922 | { | |
d62a17ae | 3923 | int idx_peer = 1; |
3924 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3925 | bgp_node_safi(vty), | |
3926 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3927 | } |
3928 | ||
d62a17ae | 3929 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3930 | neighbor_nexthop_self_force_hidden_cmd, | |
3931 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3932 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3933 | "Disable the next hop calculation for this neighbor\n" | |
3934 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3935 | |
718e3744 | 3936 | DEFUN (no_neighbor_nexthop_self, |
3937 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3939 | NO_STR |
3940 | NEIGHBOR_STR | |
3941 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3942 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3943 | { |
d62a17ae | 3944 | int idx_peer = 2; |
3945 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3946 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3947 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3948 | } |
6b0655a2 | 3949 | |
d62a17ae | 3950 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3951 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3952 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3953 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3954 | |
88b8ed8d | 3955 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3956 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3957 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3958 | NO_STR |
3959 | NEIGHBOR_STR | |
3960 | NEIGHBOR_ADDR_STR2 | |
3961 | "Disable the next hop calculation for this neighbor\n" | |
3962 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3963 | { |
d62a17ae | 3964 | int idx_peer = 2; |
3965 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3966 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3967 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3968 | } |
a538debe | 3969 | |
d62a17ae | 3970 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3971 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3973 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3974 | "Disable the next hop calculation for this neighbor\n" | |
3975 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3976 | |
c7122e14 DS |
3977 | /* neighbor as-override */ |
3978 | DEFUN (neighbor_as_override, | |
3979 | neighbor_as_override_cmd, | |
9ccf14f7 | 3980 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3981 | NEIGHBOR_STR |
3982 | NEIGHBOR_ADDR_STR2 | |
3983 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3984 | { | |
d62a17ae | 3985 | int idx_peer = 1; |
3986 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3987 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3988 | } |
3989 | ||
d62a17ae | 3990 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3991 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3992 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3993 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3994 | |
c7122e14 DS |
3995 | DEFUN (no_neighbor_as_override, |
3996 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3997 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3998 | NO_STR |
3999 | NEIGHBOR_STR | |
4000 | NEIGHBOR_ADDR_STR2 | |
4001 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4002 | { | |
d62a17ae | 4003 | int idx_peer = 2; |
4004 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4005 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4006 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4007 | } |
4008 | ||
d62a17ae | 4009 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4011 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4012 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4013 | |
718e3744 | 4014 | /* neighbor remove-private-AS. */ |
4015 | DEFUN (neighbor_remove_private_as, | |
4016 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4017 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4018 | NEIGHBOR_STR |
4019 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4020 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4021 | { |
d62a17ae | 4022 | int idx_peer = 1; |
4023 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4024 | bgp_node_safi(vty), | |
4025 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4026 | } |
4027 | ||
d62a17ae | 4028 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4029 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4030 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4031 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4032 | |
5000f21c DS |
4033 | DEFUN (neighbor_remove_private_as_all, |
4034 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4035 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4036 | NEIGHBOR_STR |
4037 | NEIGHBOR_ADDR_STR2 | |
4038 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4039 | "Apply to all AS numbers\n") |
5000f21c | 4040 | { |
d62a17ae | 4041 | int idx_peer = 1; |
4042 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4043 | bgp_node_safi(vty), | |
4044 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4045 | } |
4046 | ||
d62a17ae | 4047 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4048 | neighbor_remove_private_as_all_hidden_cmd, | |
4049 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4050 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4051 | "Remove private ASNs in outbound updates\n" | |
4052 | "Apply to all AS numbers") | |
596c17ba | 4053 | |
5000f21c DS |
4054 | DEFUN (neighbor_remove_private_as_replace_as, |
4055 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4056 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4057 | NEIGHBOR_STR |
4058 | NEIGHBOR_ADDR_STR2 | |
4059 | "Remove private ASNs in outbound updates\n" | |
4060 | "Replace private ASNs with our ASN in outbound updates\n") | |
4061 | { | |
d62a17ae | 4062 | int idx_peer = 1; |
4063 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4064 | bgp_node_safi(vty), | |
4065 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4066 | } |
4067 | ||
d62a17ae | 4068 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4069 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4070 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4071 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4072 | "Remove private ASNs in outbound updates\n" | |
4073 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4074 | |
5000f21c DS |
4075 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4076 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4077 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4078 | NEIGHBOR_STR |
4079 | NEIGHBOR_ADDR_STR2 | |
4080 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4081 | "Apply to all AS numbers\n" |
5000f21c DS |
4082 | "Replace private ASNs with our ASN in outbound updates\n") |
4083 | { | |
d62a17ae | 4084 | int idx_peer = 1; |
4085 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4086 | bgp_node_safi(vty), | |
4087 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4088 | } |
4089 | ||
d62a17ae | 4090 | ALIAS_HIDDEN( |
4091 | neighbor_remove_private_as_all_replace_as, | |
4092 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4093 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4094 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4095 | "Remove private ASNs in outbound updates\n" | |
4096 | "Apply to all AS numbers\n" | |
4097 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4098 | |
718e3744 | 4099 | DEFUN (no_neighbor_remove_private_as, |
4100 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4102 | NO_STR |
4103 | NEIGHBOR_STR | |
4104 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4105 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4106 | { |
d62a17ae | 4107 | int idx_peer = 2; |
4108 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4109 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4110 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4111 | } |
6b0655a2 | 4112 | |
d62a17ae | 4113 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4114 | no_neighbor_remove_private_as_hidden_cmd, | |
4115 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4116 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4117 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4118 | |
88b8ed8d | 4119 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4120 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4121 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4122 | NO_STR |
4123 | NEIGHBOR_STR | |
4124 | NEIGHBOR_ADDR_STR2 | |
4125 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4126 | "Apply to all AS numbers\n") |
88b8ed8d | 4127 | { |
d62a17ae | 4128 | int idx_peer = 2; |
4129 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4130 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4131 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4132 | } |
5000f21c | 4133 | |
d62a17ae | 4134 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4135 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4136 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4137 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4138 | "Remove private ASNs in outbound updates\n" | |
4139 | "Apply to all AS numbers\n") | |
596c17ba | 4140 | |
88b8ed8d | 4141 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4142 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4144 | NO_STR |
4145 | NEIGHBOR_STR | |
4146 | NEIGHBOR_ADDR_STR2 | |
4147 | "Remove private ASNs in outbound updates\n" | |
4148 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4149 | { |
d62a17ae | 4150 | int idx_peer = 2; |
4151 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4152 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4153 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4154 | } |
5000f21c | 4155 | |
d62a17ae | 4156 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4157 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4158 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4159 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4160 | "Remove private ASNs in outbound updates\n" | |
4161 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4162 | |
88b8ed8d | 4163 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4164 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4165 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4166 | NO_STR |
4167 | NEIGHBOR_STR | |
4168 | NEIGHBOR_ADDR_STR2 | |
4169 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4170 | "Apply to all AS numbers\n" |
5000f21c | 4171 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4172 | { |
d62a17ae | 4173 | int idx_peer = 2; |
4174 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4175 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4176 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4177 | } |
5000f21c | 4178 | |
d62a17ae | 4179 | ALIAS_HIDDEN( |
4180 | no_neighbor_remove_private_as_all_replace_as, | |
4181 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4182 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4183 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4184 | "Remove private ASNs in outbound updates\n" | |
4185 | "Apply to all AS numbers\n" | |
4186 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4187 | |
5000f21c | 4188 | |
718e3744 | 4189 | /* neighbor send-community. */ |
4190 | DEFUN (neighbor_send_community, | |
4191 | neighbor_send_community_cmd, | |
9ccf14f7 | 4192 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4193 | NEIGHBOR_STR |
4194 | NEIGHBOR_ADDR_STR2 | |
4195 | "Send Community attribute to this neighbor\n") | |
4196 | { | |
d62a17ae | 4197 | int idx_peer = 1; |
27c05d4d | 4198 | |
d62a17ae | 4199 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4200 | bgp_node_safi(vty), | |
4201 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4202 | } |
4203 | ||
d62a17ae | 4204 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4205 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4206 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4207 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4208 | |
718e3744 | 4209 | DEFUN (no_neighbor_send_community, |
4210 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4212 | NO_STR |
4213 | NEIGHBOR_STR | |
4214 | NEIGHBOR_ADDR_STR2 | |
4215 | "Send Community attribute to this neighbor\n") | |
4216 | { | |
d62a17ae | 4217 | int idx_peer = 2; |
27c05d4d | 4218 | |
d62a17ae | 4219 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4220 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4221 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4222 | } |
6b0655a2 | 4223 | |
d62a17ae | 4224 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4225 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4226 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4227 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4228 | |
718e3744 | 4229 | /* neighbor send-community extended. */ |
4230 | DEFUN (neighbor_send_community_type, | |
4231 | neighbor_send_community_type_cmd, | |
57d187bc | 4232 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4233 | NEIGHBOR_STR |
4234 | NEIGHBOR_ADDR_STR2 | |
4235 | "Send Community attribute to this neighbor\n" | |
4236 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4237 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4238 | "Send Extended Community attributes\n" |
57d187bc JS |
4239 | "Send Standard Community attributes\n" |
4240 | "Send Large Community attributes\n") | |
718e3744 | 4241 | { |
27c05d4d | 4242 | int idx_peer = 1; |
d7c0a89a | 4243 | uint32_t flag = 0; |
27c05d4d | 4244 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4245 | |
27c05d4d | 4246 | if (strmatch(type, "standard")) { |
d62a17ae | 4247 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4248 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4249 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4250 | } else if (strmatch(type, "large")) { |
d62a17ae | 4251 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4252 | } else if (strmatch(type, "both")) { |
d62a17ae | 4253 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4254 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4255 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4256 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4257 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4258 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4259 | } | |
4260 | ||
27c05d4d | 4261 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4262 | bgp_node_safi(vty), flag); |
4263 | } | |
4264 | ||
4265 | ALIAS_HIDDEN( | |
4266 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4267 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4268 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4269 | "Send Community attribute to this neighbor\n" | |
4270 | "Send Standard and Extended Community attributes\n" | |
4271 | "Send Standard, Large and Extended Community attributes\n" | |
4272 | "Send Extended Community attributes\n" | |
4273 | "Send Standard Community attributes\n" | |
4274 | "Send Large Community attributes\n") | |
596c17ba | 4275 | |
718e3744 | 4276 | DEFUN (no_neighbor_send_community_type, |
4277 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4278 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4279 | NO_STR |
4280 | NEIGHBOR_STR | |
4281 | NEIGHBOR_ADDR_STR2 | |
4282 | "Send Community attribute to this neighbor\n" | |
4283 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4284 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4285 | "Send Extended Community attributes\n" |
57d187bc JS |
4286 | "Send Standard Community attributes\n" |
4287 | "Send Large Community attributes\n") | |
718e3744 | 4288 | { |
d62a17ae | 4289 | int idx_peer = 2; |
27c05d4d | 4290 | uint32_t flag = 0; |
d62a17ae | 4291 | const char *type = argv[argc - 1]->text; |
4292 | ||
27c05d4d PM |
4293 | if (strmatch(type, "standard")) { |
4294 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4295 | } else if (strmatch(type, "extended")) { | |
4296 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4297 | } else if (strmatch(type, "large")) { | |
4298 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4299 | } else if (strmatch(type, "both")) { | |
4300 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4301 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4302 | } else { /* if (strmatch(type, "all")) */ | |
4303 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4304 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4305 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4306 | } | |
4307 | ||
4308 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4309 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4310 | flag); | |
d62a17ae | 4311 | } |
4312 | ||
4313 | ALIAS_HIDDEN( | |
4314 | no_neighbor_send_community_type, | |
4315 | no_neighbor_send_community_type_hidden_cmd, | |
4316 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4317 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4318 | "Send Community attribute to this neighbor\n" | |
4319 | "Send Standard and Extended Community attributes\n" | |
4320 | "Send Standard, Large and Extended Community attributes\n" | |
4321 | "Send Extended Community attributes\n" | |
4322 | "Send Standard Community attributes\n" | |
4323 | "Send Large Community attributes\n") | |
596c17ba | 4324 | |
718e3744 | 4325 | /* neighbor soft-reconfig. */ |
4326 | DEFUN (neighbor_soft_reconfiguration, | |
4327 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4328 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4329 | NEIGHBOR_STR |
4330 | NEIGHBOR_ADDR_STR2 | |
4331 | "Per neighbor soft reconfiguration\n" | |
4332 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4333 | { | |
d62a17ae | 4334 | int idx_peer = 1; |
4335 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4336 | bgp_node_safi(vty), | |
4337 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4338 | } |
4339 | ||
d62a17ae | 4340 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4341 | neighbor_soft_reconfiguration_hidden_cmd, | |
4342 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4343 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4344 | "Per neighbor soft reconfiguration\n" | |
4345 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4346 | |
718e3744 | 4347 | DEFUN (no_neighbor_soft_reconfiguration, |
4348 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4349 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4350 | NO_STR |
4351 | NEIGHBOR_STR | |
4352 | NEIGHBOR_ADDR_STR2 | |
4353 | "Per neighbor soft reconfiguration\n" | |
4354 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4355 | { | |
d62a17ae | 4356 | int idx_peer = 2; |
4357 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4358 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4359 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4360 | } |
6b0655a2 | 4361 | |
d62a17ae | 4362 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4363 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4364 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4365 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4366 | "Per neighbor soft reconfiguration\n" | |
4367 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4368 | |
718e3744 | 4369 | DEFUN (neighbor_route_reflector_client, |
4370 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4371 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4372 | NEIGHBOR_STR |
4373 | NEIGHBOR_ADDR_STR2 | |
4374 | "Configure a neighbor as Route Reflector client\n") | |
4375 | { | |
d62a17ae | 4376 | int idx_peer = 1; |
4377 | struct peer *peer; | |
718e3744 | 4378 | |
4379 | ||
d62a17ae | 4380 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4381 | if (!peer) | |
4382 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4383 | |
d62a17ae | 4384 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4385 | bgp_node_safi(vty), | |
4386 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4387 | } |
4388 | ||
d62a17ae | 4389 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4390 | neighbor_route_reflector_client_hidden_cmd, | |
4391 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4392 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4393 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4394 | |
718e3744 | 4395 | DEFUN (no_neighbor_route_reflector_client, |
4396 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4398 | NO_STR |
4399 | NEIGHBOR_STR | |
4400 | NEIGHBOR_ADDR_STR2 | |
4401 | "Configure a neighbor as Route Reflector client\n") | |
4402 | { | |
d62a17ae | 4403 | int idx_peer = 2; |
4404 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4405 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4406 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4407 | } |
6b0655a2 | 4408 | |
d62a17ae | 4409 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4410 | no_neighbor_route_reflector_client_hidden_cmd, | |
4411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4412 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4413 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4414 | |
718e3744 | 4415 | /* neighbor route-server-client. */ |
4416 | DEFUN (neighbor_route_server_client, | |
4417 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4418 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4419 | NEIGHBOR_STR |
4420 | NEIGHBOR_ADDR_STR2 | |
4421 | "Configure a neighbor as Route Server client\n") | |
4422 | { | |
d62a17ae | 4423 | int idx_peer = 1; |
4424 | struct peer *peer; | |
2a3d5731 | 4425 | |
d62a17ae | 4426 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4427 | if (!peer) | |
4428 | return CMD_WARNING_CONFIG_FAILED; | |
4429 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4430 | bgp_node_safi(vty), | |
4431 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4432 | } |
4433 | ||
d62a17ae | 4434 | ALIAS_HIDDEN(neighbor_route_server_client, |
4435 | neighbor_route_server_client_hidden_cmd, | |
4436 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4437 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4438 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4439 | |
718e3744 | 4440 | DEFUN (no_neighbor_route_server_client, |
4441 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4442 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4443 | NO_STR |
4444 | NEIGHBOR_STR | |
4445 | NEIGHBOR_ADDR_STR2 | |
4446 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4447 | { |
d62a17ae | 4448 | int idx_peer = 2; |
4449 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4450 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4451 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4452 | } |
6b0655a2 | 4453 | |
d62a17ae | 4454 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4455 | no_neighbor_route_server_client_hidden_cmd, | |
4456 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4457 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4458 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4459 | |
fee0f4c6 | 4460 | DEFUN (neighbor_nexthop_local_unchanged, |
4461 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4462 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4463 | NEIGHBOR_STR |
4464 | NEIGHBOR_ADDR_STR2 | |
4465 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4466 | "Leave link-local nexthop unchanged for this peer\n") | |
4467 | { | |
d62a17ae | 4468 | int idx_peer = 1; |
4469 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4470 | bgp_node_safi(vty), | |
4471 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4472 | } |
6b0655a2 | 4473 | |
fee0f4c6 | 4474 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4475 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4476 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4477 | NO_STR |
4478 | NEIGHBOR_STR | |
4479 | NEIGHBOR_ADDR_STR2 | |
4480 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4481 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4482 | { |
d62a17ae | 4483 | int idx_peer = 2; |
4484 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4485 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4486 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4487 | } |
6b0655a2 | 4488 | |
718e3744 | 4489 | DEFUN (neighbor_attr_unchanged, |
4490 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4491 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4492 | NEIGHBOR_STR |
4493 | NEIGHBOR_ADDR_STR2 | |
4494 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4495 | "As-path attribute\n" | |
4496 | "Nexthop attribute\n" | |
a8206004 | 4497 | "Med attribute\n") |
718e3744 | 4498 | { |
d62a17ae | 4499 | int idx = 0; |
8eeb0335 DW |
4500 | char *peer_str = argv[1]->arg; |
4501 | struct peer *peer; | |
d7c0a89a | 4502 | uint16_t flags = 0; |
8eeb0335 DW |
4503 | afi_t afi = bgp_node_afi(vty); |
4504 | safi_t safi = bgp_node_safi(vty); | |
4505 | ||
4506 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4507 | if (!peer) | |
4508 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4509 | |
4510 | if (argv_find(argv, argc, "as-path", &idx)) | |
4511 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4512 | idx = 0; | |
4513 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4514 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4515 | idx = 0; | |
4516 | if (argv_find(argv, argc, "med", &idx)) | |
4517 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4518 | ||
8eeb0335 DW |
4519 | /* no flags means all of them! */ |
4520 | if (!flags) { | |
d62a17ae | 4521 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4522 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4523 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4524 | } else { |
a4d82a8a PZ |
4525 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4526 | && peer_af_flag_check(peer, afi, safi, | |
4527 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4528 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4529 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4530 | } | |
4531 | ||
a4d82a8a PZ |
4532 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4533 | && peer_af_flag_check(peer, afi, safi, | |
4534 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4535 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4536 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4537 | } | |
4538 | ||
a4d82a8a PZ |
4539 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4540 | && peer_af_flag_check(peer, afi, safi, | |
4541 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4542 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4543 | PEER_FLAG_MED_UNCHANGED); | |
4544 | } | |
d62a17ae | 4545 | } |
4546 | ||
8eeb0335 | 4547 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4548 | } |
4549 | ||
4550 | ALIAS_HIDDEN( | |
4551 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4552 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4553 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4554 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4555 | "As-path attribute\n" | |
4556 | "Nexthop attribute\n" | |
4557 | "Med attribute\n") | |
596c17ba | 4558 | |
718e3744 | 4559 | DEFUN (no_neighbor_attr_unchanged, |
4560 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4561 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4562 | NO_STR |
718e3744 | 4563 | NEIGHBOR_STR |
4564 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4565 | "BGP attribute is propagated unchanged to this neighbor\n" |
4566 | "As-path attribute\n" | |
40e718b5 | 4567 | "Nexthop attribute\n" |
a8206004 | 4568 | "Med attribute\n") |
718e3744 | 4569 | { |
d62a17ae | 4570 | int idx = 0; |
4571 | char *peer = argv[2]->arg; | |
d7c0a89a | 4572 | uint16_t flags = 0; |
d62a17ae | 4573 | |
4574 | if (argv_find(argv, argc, "as-path", &idx)) | |
4575 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4576 | idx = 0; | |
4577 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4578 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4579 | idx = 0; | |
4580 | if (argv_find(argv, argc, "med", &idx)) | |
4581 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4582 | ||
4583 | if (!flags) // no flags means all of them! | |
4584 | { | |
4585 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4586 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4587 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4588 | } | |
4589 | ||
4590 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4591 | bgp_node_safi(vty), flags); | |
4592 | } | |
4593 | ||
4594 | ALIAS_HIDDEN( | |
4595 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4596 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4597 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4598 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4599 | "As-path attribute\n" | |
4600 | "Nexthop attribute\n" | |
4601 | "Med attribute\n") | |
718e3744 | 4602 | |
718e3744 | 4603 | /* EBGP multihop configuration. */ |
d62a17ae | 4604 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4605 | const char *ttl_str) | |
718e3744 | 4606 | { |
d62a17ae | 4607 | struct peer *peer; |
4608 | unsigned int ttl; | |
718e3744 | 4609 | |
d62a17ae | 4610 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4611 | if (!peer) | |
4612 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4613 | |
d62a17ae | 4614 | if (peer->conf_if) |
4615 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4616 | |
d62a17ae | 4617 | if (!ttl_str) |
4618 | ttl = MAXTTL; | |
4619 | else | |
4620 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4621 | |
d62a17ae | 4622 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4623 | } |
4624 | ||
d62a17ae | 4625 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4626 | { |
d62a17ae | 4627 | struct peer *peer; |
718e3744 | 4628 | |
d62a17ae | 4629 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4630 | if (!peer) | |
4631 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4632 | |
d62a17ae | 4633 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4634 | } |
4635 | ||
4636 | /* neighbor ebgp-multihop. */ | |
4637 | DEFUN (neighbor_ebgp_multihop, | |
4638 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4639 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4640 | NEIGHBOR_STR |
4641 | NEIGHBOR_ADDR_STR2 | |
4642 | "Allow EBGP neighbors not on directly connected networks\n") | |
4643 | { | |
d62a17ae | 4644 | int idx_peer = 1; |
4645 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4646 | } |
4647 | ||
4648 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4649 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4650 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4651 | NEIGHBOR_STR |
4652 | NEIGHBOR_ADDR_STR2 | |
4653 | "Allow EBGP neighbors not on directly connected networks\n" | |
4654 | "maximum hop count\n") | |
4655 | { | |
d62a17ae | 4656 | int idx_peer = 1; |
4657 | int idx_number = 3; | |
4658 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4659 | argv[idx_number]->arg); | |
718e3744 | 4660 | } |
4661 | ||
4662 | DEFUN (no_neighbor_ebgp_multihop, | |
4663 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4665 | NO_STR |
4666 | NEIGHBOR_STR | |
4667 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4668 | "Allow EBGP neighbors not on directly connected networks\n" |
4669 | "maximum hop count\n") | |
718e3744 | 4670 | { |
d62a17ae | 4671 | int idx_peer = 2; |
4672 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4673 | } |
4674 | ||
6b0655a2 | 4675 | |
6ffd2079 | 4676 | /* disable-connected-check */ |
4677 | DEFUN (neighbor_disable_connected_check, | |
4678 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4679 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4680 | NEIGHBOR_STR |
7ebe625c | 4681 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4682 | "one-hop away EBGP peer using loopback address\n" |
4683 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4684 | { |
d62a17ae | 4685 | int idx_peer = 1; |
4686 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4687 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4688 | } |
4689 | ||
4690 | DEFUN (no_neighbor_disable_connected_check, | |
4691 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4692 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4693 | NO_STR |
4694 | NEIGHBOR_STR | |
7ebe625c | 4695 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4696 | "one-hop away EBGP peer using loopback address\n" |
4697 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4698 | { |
d62a17ae | 4699 | int idx_peer = 2; |
4700 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4701 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4702 | } |
4703 | ||
47cbc09b PM |
4704 | |
4705 | /* enforce-first-as */ | |
4706 | DEFUN (neighbor_enforce_first_as, | |
4707 | neighbor_enforce_first_as_cmd, | |
4708 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4709 | NEIGHBOR_STR | |
4710 | NEIGHBOR_ADDR_STR2 | |
4711 | "Enforce the first AS for EBGP routes\n") | |
4712 | { | |
4713 | int idx_peer = 1; | |
4714 | ||
4715 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4716 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4717 | } | |
4718 | ||
4719 | DEFUN (no_neighbor_enforce_first_as, | |
4720 | no_neighbor_enforce_first_as_cmd, | |
4721 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4722 | NO_STR | |
4723 | NEIGHBOR_STR | |
4724 | NEIGHBOR_ADDR_STR2 | |
4725 | "Enforce the first AS for EBGP routes\n") | |
4726 | { | |
4727 | int idx_peer = 2; | |
4728 | ||
4729 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4730 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4731 | } | |
4732 | ||
4733 | ||
718e3744 | 4734 | DEFUN (neighbor_description, |
4735 | neighbor_description_cmd, | |
e961923c | 4736 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4737 | NEIGHBOR_STR |
4738 | NEIGHBOR_ADDR_STR2 | |
4739 | "Neighbor specific description\n" | |
4740 | "Up to 80 characters describing this neighbor\n") | |
4741 | { | |
d62a17ae | 4742 | int idx_peer = 1; |
4743 | int idx_line = 3; | |
4744 | struct peer *peer; | |
4745 | char *str; | |
718e3744 | 4746 | |
d62a17ae | 4747 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4748 | if (!peer) | |
4749 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4750 | |
d62a17ae | 4751 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4752 | |
d62a17ae | 4753 | peer_description_set(peer, str); |
718e3744 | 4754 | |
d62a17ae | 4755 | XFREE(MTYPE_TMP, str); |
718e3744 | 4756 | |
d62a17ae | 4757 | return CMD_SUCCESS; |
718e3744 | 4758 | } |
4759 | ||
4760 | DEFUN (no_neighbor_description, | |
4761 | no_neighbor_description_cmd, | |
a14810f4 | 4762 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4763 | NO_STR |
4764 | NEIGHBOR_STR | |
4765 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4766 | "Neighbor specific description\n") |
718e3744 | 4767 | { |
d62a17ae | 4768 | int idx_peer = 2; |
4769 | struct peer *peer; | |
718e3744 | 4770 | |
d62a17ae | 4771 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4772 | if (!peer) | |
4773 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4774 | |
d62a17ae | 4775 | peer_description_unset(peer); |
718e3744 | 4776 | |
d62a17ae | 4777 | return CMD_SUCCESS; |
718e3744 | 4778 | } |
4779 | ||
a14810f4 PM |
4780 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4781 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4782 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4783 | "Neighbor specific description\n" | |
4784 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4785 | |
718e3744 | 4786 | /* Neighbor update-source. */ |
d62a17ae | 4787 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4788 | const char *source_str) | |
4789 | { | |
4790 | struct peer *peer; | |
4791 | struct prefix p; | |
a14810f4 | 4792 | union sockunion su; |
d62a17ae | 4793 | |
4794 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4795 | if (!peer) | |
4796 | return CMD_WARNING_CONFIG_FAILED; | |
4797 | ||
4798 | if (peer->conf_if) | |
4799 | return CMD_WARNING; | |
4800 | ||
4801 | if (source_str) { | |
a14810f4 | 4802 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4803 | peer_update_source_addr_set(peer, &su); |
4804 | else { | |
4805 | if (str2prefix(source_str, &p)) { | |
4806 | vty_out(vty, | |
4807 | "%% Invalid update-source, remove prefix length \n"); | |
4808 | return CMD_WARNING_CONFIG_FAILED; | |
4809 | } else | |
4810 | peer_update_source_if_set(peer, source_str); | |
4811 | } | |
4812 | } else | |
4813 | peer_update_source_unset(peer); | |
4814 | ||
4815 | return CMD_SUCCESS; | |
4816 | } | |
4817 | ||
4818 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4819 | "IPv4 address\n" \ | |
4820 | "IPv6 address\n" \ | |
4821 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4822 | |
718e3744 | 4823 | DEFUN (neighbor_update_source, |
4824 | neighbor_update_source_cmd, | |
9ccf14f7 | 4825 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4826 | NEIGHBOR_STR |
4827 | NEIGHBOR_ADDR_STR2 | |
4828 | "Source of routing updates\n" | |
369688c0 | 4829 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4830 | { |
d62a17ae | 4831 | int idx_peer = 1; |
4832 | int idx_peer_2 = 3; | |
4833 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4834 | argv[idx_peer_2]->arg); | |
718e3744 | 4835 | } |
4836 | ||
4837 | DEFUN (no_neighbor_update_source, | |
4838 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4840 | NO_STR |
4841 | NEIGHBOR_STR | |
4842 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4843 | "Source of routing updates\n" |
4844 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4845 | { |
d62a17ae | 4846 | int idx_peer = 2; |
4847 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4848 | } |
6b0655a2 | 4849 | |
d62a17ae | 4850 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4851 | afi_t afi, safi_t safi, | |
4852 | const char *rmap, int set) | |
718e3744 | 4853 | { |
d62a17ae | 4854 | int ret; |
4855 | struct peer *peer; | |
1de27621 | 4856 | struct route_map *route_map; |
718e3744 | 4857 | |
d62a17ae | 4858 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4859 | if (!peer) | |
4860 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4861 | |
1de27621 DA |
4862 | if (set) { |
4863 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
4864 | ret = peer_default_originate_set(peer, afi, safi, | |
4865 | rmap, route_map); | |
4866 | } else | |
d62a17ae | 4867 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4868 | |
d62a17ae | 4869 | return bgp_vty_return(vty, ret); |
718e3744 | 4870 | } |
4871 | ||
4872 | /* neighbor default-originate. */ | |
4873 | DEFUN (neighbor_default_originate, | |
4874 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4875 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4876 | NEIGHBOR_STR |
4877 | NEIGHBOR_ADDR_STR2 | |
4878 | "Originate default route to this neighbor\n") | |
4879 | { | |
d62a17ae | 4880 | int idx_peer = 1; |
4881 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4882 | bgp_node_afi(vty), | |
4883 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4884 | } |
4885 | ||
d62a17ae | 4886 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4887 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4888 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4889 | "Originate default route to this neighbor\n") | |
596c17ba | 4890 | |
718e3744 | 4891 | DEFUN (neighbor_default_originate_rmap, |
4892 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4893 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4894 | NEIGHBOR_STR |
4895 | NEIGHBOR_ADDR_STR2 | |
4896 | "Originate default route to this neighbor\n" | |
4897 | "Route-map to specify criteria to originate default\n" | |
4898 | "route-map name\n") | |
4899 | { | |
d62a17ae | 4900 | int idx_peer = 1; |
4901 | int idx_word = 4; | |
4902 | return peer_default_originate_set_vty( | |
4903 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4904 | argv[idx_word]->arg, 1); | |
718e3744 | 4905 | } |
4906 | ||
d62a17ae | 4907 | ALIAS_HIDDEN( |
4908 | neighbor_default_originate_rmap, | |
4909 | neighbor_default_originate_rmap_hidden_cmd, | |
4910 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4911 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4912 | "Originate default route to this neighbor\n" | |
4913 | "Route-map to specify criteria to originate default\n" | |
4914 | "route-map name\n") | |
596c17ba | 4915 | |
718e3744 | 4916 | DEFUN (no_neighbor_default_originate, |
4917 | no_neighbor_default_originate_cmd, | |
a636c635 | 4918 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4919 | NO_STR |
4920 | NEIGHBOR_STR | |
4921 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4922 | "Originate default route to this neighbor\n" |
4923 | "Route-map to specify criteria to originate default\n" | |
4924 | "route-map name\n") | |
718e3744 | 4925 | { |
d62a17ae | 4926 | int idx_peer = 2; |
4927 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4928 | bgp_node_afi(vty), | |
4929 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4930 | } |
4931 | ||
d62a17ae | 4932 | ALIAS_HIDDEN( |
4933 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4934 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4935 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4936 | "Originate default route to this neighbor\n" | |
4937 | "Route-map to specify criteria to originate default\n" | |
4938 | "route-map name\n") | |
596c17ba | 4939 | |
6b0655a2 | 4940 | |
718e3744 | 4941 | /* Set neighbor's BGP port. */ |
d62a17ae | 4942 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4943 | const char *port_str) | |
4944 | { | |
4945 | struct peer *peer; | |
d7c0a89a | 4946 | uint16_t port; |
d62a17ae | 4947 | struct servent *sp; |
4948 | ||
4949 | peer = peer_lookup_vty(vty, ip_str); | |
4950 | if (!peer) | |
4951 | return CMD_WARNING_CONFIG_FAILED; | |
4952 | ||
4953 | if (!port_str) { | |
4954 | sp = getservbyname("bgp", "tcp"); | |
4955 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4956 | } else { | |
4957 | port = strtoul(port_str, NULL, 10); | |
4958 | } | |
718e3744 | 4959 | |
d62a17ae | 4960 | peer_port_set(peer, port); |
718e3744 | 4961 | |
d62a17ae | 4962 | return CMD_SUCCESS; |
718e3744 | 4963 | } |
4964 | ||
f418446b | 4965 | /* Set specified peer's BGP port. */ |
718e3744 | 4966 | DEFUN (neighbor_port, |
4967 | neighbor_port_cmd, | |
9ccf14f7 | 4968 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4969 | NEIGHBOR_STR |
4970 | NEIGHBOR_ADDR_STR | |
4971 | "Neighbor's BGP port\n" | |
4972 | "TCP port number\n") | |
4973 | { | |
d62a17ae | 4974 | int idx_ip = 1; |
4975 | int idx_number = 3; | |
4976 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4977 | argv[idx_number]->arg); | |
718e3744 | 4978 | } |
4979 | ||
4980 | DEFUN (no_neighbor_port, | |
4981 | no_neighbor_port_cmd, | |
9ccf14f7 | 4982 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4983 | NO_STR |
4984 | NEIGHBOR_STR | |
4985 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4986 | "Neighbor's BGP port\n" |
4987 | "TCP port number\n") | |
718e3744 | 4988 | { |
d62a17ae | 4989 | int idx_ip = 2; |
4990 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4991 | } |
4992 | ||
6b0655a2 | 4993 | |
718e3744 | 4994 | /* neighbor weight. */ |
d62a17ae | 4995 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4996 | safi_t safi, const char *weight_str) | |
718e3744 | 4997 | { |
d62a17ae | 4998 | int ret; |
4999 | struct peer *peer; | |
5000 | unsigned long weight; | |
718e3744 | 5001 | |
d62a17ae | 5002 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5003 | if (!peer) | |
5004 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5005 | |
d62a17ae | 5006 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5007 | |
d62a17ae | 5008 | ret = peer_weight_set(peer, afi, safi, weight); |
5009 | return bgp_vty_return(vty, ret); | |
718e3744 | 5010 | } |
5011 | ||
d62a17ae | 5012 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5013 | safi_t safi) | |
718e3744 | 5014 | { |
d62a17ae | 5015 | int ret; |
5016 | struct peer *peer; | |
718e3744 | 5017 | |
d62a17ae | 5018 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5019 | if (!peer) | |
5020 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5021 | |
d62a17ae | 5022 | ret = peer_weight_unset(peer, afi, safi); |
5023 | return bgp_vty_return(vty, ret); | |
718e3744 | 5024 | } |
5025 | ||
5026 | DEFUN (neighbor_weight, | |
5027 | neighbor_weight_cmd, | |
9ccf14f7 | 5028 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5029 | NEIGHBOR_STR |
5030 | NEIGHBOR_ADDR_STR2 | |
5031 | "Set default weight for routes from this neighbor\n" | |
5032 | "default weight\n") | |
5033 | { | |
d62a17ae | 5034 | int idx_peer = 1; |
5035 | int idx_number = 3; | |
5036 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5037 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5038 | } |
5039 | ||
d62a17ae | 5040 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5041 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5042 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5043 | "Set default weight for routes from this neighbor\n" | |
5044 | "default weight\n") | |
596c17ba | 5045 | |
718e3744 | 5046 | DEFUN (no_neighbor_weight, |
5047 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5048 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5049 | NO_STR |
5050 | NEIGHBOR_STR | |
5051 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5052 | "Set default weight for routes from this neighbor\n" |
5053 | "default weight\n") | |
718e3744 | 5054 | { |
d62a17ae | 5055 | int idx_peer = 2; |
5056 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5057 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5058 | } |
5059 | ||
d62a17ae | 5060 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5062 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5063 | "Set default weight for routes from this neighbor\n" | |
5064 | "default weight\n") | |
596c17ba | 5065 | |
6b0655a2 | 5066 | |
718e3744 | 5067 | /* Override capability negotiation. */ |
5068 | DEFUN (neighbor_override_capability, | |
5069 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5070 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5071 | NEIGHBOR_STR |
5072 | NEIGHBOR_ADDR_STR2 | |
5073 | "Override capability negotiation result\n") | |
5074 | { | |
d62a17ae | 5075 | int idx_peer = 1; |
5076 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5077 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5078 | } |
5079 | ||
5080 | DEFUN (no_neighbor_override_capability, | |
5081 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5083 | NO_STR |
5084 | NEIGHBOR_STR | |
5085 | NEIGHBOR_ADDR_STR2 | |
5086 | "Override capability negotiation result\n") | |
5087 | { | |
d62a17ae | 5088 | int idx_peer = 2; |
5089 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5090 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5091 | } |
6b0655a2 | 5092 | |
718e3744 | 5093 | DEFUN (neighbor_strict_capability, |
5094 | neighbor_strict_capability_cmd, | |
9fb964de | 5095 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5096 | NEIGHBOR_STR |
9fb964de | 5097 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5098 | "Strict capability negotiation match\n") |
5099 | { | |
9fb964de PM |
5100 | int idx_peer = 1; |
5101 | ||
5102 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5103 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5104 | } |
5105 | ||
5106 | DEFUN (no_neighbor_strict_capability, | |
5107 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5108 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5109 | NO_STR |
5110 | NEIGHBOR_STR | |
9fb964de | 5111 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5112 | "Strict capability negotiation match\n") |
5113 | { | |
9fb964de PM |
5114 | int idx_peer = 2; |
5115 | ||
5116 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5117 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5118 | } |
6b0655a2 | 5119 | |
d62a17ae | 5120 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5121 | const char *keep_str, const char *hold_str) | |
718e3744 | 5122 | { |
d62a17ae | 5123 | int ret; |
5124 | struct peer *peer; | |
d7c0a89a QY |
5125 | uint32_t keepalive; |
5126 | uint32_t holdtime; | |
718e3744 | 5127 | |
d62a17ae | 5128 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5129 | if (!peer) | |
5130 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5131 | |
d62a17ae | 5132 | keepalive = strtoul(keep_str, NULL, 10); |
5133 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5134 | |
d62a17ae | 5135 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5136 | |
d62a17ae | 5137 | return bgp_vty_return(vty, ret); |
718e3744 | 5138 | } |
6b0655a2 | 5139 | |
d62a17ae | 5140 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5141 | { |
d62a17ae | 5142 | int ret; |
5143 | struct peer *peer; | |
718e3744 | 5144 | |
d62a17ae | 5145 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5146 | if (!peer) | |
5147 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5148 | |
d62a17ae | 5149 | ret = peer_timers_unset(peer); |
718e3744 | 5150 | |
d62a17ae | 5151 | return bgp_vty_return(vty, ret); |
718e3744 | 5152 | } |
5153 | ||
5154 | DEFUN (neighbor_timers, | |
5155 | neighbor_timers_cmd, | |
9ccf14f7 | 5156 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5157 | NEIGHBOR_STR |
5158 | NEIGHBOR_ADDR_STR2 | |
5159 | "BGP per neighbor timers\n" | |
5160 | "Keepalive interval\n" | |
5161 | "Holdtime\n") | |
5162 | { | |
d62a17ae | 5163 | int idx_peer = 1; |
5164 | int idx_number = 3; | |
5165 | int idx_number_2 = 4; | |
5166 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5167 | argv[idx_number]->arg, | |
5168 | argv[idx_number_2]->arg); | |
718e3744 | 5169 | } |
5170 | ||
5171 | DEFUN (no_neighbor_timers, | |
5172 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5173 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5174 | NO_STR |
5175 | NEIGHBOR_STR | |
5176 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5177 | "BGP per neighbor timers\n" |
5178 | "Keepalive interval\n" | |
5179 | "Holdtime\n") | |
718e3744 | 5180 | { |
d62a17ae | 5181 | int idx_peer = 2; |
5182 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5183 | } |
6b0655a2 | 5184 | |
813d4307 | 5185 | |
d62a17ae | 5186 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5187 | const char *time_str) | |
718e3744 | 5188 | { |
d62a17ae | 5189 | int ret; |
5190 | struct peer *peer; | |
d7c0a89a | 5191 | uint32_t connect; |
718e3744 | 5192 | |
d62a17ae | 5193 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5194 | if (!peer) | |
5195 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5196 | |
d62a17ae | 5197 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5198 | |
d62a17ae | 5199 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5200 | |
d62a17ae | 5201 | return bgp_vty_return(vty, ret); |
718e3744 | 5202 | } |
5203 | ||
d62a17ae | 5204 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5205 | { |
d62a17ae | 5206 | int ret; |
5207 | struct peer *peer; | |
718e3744 | 5208 | |
d62a17ae | 5209 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5210 | if (!peer) | |
5211 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5212 | |
d62a17ae | 5213 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5214 | |
d62a17ae | 5215 | return bgp_vty_return(vty, ret); |
718e3744 | 5216 | } |
5217 | ||
5218 | DEFUN (neighbor_timers_connect, | |
5219 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5220 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5221 | NEIGHBOR_STR |
966f821c | 5222 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5223 | "BGP per neighbor timers\n" |
5224 | "BGP connect timer\n" | |
5225 | "Connect timer\n") | |
5226 | { | |
d62a17ae | 5227 | int idx_peer = 1; |
5228 | int idx_number = 4; | |
5229 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5230 | argv[idx_number]->arg); | |
718e3744 | 5231 | } |
5232 | ||
5233 | DEFUN (no_neighbor_timers_connect, | |
5234 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5235 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5236 | NO_STR |
5237 | NEIGHBOR_STR | |
966f821c | 5238 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5239 | "BGP per neighbor timers\n" |
8334fd5a DW |
5240 | "BGP connect timer\n" |
5241 | "Connect timer\n") | |
718e3744 | 5242 | { |
d62a17ae | 5243 | int idx_peer = 2; |
5244 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5245 | } |
5246 | ||
6b0655a2 | 5247 | |
d62a17ae | 5248 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5249 | const char *time_str, int set) | |
718e3744 | 5250 | { |
d62a17ae | 5251 | int ret; |
5252 | struct peer *peer; | |
d7c0a89a | 5253 | uint32_t routeadv = 0; |
718e3744 | 5254 | |
d62a17ae | 5255 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5256 | if (!peer) | |
5257 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5258 | |
d62a17ae | 5259 | if (time_str) |
5260 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5261 | |
d62a17ae | 5262 | if (set) |
5263 | ret = peer_advertise_interval_set(peer, routeadv); | |
5264 | else | |
5265 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5266 | |
d62a17ae | 5267 | return bgp_vty_return(vty, ret); |
718e3744 | 5268 | } |
5269 | ||
5270 | DEFUN (neighbor_advertise_interval, | |
5271 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5272 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5273 | NEIGHBOR_STR |
966f821c | 5274 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5275 | "Minimum interval between sending BGP routing updates\n" |
5276 | "time in seconds\n") | |
5277 | { | |
d62a17ae | 5278 | int idx_peer = 1; |
5279 | int idx_number = 3; | |
5280 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5281 | argv[idx_number]->arg, 1); | |
718e3744 | 5282 | } |
5283 | ||
5284 | DEFUN (no_neighbor_advertise_interval, | |
5285 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5286 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5287 | NO_STR |
5288 | NEIGHBOR_STR | |
966f821c | 5289 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5290 | "Minimum interval between sending BGP routing updates\n" |
5291 | "time in seconds\n") | |
718e3744 | 5292 | { |
d62a17ae | 5293 | int idx_peer = 2; |
5294 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5295 | } |
5296 | ||
6b0655a2 | 5297 | |
518f0eb1 DS |
5298 | /* Time to wait before processing route-map updates */ |
5299 | DEFUN (bgp_set_route_map_delay_timer, | |
5300 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5301 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5302 | SET_STR |
5303 | "BGP route-map delay timer\n" | |
5304 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5305 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5306 | { |
d62a17ae | 5307 | int idx_number = 3; |
d7c0a89a | 5308 | uint32_t rmap_delay_timer; |
d62a17ae | 5309 | |
5310 | if (argv[idx_number]->arg) { | |
5311 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5312 | bm->rmap_update_timer = rmap_delay_timer; | |
5313 | ||
5314 | /* if the dynamic update handling is being disabled, and a timer | |
5315 | * is | |
5316 | * running, stop the timer and act as if the timer has already | |
5317 | * fired. | |
5318 | */ | |
5319 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5320 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5321 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5322 | NULL, 0); | |
5323 | } | |
5324 | return CMD_SUCCESS; | |
5325 | } else { | |
5326 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5327 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5328 | } |
518f0eb1 DS |
5329 | } |
5330 | ||
5331 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5332 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5333 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5334 | NO_STR |
3a2d747c | 5335 | BGP_STR |
518f0eb1 | 5336 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5337 | "Reset to default time to wait for processing route-map changes\n" |
5338 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5339 | { |
518f0eb1 | 5340 | |
d62a17ae | 5341 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5342 | |
d62a17ae | 5343 | return CMD_SUCCESS; |
518f0eb1 DS |
5344 | } |
5345 | ||
f414725f | 5346 | |
718e3744 | 5347 | /* neighbor interface */ |
d62a17ae | 5348 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5349 | const char *str) | |
718e3744 | 5350 | { |
d62a17ae | 5351 | struct peer *peer; |
718e3744 | 5352 | |
d62a17ae | 5353 | peer = peer_lookup_vty(vty, ip_str); |
5354 | if (!peer || peer->conf_if) { | |
5355 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5356 | return CMD_WARNING_CONFIG_FAILED; | |
5357 | } | |
718e3744 | 5358 | |
d62a17ae | 5359 | if (str) |
5360 | peer_interface_set(peer, str); | |
5361 | else | |
5362 | peer_interface_unset(peer); | |
718e3744 | 5363 | |
d62a17ae | 5364 | return CMD_SUCCESS; |
718e3744 | 5365 | } |
5366 | ||
5367 | DEFUN (neighbor_interface, | |
5368 | neighbor_interface_cmd, | |
9ccf14f7 | 5369 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5370 | NEIGHBOR_STR |
5371 | NEIGHBOR_ADDR_STR | |
5372 | "Interface\n" | |
5373 | "Interface name\n") | |
5374 | { | |
d62a17ae | 5375 | int idx_ip = 1; |
5376 | int idx_word = 3; | |
5377 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5378 | } |
5379 | ||
5380 | DEFUN (no_neighbor_interface, | |
5381 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5383 | NO_STR |
5384 | NEIGHBOR_STR | |
16cedbb0 | 5385 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5386 | "Interface\n" |
5387 | "Interface name\n") | |
5388 | { | |
d62a17ae | 5389 | int idx_peer = 2; |
5390 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5391 | } |
6b0655a2 | 5392 | |
718e3744 | 5393 | DEFUN (neighbor_distribute_list, |
5394 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5395 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5396 | NEIGHBOR_STR |
5397 | NEIGHBOR_ADDR_STR2 | |
5398 | "Filter updates to/from this neighbor\n" | |
5399 | "IP access-list number\n" | |
5400 | "IP access-list number (expanded range)\n" | |
5401 | "IP Access-list name\n" | |
5402 | "Filter incoming updates\n" | |
5403 | "Filter outgoing updates\n") | |
5404 | { | |
d62a17ae | 5405 | int idx_peer = 1; |
5406 | int idx_acl = 3; | |
5407 | int direct, ret; | |
5408 | struct peer *peer; | |
a8206004 | 5409 | |
d62a17ae | 5410 | const char *pstr = argv[idx_peer]->arg; |
5411 | const char *acl = argv[idx_acl]->arg; | |
5412 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5413 | |
d62a17ae | 5414 | peer = peer_and_group_lookup_vty(vty, pstr); |
5415 | if (!peer) | |
5416 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5417 | |
d62a17ae | 5418 | /* Check filter direction. */ |
5419 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5420 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5421 | direct, acl); | |
a8206004 | 5422 | |
d62a17ae | 5423 | return bgp_vty_return(vty, ret); |
718e3744 | 5424 | } |
5425 | ||
d62a17ae | 5426 | ALIAS_HIDDEN( |
5427 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5428 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5429 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5430 | "Filter updates to/from this neighbor\n" | |
5431 | "IP access-list number\n" | |
5432 | "IP access-list number (expanded range)\n" | |
5433 | "IP Access-list name\n" | |
5434 | "Filter incoming updates\n" | |
5435 | "Filter outgoing updates\n") | |
596c17ba | 5436 | |
718e3744 | 5437 | DEFUN (no_neighbor_distribute_list, |
5438 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5440 | NO_STR |
5441 | NEIGHBOR_STR | |
5442 | NEIGHBOR_ADDR_STR2 | |
5443 | "Filter updates to/from this neighbor\n" | |
5444 | "IP access-list number\n" | |
5445 | "IP access-list number (expanded range)\n" | |
5446 | "IP Access-list name\n" | |
5447 | "Filter incoming updates\n" | |
5448 | "Filter outgoing updates\n") | |
5449 | { | |
d62a17ae | 5450 | int idx_peer = 2; |
5451 | int direct, ret; | |
5452 | struct peer *peer; | |
a8206004 | 5453 | |
d62a17ae | 5454 | const char *pstr = argv[idx_peer]->arg; |
5455 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5456 | |
d62a17ae | 5457 | peer = peer_and_group_lookup_vty(vty, pstr); |
5458 | if (!peer) | |
5459 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5460 | |
d62a17ae | 5461 | /* Check filter direction. */ |
5462 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5463 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5464 | direct); | |
a8206004 | 5465 | |
d62a17ae | 5466 | return bgp_vty_return(vty, ret); |
718e3744 | 5467 | } |
6b0655a2 | 5468 | |
d62a17ae | 5469 | ALIAS_HIDDEN( |
5470 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5471 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5472 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5473 | "Filter updates to/from this neighbor\n" | |
5474 | "IP access-list number\n" | |
5475 | "IP access-list number (expanded range)\n" | |
5476 | "IP Access-list name\n" | |
5477 | "Filter incoming updates\n" | |
5478 | "Filter outgoing updates\n") | |
596c17ba | 5479 | |
718e3744 | 5480 | /* Set prefix list to the peer. */ |
d62a17ae | 5481 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5482 | afi_t afi, safi_t safi, | |
5483 | const char *name_str, | |
5484 | const char *direct_str) | |
718e3744 | 5485 | { |
d62a17ae | 5486 | int ret; |
d62a17ae | 5487 | int direct = FILTER_IN; |
cf9ac8bf | 5488 | struct peer *peer; |
718e3744 | 5489 | |
d62a17ae | 5490 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5491 | if (!peer) | |
5492 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5493 | |
d62a17ae | 5494 | /* Check filter direction. */ |
5495 | if (strncmp(direct_str, "i", 1) == 0) | |
5496 | direct = FILTER_IN; | |
5497 | else if (strncmp(direct_str, "o", 1) == 0) | |
5498 | direct = FILTER_OUT; | |
718e3744 | 5499 | |
d62a17ae | 5500 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5501 | |
d62a17ae | 5502 | return bgp_vty_return(vty, ret); |
718e3744 | 5503 | } |
5504 | ||
d62a17ae | 5505 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5506 | afi_t afi, safi_t safi, | |
5507 | const char *direct_str) | |
718e3744 | 5508 | { |
d62a17ae | 5509 | int ret; |
5510 | struct peer *peer; | |
5511 | int direct = FILTER_IN; | |
718e3744 | 5512 | |
d62a17ae | 5513 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5514 | if (!peer) | |
5515 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5516 | |
d62a17ae | 5517 | /* Check filter direction. */ |
5518 | if (strncmp(direct_str, "i", 1) == 0) | |
5519 | direct = FILTER_IN; | |
5520 | else if (strncmp(direct_str, "o", 1) == 0) | |
5521 | direct = FILTER_OUT; | |
718e3744 | 5522 | |
d62a17ae | 5523 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5524 | |
d62a17ae | 5525 | return bgp_vty_return(vty, ret); |
718e3744 | 5526 | } |
5527 | ||
5528 | DEFUN (neighbor_prefix_list, | |
5529 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5530 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5531 | NEIGHBOR_STR |
5532 | NEIGHBOR_ADDR_STR2 | |
5533 | "Filter updates to/from this neighbor\n" | |
5534 | "Name of a prefix list\n" | |
5535 | "Filter incoming updates\n" | |
5536 | "Filter outgoing updates\n") | |
5537 | { | |
d62a17ae | 5538 | int idx_peer = 1; |
5539 | int idx_word = 3; | |
5540 | int idx_in_out = 4; | |
5541 | return peer_prefix_list_set_vty( | |
5542 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5543 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5544 | } |
5545 | ||
d62a17ae | 5546 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5547 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5548 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5549 | "Filter updates to/from this neighbor\n" | |
5550 | "Name of a prefix list\n" | |
5551 | "Filter incoming updates\n" | |
5552 | "Filter outgoing updates\n") | |
596c17ba | 5553 | |
718e3744 | 5554 | DEFUN (no_neighbor_prefix_list, |
5555 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5556 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5557 | NO_STR |
5558 | NEIGHBOR_STR | |
5559 | NEIGHBOR_ADDR_STR2 | |
5560 | "Filter updates to/from this neighbor\n" | |
5561 | "Name of a prefix list\n" | |
5562 | "Filter incoming updates\n" | |
5563 | "Filter outgoing updates\n") | |
5564 | { | |
d62a17ae | 5565 | int idx_peer = 2; |
5566 | int idx_in_out = 5; | |
5567 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5568 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5569 | argv[idx_in_out]->arg); | |
718e3744 | 5570 | } |
6b0655a2 | 5571 | |
d62a17ae | 5572 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5573 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5574 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5575 | "Filter updates to/from this neighbor\n" | |
5576 | "Name of a prefix list\n" | |
5577 | "Filter incoming updates\n" | |
5578 | "Filter outgoing updates\n") | |
596c17ba | 5579 | |
d62a17ae | 5580 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5581 | safi_t safi, const char *name_str, | |
5582 | const char *direct_str) | |
718e3744 | 5583 | { |
d62a17ae | 5584 | int ret; |
5585 | struct peer *peer; | |
5586 | int direct = FILTER_IN; | |
718e3744 | 5587 | |
d62a17ae | 5588 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5589 | if (!peer) | |
5590 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5591 | |
d62a17ae | 5592 | /* Check filter direction. */ |
5593 | if (strncmp(direct_str, "i", 1) == 0) | |
5594 | direct = FILTER_IN; | |
5595 | else if (strncmp(direct_str, "o", 1) == 0) | |
5596 | direct = FILTER_OUT; | |
718e3744 | 5597 | |
d62a17ae | 5598 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5599 | |
d62a17ae | 5600 | return bgp_vty_return(vty, ret); |
718e3744 | 5601 | } |
5602 | ||
d62a17ae | 5603 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5604 | safi_t safi, const char *direct_str) | |
718e3744 | 5605 | { |
d62a17ae | 5606 | int ret; |
5607 | struct peer *peer; | |
5608 | int direct = FILTER_IN; | |
718e3744 | 5609 | |
d62a17ae | 5610 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5611 | if (!peer) | |
5612 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5613 | |
d62a17ae | 5614 | /* Check filter direction. */ |
5615 | if (strncmp(direct_str, "i", 1) == 0) | |
5616 | direct = FILTER_IN; | |
5617 | else if (strncmp(direct_str, "o", 1) == 0) | |
5618 | direct = FILTER_OUT; | |
718e3744 | 5619 | |
d62a17ae | 5620 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5621 | |
d62a17ae | 5622 | return bgp_vty_return(vty, ret); |
718e3744 | 5623 | } |
5624 | ||
5625 | DEFUN (neighbor_filter_list, | |
5626 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5627 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5628 | NEIGHBOR_STR |
5629 | NEIGHBOR_ADDR_STR2 | |
5630 | "Establish BGP filters\n" | |
5631 | "AS path access-list name\n" | |
5632 | "Filter incoming routes\n" | |
5633 | "Filter outgoing routes\n") | |
5634 | { | |
d62a17ae | 5635 | int idx_peer = 1; |
5636 | int idx_word = 3; | |
5637 | int idx_in_out = 4; | |
5638 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5639 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5640 | argv[idx_in_out]->arg); | |
718e3744 | 5641 | } |
5642 | ||
d62a17ae | 5643 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5644 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5645 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5646 | "Establish BGP filters\n" | |
5647 | "AS path access-list name\n" | |
5648 | "Filter incoming routes\n" | |
5649 | "Filter outgoing routes\n") | |
596c17ba | 5650 | |
718e3744 | 5651 | DEFUN (no_neighbor_filter_list, |
5652 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5654 | NO_STR |
5655 | NEIGHBOR_STR | |
5656 | NEIGHBOR_ADDR_STR2 | |
5657 | "Establish BGP filters\n" | |
5658 | "AS path access-list name\n" | |
5659 | "Filter incoming routes\n" | |
5660 | "Filter outgoing routes\n") | |
5661 | { | |
d62a17ae | 5662 | int idx_peer = 2; |
5663 | int idx_in_out = 5; | |
5664 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5665 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5666 | argv[idx_in_out]->arg); | |
718e3744 | 5667 | } |
6b0655a2 | 5668 | |
d62a17ae | 5669 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5670 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5671 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5672 | "Establish BGP filters\n" | |
5673 | "AS path access-list name\n" | |
5674 | "Filter incoming routes\n" | |
5675 | "Filter outgoing routes\n") | |
596c17ba | 5676 | |
718e3744 | 5677 | /* Set route-map to the peer. */ |
d62a17ae | 5678 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5679 | afi_t afi, safi_t safi, const char *name_str, | |
5680 | const char *direct_str) | |
718e3744 | 5681 | { |
d62a17ae | 5682 | int ret; |
5683 | struct peer *peer; | |
5684 | int direct = RMAP_IN; | |
1de27621 | 5685 | struct route_map *route_map; |
718e3744 | 5686 | |
d62a17ae | 5687 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5688 | if (!peer) | |
5689 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5690 | |
d62a17ae | 5691 | /* Check filter direction. */ |
5692 | if (strncmp(direct_str, "in", 2) == 0) | |
5693 | direct = RMAP_IN; | |
5694 | else if (strncmp(direct_str, "o", 1) == 0) | |
5695 | direct = RMAP_OUT; | |
718e3744 | 5696 | |
1de27621 DA |
5697 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5698 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5699 | |
d62a17ae | 5700 | return bgp_vty_return(vty, ret); |
718e3744 | 5701 | } |
5702 | ||
d62a17ae | 5703 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5704 | afi_t afi, safi_t safi, | |
5705 | const char *direct_str) | |
718e3744 | 5706 | { |
d62a17ae | 5707 | int ret; |
5708 | struct peer *peer; | |
5709 | int direct = RMAP_IN; | |
718e3744 | 5710 | |
d62a17ae | 5711 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5712 | if (!peer) | |
5713 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5714 | |
d62a17ae | 5715 | /* Check filter direction. */ |
5716 | if (strncmp(direct_str, "in", 2) == 0) | |
5717 | direct = RMAP_IN; | |
5718 | else if (strncmp(direct_str, "o", 1) == 0) | |
5719 | direct = RMAP_OUT; | |
718e3744 | 5720 | |
d62a17ae | 5721 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5722 | |
d62a17ae | 5723 | return bgp_vty_return(vty, ret); |
718e3744 | 5724 | } |
5725 | ||
5726 | DEFUN (neighbor_route_map, | |
5727 | neighbor_route_map_cmd, | |
9ccf14f7 | 5728 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5729 | NEIGHBOR_STR |
5730 | NEIGHBOR_ADDR_STR2 | |
5731 | "Apply route map to neighbor\n" | |
5732 | "Name of route map\n" | |
5733 | "Apply map to incoming routes\n" | |
2a3d5731 | 5734 | "Apply map to outbound routes\n") |
718e3744 | 5735 | { |
d62a17ae | 5736 | int idx_peer = 1; |
5737 | int idx_word = 3; | |
5738 | int idx_in_out = 4; | |
5739 | return peer_route_map_set_vty( | |
5740 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5741 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5742 | } |
5743 | ||
d62a17ae | 5744 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5745 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5746 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5747 | "Apply route map to neighbor\n" | |
5748 | "Name of route map\n" | |
5749 | "Apply map to incoming routes\n" | |
5750 | "Apply map to outbound routes\n") | |
596c17ba | 5751 | |
718e3744 | 5752 | DEFUN (no_neighbor_route_map, |
5753 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5755 | NO_STR |
5756 | NEIGHBOR_STR | |
5757 | NEIGHBOR_ADDR_STR2 | |
5758 | "Apply route map to neighbor\n" | |
5759 | "Name of route map\n" | |
5760 | "Apply map to incoming routes\n" | |
2a3d5731 | 5761 | "Apply map to outbound routes\n") |
718e3744 | 5762 | { |
d62a17ae | 5763 | int idx_peer = 2; |
5764 | int idx_in_out = 5; | |
5765 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5766 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5767 | argv[idx_in_out]->arg); | |
718e3744 | 5768 | } |
6b0655a2 | 5769 | |
d62a17ae | 5770 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5772 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5773 | "Apply route map to neighbor\n" | |
5774 | "Name of route map\n" | |
5775 | "Apply map to incoming routes\n" | |
5776 | "Apply map to outbound routes\n") | |
596c17ba | 5777 | |
718e3744 | 5778 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5779 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5780 | afi_t afi, safi_t safi, | |
5781 | const char *name_str) | |
718e3744 | 5782 | { |
d62a17ae | 5783 | int ret; |
5784 | struct peer *peer; | |
1de27621 | 5785 | struct route_map *route_map; |
718e3744 | 5786 | |
d62a17ae | 5787 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5788 | if (!peer) | |
5789 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5790 | |
1de27621 DA |
5791 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5792 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5793 | |
d62a17ae | 5794 | return bgp_vty_return(vty, ret); |
718e3744 | 5795 | } |
5796 | ||
5797 | /* Unset route-map from the peer. */ | |
d62a17ae | 5798 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5799 | afi_t afi, safi_t safi) | |
718e3744 | 5800 | { |
d62a17ae | 5801 | int ret; |
5802 | struct peer *peer; | |
718e3744 | 5803 | |
d62a17ae | 5804 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5805 | if (!peer) | |
5806 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5807 | |
d62a17ae | 5808 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5809 | |
d62a17ae | 5810 | return bgp_vty_return(vty, ret); |
718e3744 | 5811 | } |
5812 | ||
5813 | DEFUN (neighbor_unsuppress_map, | |
5814 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5815 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5816 | NEIGHBOR_STR |
5817 | NEIGHBOR_ADDR_STR2 | |
5818 | "Route-map to selectively unsuppress suppressed routes\n" | |
5819 | "Name of route map\n") | |
5820 | { | |
d62a17ae | 5821 | int idx_peer = 1; |
5822 | int idx_word = 3; | |
5823 | return peer_unsuppress_map_set_vty( | |
5824 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5825 | argv[idx_word]->arg); | |
718e3744 | 5826 | } |
5827 | ||
d62a17ae | 5828 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5829 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5830 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5831 | "Route-map to selectively unsuppress suppressed routes\n" | |
5832 | "Name of route map\n") | |
596c17ba | 5833 | |
718e3744 | 5834 | DEFUN (no_neighbor_unsuppress_map, |
5835 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5837 | NO_STR |
5838 | NEIGHBOR_STR | |
5839 | NEIGHBOR_ADDR_STR2 | |
5840 | "Route-map to selectively unsuppress suppressed routes\n" | |
5841 | "Name of route map\n") | |
5842 | { | |
d62a17ae | 5843 | int idx_peer = 2; |
5844 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5845 | bgp_node_afi(vty), | |
5846 | bgp_node_safi(vty)); | |
718e3744 | 5847 | } |
6b0655a2 | 5848 | |
d62a17ae | 5849 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5850 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5851 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5852 | "Route-map to selectively unsuppress suppressed routes\n" | |
5853 | "Name of route map\n") | |
596c17ba | 5854 | |
d62a17ae | 5855 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5856 | afi_t afi, safi_t safi, | |
5857 | const char *num_str, | |
5858 | const char *threshold_str, int warning, | |
5859 | const char *restart_str) | |
718e3744 | 5860 | { |
d62a17ae | 5861 | int ret; |
5862 | struct peer *peer; | |
d7c0a89a QY |
5863 | uint32_t max; |
5864 | uint8_t threshold; | |
5865 | uint16_t restart; | |
718e3744 | 5866 | |
d62a17ae | 5867 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5868 | if (!peer) | |
5869 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5870 | |
d62a17ae | 5871 | max = strtoul(num_str, NULL, 10); |
5872 | if (threshold_str) | |
5873 | threshold = atoi(threshold_str); | |
5874 | else | |
5875 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5876 | |
d62a17ae | 5877 | if (restart_str) |
5878 | restart = atoi(restart_str); | |
5879 | else | |
5880 | restart = 0; | |
0a486e5f | 5881 | |
d62a17ae | 5882 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5883 | restart); | |
718e3744 | 5884 | |
d62a17ae | 5885 | return bgp_vty_return(vty, ret); |
718e3744 | 5886 | } |
5887 | ||
d62a17ae | 5888 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5889 | afi_t afi, safi_t safi) | |
718e3744 | 5890 | { |
d62a17ae | 5891 | int ret; |
5892 | struct peer *peer; | |
718e3744 | 5893 | |
d62a17ae | 5894 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5895 | if (!peer) | |
5896 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5897 | |
d62a17ae | 5898 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5899 | |
d62a17ae | 5900 | return bgp_vty_return(vty, ret); |
718e3744 | 5901 | } |
5902 | ||
5903 | /* Maximum number of prefix configuration. prefix count is different | |
5904 | for each peer configuration. So this configuration can be set for | |
5905 | each peer configuration. */ | |
5906 | DEFUN (neighbor_maximum_prefix, | |
5907 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5908 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5909 | NEIGHBOR_STR |
5910 | NEIGHBOR_ADDR_STR2 | |
5911 | "Maximum number of prefix accept from this peer\n" | |
5912 | "maximum no. of prefix limit\n") | |
5913 | { | |
d62a17ae | 5914 | int idx_peer = 1; |
5915 | int idx_number = 3; | |
5916 | return peer_maximum_prefix_set_vty( | |
5917 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5918 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5919 | } |
5920 | ||
d62a17ae | 5921 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5922 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5923 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5924 | "Maximum number of prefix accept from this peer\n" | |
5925 | "maximum no. of prefix limit\n") | |
596c17ba | 5926 | |
e0701b79 | 5927 | DEFUN (neighbor_maximum_prefix_threshold, |
5928 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5930 | NEIGHBOR_STR |
5931 | NEIGHBOR_ADDR_STR2 | |
5932 | "Maximum number of prefix accept from this peer\n" | |
5933 | "maximum no. of prefix limit\n" | |
5934 | "Threshold value (%) at which to generate a warning msg\n") | |
5935 | { | |
d62a17ae | 5936 | int idx_peer = 1; |
5937 | int idx_number = 3; | |
5938 | int idx_number_2 = 4; | |
5939 | return peer_maximum_prefix_set_vty( | |
5940 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5941 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5942 | } |
e0701b79 | 5943 | |
d62a17ae | 5944 | ALIAS_HIDDEN( |
5945 | neighbor_maximum_prefix_threshold, | |
5946 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5947 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5948 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5949 | "Maximum number of prefix accept from this peer\n" | |
5950 | "maximum no. of prefix limit\n" | |
5951 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5952 | |
718e3744 | 5953 | DEFUN (neighbor_maximum_prefix_warning, |
5954 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5955 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5956 | NEIGHBOR_STR |
5957 | NEIGHBOR_ADDR_STR2 | |
5958 | "Maximum number of prefix accept from this peer\n" | |
5959 | "maximum no. of prefix limit\n" | |
5960 | "Only give warning message when limit is exceeded\n") | |
5961 | { | |
d62a17ae | 5962 | int idx_peer = 1; |
5963 | int idx_number = 3; | |
5964 | return peer_maximum_prefix_set_vty( | |
5965 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5966 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5967 | } |
5968 | ||
d62a17ae | 5969 | ALIAS_HIDDEN( |
5970 | neighbor_maximum_prefix_warning, | |
5971 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5972 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5973 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5974 | "Maximum number of prefix accept from this peer\n" | |
5975 | "maximum no. of prefix limit\n" | |
5976 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5977 | |
e0701b79 | 5978 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5979 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5980 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5981 | NEIGHBOR_STR |
5982 | NEIGHBOR_ADDR_STR2 | |
5983 | "Maximum number of prefix accept from this peer\n" | |
5984 | "maximum no. of prefix limit\n" | |
5985 | "Threshold value (%) at which to generate a warning msg\n" | |
5986 | "Only give warning message when limit is exceeded\n") | |
5987 | { | |
d62a17ae | 5988 | int idx_peer = 1; |
5989 | int idx_number = 3; | |
5990 | int idx_number_2 = 4; | |
5991 | return peer_maximum_prefix_set_vty( | |
5992 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5993 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5994 | } |
5995 | ||
d62a17ae | 5996 | ALIAS_HIDDEN( |
5997 | neighbor_maximum_prefix_threshold_warning, | |
5998 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5999 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6000 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6001 | "Maximum number of prefix accept from this peer\n" | |
6002 | "maximum no. of prefix limit\n" | |
6003 | "Threshold value (%) at which to generate a warning msg\n" | |
6004 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6005 | |
0a486e5f | 6006 | DEFUN (neighbor_maximum_prefix_restart, |
6007 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6008 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6009 | NEIGHBOR_STR |
6010 | NEIGHBOR_ADDR_STR2 | |
6011 | "Maximum number of prefix accept from this peer\n" | |
6012 | "maximum no. of prefix limit\n" | |
6013 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6014 | "Restart interval in minutes\n") |
0a486e5f | 6015 | { |
d62a17ae | 6016 | int idx_peer = 1; |
6017 | int idx_number = 3; | |
6018 | int idx_number_2 = 5; | |
6019 | return peer_maximum_prefix_set_vty( | |
6020 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6021 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6022 | } |
6023 | ||
d62a17ae | 6024 | ALIAS_HIDDEN( |
6025 | neighbor_maximum_prefix_restart, | |
6026 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6027 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6028 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6029 | "Maximum number of prefix accept from this peer\n" | |
6030 | "maximum no. of prefix limit\n" | |
6031 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6032 | "Restart interval in minutes\n") |
596c17ba | 6033 | |
0a486e5f | 6034 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6035 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6036 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6037 | NEIGHBOR_STR |
6038 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6039 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6040 | "maximum no. of prefix limit\n" |
6041 | "Threshold value (%) at which to generate a warning msg\n" | |
6042 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6043 | "Restart interval in minutes\n") |
0a486e5f | 6044 | { |
d62a17ae | 6045 | int idx_peer = 1; |
6046 | int idx_number = 3; | |
6047 | int idx_number_2 = 4; | |
6048 | int idx_number_3 = 6; | |
6049 | return peer_maximum_prefix_set_vty( | |
6050 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6051 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6052 | argv[idx_number_3]->arg); | |
6053 | } | |
6054 | ||
6055 | ALIAS_HIDDEN( | |
6056 | neighbor_maximum_prefix_threshold_restart, | |
6057 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6058 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6059 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6060 | "Maximum number of prefixes to accept from this peer\n" | |
6061 | "maximum no. of prefix limit\n" | |
6062 | "Threshold value (%) at which to generate a warning msg\n" | |
6063 | "Restart bgp connection after limit is exceeded\n" | |
6064 | "Restart interval in minutes\n") | |
596c17ba | 6065 | |
718e3744 | 6066 | DEFUN (no_neighbor_maximum_prefix, |
6067 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6068 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6069 | NO_STR |
6070 | NEIGHBOR_STR | |
6071 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6072 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6073 | "maximum no. of prefix limit\n" |
6074 | "Threshold value (%) at which to generate a warning msg\n" | |
6075 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6076 | "Restart interval in minutes\n" |
31500417 | 6077 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6078 | { |
d62a17ae | 6079 | int idx_peer = 2; |
6080 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6081 | bgp_node_afi(vty), | |
6082 | bgp_node_safi(vty)); | |
718e3744 | 6083 | } |
e52702f2 | 6084 | |
d62a17ae | 6085 | ALIAS_HIDDEN( |
6086 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6087 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6088 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6089 | "Maximum number of prefixes to accept from this peer\n" | |
6090 | "maximum no. of prefix limit\n" | |
6091 | "Threshold value (%) at which to generate a warning msg\n" | |
6092 | "Restart bgp connection after limit is exceeded\n" | |
6093 | "Restart interval in minutes\n" | |
6094 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6095 | |
718e3744 | 6096 | |
718e3744 | 6097 | /* "neighbor allowas-in" */ |
6098 | DEFUN (neighbor_allowas_in, | |
6099 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6100 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6101 | NEIGHBOR_STR |
6102 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6103 | "Accept as-path with my AS present in it\n" |
0437e105 | 6104 | "Number of occurences of AS number\n" |
fd8503f5 | 6105 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6106 | { |
d62a17ae | 6107 | int idx_peer = 1; |
6108 | int idx_number_origin = 3; | |
6109 | int ret; | |
6110 | int origin = 0; | |
6111 | struct peer *peer; | |
6112 | int allow_num = 0; | |
6113 | ||
6114 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6115 | if (!peer) | |
6116 | return CMD_WARNING_CONFIG_FAILED; | |
6117 | ||
6118 | if (argc <= idx_number_origin) | |
6119 | allow_num = 3; | |
6120 | else { | |
6121 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6122 | origin = 1; | |
6123 | else | |
6124 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6125 | } | |
6126 | ||
6127 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6128 | allow_num, origin); | |
6129 | ||
6130 | return bgp_vty_return(vty, ret); | |
6131 | } | |
6132 | ||
6133 | ALIAS_HIDDEN( | |
6134 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6135 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6136 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6137 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6138 | "Number of occurences of AS number\n" |
d62a17ae | 6139 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6140 | |
718e3744 | 6141 | DEFUN (no_neighbor_allowas_in, |
6142 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6144 | NO_STR |
6145 | NEIGHBOR_STR | |
6146 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6147 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6148 | "Number of occurences of AS number\n" |
fd8503f5 | 6149 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6150 | { |
d62a17ae | 6151 | int idx_peer = 2; |
6152 | int ret; | |
6153 | struct peer *peer; | |
718e3744 | 6154 | |
d62a17ae | 6155 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6156 | if (!peer) | |
6157 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6158 | |
d62a17ae | 6159 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6160 | bgp_node_safi(vty)); | |
718e3744 | 6161 | |
d62a17ae | 6162 | return bgp_vty_return(vty, ret); |
718e3744 | 6163 | } |
6b0655a2 | 6164 | |
d62a17ae | 6165 | ALIAS_HIDDEN( |
6166 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6168 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6169 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6170 | "Number of occurences of AS number\n" |
d62a17ae | 6171 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6172 | |
fa411a21 NH |
6173 | DEFUN (neighbor_ttl_security, |
6174 | neighbor_ttl_security_cmd, | |
7ebe625c | 6175 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6176 | NEIGHBOR_STR |
7ebe625c | 6177 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6178 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6179 | "Specify the maximum number of hops to the BGP peer\n" |
6180 | "Number of hops to BGP peer\n") | |
fa411a21 | 6181 | { |
d62a17ae | 6182 | int idx_peer = 1; |
6183 | int idx_number = 4; | |
6184 | struct peer *peer; | |
6185 | int gtsm_hops; | |
6186 | ||
6187 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6188 | if (!peer) | |
6189 | return CMD_WARNING_CONFIG_FAILED; | |
6190 | ||
6191 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6192 | ||
7ebe625c QY |
6193 | /* |
6194 | * If 'neighbor swpX', then this is for directly connected peers, | |
6195 | * we should not accept a ttl-security hops value greater than 1. | |
6196 | */ | |
6197 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6198 | vty_out(vty, | |
6199 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6200 | argv[idx_peer]->arg); | |
6201 | return CMD_WARNING_CONFIG_FAILED; | |
6202 | } | |
6203 | ||
d62a17ae | 6204 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6205 | } |
6206 | ||
6207 | DEFUN (no_neighbor_ttl_security, | |
6208 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6209 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6210 | NO_STR |
6211 | NEIGHBOR_STR | |
7ebe625c | 6212 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6213 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6214 | "Specify the maximum number of hops to the BGP peer\n" |
6215 | "Number of hops to BGP peer\n") | |
fa411a21 | 6216 | { |
d62a17ae | 6217 | int idx_peer = 2; |
6218 | struct peer *peer; | |
fa411a21 | 6219 | |
d62a17ae | 6220 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6221 | if (!peer) | |
6222 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6223 | |
d62a17ae | 6224 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6225 | } |
6b0655a2 | 6226 | |
adbac85e DW |
6227 | DEFUN (neighbor_addpath_tx_all_paths, |
6228 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6229 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6230 | NEIGHBOR_STR |
6231 | NEIGHBOR_ADDR_STR2 | |
6232 | "Use addpath to advertise all paths to a neighbor\n") | |
6233 | { | |
d62a17ae | 6234 | int idx_peer = 1; |
6235 | struct peer *peer; | |
adbac85e | 6236 | |
d62a17ae | 6237 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6238 | if (!peer) | |
6239 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6240 | |
dcc68b5e MS |
6241 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6242 | BGP_ADDPATH_ALL); | |
6243 | return CMD_SUCCESS; | |
adbac85e DW |
6244 | } |
6245 | ||
d62a17ae | 6246 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6247 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6248 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6249 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6250 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6251 | |
adbac85e DW |
6252 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6253 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6255 | NO_STR |
6256 | NEIGHBOR_STR | |
6257 | NEIGHBOR_ADDR_STR2 | |
6258 | "Use addpath to advertise all paths to a neighbor\n") | |
6259 | { | |
d62a17ae | 6260 | int idx_peer = 2; |
dcc68b5e MS |
6261 | struct peer *peer; |
6262 | ||
6263 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6264 | if (!peer) | |
6265 | return CMD_WARNING_CONFIG_FAILED; | |
6266 | ||
6267 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6268 | != BGP_ADDPATH_ALL) { | |
6269 | vty_out(vty, | |
6270 | "%% Peer not currently configured to transmit all paths."); | |
6271 | return CMD_WARNING_CONFIG_FAILED; | |
6272 | } | |
6273 | ||
6274 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6275 | BGP_ADDPATH_NONE); | |
6276 | ||
6277 | return CMD_SUCCESS; | |
adbac85e DW |
6278 | } |
6279 | ||
d62a17ae | 6280 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6281 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6282 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6283 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6284 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6285 | |
06370dac DW |
6286 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6287 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6288 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6289 | NEIGHBOR_STR |
6290 | NEIGHBOR_ADDR_STR2 | |
6291 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6292 | { | |
d62a17ae | 6293 | int idx_peer = 1; |
6294 | struct peer *peer; | |
06370dac | 6295 | |
d62a17ae | 6296 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6297 | if (!peer) | |
6298 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6299 | |
dcc68b5e MS |
6300 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6301 | BGP_ADDPATH_BEST_PER_AS); | |
6302 | ||
6303 | return CMD_SUCCESS; | |
06370dac DW |
6304 | } |
6305 | ||
d62a17ae | 6306 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6307 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6308 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6309 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6310 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6311 | |
06370dac DW |
6312 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6313 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6314 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6315 | NO_STR |
6316 | NEIGHBOR_STR | |
6317 | NEIGHBOR_ADDR_STR2 | |
6318 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6319 | { | |
d62a17ae | 6320 | int idx_peer = 2; |
dcc68b5e MS |
6321 | struct peer *peer; |
6322 | ||
6323 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6324 | if (!peer) | |
6325 | return CMD_WARNING_CONFIG_FAILED; | |
6326 | ||
6327 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6328 | != BGP_ADDPATH_BEST_PER_AS) { | |
6329 | vty_out(vty, | |
6330 | "%% Peer not currently configured to transmit all best path per as."); | |
6331 | return CMD_WARNING_CONFIG_FAILED; | |
6332 | } | |
6333 | ||
6334 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6335 | BGP_ADDPATH_NONE); | |
6336 | ||
6337 | return CMD_SUCCESS; | |
06370dac DW |
6338 | } |
6339 | ||
d62a17ae | 6340 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6341 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6342 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6343 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6344 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6345 | |
b9c7bc5a PZ |
6346 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6347 | struct ecommunity **list) | |
ddb5b488 | 6348 | { |
b9c7bc5a PZ |
6349 | struct ecommunity *ecom = NULL; |
6350 | struct ecommunity *ecomadd; | |
ddb5b488 | 6351 | |
b9c7bc5a | 6352 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6353 | |
b9c7bc5a PZ |
6354 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6355 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6356 | if (!ecomadd) { | |
6357 | vty_out(vty, "Malformed community-list value\n"); | |
6358 | if (ecom) | |
6359 | ecommunity_free(&ecom); | |
6360 | return CMD_WARNING_CONFIG_FAILED; | |
6361 | } | |
ddb5b488 | 6362 | |
b9c7bc5a PZ |
6363 | if (ecom) { |
6364 | ecommunity_merge(ecom, ecomadd); | |
6365 | ecommunity_free(&ecomadd); | |
6366 | } else { | |
6367 | ecom = ecomadd; | |
6368 | } | |
6369 | } | |
6370 | ||
6371 | if (*list) { | |
6372 | ecommunity_free(&*list); | |
ddb5b488 | 6373 | } |
b9c7bc5a PZ |
6374 | *list = ecom; |
6375 | ||
6376 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6377 | } |
6378 | ||
0ca70ba5 DS |
6379 | /* |
6380 | * v2vimport is true if we are handling a `import vrf ...` command | |
6381 | */ | |
6382 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6383 | { |
0ca70ba5 DS |
6384 | afi_t afi; |
6385 | ||
ddb5b488 | 6386 | switch (vty->node) { |
b9c7bc5a | 6387 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6388 | afi = AFI_IP; |
6389 | break; | |
b9c7bc5a | 6390 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6391 | afi = AFI_IP6; |
6392 | break; | |
ddb5b488 PZ |
6393 | default: |
6394 | vty_out(vty, | |
b9c7bc5a | 6395 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6396 | return AFI_MAX; |
ddb5b488 | 6397 | } |
69b07479 | 6398 | |
0ca70ba5 DS |
6399 | if (!v2vimport) { |
6400 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6401 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6402 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6403 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6404 | vty_out(vty, | |
6405 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6406 | return AFI_MAX; | |
6407 | } | |
6408 | } else { | |
6409 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6410 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6411 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6412 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6413 | vty_out(vty, | |
6414 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6415 | return AFI_MAX; | |
6416 | } | |
6417 | } | |
6418 | return afi; | |
ddb5b488 PZ |
6419 | } |
6420 | ||
b9c7bc5a PZ |
6421 | DEFPY (af_rd_vpn_export, |
6422 | af_rd_vpn_export_cmd, | |
6423 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6424 | NO_STR | |
ddb5b488 | 6425 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6426 | "Between current address-family and vpn\n" |
6427 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6428 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6429 | { | |
6430 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6431 | struct prefix_rd prd; | |
6432 | int ret; | |
ddb5b488 | 6433 | afi_t afi; |
b9c7bc5a PZ |
6434 | int idx = 0; |
6435 | int yes = 1; | |
ddb5b488 | 6436 | |
b9c7bc5a | 6437 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6438 | yes = 0; |
b9c7bc5a PZ |
6439 | |
6440 | if (yes) { | |
6441 | ret = str2prefix_rd(rd_str, &prd); | |
6442 | if (!ret) { | |
6443 | vty_out(vty, "%% Malformed rd\n"); | |
6444 | return CMD_WARNING_CONFIG_FAILED; | |
6445 | } | |
ddb5b488 PZ |
6446 | } |
6447 | ||
0ca70ba5 | 6448 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6449 | if (afi == AFI_MAX) |
6450 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6451 | |
69b07479 DS |
6452 | /* |
6453 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6454 | */ | |
6455 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6456 | bgp_get_default(), bgp); | |
ddb5b488 | 6457 | |
69b07479 DS |
6458 | if (yes) { |
6459 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6460 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6461 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6462 | } else { | |
6463 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6464 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6465 | } |
6466 | ||
69b07479 DS |
6467 | /* post-change: re-export vpn routes */ |
6468 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6469 | bgp_get_default(), bgp); | |
6470 | ||
ddb5b488 PZ |
6471 | return CMD_SUCCESS; |
6472 | } | |
6473 | ||
b9c7bc5a PZ |
6474 | ALIAS (af_rd_vpn_export, |
6475 | af_no_rd_vpn_export_cmd, | |
6476 | "no rd vpn export", | |
ddb5b488 | 6477 | NO_STR |
b9c7bc5a PZ |
6478 | "Specify route distinguisher\n" |
6479 | "Between current address-family and vpn\n" | |
6480 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6481 | |
b9c7bc5a PZ |
6482 | DEFPY (af_label_vpn_export, |
6483 | af_label_vpn_export_cmd, | |
e70e9f8e | 6484 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6485 | NO_STR |
ddb5b488 | 6486 | "label value for VRF\n" |
b9c7bc5a PZ |
6487 | "Between current address-family and vpn\n" |
6488 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6489 | "Label Value <0-1048575>\n" |
6490 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6491 | { |
6492 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6493 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6494 | afi_t afi; |
b9c7bc5a PZ |
6495 | int idx = 0; |
6496 | int yes = 1; | |
6497 | ||
6498 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6499 | yes = 0; |
ddb5b488 | 6500 | |
21a16cc2 PZ |
6501 | /* If "no ...", squash trailing parameter */ |
6502 | if (!yes) | |
6503 | label_auto = NULL; | |
6504 | ||
e70e9f8e PZ |
6505 | if (yes) { |
6506 | if (!label_auto) | |
6507 | label = label_val; /* parser should force unsigned */ | |
6508 | } | |
ddb5b488 | 6509 | |
0ca70ba5 | 6510 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6511 | if (afi == AFI_MAX) |
6512 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6513 | |
e70e9f8e | 6514 | |
69b07479 DS |
6515 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6516 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6517 | /* no change */ | |
6518 | return CMD_SUCCESS; | |
e70e9f8e | 6519 | |
69b07479 DS |
6520 | /* |
6521 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6522 | */ | |
6523 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6524 | bgp_get_default(), bgp); | |
6525 | ||
6526 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6527 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6528 | ||
6529 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6530 | ||
6531 | /* | |
6532 | * label has previously been automatically | |
6533 | * assigned by labelpool: release it | |
6534 | * | |
6535 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6536 | * means the automatic assignment is in flight | |
6537 | * and therefore the labelpool callback must | |
6538 | * detect that the auto label is not needed. | |
6539 | */ | |
6540 | ||
6541 | bgp_lp_release(LP_TYPE_VRF, | |
6542 | &bgp->vpn_policy[afi], | |
6543 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6544 | } |
69b07479 DS |
6545 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6546 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6547 | } | |
ddb5b488 | 6548 | |
69b07479 DS |
6549 | bgp->vpn_policy[afi].tovpn_label = label; |
6550 | if (label_auto) { | |
6551 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6552 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6553 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6554 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6555 | } |
6556 | ||
69b07479 DS |
6557 | /* post-change: re-export vpn routes */ |
6558 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6559 | bgp_get_default(), bgp); | |
6560 | ||
ddb5b488 PZ |
6561 | return CMD_SUCCESS; |
6562 | } | |
6563 | ||
b9c7bc5a PZ |
6564 | ALIAS (af_label_vpn_export, |
6565 | af_no_label_vpn_export_cmd, | |
6566 | "no label vpn export", | |
6567 | NO_STR | |
6568 | "label value for VRF\n" | |
6569 | "Between current address-family and vpn\n" | |
6570 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6571 | |
b9c7bc5a PZ |
6572 | DEFPY (af_nexthop_vpn_export, |
6573 | af_nexthop_vpn_export_cmd, | |
6574 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6575 | NO_STR | |
ddb5b488 | 6576 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6577 | "Between current address-family and vpn\n" |
6578 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6579 | "IPv4 prefix\n" |
6580 | "IPv6 prefix\n") | |
6581 | { | |
6582 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6583 | afi_t afi; |
ddb5b488 | 6584 | struct prefix p; |
b9c7bc5a PZ |
6585 | int idx = 0; |
6586 | int yes = 1; | |
ddb5b488 | 6587 | |
b9c7bc5a | 6588 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6589 | yes = 0; |
b9c7bc5a PZ |
6590 | |
6591 | if (yes) { | |
6592 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6593 | return CMD_WARNING_CONFIG_FAILED; | |
6594 | } | |
ddb5b488 | 6595 | |
0ca70ba5 | 6596 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6597 | if (afi == AFI_MAX) |
6598 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6599 | |
69b07479 DS |
6600 | /* |
6601 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6602 | */ | |
6603 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6604 | bgp_get_default(), bgp); | |
ddb5b488 | 6605 | |
69b07479 DS |
6606 | if (yes) { |
6607 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6608 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6609 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6610 | } else { | |
6611 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6612 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6613 | } |
6614 | ||
69b07479 DS |
6615 | /* post-change: re-export vpn routes */ |
6616 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6617 | bgp_get_default(), bgp); | |
6618 | ||
ddb5b488 PZ |
6619 | return CMD_SUCCESS; |
6620 | } | |
6621 | ||
b9c7bc5a PZ |
6622 | ALIAS (af_nexthop_vpn_export, |
6623 | af_no_nexthop_vpn_export_cmd, | |
6624 | "no nexthop vpn export", | |
ddb5b488 | 6625 | NO_STR |
b9c7bc5a PZ |
6626 | "Specify next hop to use for VRF advertised prefixes\n" |
6627 | "Between current address-family and vpn\n" | |
6628 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6629 | |
b9c7bc5a | 6630 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6631 | { |
b9c7bc5a PZ |
6632 | if (!strcmp(dstr, "import")) { |
6633 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6634 | } else if (!strcmp(dstr, "export")) { | |
6635 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6636 | } else if (!strcmp(dstr, "both")) { | |
6637 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6638 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6639 | } else { | |
6640 | vty_out(vty, "%% direction parse error\n"); | |
6641 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6642 | } |
ddb5b488 PZ |
6643 | return CMD_SUCCESS; |
6644 | } | |
6645 | ||
b9c7bc5a PZ |
6646 | DEFPY (af_rt_vpn_imexport, |
6647 | af_rt_vpn_imexport_cmd, | |
6648 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6649 | NO_STR | |
6650 | "Specify route target list\n" | |
ddb5b488 | 6651 | "Specify route target list\n" |
b9c7bc5a PZ |
6652 | "Between current address-family and vpn\n" |
6653 | "For routes leaked from vpn to current address-family: match any\n" | |
6654 | "For routes leaked from current address-family to vpn: set\n" | |
6655 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6656 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6657 | { | |
6658 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6659 | int ret; | |
6660 | struct ecommunity *ecom = NULL; | |
6661 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6662 | vpn_policy_direction_t dir; |
6663 | afi_t afi; | |
6664 | int idx = 0; | |
b9c7bc5a | 6665 | int yes = 1; |
ddb5b488 | 6666 | |
b9c7bc5a | 6667 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6668 | yes = 0; |
b9c7bc5a | 6669 | |
0ca70ba5 | 6670 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6671 | if (afi == AFI_MAX) |
6672 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6673 | |
b9c7bc5a | 6674 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6675 | if (ret != CMD_SUCCESS) |
6676 | return ret; | |
6677 | ||
b9c7bc5a PZ |
6678 | if (yes) { |
6679 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6680 | vty_out(vty, "%% Missing RTLIST\n"); | |
6681 | return CMD_WARNING_CONFIG_FAILED; | |
6682 | } | |
6683 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6684 | if (ret != CMD_SUCCESS) { | |
6685 | return ret; | |
6686 | } | |
ddb5b488 PZ |
6687 | } |
6688 | ||
69b07479 DS |
6689 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6690 | if (!dodir[dir]) | |
ddb5b488 | 6691 | continue; |
ddb5b488 | 6692 | |
69b07479 | 6693 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6694 | |
69b07479 DS |
6695 | if (yes) { |
6696 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6697 | ecommunity_free( | |
6698 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6699 | bgp->vpn_policy[afi].rtlist[dir] = | |
6700 | ecommunity_dup(ecom); | |
6701 | } else { | |
6702 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6703 | ecommunity_free( | |
6704 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6705 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6706 | } |
69b07479 DS |
6707 | |
6708 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6709 | } |
69b07479 | 6710 | |
d555f3e9 PZ |
6711 | if (ecom) |
6712 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6713 | |
6714 | return CMD_SUCCESS; | |
6715 | } | |
6716 | ||
b9c7bc5a PZ |
6717 | ALIAS (af_rt_vpn_imexport, |
6718 | af_no_rt_vpn_imexport_cmd, | |
6719 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6720 | NO_STR |
6721 | "Specify route target list\n" | |
b9c7bc5a PZ |
6722 | "Specify route target list\n" |
6723 | "Between current address-family and vpn\n" | |
6724 | "For routes leaked from vpn to current address-family\n" | |
6725 | "For routes leaked from current address-family to vpn\n" | |
6726 | "both import and export\n") | |
6727 | ||
6728 | DEFPY (af_route_map_vpn_imexport, | |
6729 | af_route_map_vpn_imexport_cmd, | |
6730 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6731 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6732 | NO_STR | |
ddb5b488 | 6733 | "Specify route map\n" |
b9c7bc5a PZ |
6734 | "Between current address-family and vpn\n" |
6735 | "For routes leaked from vpn to current address-family\n" | |
6736 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6737 | "name of route-map\n") |
6738 | { | |
6739 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6740 | int ret; | |
6741 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6742 | vpn_policy_direction_t dir; |
6743 | afi_t afi; | |
ddb5b488 | 6744 | int idx = 0; |
b9c7bc5a | 6745 | int yes = 1; |
ddb5b488 | 6746 | |
b9c7bc5a | 6747 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6748 | yes = 0; |
b9c7bc5a | 6749 | |
0ca70ba5 | 6750 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6751 | if (afi == AFI_MAX) |
6752 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6753 | |
b9c7bc5a | 6754 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6755 | if (ret != CMD_SUCCESS) |
6756 | return ret; | |
6757 | ||
69b07479 DS |
6758 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6759 | if (!dodir[dir]) | |
ddb5b488 | 6760 | continue; |
ddb5b488 | 6761 | |
69b07479 | 6762 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6763 | |
69b07479 DS |
6764 | if (yes) { |
6765 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6766 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6767 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6768 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6769 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6770 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6771 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6772 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6773 | return CMD_SUCCESS; | |
6774 | } else { | |
6775 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6776 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6777 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6778 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6779 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6780 | } |
69b07479 DS |
6781 | |
6782 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6783 | } |
6784 | ||
6785 | return CMD_SUCCESS; | |
6786 | } | |
6787 | ||
b9c7bc5a PZ |
6788 | ALIAS (af_route_map_vpn_imexport, |
6789 | af_no_route_map_vpn_imexport_cmd, | |
6790 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6791 | NO_STR |
6792 | "Specify route map\n" | |
b9c7bc5a PZ |
6793 | "Between current address-family and vpn\n" |
6794 | "For routes leaked from vpn to current address-family\n" | |
6795 | "For routes leaked from current address-family to vpn\n") | |
6796 | ||
bb4f6190 DS |
6797 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6798 | "[no] import vrf route-map RMAP$rmap_str", | |
6799 | NO_STR | |
6800 | "Import routes from another VRF\n" | |
6801 | "Vrf routes being filtered\n" | |
6802 | "Specify route map\n" | |
6803 | "name of route-map\n") | |
6804 | { | |
6805 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6806 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6807 | afi_t afi; | |
6808 | int idx = 0; | |
6809 | int yes = 1; | |
6810 | struct bgp *bgp_default; | |
6811 | ||
6812 | if (argv_find(argv, argc, "no", &idx)) | |
6813 | yes = 0; | |
6814 | ||
0ca70ba5 | 6815 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6816 | if (afi == AFI_MAX) |
6817 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6818 | |
6819 | bgp_default = bgp_get_default(); | |
6820 | if (!bgp_default) { | |
6821 | int32_t ret; | |
6822 | as_t as = bgp->as; | |
6823 | ||
6824 | /* Auto-create assuming the same AS */ | |
6825 | ret = bgp_get(&bgp_default, &as, NULL, | |
6826 | BGP_INSTANCE_TYPE_DEFAULT); | |
6827 | ||
6828 | if (ret) { | |
6829 | vty_out(vty, | |
6830 | "VRF default is not configured as a bgp instance\n"); | |
6831 | return CMD_WARNING; | |
6832 | } | |
6833 | } | |
6834 | ||
69b07479 | 6835 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6836 | |
69b07479 DS |
6837 | if (yes) { |
6838 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6839 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6840 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6841 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6842 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6843 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6844 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6845 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6846 | return CMD_SUCCESS; | |
6847 | } else { | |
6848 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6849 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6850 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6851 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6852 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6853 | } |
6854 | ||
69b07479 DS |
6855 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6856 | ||
bb4f6190 DS |
6857 | return CMD_SUCCESS; |
6858 | } | |
6859 | ||
6860 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6861 | "no import vrf route-map", | |
6862 | NO_STR | |
6863 | "Import routes from another VRF\n" | |
6864 | "Vrf routes being filtered\n" | |
6865 | "Specify route map\n") | |
6866 | ||
4d1b335c DA |
6867 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6868 | "[no] import vrf VIEWVRFNAME$import_name", | |
6869 | NO_STR | |
6870 | "Import routes from another VRF\n" | |
6871 | "VRF to import from\n" | |
6872 | "The name of the VRF\n") | |
12a844a5 DS |
6873 | { |
6874 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6875 | struct listnode *node; | |
79ef8664 DS |
6876 | struct bgp *vrf_bgp, *bgp_default; |
6877 | int32_t ret = 0; | |
6878 | as_t as = bgp->as; | |
12a844a5 DS |
6879 | bool remove = false; |
6880 | int32_t idx = 0; | |
6881 | char *vname; | |
a8dadcf6 | 6882 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6883 | safi_t safi; |
6884 | afi_t afi; | |
6885 | ||
867f0cca | 6886 | if (import_name == NULL) { |
6887 | vty_out(vty, "%% Missing import name\n"); | |
6888 | return CMD_WARNING; | |
6889 | } | |
6890 | ||
12a844a5 DS |
6891 | if (argv_find(argv, argc, "no", &idx)) |
6892 | remove = true; | |
6893 | ||
0ca70ba5 DS |
6894 | afi = vpn_policy_getafi(vty, bgp, true); |
6895 | if (afi == AFI_MAX) | |
6896 | return CMD_WARNING_CONFIG_FAILED; | |
6897 | ||
12a844a5 DS |
6898 | safi = bgp_node_safi(vty); |
6899 | ||
25679caa | 6900 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6901 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6902 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6903 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6904 | remove ? "unimport" : "import", import_name); | |
6905 | return CMD_WARNING; | |
6906 | } | |
6907 | ||
79ef8664 DS |
6908 | bgp_default = bgp_get_default(); |
6909 | if (!bgp_default) { | |
6910 | /* Auto-create assuming the same AS */ | |
6911 | ret = bgp_get(&bgp_default, &as, NULL, | |
6912 | BGP_INSTANCE_TYPE_DEFAULT); | |
6913 | ||
6914 | if (ret) { | |
6915 | vty_out(vty, | |
6916 | "VRF default is not configured as a bgp instance\n"); | |
6917 | return CMD_WARNING; | |
6918 | } | |
6919 | } | |
6920 | ||
12a844a5 DS |
6921 | vrf_bgp = bgp_lookup_by_name(import_name); |
6922 | if (!vrf_bgp) { | |
5742e42b | 6923 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6924 | vrf_bgp = bgp_default; |
6925 | else | |
0fb8d6e6 DS |
6926 | /* Auto-create assuming the same AS */ |
6927 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6928 | |
6e2c7fe6 | 6929 | if (ret) { |
020a3f60 DS |
6930 | vty_out(vty, |
6931 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6932 | import_name); |
6933 | return CMD_WARNING; | |
6934 | } | |
12a844a5 DS |
6935 | } |
6936 | ||
12a844a5 | 6937 | if (remove) { |
44338987 | 6938 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6939 | } else { |
44338987 | 6940 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6941 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6942 | vname)) { | |
6943 | if (strcmp(vname, import_name) == 0) | |
6944 | return CMD_WARNING; | |
6945 | } | |
6946 | ||
44338987 | 6947 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6948 | } |
6949 | ||
6950 | return CMD_SUCCESS; | |
6951 | } | |
6952 | ||
b9c7bc5a PZ |
6953 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6954 | DEFPY (bgp_imexport_vpn, | |
6955 | bgp_imexport_vpn_cmd, | |
6956 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6957 | NO_STR |
6958 | "Import routes to this address-family\n" | |
6959 | "Export routes from this address-family\n" | |
6960 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6961 | { |
6962 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6963 | int previous_state; |
ddb5b488 | 6964 | afi_t afi; |
b9c7bc5a | 6965 | safi_t safi; |
ddb5b488 | 6966 | int idx = 0; |
b9c7bc5a PZ |
6967 | int yes = 1; |
6968 | int flag; | |
6969 | vpn_policy_direction_t dir; | |
ddb5b488 | 6970 | |
b9c7bc5a | 6971 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6972 | yes = 0; |
ddb5b488 | 6973 | |
b9c7bc5a PZ |
6974 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6975 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6976 | |
b9c7bc5a PZ |
6977 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6978 | return CMD_WARNING_CONFIG_FAILED; | |
6979 | } | |
ddb5b488 | 6980 | |
b9c7bc5a PZ |
6981 | afi = bgp_node_afi(vty); |
6982 | safi = bgp_node_safi(vty); | |
6983 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6984 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6985 | return CMD_WARNING_CONFIG_FAILED; | |
6986 | } | |
ddb5b488 | 6987 | |
b9c7bc5a PZ |
6988 | if (!strcmp(direction_str, "import")) { |
6989 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6990 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6991 | } else if (!strcmp(direction_str, "export")) { | |
6992 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6993 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6994 | } else { | |
6995 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6996 | return CMD_WARNING_CONFIG_FAILED; | |
6997 | } | |
6998 | ||
6999 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7000 | |
b9c7bc5a PZ |
7001 | if (yes) { |
7002 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7003 | if (!previous_state) { | |
7004 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7005 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7006 | } | |
b9c7bc5a PZ |
7007 | } else { |
7008 | if (previous_state) { | |
7009 | /* trigger un-export current vrf */ | |
7010 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7011 | } | |
7012 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7013 | } |
7014 | ||
7015 | return CMD_SUCCESS; | |
7016 | } | |
7017 | ||
301ad80a PG |
7018 | DEFPY (af_routetarget_import, |
7019 | af_routetarget_import_cmd, | |
7020 | "[no] <rt|route-target> redirect import RTLIST...", | |
7021 | NO_STR | |
7022 | "Specify route target list\n" | |
7023 | "Specify route target list\n" | |
7024 | "Flow-spec redirect type route target\n" | |
7025 | "Import routes to this address-family\n" | |
7026 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7027 | { | |
7028 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7029 | int ret; | |
7030 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7031 | afi_t afi; |
7032 | int idx = 0; | |
7033 | int yes = 1; | |
7034 | ||
7035 | if (argv_find(argv, argc, "no", &idx)) | |
7036 | yes = 0; | |
7037 | ||
0ca70ba5 | 7038 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7039 | if (afi == AFI_MAX) |
7040 | return CMD_WARNING_CONFIG_FAILED; | |
7041 | ||
301ad80a PG |
7042 | if (yes) { |
7043 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7044 | vty_out(vty, "%% Missing RTLIST\n"); | |
7045 | return CMD_WARNING_CONFIG_FAILED; | |
7046 | } | |
7047 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7048 | if (ret != CMD_SUCCESS) | |
7049 | return ret; | |
7050 | } | |
69b07479 DS |
7051 | |
7052 | if (yes) { | |
7053 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7054 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7055 | .import_redirect_rtlist); |
69b07479 DS |
7056 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7057 | ecommunity_dup(ecom); | |
7058 | } else { | |
7059 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7060 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7061 | .import_redirect_rtlist); |
69b07479 | 7062 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7063 | } |
69b07479 | 7064 | |
301ad80a PG |
7065 | if (ecom) |
7066 | ecommunity_free(&ecom); | |
7067 | ||
7068 | return CMD_SUCCESS; | |
7069 | } | |
7070 | ||
505e5056 | 7071 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7072 | address_family_ipv4_safi_cmd, |
7073 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7074 | "Enter Address Family command mode\n" | |
7075 | "Address Family\n" | |
7076 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7077 | { |
f51bae9c | 7078 | |
d62a17ae | 7079 | if (argc == 3) { |
2131d5cf | 7080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7081 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7082 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7083 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7084 | && safi != SAFI_EVPN) { |
31947174 MK |
7085 | vty_out(vty, |
7086 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7087 | return CMD_WARNING_CONFIG_FAILED; |
7088 | } | |
d62a17ae | 7089 | vty->node = bgp_node_type(AFI_IP, safi); |
7090 | } else | |
7091 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7092 | |
d62a17ae | 7093 | return CMD_SUCCESS; |
718e3744 | 7094 | } |
7095 | ||
505e5056 | 7096 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7097 | address_family_ipv6_safi_cmd, |
7098 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7099 | "Enter Address Family command mode\n" | |
7100 | "Address Family\n" | |
7101 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7102 | { |
d62a17ae | 7103 | if (argc == 3) { |
2131d5cf | 7104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7105 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7106 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7107 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7108 | && safi != SAFI_EVPN) { |
31947174 MK |
7109 | vty_out(vty, |
7110 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7111 | return CMD_WARNING_CONFIG_FAILED; |
7112 | } | |
d62a17ae | 7113 | vty->node = bgp_node_type(AFI_IP6, safi); |
7114 | } else | |
7115 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7116 | |
d62a17ae | 7117 | return CMD_SUCCESS; |
25ffbdc1 | 7118 | } |
718e3744 | 7119 | |
d6902373 | 7120 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7121 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7122 | address_family_vpnv4_cmd, |
8334fd5a | 7123 | "address-family vpnv4 [unicast]", |
718e3744 | 7124 | "Enter Address Family command mode\n" |
8c3deaae | 7125 | "Address Family\n" |
3a2d747c | 7126 | "Address Family modifier\n") |
718e3744 | 7127 | { |
d62a17ae | 7128 | vty->node = BGP_VPNV4_NODE; |
7129 | return CMD_SUCCESS; | |
718e3744 | 7130 | } |
7131 | ||
505e5056 | 7132 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7133 | address_family_vpnv6_cmd, |
8334fd5a | 7134 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7135 | "Enter Address Family command mode\n" |
8c3deaae | 7136 | "Address Family\n" |
3a2d747c | 7137 | "Address Family modifier\n") |
8ecd3266 | 7138 | { |
d62a17ae | 7139 | vty->node = BGP_VPNV6_NODE; |
7140 | return CMD_SUCCESS; | |
8ecd3266 | 7141 | } |
c016b6c7 | 7142 | #endif |
d6902373 | 7143 | |
505e5056 | 7144 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7145 | address_family_evpn_cmd, |
7111c1a0 | 7146 | "address-family l2vpn evpn", |
4e0b7b6d | 7147 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7148 | "Address Family\n" |
7149 | "Address Family modifier\n") | |
4e0b7b6d | 7150 | { |
2131d5cf | 7151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7152 | vty->node = BGP_EVPN_NODE; |
7153 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7154 | } |
7155 | ||
505e5056 | 7156 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7157 | exit_address_family_cmd, |
7158 | "exit-address-family", | |
7159 | "Exit from Address Family configuration mode\n") | |
7160 | { | |
d62a17ae | 7161 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7162 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7163 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7164 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7165 | || vty->node == BGP_EVPN_NODE |
7166 | || vty->node == BGP_FLOWSPECV4_NODE | |
7167 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7168 | vty->node = BGP_NODE; |
7169 | return CMD_SUCCESS; | |
718e3744 | 7170 | } |
6b0655a2 | 7171 | |
8ad7271d | 7172 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7173 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7174 | const char *ip_str, afi_t afi, safi_t safi, | |
7175 | struct prefix_rd *prd) | |
7176 | { | |
7177 | int ret; | |
7178 | struct prefix match; | |
7179 | struct bgp_node *rn; | |
7180 | struct bgp_node *rm; | |
7181 | struct bgp *bgp; | |
7182 | struct bgp_table *table; | |
7183 | struct bgp_table *rib; | |
7184 | ||
7185 | /* BGP structure lookup. */ | |
7186 | if (view_name) { | |
7187 | bgp = bgp_lookup_by_name(view_name); | |
7188 | if (bgp == NULL) { | |
7189 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7190 | view_name); | |
7191 | return CMD_WARNING; | |
7192 | } | |
7193 | } else { | |
7194 | bgp = bgp_get_default(); | |
7195 | if (bgp == NULL) { | |
7196 | vty_out(vty, "%% No BGP process is configured\n"); | |
7197 | return CMD_WARNING; | |
7198 | } | |
7199 | } | |
7200 | ||
7201 | /* Check IP address argument. */ | |
7202 | ret = str2prefix(ip_str, &match); | |
7203 | if (!ret) { | |
7204 | vty_out(vty, "%% address is malformed\n"); | |
7205 | return CMD_WARNING; | |
7206 | } | |
7207 | ||
7208 | match.family = afi2family(afi); | |
7209 | rib = bgp->rib[afi][safi]; | |
7210 | ||
7211 | if (safi == SAFI_MPLS_VPN) { | |
7212 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7213 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7214 | continue; | |
7215 | ||
7216 | if ((table = rn->info) != NULL) { | |
7217 | if ((rm = bgp_node_match(table, &match)) | |
7218 | != NULL) { | |
7219 | if (rm->p.prefixlen | |
7220 | == match.prefixlen) { | |
343cdb61 | 7221 | SET_FLAG(rm->flags, |
d62a17ae | 7222 | BGP_NODE_USER_CLEAR); |
7223 | bgp_process(bgp, rm, afi, safi); | |
7224 | } | |
7225 | bgp_unlock_node(rm); | |
7226 | } | |
7227 | } | |
7228 | } | |
7229 | } else { | |
7230 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7231 | if (rn->p.prefixlen == match.prefixlen) { | |
7232 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7233 | bgp_process(bgp, rn, afi, safi); | |
7234 | } | |
7235 | bgp_unlock_node(rn); | |
7236 | } | |
7237 | } | |
7238 | ||
7239 | return CMD_SUCCESS; | |
8ad7271d DS |
7240 | } |
7241 | ||
b09b5ae0 | 7242 | /* one clear bgp command to rule them all */ |
718e3744 | 7243 | DEFUN (clear_ip_bgp_all, |
7244 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 7245 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7246 | CLEAR_STR |
7247 | IP_STR | |
7248 | BGP_STR | |
838758ac | 7249 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
7250 | BGP_AFI_HELP_STR |
7251 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
7252 | "Clear all peers\n" |
7253 | "BGP neighbor address to clear\n" | |
a80beece | 7254 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7255 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7256 | "Clear peers with the AS number\n" |
7257 | "Clear all external peers\n" | |
718e3744 | 7258 | "Clear all members of peer-group\n" |
b09b5ae0 | 7259 | "BGP peer-group name\n" |
b09b5ae0 DW |
7260 | BGP_SOFT_STR |
7261 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7262 | BGP_SOFT_OUT_STR |
7263 | BGP_SOFT_IN_STR | |
7264 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7265 | BGP_SOFT_OUT_STR) |
718e3744 | 7266 | { |
d62a17ae | 7267 | char *vrf = NULL; |
7268 | ||
7269 | afi_t afi = AFI_IP6; | |
7270 | safi_t safi = SAFI_UNICAST; | |
7271 | enum clear_sort clr_sort = clear_peer; | |
7272 | enum bgp_clear_type clr_type; | |
7273 | char *clr_arg = NULL; | |
7274 | ||
7275 | int idx = 0; | |
7276 | ||
7277 | /* clear [ip] bgp */ | |
7278 | if (argv_find(argv, argc, "ip", &idx)) | |
7279 | afi = AFI_IP; | |
7280 | ||
9a8bdf1c PG |
7281 | /* [<vrf> VIEWVRFNAME] */ |
7282 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7283 | vrf = argv[idx + 1]->arg; | |
7284 | idx += 2; | |
7285 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7286 | vrf = NULL; | |
7287 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7288 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7289 | vrf = argv[idx + 1]->arg; |
7290 | idx += 2; | |
7291 | } | |
d62a17ae | 7292 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7293 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7294 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7295 | ||
7296 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7297 | if (argv_find(argv, argc, "*", &idx)) { | |
7298 | clr_sort = clear_all; | |
7299 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7300 | clr_sort = clear_peer; | |
7301 | clr_arg = argv[idx]->arg; | |
7302 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7303 | clr_sort = clear_peer; | |
7304 | clr_arg = argv[idx]->arg; | |
7305 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7306 | clr_sort = clear_group; | |
7307 | idx++; | |
7308 | clr_arg = argv[idx]->arg; | |
7309 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7310 | clr_sort = clear_peer; | |
7311 | clr_arg = argv[idx]->arg; | |
7312 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7313 | clr_sort = clear_as; | |
7314 | clr_arg = argv[idx]->arg; | |
7315 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7316 | clr_sort = clear_external; | |
7317 | } | |
7318 | ||
7319 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7320 | if (argv_find(argv, argc, "soft", &idx)) { | |
7321 | if (argv_find(argv, argc, "in", &idx) | |
7322 | || argv_find(argv, argc, "out", &idx)) | |
7323 | clr_type = strmatch(argv[idx]->text, "in") | |
7324 | ? BGP_CLEAR_SOFT_IN | |
7325 | : BGP_CLEAR_SOFT_OUT; | |
7326 | else | |
7327 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7328 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7329 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7330 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7331 | : BGP_CLEAR_SOFT_IN; | |
7332 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7333 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7334 | } else | |
7335 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7336 | ||
7337 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7338 | } |
01080f7c | 7339 | |
8ad7271d DS |
7340 | DEFUN (clear_ip_bgp_prefix, |
7341 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7342 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7343 | CLEAR_STR |
7344 | IP_STR | |
7345 | BGP_STR | |
838758ac | 7346 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7347 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7348 | "IPv4 prefix\n") |
8ad7271d | 7349 | { |
d62a17ae | 7350 | char *vrf = NULL; |
7351 | char *prefix = NULL; | |
8ad7271d | 7352 | |
d62a17ae | 7353 | int idx = 0; |
01080f7c | 7354 | |
d62a17ae | 7355 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7356 | if (argv_find(argv, argc, "vrf", &idx)) { |
7357 | vrf = argv[idx + 1]->arg; | |
7358 | idx += 2; | |
7359 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7360 | vrf = NULL; | |
7361 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7362 | /* [<view> VIEWVRFNAME] */ | |
7363 | vrf = argv[idx + 1]->arg; | |
7364 | idx += 2; | |
7365 | } | |
0c7b1b01 | 7366 | |
d62a17ae | 7367 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7368 | |
d62a17ae | 7369 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7370 | } |
8ad7271d | 7371 | |
b09b5ae0 DW |
7372 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7373 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7374 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7375 | CLEAR_STR |
3a2d747c | 7376 | IP_STR |
718e3744 | 7377 | BGP_STR |
8c3deaae | 7378 | "Address Family\n" |
46f296b4 | 7379 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7380 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7381 | "IPv6 prefix\n") |
718e3744 | 7382 | { |
9b475e76 PG |
7383 | int idx_safi = 0; |
7384 | int idx_ipv6_prefix = 0; | |
7385 | safi_t safi = SAFI_UNICAST; | |
7386 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7387 | argv[idx_ipv6_prefix]->arg : NULL; | |
7388 | ||
7389 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7390 | return bgp_clear_prefix( |
9b475e76 PG |
7391 | vty, NULL, prefix, AFI_IP6, |
7392 | safi, NULL); | |
838758ac | 7393 | } |
01080f7c | 7394 | |
b09b5ae0 DW |
7395 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7396 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7397 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7398 | CLEAR_STR |
3a2d747c | 7399 | IP_STR |
718e3744 | 7400 | BGP_STR |
838758ac | 7401 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7402 | "Address Family\n" |
46f296b4 | 7403 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7404 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7405 | "IPv6 prefix\n") |
718e3744 | 7406 | { |
9b475e76 | 7407 | int idx_safi = 0; |
9a8bdf1c | 7408 | int idx_vrfview = 0; |
9b475e76 PG |
7409 | int idx_ipv6_prefix = 0; |
7410 | safi_t safi = SAFI_UNICAST; | |
7411 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7412 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7413 | char *vrfview = NULL; |
9b475e76 | 7414 | |
9a8bdf1c PG |
7415 | /* [<view|vrf> VIEWVRFNAME] */ |
7416 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7417 | vrfview = argv[idx_vrfview + 1]->arg; | |
7418 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7419 | vrfview = NULL; | |
7420 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7421 | /* [<view> VIEWVRFNAME] */ | |
7422 | vrfview = argv[idx_vrfview + 1]->arg; | |
7423 | } | |
9b475e76 PG |
7424 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7425 | ||
d62a17ae | 7426 | return bgp_clear_prefix( |
9b475e76 PG |
7427 | vty, vrfview, prefix, |
7428 | AFI_IP6, safi, NULL); | |
718e3744 | 7429 | } |
7430 | ||
b09b5ae0 DW |
7431 | DEFUN (show_bgp_views, |
7432 | show_bgp_views_cmd, | |
d6e3c605 | 7433 | "show [ip] bgp views", |
b09b5ae0 | 7434 | SHOW_STR |
d6e3c605 | 7435 | IP_STR |
01080f7c | 7436 | BGP_STR |
b09b5ae0 | 7437 | "Show the defined BGP views\n") |
01080f7c | 7438 | { |
d62a17ae | 7439 | struct list *inst = bm->bgp; |
7440 | struct listnode *node; | |
7441 | struct bgp *bgp; | |
01080f7c | 7442 | |
d62a17ae | 7443 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7444 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7445 | return CMD_WARNING; | |
7446 | } | |
e52702f2 | 7447 | |
d62a17ae | 7448 | vty_out(vty, "Defined BGP views:\n"); |
7449 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7450 | /* Skip VRFs. */ | |
7451 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7452 | continue; | |
7453 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7454 | bgp->as); | |
7455 | } | |
e52702f2 | 7456 | |
d62a17ae | 7457 | return CMD_SUCCESS; |
e0081f70 ML |
7458 | } |
7459 | ||
8386ac43 | 7460 | DEFUN (show_bgp_vrfs, |
7461 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7462 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7463 | SHOW_STR |
d6e3c605 | 7464 | IP_STR |
8386ac43 | 7465 | BGP_STR |
7466 | "Show BGP VRFs\n" | |
9973d184 | 7467 | JSON_STR) |
8386ac43 | 7468 | { |
fe1dc5a3 | 7469 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7470 | struct list *inst = bm->bgp; |
7471 | struct listnode *node; | |
7472 | struct bgp *bgp; | |
9f049418 | 7473 | bool uj = use_json(argc, argv); |
d62a17ae | 7474 | json_object *json = NULL; |
7475 | json_object *json_vrfs = NULL; | |
7476 | int count = 0; | |
d62a17ae | 7477 | |
7478 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7479 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7480 | return CMD_WARNING; | |
7481 | } | |
7482 | ||
7483 | if (uj) { | |
7484 | json = json_object_new_object(); | |
7485 | json_vrfs = json_object_new_object(); | |
7486 | } | |
7487 | ||
7488 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7489 | const char *name, *type; | |
7490 | struct peer *peer; | |
7fe96307 | 7491 | struct listnode *node2, *nnode2; |
d62a17ae | 7492 | int peers_cfg, peers_estb; |
7493 | json_object *json_vrf = NULL; | |
d62a17ae | 7494 | |
7495 | /* Skip Views. */ | |
7496 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7497 | continue; | |
7498 | ||
7499 | count++; | |
7500 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7501 | vty_out(vty, |
7502 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7503 | "Type", "Id", "routerId", "#PeersVfg", |
7504 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7505 | |
7506 | peers_cfg = peers_estb = 0; | |
7507 | if (uj) | |
7508 | json_vrf = json_object_new_object(); | |
7509 | ||
7510 | ||
7fe96307 | 7511 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7512 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7513 | continue; | |
7514 | peers_cfg++; | |
7515 | if (peer->status == Established) | |
7516 | peers_estb++; | |
7517 | } | |
7518 | ||
7519 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7520 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7521 | type = "DFLT"; |
7522 | } else { | |
7523 | name = bgp->name; | |
7524 | type = "VRF"; | |
7525 | } | |
7526 | ||
a8bf7d9c | 7527 | |
d62a17ae | 7528 | if (uj) { |
a4d82a8a PZ |
7529 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7530 | ? -1 | |
7531 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7532 | json_object_string_add(json_vrf, "type", type); |
7533 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7534 | json_object_string_add(json_vrf, "routerId", | |
7535 | inet_ntoa(bgp->router_id)); | |
7536 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7537 | peers_cfg); | |
7538 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7539 | peers_estb); | |
7540 | ||
fe1dc5a3 | 7541 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7542 | json_object_string_add( |
7543 | json_vrf, "rmac", | |
7544 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7545 | json_object_object_add(json_vrfs, name, json_vrf); |
7546 | } else | |
fe1dc5a3 MK |
7547 | vty_out(vty, |
7548 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7549 | type, |
7550 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7551 | : (int)bgp->vrf_id, | |
7552 | inet_ntoa(bgp->router_id), peers_cfg, | |
7553 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7554 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7555 | } |
7556 | ||
7557 | if (uj) { | |
7558 | json_object_object_add(json, "vrfs", json_vrfs); | |
7559 | ||
7560 | json_object_int_add(json, "totalVrfs", count); | |
7561 | ||
996c9314 LB |
7562 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7563 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7564 | json_object_free(json); |
7565 | } else { | |
7566 | if (count) | |
7567 | vty_out(vty, | |
7568 | "\nTotal number of VRFs (including default): %d\n", | |
7569 | count); | |
7570 | } | |
7571 | ||
7572 | return CMD_SUCCESS; | |
8386ac43 | 7573 | } |
7574 | ||
acf71666 MK |
7575 | |
7576 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7577 | { | |
0291c246 | 7578 | struct vty *vty = (struct vty *)args; |
60466a63 | 7579 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7580 | |
60466a63 | 7581 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7582 | tip->refcnt); |
7583 | } | |
7584 | ||
7585 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7586 | { | |
7587 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7588 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7589 | |
7590 | vty_out(vty, "Tunnel-ip database:\n"); | |
7591 | hash_iterate(bgp->tip_hash, | |
7592 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7593 | vty); | |
7594 | } | |
7595 | ||
15c81ca4 DS |
7596 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7597 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7598 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7599 | "martian next-hops\n" |
7600 | "martian next-hop database\n") | |
acf71666 | 7601 | { |
0291c246 | 7602 | struct bgp *bgp = NULL; |
15c81ca4 | 7603 | int idx = 0; |
9a8bdf1c PG |
7604 | char *name = NULL; |
7605 | ||
7606 | /* [<vrf> VIEWVRFNAME] */ | |
7607 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7608 | name = argv[idx + 1]->arg; | |
7609 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7610 | name = NULL; | |
7611 | } else if (argv_find(argv, argc, "view", &idx)) | |
7612 | /* [<view> VIEWVRFNAME] */ | |
7613 | name = argv[idx + 1]->arg; | |
7614 | if (name) | |
7615 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7616 | else |
7617 | bgp = bgp_get_default(); | |
acf71666 | 7618 | |
acf71666 MK |
7619 | if (!bgp) { |
7620 | vty_out(vty, "%% No BGP process is configured\n"); | |
7621 | return CMD_WARNING; | |
7622 | } | |
7623 | bgp_show_martian_nexthops(vty, bgp); | |
7624 | ||
7625 | return CMD_SUCCESS; | |
7626 | } | |
7627 | ||
f412b39a | 7628 | DEFUN (show_bgp_memory, |
4bf6a362 | 7629 | show_bgp_memory_cmd, |
7fa12b13 | 7630 | "show [ip] bgp memory", |
4bf6a362 | 7631 | SHOW_STR |
3a2d747c | 7632 | IP_STR |
4bf6a362 PJ |
7633 | BGP_STR |
7634 | "Global BGP memory statistics\n") | |
7635 | { | |
d62a17ae | 7636 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7637 | unsigned long count; | |
7638 | ||
7639 | /* RIB related usage stats */ | |
7640 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7641 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7642 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7643 | count * sizeof(struct bgp_node))); | |
7644 | ||
7645 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7646 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7647 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7648 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7649 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7650 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7651 | count, | |
4b7e6066 DS |
7652 | mtype_memstr( |
7653 | memstrbuf, sizeof(memstrbuf), | |
7654 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7655 | |
7656 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7657 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7658 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7659 | count * sizeof(struct bgp_static))); | |
7660 | ||
7661 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7662 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7663 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7664 | count * sizeof(struct bpacket))); | |
7665 | ||
7666 | /* Adj-In/Out */ | |
7667 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7668 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7669 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7670 | count * sizeof(struct bgp_adj_in))); | |
7671 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7672 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7673 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7674 | count * sizeof(struct bgp_adj_out))); | |
7675 | ||
7676 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7677 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7678 | count, | |
7679 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7680 | count * sizeof(struct bgp_nexthop_cache))); | |
7681 | ||
7682 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7683 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7684 | count, | |
7685 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7686 | count * sizeof(struct bgp_damp_info))); | |
7687 | ||
7688 | /* Attributes */ | |
7689 | count = attr_count(); | |
7690 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7691 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7692 | count * sizeof(struct attr))); | |
7693 | ||
7694 | if ((count = attr_unknown_count())) | |
7695 | vty_out(vty, "%ld unknown attributes\n", count); | |
7696 | ||
7697 | /* AS_PATH attributes */ | |
7698 | count = aspath_count(); | |
7699 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7700 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7701 | count * sizeof(struct aspath))); | |
7702 | ||
7703 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7704 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7705 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7706 | count * sizeof(struct assegment))); | |
7707 | ||
7708 | /* Other attributes */ | |
7709 | if ((count = community_count())) | |
7710 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7711 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7712 | count * sizeof(struct community))); | |
d62a17ae | 7713 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7714 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7715 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7716 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7717 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7718 | vty_out(vty, | |
7719 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7720 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7721 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7722 | |
7723 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7724 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7725 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7726 | count * sizeof(struct cluster_list))); | |
7727 | ||
7728 | /* Peer related usage */ | |
7729 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7730 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7732 | count * sizeof(struct peer))); | |
7733 | ||
7734 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7735 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7736 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7737 | count * sizeof(struct peer_group))); | |
7738 | ||
7739 | /* Other */ | |
7740 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7741 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7742 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7743 | count * sizeof(struct hash))); | |
7744 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7745 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7746 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7747 | count * sizeof(struct hash_backet))); | |
7748 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7749 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7750 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7751 | count * sizeof(regex_t))); | |
d62a17ae | 7752 | return CMD_SUCCESS; |
4bf6a362 | 7753 | } |
fee0f4c6 | 7754 | |
57a9c8a8 DS |
7755 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7756 | { | |
7757 | json_object *bestpath = json_object_new_object(); | |
7758 | ||
7759 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7760 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7761 | ||
7762 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7763 | json_object_string_add(bestpath, "asPath", "confed"); | |
7764 | ||
7765 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7766 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7767 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7768 | "as-set"); |
7769 | else | |
a4d82a8a | 7770 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7771 | "true"); |
7772 | } else | |
a4d82a8a | 7773 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7774 | |
7775 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7776 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7777 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7778 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7779 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7780 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7781 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7782 | json_object_string_add(bestpath, "med", | |
7783 | "missing-as-worst"); | |
7784 | else | |
7785 | json_object_string_add(bestpath, "med", "true"); | |
7786 | } | |
7787 | ||
7788 | json_object_object_add(json, "bestPath", bestpath); | |
7789 | } | |
7790 | ||
718e3744 | 7791 | /* Show BGP peer's summary information. */ |
d62a17ae | 7792 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7793 | bool use_json, json_object *json) |
d62a17ae | 7794 | { |
7795 | struct peer *peer; | |
7796 | struct listnode *node, *nnode; | |
7797 | unsigned int count = 0, dn_count = 0; | |
7798 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7799 | char neighbor_buf[VTY_BUFSIZ]; | |
7800 | int neighbor_col_default_width = 16; | |
7801 | int len; | |
7802 | int max_neighbor_width = 0; | |
7803 | int pfx_rcd_safi; | |
7804 | json_object *json_peer = NULL; | |
7805 | json_object *json_peers = NULL; | |
50e05855 | 7806 | struct peer_af *paf; |
d62a17ae | 7807 | |
7808 | /* labeled-unicast routes are installed in the unicast table so in order | |
7809 | * to | |
7810 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7811 | */ | |
7812 | if (safi == SAFI_LABELED_UNICAST) | |
7813 | pfx_rcd_safi = SAFI_UNICAST; | |
7814 | else | |
7815 | pfx_rcd_safi = safi; | |
7816 | ||
7817 | if (use_json) { | |
7818 | if (json == NULL) | |
7819 | json = json_object_new_object(); | |
7820 | ||
7821 | json_peers = json_object_new_object(); | |
7822 | } else { | |
7823 | /* Loop over all neighbors that will be displayed to determine | |
7824 | * how many | |
7825 | * characters are needed for the Neighbor column | |
7826 | */ | |
7827 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7828 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7829 | continue; | |
7830 | ||
7831 | if (peer->afc[afi][safi]) { | |
7832 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7833 | if (peer_dynamic_neighbor(peer)) | |
7834 | dn_flag[0] = '*'; | |
7835 | ||
7836 | if (peer->hostname | |
7837 | && bgp_flag_check(bgp, | |
7838 | BGP_FLAG_SHOW_HOSTNAME)) | |
7839 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7840 | dn_flag, peer->hostname, | |
7841 | peer->host); | |
7842 | else | |
7843 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7844 | peer->host); | |
7845 | ||
7846 | len = strlen(neighbor_buf); | |
7847 | ||
7848 | if (len > max_neighbor_width) | |
7849 | max_neighbor_width = len; | |
7850 | } | |
7851 | } | |
f933309e | 7852 | |
d62a17ae | 7853 | /* Originally we displayed the Neighbor column as 16 |
7854 | * characters wide so make that the default | |
7855 | */ | |
7856 | if (max_neighbor_width < neighbor_col_default_width) | |
7857 | max_neighbor_width = neighbor_col_default_width; | |
7858 | } | |
f933309e | 7859 | |
d62a17ae | 7860 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7861 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7862 | continue; | |
7863 | ||
ea47320b DL |
7864 | if (!peer->afc[afi][safi]) |
7865 | continue; | |
d62a17ae | 7866 | |
ea47320b DL |
7867 | if (!count) { |
7868 | unsigned long ents; | |
7869 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7870 | int64_t vrf_id_ui; |
d62a17ae | 7871 | |
a4d82a8a PZ |
7872 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7873 | ? -1 | |
7874 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7875 | |
7876 | /* Usage summary and header */ | |
7877 | if (use_json) { | |
7878 | json_object_string_add( | |
7879 | json, "routerId", | |
7880 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7881 | json_object_int_add(json, "as", bgp->as); |
7882 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7883 | json_object_string_add( |
7884 | json, "vrfName", | |
7885 | (bgp->inst_type | |
7886 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7887 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7888 | : bgp->name); |
7889 | } else { | |
7890 | vty_out(vty, | |
7891 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7892 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7893 | bgp->vrf_id == VRF_UNKNOWN |
7894 | ? -1 | |
7895 | : (int)bgp->vrf_id); | |
ea47320b DL |
7896 | vty_out(vty, "\n"); |
7897 | } | |
d62a17ae | 7898 | |
ea47320b | 7899 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7900 | if (use_json) { |
ea47320b | 7901 | json_object_int_add( |
60466a63 | 7902 | json, "updateDelayLimit", |
ea47320b | 7903 | bgp->v_update_delay); |
d62a17ae | 7904 | |
ea47320b DL |
7905 | if (bgp->v_update_delay |
7906 | != bgp->v_establish_wait) | |
d62a17ae | 7907 | json_object_int_add( |
7908 | json, | |
ea47320b DL |
7909 | "updateDelayEstablishWait", |
7910 | bgp->v_establish_wait); | |
d62a17ae | 7911 | |
60466a63 | 7912 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7913 | json_object_string_add( |
7914 | json, | |
7915 | "updateDelayFirstNeighbor", | |
7916 | bgp->update_delay_begin_time); | |
7917 | json_object_boolean_true_add( | |
7918 | json, | |
7919 | "updateDelayInProgress"); | |
7920 | } else { | |
7921 | if (bgp->update_delay_over) { | |
d62a17ae | 7922 | json_object_string_add( |
7923 | json, | |
7924 | "updateDelayFirstNeighbor", | |
7925 | bgp->update_delay_begin_time); | |
ea47320b | 7926 | json_object_string_add( |
d62a17ae | 7927 | json, |
ea47320b DL |
7928 | "updateDelayBestpathResumed", |
7929 | bgp->update_delay_end_time); | |
7930 | json_object_string_add( | |
d62a17ae | 7931 | json, |
ea47320b DL |
7932 | "updateDelayZebraUpdateResume", |
7933 | bgp->update_delay_zebra_resume_time); | |
7934 | json_object_string_add( | |
7935 | json, | |
7936 | "updateDelayPeerUpdateResume", | |
7937 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7938 | } |
ea47320b DL |
7939 | } |
7940 | } else { | |
7941 | vty_out(vty, | |
7942 | "Read-only mode update-delay limit: %d seconds\n", | |
7943 | bgp->v_update_delay); | |
7944 | if (bgp->v_update_delay | |
7945 | != bgp->v_establish_wait) | |
d62a17ae | 7946 | vty_out(vty, |
ea47320b DL |
7947 | " Establish wait: %d seconds\n", |
7948 | bgp->v_establish_wait); | |
d62a17ae | 7949 | |
60466a63 | 7950 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7951 | vty_out(vty, |
7952 | " First neighbor established: %s\n", | |
7953 | bgp->update_delay_begin_time); | |
7954 | vty_out(vty, | |
7955 | " Delay in progress\n"); | |
7956 | } else { | |
7957 | if (bgp->update_delay_over) { | |
d62a17ae | 7958 | vty_out(vty, |
7959 | " First neighbor established: %s\n", | |
7960 | bgp->update_delay_begin_time); | |
7961 | vty_out(vty, | |
ea47320b DL |
7962 | " Best-paths resumed: %s\n", |
7963 | bgp->update_delay_end_time); | |
7964 | vty_out(vty, | |
7965 | " zebra update resumed: %s\n", | |
7966 | bgp->update_delay_zebra_resume_time); | |
7967 | vty_out(vty, | |
7968 | " peers update resumed: %s\n", | |
7969 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7970 | } |
7971 | } | |
7972 | } | |
ea47320b | 7973 | } |
d62a17ae | 7974 | |
ea47320b DL |
7975 | if (use_json) { |
7976 | if (bgp_maxmed_onstartup_configured(bgp) | |
7977 | && bgp->maxmed_active) | |
7978 | json_object_boolean_true_add( | |
60466a63 | 7979 | json, "maxMedOnStartup"); |
ea47320b DL |
7980 | if (bgp->v_maxmed_admin) |
7981 | json_object_boolean_true_add( | |
60466a63 | 7982 | json, "maxMedAdministrative"); |
d62a17ae | 7983 | |
ea47320b DL |
7984 | json_object_int_add( |
7985 | json, "tableVersion", | |
60466a63 | 7986 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7987 | |
60466a63 QY |
7988 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7989 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7990 | json_object_int_add( |
7991 | json, "ribMemory", | |
7992 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7993 | |
ea47320b | 7994 | ents = listcount(bgp->peer); |
60466a63 QY |
7995 | json_object_int_add(json, "peerCount", ents); |
7996 | json_object_int_add(json, "peerMemory", | |
7997 | ents * sizeof(struct peer)); | |
d62a17ae | 7998 | |
ea47320b DL |
7999 | if ((ents = listcount(bgp->group))) { |
8000 | json_object_int_add( | |
60466a63 | 8001 | json, "peerGroupCount", ents); |
ea47320b DL |
8002 | json_object_int_add( |
8003 | json, "peerGroupMemory", | |
996c9314 LB |
8004 | ents * sizeof(struct |
8005 | peer_group)); | |
ea47320b | 8006 | } |
d62a17ae | 8007 | |
ea47320b DL |
8008 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8009 | BGP_CONFIG_DAMPENING)) | |
8010 | json_object_boolean_true_add( | |
60466a63 | 8011 | json, "dampeningEnabled"); |
ea47320b DL |
8012 | } else { |
8013 | if (bgp_maxmed_onstartup_configured(bgp) | |
8014 | && bgp->maxmed_active) | |
d62a17ae | 8015 | vty_out(vty, |
ea47320b DL |
8016 | "Max-med on-startup active\n"); |
8017 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8018 | vty_out(vty, |
ea47320b | 8019 | "Max-med administrative active\n"); |
d62a17ae | 8020 | |
60466a63 QY |
8021 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8022 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8023 | |
60466a63 | 8024 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8025 | vty_out(vty, |
8026 | "RIB entries %ld, using %s of memory\n", | |
8027 | ents, | |
996c9314 LB |
8028 | mtype_memstr(memstrbuf, |
8029 | sizeof(memstrbuf), | |
8030 | ents * sizeof(struct | |
8031 | bgp_node))); | |
ea47320b DL |
8032 | |
8033 | /* Peer related usage */ | |
8034 | ents = listcount(bgp->peer); | |
60466a63 | 8035 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8036 | ents, |
8037 | mtype_memstr( | |
60466a63 QY |
8038 | memstrbuf, sizeof(memstrbuf), |
8039 | ents * sizeof(struct peer))); | |
ea47320b DL |
8040 | |
8041 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8042 | vty_out(vty, |
ea47320b | 8043 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8044 | ents, |
8045 | mtype_memstr( | |
8046 | memstrbuf, | |
8047 | sizeof(memstrbuf), | |
996c9314 LB |
8048 | ents * sizeof(struct |
8049 | peer_group))); | |
d62a17ae | 8050 | |
ea47320b DL |
8051 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8052 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8053 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8054 | vty_out(vty, "\n"); |
d62a17ae | 8055 | |
ea47320b DL |
8056 | /* Subtract 8 here because 'Neighbor' is |
8057 | * 8 characters */ | |
8058 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8059 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8060 | " "); | |
ea47320b DL |
8061 | vty_out(vty, |
8062 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8063 | } |
ea47320b | 8064 | } |
d62a17ae | 8065 | |
ea47320b | 8066 | count++; |
d62a17ae | 8067 | |
ea47320b DL |
8068 | if (use_json) { |
8069 | json_peer = json_object_new_object(); | |
d62a17ae | 8070 | |
b4e9dcba DD |
8071 | if (peer_dynamic_neighbor(peer)) { |
8072 | dn_count++; | |
60466a63 QY |
8073 | json_object_boolean_true_add(json_peer, |
8074 | "dynamicPeer"); | |
b4e9dcba | 8075 | } |
d62a17ae | 8076 | |
ea47320b | 8077 | if (peer->hostname) |
60466a63 | 8078 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8079 | peer->hostname); |
d62a17ae | 8080 | |
ea47320b | 8081 | if (peer->domainname) |
60466a63 QY |
8082 | json_object_string_add(json_peer, "domainname", |
8083 | peer->domainname); | |
d62a17ae | 8084 | |
60466a63 | 8085 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8086 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8087 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8088 | PEER_TOTAL_RX(peer)); |
60466a63 | 8089 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8090 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8091 | |
8092 | json_object_int_add(json_peer, "tableVersion", | |
8093 | peer->version[afi][safi]); | |
8094 | json_object_int_add(json_peer, "outq", | |
8095 | peer->obuf->count); | |
8096 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8097 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8098 | use_json, json_peer); | |
50e05855 AD |
8099 | |
8100 | /* | |
8101 | * Adding "pfxRcd" field to match with the corresponding | |
8102 | * CLI. "prefixReceivedCount" will be deprecated in | |
8103 | * future. | |
8104 | */ | |
60466a63 QY |
8105 | json_object_int_add(json_peer, "prefixReceivedCount", |
8106 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8107 | json_object_int_add(json_peer, "pfxRcd", |
8108 | peer->pcount[afi][pfx_rcd_safi]); | |
8109 | ||
8110 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8111 | if (paf && PAF_SUBGRP(paf)) | |
8112 | json_object_int_add(json_peer, | |
8113 | "pfxSnt", | |
8114 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8115 | |
ea47320b | 8116 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8117 | json_object_string_add(json_peer, "state", |
ea47320b | 8118 | "Idle (Admin)"); |
9199a725 TM |
8119 | else if (peer->afc_recv[afi][safi]) |
8120 | json_object_string_add( | |
8121 | json_peer, "state", | |
8122 | lookup_msg(bgp_status_msg, peer->status, | |
8123 | NULL)); | |
60466a63 QY |
8124 | else if (CHECK_FLAG(peer->sflags, |
8125 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8126 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8127 | "Idle (PfxCt)"); |
8128 | else | |
8129 | json_object_string_add( | |
8130 | json_peer, "state", | |
60466a63 QY |
8131 | lookup_msg(bgp_status_msg, peer->status, |
8132 | NULL)); | |
ea47320b DL |
8133 | |
8134 | if (peer->conf_if) | |
60466a63 | 8135 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8136 | "interface"); |
8137 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8138 | json_object_string_add(json_peer, "idType", |
8139 | "ipv4"); | |
ea47320b | 8140 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8141 | json_object_string_add(json_peer, "idType", |
8142 | "ipv6"); | |
d62a17ae | 8143 | |
ea47320b DL |
8144 | json_object_object_add(json_peers, peer->host, |
8145 | json_peer); | |
8146 | } else { | |
8147 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8148 | if (peer_dynamic_neighbor(peer)) { | |
8149 | dn_count++; | |
8150 | dn_flag[0] = '*'; | |
8151 | } | |
d62a17ae | 8152 | |
ea47320b | 8153 | if (peer->hostname |
60466a63 | 8154 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8155 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8156 | peer->hostname, peer->host); |
ea47320b | 8157 | else |
60466a63 | 8158 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8159 | |
8160 | /* pad the neighbor column with spaces */ | |
8161 | if (len < max_neighbor_width) | |
60466a63 QY |
8162 | vty_out(vty, "%*s", max_neighbor_width - len, |
8163 | " "); | |
ea47320b | 8164 | |
86a55b99 | 8165 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8166 | peer->as, PEER_TOTAL_RX(peer), |
8167 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8168 | 0, peer->obuf->count, | |
d62a17ae | 8169 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8170 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8171 | |
ea47320b | 8172 | if (peer->status == Established) |
2f8f4f10 | 8173 | if (peer->afc_recv[afi][safi]) |
95077abf | 8174 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8175 | peer->pcount[afi] |
8176 | [pfx_rcd_safi]); | |
95077abf DW |
8177 | else |
8178 | vty_out(vty, " NoNeg"); | |
ea47320b | 8179 | else { |
60466a63 | 8180 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8181 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8182 | else if (CHECK_FLAG( |
8183 | peer->sflags, | |
8184 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8185 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8186 | else |
ea47320b | 8187 | vty_out(vty, " %12s", |
60466a63 QY |
8188 | lookup_msg(bgp_status_msg, |
8189 | peer->status, NULL)); | |
d62a17ae | 8190 | } |
ea47320b | 8191 | vty_out(vty, "\n"); |
d62a17ae | 8192 | } |
8193 | } | |
f933309e | 8194 | |
d62a17ae | 8195 | if (use_json) { |
8196 | json_object_object_add(json, "peers", json_peers); | |
8197 | ||
8198 | json_object_int_add(json, "totalPeers", count); | |
8199 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8200 | ||
57a9c8a8 DS |
8201 | bgp_show_bestpath_json(bgp, json); |
8202 | ||
996c9314 LB |
8203 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8204 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8205 | json_object_free(json); |
8206 | } else { | |
8207 | if (count) | |
8208 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8209 | else { | |
d6ceaca3 | 8210 | vty_out(vty, "No %s neighbor is configured\n", |
8211 | afi_safi_print(afi, safi)); | |
d62a17ae | 8212 | } |
b05a1c8b | 8213 | |
d6ceaca3 | 8214 | if (dn_count) { |
d62a17ae | 8215 | vty_out(vty, "* - dynamic neighbor\n"); |
8216 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8217 | dn_count, bgp->dynamic_neighbors_limit); | |
8218 | } | |
8219 | } | |
1ff9a340 | 8220 | |
d62a17ae | 8221 | return CMD_SUCCESS; |
718e3744 | 8222 | } |
8223 | ||
d62a17ae | 8224 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8225 | int safi, bool use_json, |
d62a17ae | 8226 | json_object *json) |
8227 | { | |
8228 | int is_first = 1; | |
8229 | int afi_wildcard = (afi == AFI_MAX); | |
8230 | int safi_wildcard = (safi == SAFI_MAX); | |
8231 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8232 | bool nbr_output = false; |
d62a17ae | 8233 | |
8234 | if (use_json && is_wildcard) | |
8235 | vty_out(vty, "{\n"); | |
8236 | if (afi_wildcard) | |
8237 | afi = 1; /* AFI_IP */ | |
8238 | while (afi < AFI_MAX) { | |
8239 | if (safi_wildcard) | |
8240 | safi = 1; /* SAFI_UNICAST */ | |
8241 | while (safi < SAFI_MAX) { | |
318cac96 | 8242 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8243 | nbr_output = true; |
d62a17ae | 8244 | if (is_wildcard) { |
8245 | /* | |
8246 | * So limit output to those afi/safi | |
8247 | * pairs that | |
8248 | * actualy have something interesting in | |
8249 | * them | |
8250 | */ | |
8251 | if (use_json) { | |
8252 | json = json_object_new_object(); | |
8253 | ||
8254 | if (!is_first) | |
8255 | vty_out(vty, ",\n"); | |
8256 | else | |
8257 | is_first = 0; | |
8258 | ||
8259 | vty_out(vty, "\"%s\":", | |
8260 | afi_safi_json(afi, | |
8261 | safi)); | |
8262 | } else { | |
8263 | vty_out(vty, "\n%s Summary:\n", | |
8264 | afi_safi_print(afi, | |
8265 | safi)); | |
8266 | } | |
8267 | } | |
8268 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8269 | json); | |
8270 | } | |
8271 | safi++; | |
d62a17ae | 8272 | if (!safi_wildcard) |
8273 | safi = SAFI_MAX; | |
8274 | } | |
8275 | afi++; | |
ee851c8c | 8276 | if (!afi_wildcard) |
d62a17ae | 8277 | afi = AFI_MAX; |
8278 | } | |
8279 | ||
8280 | if (use_json && is_wildcard) | |
8281 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8282 | else if (!nbr_output) { |
8283 | if (use_json) | |
8284 | vty_out(vty, "{}\n"); | |
8285 | else | |
8286 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8287 | } | |
d62a17ae | 8288 | } |
8289 | ||
8290 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8291 | safi_t safi, bool use_json) |
d62a17ae | 8292 | { |
8293 | struct listnode *node, *nnode; | |
8294 | struct bgp *bgp; | |
8295 | json_object *json = NULL; | |
8296 | int is_first = 1; | |
9f049418 | 8297 | bool nbr_output = false; |
d62a17ae | 8298 | |
8299 | if (use_json) | |
8300 | vty_out(vty, "{\n"); | |
8301 | ||
8302 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8303 | nbr_output = true; |
d62a17ae | 8304 | if (use_json) { |
8305 | json = json_object_new_object(); | |
8306 | ||
8307 | if (!is_first) | |
8308 | vty_out(vty, ",\n"); | |
8309 | else | |
8310 | is_first = 0; | |
8311 | ||
8312 | vty_out(vty, "\"%s\":", | |
8313 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8314 | ? VRF_DEFAULT_NAME |
d62a17ae | 8315 | : bgp->name); |
8316 | } else { | |
8317 | vty_out(vty, "\nInstance %s:\n", | |
8318 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8319 | ? VRF_DEFAULT_NAME |
d62a17ae | 8320 | : bgp->name); |
8321 | } | |
8322 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8323 | } | |
8324 | ||
8325 | if (use_json) | |
8326 | vty_out(vty, "}\n"); | |
9f049418 DS |
8327 | else if (!nbr_output) |
8328 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8329 | } |
8330 | ||
8331 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8332 | safi_t safi, bool use_json) |
d62a17ae | 8333 | { |
8334 | struct bgp *bgp; | |
8335 | ||
8336 | if (name) { | |
8337 | if (strmatch(name, "all")) { | |
8338 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8339 | use_json); | |
8340 | return CMD_SUCCESS; | |
8341 | } else { | |
8342 | bgp = bgp_lookup_by_name(name); | |
8343 | ||
8344 | if (!bgp) { | |
8345 | if (use_json) | |
8346 | vty_out(vty, "{}\n"); | |
8347 | else | |
8348 | vty_out(vty, | |
ca61fd25 | 8349 | "%% BGP instance not found\n"); |
d62a17ae | 8350 | return CMD_WARNING; |
8351 | } | |
8352 | ||
8353 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8354 | NULL); | |
8355 | return CMD_SUCCESS; | |
8356 | } | |
8357 | } | |
8358 | ||
8359 | bgp = bgp_get_default(); | |
8360 | ||
8361 | if (bgp) | |
8362 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8363 | else { |
ca61fd25 DS |
8364 | if (use_json) |
8365 | vty_out(vty, "{}\n"); | |
8366 | else | |
8367 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8368 | return CMD_WARNING; |
8369 | } | |
d62a17ae | 8370 | |
8371 | return CMD_SUCCESS; | |
4fb25c53 DW |
8372 | } |
8373 | ||
716b2d8a | 8374 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8375 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8376 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8377 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8378 | SHOW_STR |
8379 | IP_STR | |
8380 | BGP_STR | |
8386ac43 | 8381 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8382 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8383 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8384 | "Summary of BGP neighbor status\n" |
9973d184 | 8385 | JSON_STR) |
718e3744 | 8386 | { |
d62a17ae | 8387 | char *vrf = NULL; |
8388 | afi_t afi = AFI_MAX; | |
8389 | safi_t safi = SAFI_MAX; | |
8390 | ||
8391 | int idx = 0; | |
8392 | ||
8393 | /* show [ip] bgp */ | |
8394 | if (argv_find(argv, argc, "ip", &idx)) | |
8395 | afi = AFI_IP; | |
9a8bdf1c PG |
8396 | /* [<vrf> VIEWVRFNAME] */ |
8397 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8398 | vrf = argv[idx + 1]->arg; | |
8399 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8400 | vrf = NULL; | |
8401 | } else if (argv_find(argv, argc, "view", &idx)) | |
8402 | /* [<view> VIEWVRFNAME] */ | |
8403 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8404 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8405 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8406 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8407 | } | |
8408 | ||
9f049418 | 8409 | bool uj = use_json(argc, argv); |
d62a17ae | 8410 | |
8411 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8412 | } | |
8413 | ||
8414 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8415 | { | |
8416 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8417 | return "IPv4 Unicast"; | |
8418 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8419 | return "IPv4 Multicast"; | |
8420 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8421 | return "IPv4 Labeled Unicast"; | |
8422 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8423 | return "IPv4 VPN"; | |
8424 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8425 | return "IPv4 Encap"; | |
7c40bf39 | 8426 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8427 | return "IPv4 Flowspec"; | |
d62a17ae | 8428 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8429 | return "IPv6 Unicast"; | |
8430 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8431 | return "IPv6 Multicast"; | |
8432 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8433 | return "IPv6 Labeled Unicast"; | |
8434 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8435 | return "IPv6 VPN"; | |
8436 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8437 | return "IPv6 Encap"; | |
7c40bf39 | 8438 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8439 | return "IPv6 Flowspec"; | |
d62a17ae | 8440 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8441 | return "L2VPN EVPN"; | |
8442 | else | |
8443 | return "Unknown"; | |
538621f2 | 8444 | } |
8445 | ||
b9f77ec8 DS |
8446 | /* |
8447 | * Please note that we have intentionally camelCased | |
8448 | * the return strings here. So if you want | |
8449 | * to use this function, please ensure you | |
8450 | * are doing this within json output | |
8451 | */ | |
d62a17ae | 8452 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8453 | { | |
8454 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8455 | return "ipv4Unicast"; | |
8456 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8457 | return "ipv4Multicast"; | |
8458 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8459 | return "ipv4LabeledUnicast"; | |
8460 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8461 | return "ipv4Vpn"; | |
8462 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8463 | return "ipv4Encap"; | |
7c40bf39 | 8464 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8465 | return "ipv4Flowspec"; | |
d62a17ae | 8466 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8467 | return "ipv6Unicast"; | |
8468 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8469 | return "ipv6Multicast"; | |
8470 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8471 | return "ipv6LabeledUnicast"; | |
8472 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8473 | return "ipv6Vpn"; | |
8474 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8475 | return "ipv6Encap"; | |
7c40bf39 | 8476 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8477 | return "ipv6Flowspec"; | |
d62a17ae | 8478 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8479 | return "l2VpnEvpn"; | |
8480 | else | |
8481 | return "Unknown"; | |
27162734 LB |
8482 | } |
8483 | ||
718e3744 | 8484 | /* Show BGP peer's information. */ |
d62a17ae | 8485 | enum show_type { show_all, show_peer }; |
8486 | ||
8487 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8488 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8489 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8490 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8491 | bool use_json, json_object *json_pref) |
d62a17ae | 8492 | { |
8493 | /* Send-Mode */ | |
8494 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8495 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8496 | if (use_json) { | |
8497 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8498 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8499 | json_object_string_add(json_pref, "sendMode", | |
8500 | "advertisedAndReceived"); | |
8501 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8502 | json_object_string_add(json_pref, "sendMode", | |
8503 | "advertised"); | |
8504 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8505 | json_object_string_add(json_pref, "sendMode", | |
8506 | "received"); | |
8507 | } else { | |
8508 | vty_out(vty, " Send-mode: "); | |
8509 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8510 | vty_out(vty, "advertised"); | |
8511 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8512 | vty_out(vty, "%sreceived", | |
8513 | CHECK_FLAG(p->af_cap[afi][safi], | |
8514 | adv_smcap) | |
8515 | ? ", " | |
8516 | : ""); | |
8517 | vty_out(vty, "\n"); | |
8518 | } | |
8519 | } | |
8520 | ||
8521 | /* Receive-Mode */ | |
8522 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8523 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8524 | if (use_json) { | |
8525 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8526 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8527 | json_object_string_add(json_pref, "recvMode", | |
8528 | "advertisedAndReceived"); | |
8529 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8530 | json_object_string_add(json_pref, "recvMode", | |
8531 | "advertised"); | |
8532 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8533 | json_object_string_add(json_pref, "recvMode", | |
8534 | "received"); | |
8535 | } else { | |
8536 | vty_out(vty, " Receive-mode: "); | |
8537 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8538 | vty_out(vty, "advertised"); | |
8539 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8540 | vty_out(vty, "%sreceived", | |
8541 | CHECK_FLAG(p->af_cap[afi][safi], | |
8542 | adv_rmcap) | |
8543 | ? ", " | |
8544 | : ""); | |
8545 | vty_out(vty, "\n"); | |
8546 | } | |
8547 | } | |
8548 | } | |
8549 | ||
8550 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8551 | safi_t safi, bool use_json, |
d62a17ae | 8552 | json_object *json_neigh) |
8553 | { | |
0291c246 MK |
8554 | struct bgp_filter *filter; |
8555 | struct peer_af *paf; | |
8556 | char orf_pfx_name[BUFSIZ]; | |
8557 | int orf_pfx_count; | |
8558 | json_object *json_af = NULL; | |
8559 | json_object *json_prefA = NULL; | |
8560 | json_object *json_prefB = NULL; | |
8561 | json_object *json_addr = NULL; | |
d62a17ae | 8562 | |
8563 | if (use_json) { | |
8564 | json_addr = json_object_new_object(); | |
8565 | json_af = json_object_new_object(); | |
8566 | filter = &p->filter[afi][safi]; | |
8567 | ||
8568 | if (peer_group_active(p)) | |
8569 | json_object_string_add(json_addr, "peerGroupMember", | |
8570 | p->group->name); | |
8571 | ||
8572 | paf = peer_af_find(p, afi, safi); | |
8573 | if (paf && PAF_SUBGRP(paf)) { | |
8574 | json_object_int_add(json_addr, "updateGroupId", | |
8575 | PAF_UPDGRP(paf)->id); | |
8576 | json_object_int_add(json_addr, "subGroupId", | |
8577 | PAF_SUBGRP(paf)->id); | |
8578 | json_object_int_add(json_addr, "packetQueueLength", | |
8579 | bpacket_queue_virtual_length(paf)); | |
8580 | } | |
8581 | ||
8582 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8583 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8584 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8585 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8586 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8587 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8588 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8589 | json_object_int_add(json_af, "orfType", | |
8590 | ORF_TYPE_PREFIX); | |
8591 | json_prefA = json_object_new_object(); | |
8592 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8593 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8594 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8595 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8596 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8597 | use_json, json_prefA); | |
8598 | json_object_object_add(json_af, "orfPrefixList", | |
8599 | json_prefA); | |
8600 | } | |
8601 | ||
8602 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8603 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8604 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8605 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8606 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8607 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8608 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8609 | json_object_int_add(json_af, "orfOldType", | |
8610 | ORF_TYPE_PREFIX_OLD); | |
8611 | json_prefB = json_object_new_object(); | |
8612 | bgp_show_peer_afi_orf_cap( | |
8613 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8614 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8615 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8616 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8617 | json_prefB); | |
8618 | json_object_object_add(json_af, "orfOldPrefixList", | |
8619 | json_prefB); | |
8620 | } | |
8621 | ||
8622 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8623 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8624 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8625 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8626 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8627 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8628 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8629 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8630 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8631 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8632 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8633 | json_object_object_add(json_addr, "afDependentCap", | |
8634 | json_af); | |
8635 | else | |
8636 | json_object_free(json_af); | |
8637 | ||
8638 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8639 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8640 | NULL, afi, orf_pfx_name, use_json); | |
8641 | ||
8642 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8643 | PEER_STATUS_ORF_PREFIX_SEND) | |
8644 | || orf_pfx_count) { | |
8645 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8646 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8647 | json_object_boolean_true_add(json_neigh, | |
8648 | "orfSent"); | |
8649 | if (orf_pfx_count) | |
8650 | json_object_int_add(json_addr, "orfRecvCounter", | |
8651 | orf_pfx_count); | |
8652 | } | |
8653 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8654 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8655 | json_object_string_add( | |
8656 | json_addr, "orfFirstUpdate", | |
8657 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8658 | ||
8659 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8660 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8661 | json_object_boolean_true_add(json_addr, | |
8662 | "routeReflectorClient"); | |
8663 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8664 | PEER_FLAG_RSERVER_CLIENT)) | |
8665 | json_object_boolean_true_add(json_addr, | |
8666 | "routeServerClient"); | |
8667 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8668 | json_object_boolean_true_add(json_addr, | |
8669 | "inboundSoftConfigPermit"); | |
8670 | ||
8671 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8672 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8673 | json_object_boolean_true_add( | |
8674 | json_addr, | |
8675 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8676 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8677 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8678 | json_object_boolean_true_add( | |
8679 | json_addr, | |
8680 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8681 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8682 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8683 | json_object_boolean_true_add( | |
8684 | json_addr, | |
8685 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8686 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8687 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8688 | json_object_boolean_true_add( | |
8689 | json_addr, | |
8690 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8691 | ||
dcc68b5e MS |
8692 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8693 | json_object_boolean_true_add( | |
8694 | json_addr, | |
8695 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8696 | ->type_json_name); | |
d62a17ae | 8697 | |
8698 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8699 | json_object_string_add(json_addr, | |
8700 | "overrideASNsInOutboundUpdates", | |
8701 | "ifAspathEqualRemoteAs"); | |
8702 | ||
8703 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8704 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8705 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8706 | json_object_boolean_true_add(json_addr, | |
8707 | "routerAlwaysNextHop"); | |
8708 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8709 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8710 | json_object_boolean_true_add( | |
8711 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8712 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8713 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8714 | json_object_boolean_true_add( | |
8715 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8716 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8717 | json_object_boolean_true_add( | |
8718 | json_addr, "unchangedMedPropogatedToNbr"); | |
8719 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8720 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8721 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8722 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8723 | PEER_FLAG_SEND_COMMUNITY) | |
8724 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8725 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8726 | json_object_string_add(json_addr, | |
8727 | "commAttriSentToNbr", | |
8728 | "extendedAndStandard"); | |
8729 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8730 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8731 | json_object_string_add(json_addr, | |
8732 | "commAttriSentToNbr", | |
8733 | "extended"); | |
8734 | else | |
8735 | json_object_string_add(json_addr, | |
8736 | "commAttriSentToNbr", | |
8737 | "standard"); | |
8738 | } | |
8739 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8740 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8741 | if (p->default_rmap[afi][safi].name) | |
8742 | json_object_string_add( | |
8743 | json_addr, "defaultRouteMap", | |
8744 | p->default_rmap[afi][safi].name); | |
8745 | ||
8746 | if (paf && PAF_SUBGRP(paf) | |
8747 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8748 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8749 | json_object_boolean_true_add(json_addr, | |
8750 | "defaultSent"); | |
8751 | else | |
8752 | json_object_boolean_true_add(json_addr, | |
8753 | "defaultNotSent"); | |
8754 | } | |
8755 | ||
dff8f48d | 8756 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8757 | if (is_evpn_enabled()) |
60466a63 QY |
8758 | json_object_boolean_true_add( |
8759 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8760 | } |
8761 | ||
d62a17ae | 8762 | if (filter->plist[FILTER_IN].name |
8763 | || filter->dlist[FILTER_IN].name | |
8764 | || filter->aslist[FILTER_IN].name | |
8765 | || filter->map[RMAP_IN].name) | |
8766 | json_object_boolean_true_add(json_addr, | |
8767 | "inboundPathPolicyConfig"); | |
8768 | if (filter->plist[FILTER_OUT].name | |
8769 | || filter->dlist[FILTER_OUT].name | |
8770 | || filter->aslist[FILTER_OUT].name | |
8771 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8772 | json_object_boolean_true_add( | |
8773 | json_addr, "outboundPathPolicyConfig"); | |
8774 | ||
8775 | /* prefix-list */ | |
8776 | if (filter->plist[FILTER_IN].name) | |
8777 | json_object_string_add(json_addr, | |
8778 | "incomingUpdatePrefixFilterList", | |
8779 | filter->plist[FILTER_IN].name); | |
8780 | if (filter->plist[FILTER_OUT].name) | |
8781 | json_object_string_add(json_addr, | |
8782 | "outgoingUpdatePrefixFilterList", | |
8783 | filter->plist[FILTER_OUT].name); | |
8784 | ||
8785 | /* distribute-list */ | |
8786 | if (filter->dlist[FILTER_IN].name) | |
8787 | json_object_string_add( | |
8788 | json_addr, "incomingUpdateNetworkFilterList", | |
8789 | filter->dlist[FILTER_IN].name); | |
8790 | if (filter->dlist[FILTER_OUT].name) | |
8791 | json_object_string_add( | |
8792 | json_addr, "outgoingUpdateNetworkFilterList", | |
8793 | filter->dlist[FILTER_OUT].name); | |
8794 | ||
8795 | /* filter-list. */ | |
8796 | if (filter->aslist[FILTER_IN].name) | |
8797 | json_object_string_add(json_addr, | |
8798 | "incomingUpdateAsPathFilterList", | |
8799 | filter->aslist[FILTER_IN].name); | |
8800 | if (filter->aslist[FILTER_OUT].name) | |
8801 | json_object_string_add(json_addr, | |
8802 | "outgoingUpdateAsPathFilterList", | |
8803 | filter->aslist[FILTER_OUT].name); | |
8804 | ||
8805 | /* route-map. */ | |
8806 | if (filter->map[RMAP_IN].name) | |
8807 | json_object_string_add( | |
8808 | json_addr, "routeMapForIncomingAdvertisements", | |
8809 | filter->map[RMAP_IN].name); | |
8810 | if (filter->map[RMAP_OUT].name) | |
8811 | json_object_string_add( | |
8812 | json_addr, "routeMapForOutgoingAdvertisements", | |
8813 | filter->map[RMAP_OUT].name); | |
8814 | ||
8815 | /* unsuppress-map */ | |
8816 | if (filter->usmap.name) | |
8817 | json_object_string_add(json_addr, | |
8818 | "selectiveUnsuppressRouteMap", | |
8819 | filter->usmap.name); | |
8820 | ||
8821 | /* Receive prefix count */ | |
8822 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8823 | p->pcount[afi][safi]); | |
50e05855 AD |
8824 | if (paf && PAF_SUBGRP(paf)) |
8825 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8826 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8827 | |
8828 | /* Maximum prefix */ | |
8829 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8830 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8831 | p->pmax[afi][safi]); | |
8832 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8833 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8834 | json_object_boolean_true_add( | |
8835 | json_addr, "prefixAllowedMaxWarning"); | |
8836 | json_object_int_add(json_addr, | |
8837 | "prefixAllowedWarningThresh", | |
8838 | p->pmax_threshold[afi][safi]); | |
8839 | if (p->pmax_restart[afi][safi]) | |
8840 | json_object_int_add( | |
8841 | json_addr, | |
8842 | "prefixAllowedRestartIntervalMsecs", | |
8843 | p->pmax_restart[afi][safi] * 60000); | |
8844 | } | |
8845 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8846 | json_addr); | |
8847 | ||
8848 | } else { | |
8849 | filter = &p->filter[afi][safi]; | |
8850 | ||
8851 | vty_out(vty, " For address family: %s\n", | |
8852 | afi_safi_print(afi, safi)); | |
8853 | ||
8854 | if (peer_group_active(p)) | |
8855 | vty_out(vty, " %s peer-group member\n", | |
8856 | p->group->name); | |
8857 | ||
8858 | paf = peer_af_find(p, afi, safi); | |
8859 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8860 | vty_out(vty, " Update group %" PRIu64 |
8861 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8862 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8863 | vty_out(vty, " Packet Queue length %d\n", | |
8864 | bpacket_queue_virtual_length(paf)); | |
8865 | } else { | |
8866 | vty_out(vty, " Not part of any update group\n"); | |
8867 | } | |
8868 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8869 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8870 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8871 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8872 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8873 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8874 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8875 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8876 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8877 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8878 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8879 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8880 | ||
8881 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8882 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8883 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8884 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8885 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8886 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8887 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8888 | vty_out(vty, | |
8889 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8890 | ORF_TYPE_PREFIX); | |
8891 | bgp_show_peer_afi_orf_cap( | |
8892 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8893 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8894 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8895 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8896 | } | |
8897 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8898 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8899 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8900 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8901 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8902 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8903 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8904 | vty_out(vty, | |
8905 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8906 | ORF_TYPE_PREFIX_OLD); | |
8907 | bgp_show_peer_afi_orf_cap( | |
8908 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8909 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8910 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8911 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8912 | } | |
8913 | ||
8914 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8915 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8916 | NULL, afi, orf_pfx_name, use_json); | |
8917 | ||
8918 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8919 | PEER_STATUS_ORF_PREFIX_SEND) | |
8920 | || orf_pfx_count) { | |
8921 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8922 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8923 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8924 | vty_out(vty, " sent;"); | |
8925 | if (orf_pfx_count) | |
8926 | vty_out(vty, " received (%d entries)", | |
8927 | orf_pfx_count); | |
8928 | vty_out(vty, "\n"); | |
8929 | } | |
8930 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8931 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8932 | vty_out(vty, | |
8933 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8934 | ||
8935 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8936 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8937 | vty_out(vty, " Route-Reflector Client\n"); | |
8938 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8939 | PEER_FLAG_RSERVER_CLIENT)) | |
8940 | vty_out(vty, " Route-Server Client\n"); | |
8941 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8942 | vty_out(vty, | |
8943 | " Inbound soft reconfiguration allowed\n"); | |
8944 | ||
8945 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8946 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8947 | vty_out(vty, | |
8948 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8949 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8950 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8951 | vty_out(vty, | |
8952 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8953 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8954 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8955 | vty_out(vty, | |
8956 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8957 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8958 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8959 | vty_out(vty, | |
8960 | " Private AS numbers removed in updates to this neighbor\n"); | |
8961 | ||
dcc68b5e MS |
8962 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8963 | vty_out(vty, " %s\n", | |
8964 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8965 | ->human_description); | |
d62a17ae | 8966 | |
8967 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8968 | vty_out(vty, | |
8969 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8970 | ||
8971 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8972 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8973 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8974 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8975 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8976 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8977 | vty_out(vty, | |
8978 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8979 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8980 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8981 | vty_out(vty, | |
8982 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8983 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8984 | vty_out(vty, | |
8985 | " MED is propagated unchanged to this neighbor\n"); | |
8986 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8987 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8988 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8989 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8990 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8991 | vty_out(vty, | |
8992 | " Community attribute sent to this neighbor"); | |
8993 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8994 | PEER_FLAG_SEND_COMMUNITY) | |
8995 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8996 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8997 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8998 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8999 | vty_out(vty, "(all)\n"); | |
9000 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9001 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9002 | vty_out(vty, "(large)\n"); | |
9003 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9004 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9005 | vty_out(vty, "(extended)\n"); | |
9006 | else | |
9007 | vty_out(vty, "(standard)\n"); | |
9008 | } | |
9009 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9010 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9011 | vty_out(vty, " Default information originate,"); | |
9012 | ||
9013 | if (p->default_rmap[afi][safi].name) | |
9014 | vty_out(vty, " default route-map %s%s,", | |
9015 | p->default_rmap[afi][safi].map ? "*" | |
9016 | : "", | |
9017 | p->default_rmap[afi][safi].name); | |
9018 | if (paf && PAF_SUBGRP(paf) | |
9019 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9020 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9021 | vty_out(vty, " default sent\n"); | |
9022 | else | |
9023 | vty_out(vty, " default not sent\n"); | |
9024 | } | |
9025 | ||
dff8f48d MK |
9026 | /* advertise-vni-all */ |
9027 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9028 | if (is_evpn_enabled()) |
dff8f48d MK |
9029 | vty_out(vty, " advertise-all-vni\n"); |
9030 | } | |
9031 | ||
d62a17ae | 9032 | if (filter->plist[FILTER_IN].name |
9033 | || filter->dlist[FILTER_IN].name | |
9034 | || filter->aslist[FILTER_IN].name | |
9035 | || filter->map[RMAP_IN].name) | |
9036 | vty_out(vty, " Inbound path policy configured\n"); | |
9037 | if (filter->plist[FILTER_OUT].name | |
9038 | || filter->dlist[FILTER_OUT].name | |
9039 | || filter->aslist[FILTER_OUT].name | |
9040 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9041 | vty_out(vty, " Outbound path policy configured\n"); | |
9042 | ||
9043 | /* prefix-list */ | |
9044 | if (filter->plist[FILTER_IN].name) | |
9045 | vty_out(vty, | |
9046 | " Incoming update prefix filter list is %s%s\n", | |
9047 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9048 | filter->plist[FILTER_IN].name); | |
9049 | if (filter->plist[FILTER_OUT].name) | |
9050 | vty_out(vty, | |
9051 | " Outgoing update prefix filter list is %s%s\n", | |
9052 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9053 | filter->plist[FILTER_OUT].name); | |
9054 | ||
9055 | /* distribute-list */ | |
9056 | if (filter->dlist[FILTER_IN].name) | |
9057 | vty_out(vty, | |
9058 | " Incoming update network filter list is %s%s\n", | |
9059 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9060 | filter->dlist[FILTER_IN].name); | |
9061 | if (filter->dlist[FILTER_OUT].name) | |
9062 | vty_out(vty, | |
9063 | " Outgoing update network filter list is %s%s\n", | |
9064 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9065 | filter->dlist[FILTER_OUT].name); | |
9066 | ||
9067 | /* filter-list. */ | |
9068 | if (filter->aslist[FILTER_IN].name) | |
9069 | vty_out(vty, | |
9070 | " Incoming update AS path filter list is %s%s\n", | |
9071 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9072 | filter->aslist[FILTER_IN].name); | |
9073 | if (filter->aslist[FILTER_OUT].name) | |
9074 | vty_out(vty, | |
9075 | " Outgoing update AS path filter list is %s%s\n", | |
9076 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9077 | filter->aslist[FILTER_OUT].name); | |
9078 | ||
9079 | /* route-map. */ | |
9080 | if (filter->map[RMAP_IN].name) | |
9081 | vty_out(vty, | |
9082 | " Route map for incoming advertisements is %s%s\n", | |
9083 | filter->map[RMAP_IN].map ? "*" : "", | |
9084 | filter->map[RMAP_IN].name); | |
9085 | if (filter->map[RMAP_OUT].name) | |
9086 | vty_out(vty, | |
9087 | " Route map for outgoing advertisements is %s%s\n", | |
9088 | filter->map[RMAP_OUT].map ? "*" : "", | |
9089 | filter->map[RMAP_OUT].name); | |
9090 | ||
9091 | /* unsuppress-map */ | |
9092 | if (filter->usmap.name) | |
9093 | vty_out(vty, | |
9094 | " Route map for selective unsuppress is %s%s\n", | |
9095 | filter->usmap.map ? "*" : "", | |
9096 | filter->usmap.name); | |
9097 | ||
9098 | /* Receive prefix count */ | |
9099 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9100 | ||
9101 | /* Maximum prefix */ | |
9102 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9103 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9104 | p->pmax[afi][safi], | |
9105 | CHECK_FLAG(p->af_flags[afi][safi], | |
9106 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9107 | ? " (warning-only)" | |
9108 | : ""); | |
9109 | vty_out(vty, " Threshold for warning message %d%%", | |
9110 | p->pmax_threshold[afi][safi]); | |
9111 | if (p->pmax_restart[afi][safi]) | |
9112 | vty_out(vty, ", restart interval %d min", | |
9113 | p->pmax_restart[afi][safi]); | |
9114 | vty_out(vty, "\n"); | |
9115 | } | |
9116 | ||
9117 | vty_out(vty, "\n"); | |
9118 | } | |
9119 | } | |
9120 | ||
9f049418 | 9121 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9122 | json_object *json) |
718e3744 | 9123 | { |
d62a17ae | 9124 | struct bgp *bgp; |
9125 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9126 | char timebuf[BGP_UPTIME_LEN]; | |
9127 | char dn_flag[2]; | |
9128 | const char *subcode_str; | |
9129 | const char *code_str; | |
9130 | afi_t afi; | |
9131 | safi_t safi; | |
d7c0a89a QY |
9132 | uint16_t i; |
9133 | uint8_t *msg; | |
d62a17ae | 9134 | json_object *json_neigh = NULL; |
9135 | time_t epoch_tbuf; | |
718e3744 | 9136 | |
d62a17ae | 9137 | bgp = p->bgp; |
9138 | ||
9139 | if (use_json) | |
9140 | json_neigh = json_object_new_object(); | |
9141 | ||
9142 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9143 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9144 | dn_flag[0] = '*'; | |
9145 | ||
9146 | if (!use_json) { | |
9147 | if (p->conf_if) /* Configured interface name. */ | |
9148 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9149 | BGP_PEER_SU_UNSPEC(p) | |
9150 | ? "None" | |
9151 | : sockunion2str(&p->su, buf, | |
9152 | SU_ADDRSTRLEN)); | |
9153 | else /* Configured IP address. */ | |
9154 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9155 | p->host); | |
9156 | } | |
9157 | ||
9158 | if (use_json) { | |
9159 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9160 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9161 | "none"); | |
9162 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9163 | json_object_string_add( | |
9164 | json_neigh, "bgpNeighborAddr", | |
9165 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9166 | ||
9167 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9168 | ||
9169 | if (p->change_local_as) | |
9170 | json_object_int_add(json_neigh, "localAs", | |
9171 | p->change_local_as); | |
9172 | else | |
9173 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9174 | ||
9175 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9176 | json_object_boolean_true_add(json_neigh, | |
9177 | "localAsNoPrepend"); | |
9178 | ||
9179 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9180 | json_object_boolean_true_add(json_neigh, | |
9181 | "localAsReplaceAs"); | |
9182 | } else { | |
9183 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9184 | || (p->as_type == AS_INTERNAL)) | |
9185 | vty_out(vty, "remote AS %u, ", p->as); | |
9186 | else | |
9187 | vty_out(vty, "remote AS Unspecified, "); | |
9188 | vty_out(vty, "local AS %u%s%s, ", | |
9189 | p->change_local_as ? p->change_local_as : p->local_as, | |
9190 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9191 | ? " no-prepend" | |
9192 | : "", | |
9193 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9194 | ? " replace-as" | |
9195 | : ""); | |
9196 | } | |
9197 | /* peer type internal, external, confed-internal or confed-external */ | |
9198 | if (p->as == p->local_as) { | |
9199 | if (use_json) { | |
9200 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9201 | json_object_boolean_true_add( | |
9202 | json_neigh, "nbrConfedInternalLink"); | |
9203 | else | |
9204 | json_object_boolean_true_add(json_neigh, | |
9205 | "nbrInternalLink"); | |
9206 | } else { | |
9207 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9208 | vty_out(vty, "confed-internal link\n"); | |
9209 | else | |
9210 | vty_out(vty, "internal link\n"); | |
9211 | } | |
9212 | } else { | |
9213 | if (use_json) { | |
9214 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9215 | json_object_boolean_true_add( | |
9216 | json_neigh, "nbrConfedExternalLink"); | |
9217 | else | |
9218 | json_object_boolean_true_add(json_neigh, | |
9219 | "nbrExternalLink"); | |
9220 | } else { | |
9221 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9222 | vty_out(vty, "confed-external link\n"); | |
9223 | else | |
9224 | vty_out(vty, "external link\n"); | |
9225 | } | |
9226 | } | |
9227 | ||
9228 | /* Description. */ | |
9229 | if (p->desc) { | |
9230 | if (use_json) | |
9231 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9232 | else | |
9233 | vty_out(vty, " Description: %s\n", p->desc); | |
9234 | } | |
9235 | ||
9236 | if (p->hostname) { | |
9237 | if (use_json) { | |
9238 | if (p->hostname) | |
9239 | json_object_string_add(json_neigh, "hostname", | |
9240 | p->hostname); | |
9241 | ||
9242 | if (p->domainname) | |
9243 | json_object_string_add(json_neigh, "domainname", | |
9244 | p->domainname); | |
9245 | } else { | |
9246 | if (p->domainname && (p->domainname[0] != '\0')) | |
9247 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9248 | p->domainname); | |
9249 | else | |
9250 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9251 | } | |
9252 | } | |
9253 | ||
9254 | /* Peer-group */ | |
9255 | if (p->group) { | |
9256 | if (use_json) { | |
9257 | json_object_string_add(json_neigh, "peerGroup", | |
9258 | p->group->name); | |
9259 | ||
9260 | if (dn_flag[0]) { | |
9261 | struct prefix prefix, *range = NULL; | |
9262 | ||
9263 | sockunion2hostprefix(&(p->su), &prefix); | |
9264 | range = peer_group_lookup_dynamic_neighbor_range( | |
9265 | p->group, &prefix); | |
9266 | ||
9267 | if (range) { | |
9268 | prefix2str(range, buf1, sizeof(buf1)); | |
9269 | json_object_string_add( | |
9270 | json_neigh, | |
9271 | "peerSubnetRangeGroup", buf1); | |
9272 | } | |
9273 | } | |
9274 | } else { | |
9275 | vty_out(vty, | |
9276 | " Member of peer-group %s for session parameters\n", | |
9277 | p->group->name); | |
9278 | ||
9279 | if (dn_flag[0]) { | |
9280 | struct prefix prefix, *range = NULL; | |
9281 | ||
9282 | sockunion2hostprefix(&(p->su), &prefix); | |
9283 | range = peer_group_lookup_dynamic_neighbor_range( | |
9284 | p->group, &prefix); | |
9285 | ||
9286 | if (range) { | |
9287 | prefix2str(range, buf1, sizeof(buf1)); | |
9288 | vty_out(vty, | |
9289 | " Belongs to the subnet range group: %s\n", | |
9290 | buf1); | |
9291 | } | |
9292 | } | |
9293 | } | |
9294 | } | |
9295 | ||
9296 | if (use_json) { | |
9297 | /* Administrative shutdown. */ | |
9298 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9299 | json_object_boolean_true_add(json_neigh, | |
9300 | "adminShutDown"); | |
9301 | ||
9302 | /* BGP Version. */ | |
9303 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9304 | json_object_string_add( | |
9305 | json_neigh, "remoteRouterId", | |
9306 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9307 | json_object_string_add( |
9308 | json_neigh, "localRouterId", | |
9309 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9310 | sizeof(buf1))); | |
d62a17ae | 9311 | |
9312 | /* Confederation */ | |
9313 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9314 | && bgp_confederation_peers_check(bgp, p->as)) | |
9315 | json_object_boolean_true_add(json_neigh, | |
9316 | "nbrCommonAdmin"); | |
9317 | ||
9318 | /* Status. */ | |
9319 | json_object_string_add( | |
9320 | json_neigh, "bgpState", | |
9321 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9322 | ||
9323 | if (p->status == Established) { | |
9324 | time_t uptime; | |
d62a17ae | 9325 | |
9326 | uptime = bgp_clock(); | |
9327 | uptime -= p->uptime; | |
d62a17ae | 9328 | epoch_tbuf = time(NULL) - uptime; |
9329 | ||
bee57a7a | 9330 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9331 | CPP_NOTICE( |
9332 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9333 | #endif |
9334 | /* | |
9335 | * bgpTimerUp was miliseconds that was accurate | |
9336 | * up to 1 day, then the value returned | |
9337 | * became garbage. So in order to provide | |
9338 | * some level of backwards compatability, | |
9339 | * we still provde the data, but now | |
9340 | * we are returning the correct value | |
9341 | * and also adding a new bgpTimerUpMsec | |
9342 | * which will allow us to deprecate | |
9343 | * this eventually | |
9344 | */ | |
d62a17ae | 9345 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9346 | uptime * 1000); |
d3c7efed DS |
9347 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9348 | uptime * 1000); | |
d62a17ae | 9349 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9350 | peer_uptime(p->uptime, timebuf, | |
9351 | BGP_UPTIME_LEN, 0, | |
9352 | NULL)); | |
9353 | json_object_int_add(json_neigh, | |
9354 | "bgpTimerUpEstablishedEpoch", | |
9355 | epoch_tbuf); | |
9356 | } | |
9357 | ||
9358 | else if (p->status == Active) { | |
9359 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9360 | json_object_string_add(json_neigh, "bgpStateIs", | |
9361 | "passive"); | |
9362 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9363 | json_object_string_add(json_neigh, "bgpStateIs", | |
9364 | "passiveNSF"); | |
9365 | } | |
9366 | ||
9367 | /* read timer */ | |
9368 | time_t uptime; | |
9369 | struct tm *tm; | |
9370 | ||
9371 | uptime = bgp_clock(); | |
9372 | uptime -= p->readtime; | |
9373 | tm = gmtime(&uptime); | |
9374 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9375 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9376 | + (tm->tm_hour * 3600000)); | |
9377 | ||
9378 | uptime = bgp_clock(); | |
9379 | uptime -= p->last_write; | |
9380 | tm = gmtime(&uptime); | |
9381 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9382 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9383 | + (tm->tm_hour * 3600000)); | |
9384 | ||
9385 | uptime = bgp_clock(); | |
9386 | uptime -= p->update_time; | |
9387 | tm = gmtime(&uptime); | |
9388 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9389 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9390 | + (tm->tm_hour * 3600000)); | |
9391 | ||
9392 | /* Configured timer values. */ | |
9393 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9394 | p->v_holdtime * 1000); | |
9395 | json_object_int_add(json_neigh, | |
9396 | "bgpTimerKeepAliveIntervalMsecs", | |
9397 | p->v_keepalive * 1000); | |
b90a8e13 | 9398 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9399 | json_object_int_add(json_neigh, |
9400 | "bgpTimerConfiguredHoldTimeMsecs", | |
9401 | p->holdtime * 1000); | |
9402 | json_object_int_add( | |
9403 | json_neigh, | |
9404 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9405 | p->keepalive * 1000); | |
d25e4efc | 9406 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9407 | || (bgp->default_keepalive |
9408 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9409 | json_object_int_add(json_neigh, |
9410 | "bgpTimerConfiguredHoldTimeMsecs", | |
9411 | bgp->default_holdtime); | |
9412 | json_object_int_add( | |
9413 | json_neigh, | |
9414 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9415 | bgp->default_keepalive); | |
d62a17ae | 9416 | } |
9417 | } else { | |
9418 | /* Administrative shutdown. */ | |
9419 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9420 | vty_out(vty, " Administratively shut down\n"); | |
9421 | ||
9422 | /* BGP Version. */ | |
9423 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9424 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9425 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9426 | vty_out(vty, ", local router ID %s\n", |
9427 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9428 | sizeof(buf1))); | |
d62a17ae | 9429 | |
9430 | /* Confederation */ | |
9431 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9432 | && bgp_confederation_peers_check(bgp, p->as)) | |
9433 | vty_out(vty, | |
9434 | " Neighbor under common administration\n"); | |
9435 | ||
9436 | /* Status. */ | |
9437 | vty_out(vty, " BGP state = %s", | |
9438 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9439 | ||
9440 | if (p->status == Established) | |
9441 | vty_out(vty, ", up for %8s", | |
9442 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9443 | 0, NULL)); | |
9444 | ||
9445 | else if (p->status == Active) { | |
9446 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9447 | vty_out(vty, " (passive)"); | |
9448 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9449 | vty_out(vty, " (NSF passive)"); | |
9450 | } | |
9451 | vty_out(vty, "\n"); | |
9452 | ||
9453 | /* read timer */ | |
9454 | vty_out(vty, " Last read %s", | |
9455 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9456 | NULL)); | |
9457 | vty_out(vty, ", Last write %s\n", | |
9458 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9459 | NULL)); | |
9460 | ||
9461 | /* Configured timer values. */ | |
9462 | vty_out(vty, | |
9463 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9464 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9465 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9466 | vty_out(vty, " Configured hold time is %d", |
9467 | p->holdtime); | |
9468 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9469 | p->keepalive); | |
d25e4efc | 9470 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9471 | || (bgp->default_keepalive |
9472 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9473 | vty_out(vty, " Configured hold time is %d", |
9474 | bgp->default_holdtime); | |
9475 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9476 | bgp->default_keepalive); | |
d62a17ae | 9477 | } |
9478 | } | |
9479 | /* Capability. */ | |
9480 | if (p->status == Established) { | |
9481 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9482 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9483 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9484 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9485 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9486 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9487 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9488 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9489 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9490 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9491 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9492 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9493 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9494 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9495 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9496 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9497 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9498 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9499 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9500 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9501 | if (use_json) { | |
9502 | json_object *json_cap = NULL; | |
9503 | ||
9504 | json_cap = json_object_new_object(); | |
9505 | ||
9506 | /* AS4 */ | |
9507 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9508 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9509 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9510 | && CHECK_FLAG(p->cap, | |
9511 | PEER_CAP_AS4_RCV)) | |
9512 | json_object_string_add( | |
9513 | json_cap, "4byteAs", | |
9514 | "advertisedAndReceived"); | |
9515 | else if (CHECK_FLAG(p->cap, | |
9516 | PEER_CAP_AS4_ADV)) | |
9517 | json_object_string_add( | |
9518 | json_cap, "4byteAs", | |
9519 | "advertised"); | |
9520 | else if (CHECK_FLAG(p->cap, | |
9521 | PEER_CAP_AS4_RCV)) | |
9522 | json_object_string_add( | |
9523 | json_cap, "4byteAs", | |
9524 | "received"); | |
9525 | } | |
9526 | ||
9527 | /* AddPath */ | |
9528 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9529 | || CHECK_FLAG(p->cap, | |
9530 | PEER_CAP_ADDPATH_ADV)) { | |
9531 | json_object *json_add = NULL; | |
9532 | const char *print_store; | |
9533 | ||
9534 | json_add = json_object_new_object(); | |
9535 | ||
05c7a1cc QY |
9536 | FOREACH_AFI_SAFI (afi, safi) { |
9537 | json_object *json_sub = NULL; | |
9538 | json_sub = | |
9539 | json_object_new_object(); | |
9540 | print_store = afi_safi_print( | |
9541 | afi, safi); | |
d62a17ae | 9542 | |
05c7a1cc QY |
9543 | if (CHECK_FLAG( |
9544 | p->af_cap[afi] | |
9545 | [safi], | |
9546 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9547 | || CHECK_FLAG( | |
9548 | p->af_cap[afi] | |
9549 | [safi], | |
9550 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9551 | if (CHECK_FLAG( |
9552 | p->af_cap | |
9553 | [afi] | |
9554 | [safi], | |
9555 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9556 | && CHECK_FLAG( |
d62a17ae | 9557 | p->af_cap |
9558 | [afi] | |
9559 | [safi], | |
05c7a1cc QY |
9560 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9561 | json_object_boolean_true_add( | |
9562 | json_sub, | |
9563 | "txAdvertisedAndReceived"); | |
9564 | else if ( | |
9565 | CHECK_FLAG( | |
9566 | p->af_cap | |
9567 | [afi] | |
9568 | [safi], | |
9569 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9570 | json_object_boolean_true_add( | |
9571 | json_sub, | |
9572 | "txAdvertised"); | |
9573 | else if ( | |
9574 | CHECK_FLAG( | |
9575 | p->af_cap | |
9576 | [afi] | |
9577 | [safi], | |
9578 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9579 | json_object_boolean_true_add( | |
9580 | json_sub, | |
9581 | "txReceived"); | |
9582 | } | |
d62a17ae | 9583 | |
05c7a1cc QY |
9584 | if (CHECK_FLAG( |
9585 | p->af_cap[afi] | |
9586 | [safi], | |
9587 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9588 | || CHECK_FLAG( | |
9589 | p->af_cap[afi] | |
9590 | [safi], | |
9591 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9592 | if (CHECK_FLAG( |
9593 | p->af_cap | |
9594 | [afi] | |
9595 | [safi], | |
9596 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9597 | && CHECK_FLAG( |
d62a17ae | 9598 | p->af_cap |
9599 | [afi] | |
9600 | [safi], | |
9601 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9602 | json_object_boolean_true_add( |
9603 | json_sub, | |
9604 | "rxAdvertisedAndReceived"); | |
9605 | else if ( | |
9606 | CHECK_FLAG( | |
9607 | p->af_cap | |
9608 | [afi] | |
9609 | [safi], | |
9610 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9611 | json_object_boolean_true_add( | |
9612 | json_sub, | |
9613 | "rxAdvertised"); | |
9614 | else if ( | |
9615 | CHECK_FLAG( | |
9616 | p->af_cap | |
9617 | [afi] | |
9618 | [safi], | |
9619 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9620 | json_object_boolean_true_add( | |
9621 | json_sub, | |
9622 | "rxReceived"); | |
d62a17ae | 9623 | } |
9624 | ||
05c7a1cc QY |
9625 | if (CHECK_FLAG( |
9626 | p->af_cap[afi] | |
9627 | [safi], | |
9628 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9629 | || CHECK_FLAG( | |
9630 | p->af_cap[afi] | |
9631 | [safi], | |
9632 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9633 | || CHECK_FLAG( | |
9634 | p->af_cap[afi] | |
9635 | [safi], | |
9636 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9637 | || CHECK_FLAG( | |
9638 | p->af_cap[afi] | |
9639 | [safi], | |
9640 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9641 | json_object_object_add( | |
9642 | json_add, | |
9643 | print_store, | |
9644 | json_sub); | |
9645 | else | |
9646 | json_object_free( | |
9647 | json_sub); | |
9648 | } | |
9649 | ||
d62a17ae | 9650 | json_object_object_add( |
9651 | json_cap, "addPath", json_add); | |
9652 | } | |
9653 | ||
9654 | /* Dynamic */ | |
9655 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9656 | || CHECK_FLAG(p->cap, | |
9657 | PEER_CAP_DYNAMIC_ADV)) { | |
9658 | if (CHECK_FLAG(p->cap, | |
9659 | PEER_CAP_DYNAMIC_ADV) | |
9660 | && CHECK_FLAG(p->cap, | |
9661 | PEER_CAP_DYNAMIC_RCV)) | |
9662 | json_object_string_add( | |
9663 | json_cap, "dynamic", | |
9664 | "advertisedAndReceived"); | |
9665 | else if (CHECK_FLAG( | |
9666 | p->cap, | |
9667 | PEER_CAP_DYNAMIC_ADV)) | |
9668 | json_object_string_add( | |
9669 | json_cap, "dynamic", | |
9670 | "advertised"); | |
9671 | else if (CHECK_FLAG( | |
9672 | p->cap, | |
9673 | PEER_CAP_DYNAMIC_RCV)) | |
9674 | json_object_string_add( | |
9675 | json_cap, "dynamic", | |
9676 | "received"); | |
9677 | } | |
9678 | ||
9679 | /* Extended nexthop */ | |
9680 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9681 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9682 | json_object *json_nxt = NULL; | |
9683 | const char *print_store; | |
9684 | ||
9685 | ||
9686 | if (CHECK_FLAG(p->cap, | |
9687 | PEER_CAP_ENHE_ADV) | |
9688 | && CHECK_FLAG(p->cap, | |
9689 | PEER_CAP_ENHE_RCV)) | |
9690 | json_object_string_add( | |
9691 | json_cap, | |
9692 | "extendedNexthop", | |
9693 | "advertisedAndReceived"); | |
9694 | else if (CHECK_FLAG(p->cap, | |
9695 | PEER_CAP_ENHE_ADV)) | |
9696 | json_object_string_add( | |
9697 | json_cap, | |
9698 | "extendedNexthop", | |
9699 | "advertised"); | |
9700 | else if (CHECK_FLAG(p->cap, | |
9701 | PEER_CAP_ENHE_RCV)) | |
9702 | json_object_string_add( | |
9703 | json_cap, | |
9704 | "extendedNexthop", | |
9705 | "received"); | |
9706 | ||
9707 | if (CHECK_FLAG(p->cap, | |
9708 | PEER_CAP_ENHE_RCV)) { | |
9709 | json_nxt = | |
9710 | json_object_new_object(); | |
9711 | ||
9712 | for (safi = SAFI_UNICAST; | |
9713 | safi < SAFI_MAX; safi++) { | |
9714 | if (CHECK_FLAG( | |
9715 | p->af_cap | |
9716 | [AFI_IP] | |
9717 | [safi], | |
9718 | PEER_CAP_ENHE_AF_RCV)) { | |
9719 | print_store = afi_safi_print( | |
9720 | AFI_IP, | |
9721 | safi); | |
9722 | json_object_string_add( | |
9723 | json_nxt, | |
9724 | print_store, | |
0437e105 | 9725 | "received"); |
d62a17ae | 9726 | } |
9727 | } | |
9728 | json_object_object_add( | |
9729 | json_cap, | |
9730 | "extendedNexthopFamililesByPeer", | |
9731 | json_nxt); | |
9732 | } | |
9733 | } | |
9734 | ||
9735 | /* Route Refresh */ | |
9736 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9737 | || CHECK_FLAG(p->cap, | |
9738 | PEER_CAP_REFRESH_NEW_RCV) | |
9739 | || CHECK_FLAG(p->cap, | |
9740 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9741 | if (CHECK_FLAG(p->cap, | |
9742 | PEER_CAP_REFRESH_ADV) | |
9743 | && (CHECK_FLAG( | |
9744 | p->cap, | |
9745 | PEER_CAP_REFRESH_NEW_RCV) | |
9746 | || CHECK_FLAG( | |
9747 | p->cap, | |
9748 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9749 | if (CHECK_FLAG( | |
9750 | p->cap, | |
9751 | PEER_CAP_REFRESH_OLD_RCV) | |
9752 | && CHECK_FLAG( | |
9753 | p->cap, | |
9754 | PEER_CAP_REFRESH_NEW_RCV)) | |
9755 | json_object_string_add( | |
9756 | json_cap, | |
9757 | "routeRefresh", | |
9758 | "advertisedAndReceivedOldNew"); | |
9759 | else { | |
9760 | if (CHECK_FLAG( | |
9761 | p->cap, | |
9762 | PEER_CAP_REFRESH_OLD_RCV)) | |
9763 | json_object_string_add( | |
9764 | json_cap, | |
9765 | "routeRefresh", | |
9766 | "advertisedAndReceivedOld"); | |
9767 | else | |
9768 | json_object_string_add( | |
9769 | json_cap, | |
9770 | "routeRefresh", | |
9771 | "advertisedAndReceivedNew"); | |
9772 | } | |
9773 | } else if ( | |
9774 | CHECK_FLAG( | |
9775 | p->cap, | |
9776 | PEER_CAP_REFRESH_ADV)) | |
9777 | json_object_string_add( | |
9778 | json_cap, | |
9779 | "routeRefresh", | |
9780 | "advertised"); | |
9781 | else if ( | |
9782 | CHECK_FLAG( | |
9783 | p->cap, | |
9784 | PEER_CAP_REFRESH_NEW_RCV) | |
9785 | || CHECK_FLAG( | |
9786 | p->cap, | |
9787 | PEER_CAP_REFRESH_OLD_RCV)) | |
9788 | json_object_string_add( | |
9789 | json_cap, | |
9790 | "routeRefresh", | |
9791 | "received"); | |
9792 | } | |
9793 | ||
9794 | /* Multiprotocol Extensions */ | |
9795 | json_object *json_multi = NULL; | |
9796 | json_multi = json_object_new_object(); | |
9797 | ||
05c7a1cc QY |
9798 | FOREACH_AFI_SAFI (afi, safi) { |
9799 | if (p->afc_adv[afi][safi] | |
9800 | || p->afc_recv[afi][safi]) { | |
9801 | json_object *json_exten = NULL; | |
9802 | json_exten = | |
9803 | json_object_new_object(); | |
9804 | ||
d62a17ae | 9805 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9806 | && p->afc_recv[afi][safi]) |
9807 | json_object_boolean_true_add( | |
9808 | json_exten, | |
9809 | "advertisedAndReceived"); | |
9810 | else if (p->afc_adv[afi][safi]) | |
9811 | json_object_boolean_true_add( | |
9812 | json_exten, | |
9813 | "advertised"); | |
9814 | else if (p->afc_recv[afi][safi]) | |
9815 | json_object_boolean_true_add( | |
9816 | json_exten, | |
9817 | "received"); | |
d62a17ae | 9818 | |
05c7a1cc QY |
9819 | json_object_object_add( |
9820 | json_multi, | |
9821 | afi_safi_print(afi, | |
9822 | safi), | |
9823 | json_exten); | |
d62a17ae | 9824 | } |
9825 | } | |
9826 | json_object_object_add( | |
9827 | json_cap, "multiprotocolExtensions", | |
9828 | json_multi); | |
9829 | ||
d77114b7 | 9830 | /* Hostname capabilities */ |
60466a63 | 9831 | json_object *json_hname = NULL; |
d77114b7 MK |
9832 | |
9833 | json_hname = json_object_new_object(); | |
9834 | ||
9835 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9836 | json_object_string_add( | |
60466a63 QY |
9837 | json_hname, "advHostName", |
9838 | bgp->peer_self->hostname | |
9839 | ? bgp->peer_self | |
9840 | ->hostname | |
d77114b7 MK |
9841 | : "n/a"); |
9842 | json_object_string_add( | |
60466a63 QY |
9843 | json_hname, "advDomainName", |
9844 | bgp->peer_self->domainname | |
9845 | ? bgp->peer_self | |
9846 | ->domainname | |
d77114b7 MK |
9847 | : "n/a"); |
9848 | } | |
9849 | ||
9850 | ||
9851 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9852 | json_object_string_add( | |
60466a63 QY |
9853 | json_hname, "rcvHostName", |
9854 | p->hostname ? p->hostname | |
9855 | : "n/a"); | |
d77114b7 | 9856 | json_object_string_add( |
60466a63 QY |
9857 | json_hname, "rcvDomainName", |
9858 | p->domainname ? p->domainname | |
9859 | : "n/a"); | |
d77114b7 MK |
9860 | } |
9861 | ||
60466a63 | 9862 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9863 | json_hname); |
9864 | ||
d62a17ae | 9865 | /* Gracefull Restart */ |
9866 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9867 | || CHECK_FLAG(p->cap, | |
9868 | PEER_CAP_RESTART_ADV)) { | |
9869 | if (CHECK_FLAG(p->cap, | |
9870 | PEER_CAP_RESTART_ADV) | |
9871 | && CHECK_FLAG(p->cap, | |
9872 | PEER_CAP_RESTART_RCV)) | |
9873 | json_object_string_add( | |
9874 | json_cap, | |
9875 | "gracefulRestart", | |
9876 | "advertisedAndReceived"); | |
9877 | else if (CHECK_FLAG( | |
9878 | p->cap, | |
9879 | PEER_CAP_RESTART_ADV)) | |
9880 | json_object_string_add( | |
9881 | json_cap, | |
9882 | "gracefulRestartCapability", | |
9883 | "advertised"); | |
9884 | else if (CHECK_FLAG( | |
9885 | p->cap, | |
9886 | PEER_CAP_RESTART_RCV)) | |
9887 | json_object_string_add( | |
9888 | json_cap, | |
9889 | "gracefulRestartCapability", | |
9890 | "received"); | |
9891 | ||
9892 | if (CHECK_FLAG(p->cap, | |
9893 | PEER_CAP_RESTART_RCV)) { | |
9894 | int restart_af_count = 0; | |
9895 | json_object *json_restart = | |
9896 | NULL; | |
9897 | json_restart = | |
9898 | json_object_new_object(); | |
9899 | ||
9900 | json_object_int_add( | |
9901 | json_cap, | |
9902 | "gracefulRestartRemoteTimerMsecs", | |
9903 | p->v_gr_restart * 1000); | |
9904 | ||
05c7a1cc QY |
9905 | FOREACH_AFI_SAFI (afi, safi) { |
9906 | if (CHECK_FLAG( | |
9907 | p->af_cap | |
9908 | [afi] | |
9909 | [safi], | |
9910 | PEER_CAP_RESTART_AF_RCV)) { | |
9911 | json_object * | |
9912 | json_sub = | |
9913 | NULL; | |
9914 | json_sub = | |
9915 | json_object_new_object(); | |
9916 | ||
d62a17ae | 9917 | if (CHECK_FLAG( |
9918 | p->af_cap | |
9919 | [afi] | |
9920 | [safi], | |
05c7a1cc QY |
9921 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9922 | json_object_boolean_true_add( | |
9923 | json_sub, | |
9924 | "preserved"); | |
9925 | restart_af_count++; | |
9926 | json_object_object_add( | |
9927 | json_restart, | |
9928 | afi_safi_print( | |
9929 | afi, | |
9930 | safi), | |
9931 | json_sub); | |
d62a17ae | 9932 | } |
9933 | } | |
9934 | if (!restart_af_count) { | |
9935 | json_object_string_add( | |
9936 | json_cap, | |
9937 | "addressFamiliesByPeer", | |
9938 | "none"); | |
9939 | json_object_free( | |
9940 | json_restart); | |
9941 | } else | |
9942 | json_object_object_add( | |
9943 | json_cap, | |
9944 | "addressFamiliesByPeer", | |
9945 | json_restart); | |
9946 | } | |
9947 | } | |
9948 | json_object_object_add(json_neigh, | |
9949 | "neighborCapabilities", | |
9950 | json_cap); | |
9951 | } else { | |
9952 | vty_out(vty, " Neighbor capabilities:\n"); | |
9953 | ||
9954 | /* AS4 */ | |
9955 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9956 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9957 | vty_out(vty, " 4 Byte AS:"); | |
9958 | if (CHECK_FLAG(p->cap, | |
9959 | PEER_CAP_AS4_ADV)) | |
9960 | vty_out(vty, " advertised"); | |
9961 | if (CHECK_FLAG(p->cap, | |
9962 | PEER_CAP_AS4_RCV)) | |
9963 | vty_out(vty, " %sreceived", | |
9964 | CHECK_FLAG( | |
9965 | p->cap, | |
9966 | PEER_CAP_AS4_ADV) | |
9967 | ? "and " | |
9968 | : ""); | |
9969 | vty_out(vty, "\n"); | |
9970 | } | |
9971 | ||
9972 | /* AddPath */ | |
9973 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9974 | || CHECK_FLAG(p->cap, | |
9975 | PEER_CAP_ADDPATH_ADV)) { | |
9976 | vty_out(vty, " AddPath:\n"); | |
9977 | ||
05c7a1cc QY |
9978 | FOREACH_AFI_SAFI (afi, safi) { |
9979 | if (CHECK_FLAG( | |
9980 | p->af_cap[afi] | |
9981 | [safi], | |
9982 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9983 | || CHECK_FLAG( | |
9984 | p->af_cap[afi] | |
9985 | [safi], | |
9986 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
9987 | vty_out(vty, | |
9988 | " %s: TX ", | |
9989 | afi_safi_print( | |
9990 | afi, | |
9991 | safi)); | |
9992 | ||
d62a17ae | 9993 | if (CHECK_FLAG( |
9994 | p->af_cap | |
9995 | [afi] | |
9996 | [safi], | |
05c7a1cc | 9997 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 9998 | vty_out(vty, |
05c7a1cc | 9999 | "advertised %s", |
d62a17ae | 10000 | afi_safi_print( |
10001 | afi, | |
10002 | safi)); | |
10003 | ||
05c7a1cc QY |
10004 | if (CHECK_FLAG( |
10005 | p->af_cap | |
10006 | [afi] | |
10007 | [safi], | |
10008 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10009 | vty_out(vty, | |
10010 | "%sreceived", | |
10011 | CHECK_FLAG( | |
10012 | p->af_cap | |
10013 | [afi] | |
10014 | [safi], | |
10015 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10016 | ? " and " | |
10017 | : ""); | |
d62a17ae | 10018 | |
05c7a1cc QY |
10019 | vty_out(vty, "\n"); |
10020 | } | |
d62a17ae | 10021 | |
05c7a1cc QY |
10022 | if (CHECK_FLAG( |
10023 | p->af_cap[afi] | |
10024 | [safi], | |
10025 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10026 | || CHECK_FLAG( | |
10027 | p->af_cap[afi] | |
10028 | [safi], | |
10029 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10030 | vty_out(vty, | |
10031 | " %s: RX ", | |
10032 | afi_safi_print( | |
10033 | afi, | |
10034 | safi)); | |
d62a17ae | 10035 | |
10036 | if (CHECK_FLAG( | |
10037 | p->af_cap | |
10038 | [afi] | |
10039 | [safi], | |
05c7a1cc | 10040 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10041 | vty_out(vty, |
05c7a1cc | 10042 | "advertised %s", |
d62a17ae | 10043 | afi_safi_print( |
10044 | afi, | |
10045 | safi)); | |
10046 | ||
05c7a1cc QY |
10047 | if (CHECK_FLAG( |
10048 | p->af_cap | |
10049 | [afi] | |
10050 | [safi], | |
10051 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10052 | vty_out(vty, |
05c7a1cc QY |
10053 | "%sreceived", |
10054 | CHECK_FLAG( | |
10055 | p->af_cap | |
10056 | [afi] | |
10057 | [safi], | |
10058 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10059 | ? " and " | |
10060 | : ""); | |
10061 | ||
10062 | vty_out(vty, "\n"); | |
d62a17ae | 10063 | } |
05c7a1cc | 10064 | } |
d62a17ae | 10065 | } |
10066 | ||
10067 | /* Dynamic */ | |
10068 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10069 | || CHECK_FLAG(p->cap, | |
10070 | PEER_CAP_DYNAMIC_ADV)) { | |
10071 | vty_out(vty, " Dynamic:"); | |
10072 | if (CHECK_FLAG(p->cap, | |
10073 | PEER_CAP_DYNAMIC_ADV)) | |
10074 | vty_out(vty, " advertised"); | |
10075 | if (CHECK_FLAG(p->cap, | |
10076 | PEER_CAP_DYNAMIC_RCV)) | |
10077 | vty_out(vty, " %sreceived", | |
10078 | CHECK_FLAG( | |
10079 | p->cap, | |
10080 | PEER_CAP_DYNAMIC_ADV) | |
10081 | ? "and " | |
10082 | : ""); | |
10083 | vty_out(vty, "\n"); | |
10084 | } | |
10085 | ||
10086 | /* Extended nexthop */ | |
10087 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10088 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10089 | vty_out(vty, " Extended nexthop:"); | |
10090 | if (CHECK_FLAG(p->cap, | |
10091 | PEER_CAP_ENHE_ADV)) | |
10092 | vty_out(vty, " advertised"); | |
10093 | if (CHECK_FLAG(p->cap, | |
10094 | PEER_CAP_ENHE_RCV)) | |
10095 | vty_out(vty, " %sreceived", | |
10096 | CHECK_FLAG( | |
10097 | p->cap, | |
10098 | PEER_CAP_ENHE_ADV) | |
10099 | ? "and " | |
10100 | : ""); | |
10101 | vty_out(vty, "\n"); | |
10102 | ||
10103 | if (CHECK_FLAG(p->cap, | |
10104 | PEER_CAP_ENHE_RCV)) { | |
10105 | vty_out(vty, | |
10106 | " Address families by peer:\n "); | |
10107 | for (safi = SAFI_UNICAST; | |
10108 | safi < SAFI_MAX; safi++) | |
10109 | if (CHECK_FLAG( | |
10110 | p->af_cap | |
10111 | [AFI_IP] | |
10112 | [safi], | |
10113 | PEER_CAP_ENHE_AF_RCV)) | |
10114 | vty_out(vty, | |
10115 | " %s\n", | |
10116 | afi_safi_print( | |
10117 | AFI_IP, | |
10118 | safi)); | |
10119 | } | |
10120 | } | |
10121 | ||
10122 | /* Route Refresh */ | |
10123 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10124 | || CHECK_FLAG(p->cap, | |
10125 | PEER_CAP_REFRESH_NEW_RCV) | |
10126 | || CHECK_FLAG(p->cap, | |
10127 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10128 | vty_out(vty, " Route refresh:"); | |
10129 | if (CHECK_FLAG(p->cap, | |
10130 | PEER_CAP_REFRESH_ADV)) | |
10131 | vty_out(vty, " advertised"); | |
10132 | if (CHECK_FLAG(p->cap, | |
10133 | PEER_CAP_REFRESH_NEW_RCV) | |
10134 | || CHECK_FLAG( | |
10135 | p->cap, | |
10136 | PEER_CAP_REFRESH_OLD_RCV)) | |
10137 | vty_out(vty, " %sreceived(%s)", | |
10138 | CHECK_FLAG( | |
10139 | p->cap, | |
10140 | PEER_CAP_REFRESH_ADV) | |
10141 | ? "and " | |
10142 | : "", | |
10143 | (CHECK_FLAG( | |
10144 | p->cap, | |
10145 | PEER_CAP_REFRESH_OLD_RCV) | |
10146 | && CHECK_FLAG( | |
10147 | p->cap, | |
10148 | PEER_CAP_REFRESH_NEW_RCV)) | |
10149 | ? "old & new" | |
10150 | : CHECK_FLAG( | |
10151 | p->cap, | |
10152 | PEER_CAP_REFRESH_OLD_RCV) | |
10153 | ? "old" | |
10154 | : "new"); | |
10155 | ||
10156 | vty_out(vty, "\n"); | |
10157 | } | |
10158 | ||
10159 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10160 | FOREACH_AFI_SAFI (afi, safi) |
10161 | if (p->afc_adv[afi][safi] | |
10162 | || p->afc_recv[afi][safi]) { | |
10163 | vty_out(vty, | |
10164 | " Address Family %s:", | |
10165 | afi_safi_print(afi, | |
10166 | safi)); | |
10167 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10168 | vty_out(vty, |
05c7a1cc QY |
10169 | " advertised"); |
10170 | if (p->afc_recv[afi][safi]) | |
10171 | vty_out(vty, | |
10172 | " %sreceived", | |
10173 | p->afc_adv[afi] | |
10174 | [safi] | |
10175 | ? "and " | |
10176 | : ""); | |
10177 | vty_out(vty, "\n"); | |
10178 | } | |
d62a17ae | 10179 | |
10180 | /* Hostname capability */ | |
60466a63 | 10181 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10182 | |
10183 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10184 | vty_out(vty, |
10185 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10186 | bgp->peer_self->hostname |
10187 | ? bgp->peer_self | |
10188 | ->hostname | |
d77114b7 | 10189 | : "n/a", |
60466a63 QY |
10190 | bgp->peer_self->domainname |
10191 | ? bgp->peer_self | |
10192 | ->domainname | |
d77114b7 MK |
10193 | : "n/a"); |
10194 | } else { | |
10195 | vty_out(vty, " not advertised"); | |
d62a17ae | 10196 | } |
10197 | ||
d77114b7 | 10198 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10199 | vty_out(vty, |
10200 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10201 | p->hostname ? p->hostname |
10202 | : "n/a", | |
10203 | p->domainname ? p->domainname | |
10204 | : "n/a"); | |
d77114b7 MK |
10205 | } else { |
10206 | vty_out(vty, " not received"); | |
10207 | } | |
10208 | ||
10209 | vty_out(vty, "\n"); | |
10210 | ||
d62a17ae | 10211 | /* Gracefull Restart */ |
10212 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10213 | || CHECK_FLAG(p->cap, | |
10214 | PEER_CAP_RESTART_ADV)) { | |
10215 | vty_out(vty, | |
10216 | " Graceful Restart Capabilty:"); | |
10217 | if (CHECK_FLAG(p->cap, | |
10218 | PEER_CAP_RESTART_ADV)) | |
10219 | vty_out(vty, " advertised"); | |
10220 | if (CHECK_FLAG(p->cap, | |
10221 | PEER_CAP_RESTART_RCV)) | |
10222 | vty_out(vty, " %sreceived", | |
10223 | CHECK_FLAG( | |
10224 | p->cap, | |
10225 | PEER_CAP_RESTART_ADV) | |
10226 | ? "and " | |
10227 | : ""); | |
10228 | vty_out(vty, "\n"); | |
10229 | ||
10230 | if (CHECK_FLAG(p->cap, | |
10231 | PEER_CAP_RESTART_RCV)) { | |
10232 | int restart_af_count = 0; | |
10233 | ||
10234 | vty_out(vty, | |
10235 | " Remote Restart timer is %d seconds\n", | |
10236 | p->v_gr_restart); | |
10237 | vty_out(vty, | |
10238 | " Address families by peer:\n "); | |
10239 | ||
05c7a1cc QY |
10240 | FOREACH_AFI_SAFI (afi, safi) |
10241 | if (CHECK_FLAG( | |
10242 | p->af_cap | |
10243 | [afi] | |
10244 | [safi], | |
10245 | PEER_CAP_RESTART_AF_RCV)) { | |
10246 | vty_out(vty, | |
10247 | "%s%s(%s)", | |
10248 | restart_af_count | |
10249 | ? ", " | |
10250 | : "", | |
10251 | afi_safi_print( | |
10252 | afi, | |
10253 | safi), | |
10254 | CHECK_FLAG( | |
10255 | p->af_cap | |
10256 | [afi] | |
10257 | [safi], | |
10258 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10259 | ? "preserved" | |
10260 | : "not preserved"); | |
10261 | restart_af_count++; | |
10262 | } | |
d62a17ae | 10263 | if (!restart_af_count) |
10264 | vty_out(vty, "none"); | |
10265 | vty_out(vty, "\n"); | |
10266 | } | |
10267 | } | |
10268 | } | |
10269 | } | |
10270 | } | |
10271 | ||
10272 | /* graceful restart information */ | |
10273 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10274 | || p->t_gr_stale) { | |
10275 | json_object *json_grace = NULL; | |
10276 | json_object *json_grace_send = NULL; | |
10277 | json_object *json_grace_recv = NULL; | |
10278 | int eor_send_af_count = 0; | |
10279 | int eor_receive_af_count = 0; | |
10280 | ||
10281 | if (use_json) { | |
10282 | json_grace = json_object_new_object(); | |
10283 | json_grace_send = json_object_new_object(); | |
10284 | json_grace_recv = json_object_new_object(); | |
10285 | ||
10286 | if (p->status == Established) { | |
05c7a1cc QY |
10287 | FOREACH_AFI_SAFI (afi, safi) { |
10288 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10289 | PEER_STATUS_EOR_SEND)) { | |
10290 | json_object_boolean_true_add( | |
10291 | json_grace_send, | |
10292 | afi_safi_print(afi, | |
10293 | safi)); | |
10294 | eor_send_af_count++; | |
d62a17ae | 10295 | } |
10296 | } | |
05c7a1cc QY |
10297 | FOREACH_AFI_SAFI (afi, safi) { |
10298 | if (CHECK_FLAG( | |
10299 | p->af_sflags[afi][safi], | |
10300 | PEER_STATUS_EOR_RECEIVED)) { | |
10301 | json_object_boolean_true_add( | |
10302 | json_grace_recv, | |
10303 | afi_safi_print(afi, | |
10304 | safi)); | |
10305 | eor_receive_af_count++; | |
d62a17ae | 10306 | } |
10307 | } | |
10308 | } | |
10309 | ||
10310 | json_object_object_add(json_grace, "endOfRibSend", | |
10311 | json_grace_send); | |
10312 | json_object_object_add(json_grace, "endOfRibRecv", | |
10313 | json_grace_recv); | |
10314 | ||
10315 | if (p->t_gr_restart) | |
10316 | json_object_int_add(json_grace, | |
10317 | "gracefulRestartTimerMsecs", | |
10318 | thread_timer_remain_second( | |
10319 | p->t_gr_restart) | |
10320 | * 1000); | |
10321 | ||
10322 | if (p->t_gr_stale) | |
10323 | json_object_int_add( | |
10324 | json_grace, | |
10325 | "gracefulStalepathTimerMsecs", | |
10326 | thread_timer_remain_second( | |
10327 | p->t_gr_stale) | |
10328 | * 1000); | |
10329 | ||
10330 | json_object_object_add( | |
10331 | json_neigh, "gracefulRestartInfo", json_grace); | |
10332 | } else { | |
0437e105 | 10333 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10334 | if (p->status == Established) { |
10335 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10336 | FOREACH_AFI_SAFI (afi, safi) { |
10337 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10338 | PEER_STATUS_EOR_SEND)) { | |
10339 | vty_out(vty, "%s%s", | |
10340 | eor_send_af_count ? ", " | |
10341 | : "", | |
10342 | afi_safi_print(afi, | |
10343 | safi)); | |
10344 | eor_send_af_count++; | |
d62a17ae | 10345 | } |
10346 | } | |
10347 | vty_out(vty, "\n"); | |
10348 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10349 | FOREACH_AFI_SAFI (afi, safi) { |
10350 | if (CHECK_FLAG( | |
10351 | p->af_sflags[afi][safi], | |
10352 | PEER_STATUS_EOR_RECEIVED)) { | |
10353 | vty_out(vty, "%s%s", | |
10354 | eor_receive_af_count | |
10355 | ? ", " | |
10356 | : "", | |
10357 | afi_safi_print(afi, | |
10358 | safi)); | |
10359 | eor_receive_af_count++; | |
d62a17ae | 10360 | } |
10361 | } | |
10362 | vty_out(vty, "\n"); | |
10363 | } | |
10364 | ||
10365 | if (p->t_gr_restart) | |
10366 | vty_out(vty, | |
10367 | " The remaining time of restart timer is %ld\n", | |
10368 | thread_timer_remain_second( | |
10369 | p->t_gr_restart)); | |
10370 | ||
10371 | if (p->t_gr_stale) | |
10372 | vty_out(vty, | |
10373 | " The remaining time of stalepath timer is %ld\n", | |
10374 | thread_timer_remain_second( | |
10375 | p->t_gr_stale)); | |
10376 | } | |
10377 | } | |
10378 | if (use_json) { | |
10379 | json_object *json_stat = NULL; | |
10380 | json_stat = json_object_new_object(); | |
10381 | /* Packet counts. */ | |
10382 | json_object_int_add(json_stat, "depthInq", 0); | |
10383 | json_object_int_add(json_stat, "depthOutq", | |
10384 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10385 | json_object_int_add(json_stat, "opensSent", |
10386 | atomic_load_explicit(&p->open_out, | |
10387 | memory_order_relaxed)); | |
10388 | json_object_int_add(json_stat, "opensRecv", | |
10389 | atomic_load_explicit(&p->open_in, | |
10390 | memory_order_relaxed)); | |
d62a17ae | 10391 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10392 | atomic_load_explicit(&p->notify_out, |
10393 | memory_order_relaxed)); | |
d62a17ae | 10394 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10395 | atomic_load_explicit(&p->notify_in, |
10396 | memory_order_relaxed)); | |
10397 | json_object_int_add(json_stat, "updatesSent", | |
10398 | atomic_load_explicit(&p->update_out, | |
10399 | memory_order_relaxed)); | |
10400 | json_object_int_add(json_stat, "updatesRecv", | |
10401 | atomic_load_explicit(&p->update_in, | |
10402 | memory_order_relaxed)); | |
d62a17ae | 10403 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10404 | atomic_load_explicit(&p->keepalive_out, |
10405 | memory_order_relaxed)); | |
d62a17ae | 10406 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10407 | atomic_load_explicit(&p->keepalive_in, |
10408 | memory_order_relaxed)); | |
d62a17ae | 10409 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10410 | atomic_load_explicit(&p->refresh_out, |
10411 | memory_order_relaxed)); | |
d62a17ae | 10412 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10413 | atomic_load_explicit(&p->refresh_in, |
10414 | memory_order_relaxed)); | |
d62a17ae | 10415 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10416 | atomic_load_explicit(&p->dynamic_cap_out, |
10417 | memory_order_relaxed)); | |
d62a17ae | 10418 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10419 | atomic_load_explicit(&p->dynamic_cap_in, |
10420 | memory_order_relaxed)); | |
10421 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10422 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10423 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10424 | } else { | |
10425 | /* Packet counts. */ | |
10426 | vty_out(vty, " Message statistics:\n"); | |
10427 | vty_out(vty, " Inq depth is 0\n"); | |
10428 | vty_out(vty, " Outq depth is %lu\n", | |
10429 | (unsigned long)p->obuf->count); | |
10430 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10431 | vty_out(vty, " Opens: %10d %10d\n", |
10432 | atomic_load_explicit(&p->open_out, | |
10433 | memory_order_relaxed), | |
10434 | atomic_load_explicit(&p->open_in, | |
10435 | memory_order_relaxed)); | |
10436 | vty_out(vty, " Notifications: %10d %10d\n", | |
10437 | atomic_load_explicit(&p->notify_out, | |
10438 | memory_order_relaxed), | |
10439 | atomic_load_explicit(&p->notify_in, | |
10440 | memory_order_relaxed)); | |
10441 | vty_out(vty, " Updates: %10d %10d\n", | |
10442 | atomic_load_explicit(&p->update_out, | |
10443 | memory_order_relaxed), | |
10444 | atomic_load_explicit(&p->update_in, | |
10445 | memory_order_relaxed)); | |
10446 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10447 | atomic_load_explicit(&p->keepalive_out, | |
10448 | memory_order_relaxed), | |
10449 | atomic_load_explicit(&p->keepalive_in, | |
10450 | memory_order_relaxed)); | |
10451 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10452 | atomic_load_explicit(&p->refresh_out, | |
10453 | memory_order_relaxed), | |
10454 | atomic_load_explicit(&p->refresh_in, | |
10455 | memory_order_relaxed)); | |
d62a17ae | 10456 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10457 | atomic_load_explicit(&p->dynamic_cap_out, |
10458 | memory_order_relaxed), | |
10459 | atomic_load_explicit(&p->dynamic_cap_in, | |
10460 | memory_order_relaxed)); | |
10461 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10462 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10463 | } |
10464 | ||
10465 | if (use_json) { | |
10466 | /* advertisement-interval */ | |
10467 | json_object_int_add(json_neigh, | |
10468 | "minBtwnAdvertisementRunsTimerMsecs", | |
10469 | p->v_routeadv * 1000); | |
10470 | ||
10471 | /* Update-source. */ | |
10472 | if (p->update_if || p->update_source) { | |
10473 | if (p->update_if) | |
10474 | json_object_string_add(json_neigh, | |
10475 | "updateSource", | |
10476 | p->update_if); | |
10477 | else if (p->update_source) | |
10478 | json_object_string_add( | |
10479 | json_neigh, "updateSource", | |
10480 | sockunion2str(p->update_source, buf1, | |
10481 | SU_ADDRSTRLEN)); | |
10482 | } | |
10483 | } else { | |
10484 | /* advertisement-interval */ | |
10485 | vty_out(vty, | |
10486 | " Minimum time between advertisement runs is %d seconds\n", | |
10487 | p->v_routeadv); | |
10488 | ||
10489 | /* Update-source. */ | |
10490 | if (p->update_if || p->update_source) { | |
10491 | vty_out(vty, " Update source is "); | |
10492 | if (p->update_if) | |
10493 | vty_out(vty, "%s", p->update_if); | |
10494 | else if (p->update_source) | |
10495 | vty_out(vty, "%s", | |
10496 | sockunion2str(p->update_source, buf1, | |
10497 | SU_ADDRSTRLEN)); | |
10498 | vty_out(vty, "\n"); | |
10499 | } | |
10500 | ||
10501 | vty_out(vty, "\n"); | |
10502 | } | |
10503 | ||
10504 | /* Address Family Information */ | |
10505 | json_object *json_hold = NULL; | |
10506 | ||
10507 | if (use_json) | |
10508 | json_hold = json_object_new_object(); | |
10509 | ||
05c7a1cc QY |
10510 | FOREACH_AFI_SAFI (afi, safi) |
10511 | if (p->afc[afi][safi]) | |
10512 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10513 | json_hold); | |
d62a17ae | 10514 | |
10515 | if (use_json) { | |
10516 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10517 | json_hold); | |
10518 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10519 | p->established); | |
10520 | json_object_int_add(json_neigh, "connectionsDropped", | |
10521 | p->dropped); | |
10522 | } else | |
10523 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10524 | p->established, p->dropped); | |
10525 | ||
10526 | if (!p->last_reset) { | |
10527 | if (use_json) | |
10528 | json_object_string_add(json_neigh, "lastReset", | |
10529 | "never"); | |
10530 | else | |
10531 | vty_out(vty, " Last reset never\n"); | |
10532 | } else { | |
10533 | if (use_json) { | |
10534 | time_t uptime; | |
10535 | struct tm *tm; | |
10536 | ||
10537 | uptime = bgp_clock(); | |
10538 | uptime -= p->resettime; | |
10539 | tm = gmtime(&uptime); | |
10540 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10541 | (tm->tm_sec * 1000) | |
10542 | + (tm->tm_min * 60000) | |
10543 | + (tm->tm_hour * 3600000)); | |
10544 | json_object_string_add( | |
10545 | json_neigh, "lastResetDueTo", | |
10546 | peer_down_str[(int)p->last_reset]); | |
10547 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10548 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10549 | char errorcodesubcode_hexstr[5]; | |
10550 | char errorcodesubcode_str[256]; | |
10551 | ||
10552 | code_str = bgp_notify_code_str(p->notify.code); | |
10553 | subcode_str = bgp_notify_subcode_str( | |
10554 | p->notify.code, p->notify.subcode); | |
10555 | ||
10556 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10557 | p->notify.code, p->notify.subcode); | |
10558 | json_object_string_add(json_neigh, | |
10559 | "lastErrorCodeSubcode", | |
10560 | errorcodesubcode_hexstr); | |
10561 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10562 | code_str, subcode_str); | |
10563 | json_object_string_add(json_neigh, | |
10564 | "lastNotificationReason", | |
10565 | errorcodesubcode_str); | |
10566 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10567 | && p->notify.code == BGP_NOTIFY_CEASE | |
10568 | && (p->notify.subcode | |
10569 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10570 | || p->notify.subcode | |
10571 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10572 | && p->notify.length) { | |
10573 | char msgbuf[1024]; | |
10574 | const char *msg_str; | |
10575 | ||
10576 | msg_str = bgp_notify_admin_message( | |
10577 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10578 | (uint8_t *)p->notify.data, |
d62a17ae | 10579 | p->notify.length); |
10580 | if (msg_str) | |
10581 | json_object_string_add( | |
10582 | json_neigh, | |
10583 | "lastShutdownDescription", | |
10584 | msg_str); | |
10585 | } | |
10586 | } | |
10587 | } else { | |
10588 | vty_out(vty, " Last reset %s, ", | |
10589 | peer_uptime(p->resettime, timebuf, | |
10590 | BGP_UPTIME_LEN, 0, NULL)); | |
10591 | ||
10592 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10593 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10594 | code_str = bgp_notify_code_str(p->notify.code); | |
10595 | subcode_str = bgp_notify_subcode_str( | |
10596 | p->notify.code, p->notify.subcode); | |
10597 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10598 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10599 | ? "sent" | |
10600 | : "received", | |
10601 | code_str, subcode_str); | |
10602 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10603 | && p->notify.code == BGP_NOTIFY_CEASE | |
10604 | && (p->notify.subcode | |
10605 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10606 | || p->notify.subcode | |
10607 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10608 | && p->notify.length) { | |
10609 | char msgbuf[1024]; | |
10610 | const char *msg_str; | |
10611 | ||
10612 | msg_str = bgp_notify_admin_message( | |
10613 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10614 | (uint8_t *)p->notify.data, |
d62a17ae | 10615 | p->notify.length); |
10616 | if (msg_str) | |
10617 | vty_out(vty, | |
10618 | " Message: \"%s\"\n", | |
10619 | msg_str); | |
10620 | } | |
10621 | } else { | |
10622 | vty_out(vty, "due to %s\n", | |
10623 | peer_down_str[(int)p->last_reset]); | |
10624 | } | |
10625 | ||
10626 | if (p->last_reset_cause_size) { | |
10627 | msg = p->last_reset_cause; | |
10628 | vty_out(vty, | |
10629 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10630 | for (i = 1; i <= p->last_reset_cause_size; | |
10631 | i++) { | |
10632 | vty_out(vty, "%02X", *msg++); | |
10633 | ||
10634 | if (i != p->last_reset_cause_size) { | |
10635 | if (i % 16 == 0) { | |
10636 | vty_out(vty, "\n "); | |
10637 | } else if (i % 4 == 0) { | |
10638 | vty_out(vty, " "); | |
10639 | } | |
10640 | } | |
10641 | } | |
10642 | vty_out(vty, "\n"); | |
10643 | } | |
10644 | } | |
10645 | } | |
10646 | ||
10647 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10648 | if (use_json) | |
10649 | json_object_boolean_true_add(json_neigh, | |
10650 | "prefixesConfigExceedMax"); | |
10651 | else | |
10652 | vty_out(vty, | |
10653 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10654 | ||
10655 | if (p->t_pmax_restart) { | |
10656 | if (use_json) { | |
10657 | json_object_boolean_true_add( | |
10658 | json_neigh, "reducePrefixNumFrom"); | |
10659 | json_object_int_add(json_neigh, | |
10660 | "restartInTimerMsec", | |
10661 | thread_timer_remain_second( | |
10662 | p->t_pmax_restart) | |
10663 | * 1000); | |
10664 | } else | |
10665 | vty_out(vty, | |
10666 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10667 | p->host, thread_timer_remain_second( |
10668 | p->t_pmax_restart)); | |
d62a17ae | 10669 | } else { |
10670 | if (use_json) | |
10671 | json_object_boolean_true_add( | |
10672 | json_neigh, | |
10673 | "reducePrefixNumAndClearIpBgp"); | |
10674 | else | |
10675 | vty_out(vty, | |
10676 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10677 | p->host); | |
10678 | } | |
10679 | } | |
10680 | ||
10681 | /* EBGP Multihop and GTSM */ | |
10682 | if (p->sort != BGP_PEER_IBGP) { | |
10683 | if (use_json) { | |
10684 | if (p->gtsm_hops > 0) | |
10685 | json_object_int_add(json_neigh, | |
10686 | "externalBgpNbrMaxHopsAway", | |
10687 | p->gtsm_hops); | |
10688 | else if (p->ttl > 1) | |
10689 | json_object_int_add(json_neigh, | |
10690 | "externalBgpNbrMaxHopsAway", | |
10691 | p->ttl); | |
10692 | } else { | |
10693 | if (p->gtsm_hops > 0) | |
10694 | vty_out(vty, | |
10695 | " External BGP neighbor may be up to %d hops away.\n", | |
10696 | p->gtsm_hops); | |
10697 | else if (p->ttl > 1) | |
10698 | vty_out(vty, | |
10699 | " External BGP neighbor may be up to %d hops away.\n", | |
10700 | p->ttl); | |
10701 | } | |
10702 | } else { | |
10703 | if (p->gtsm_hops > 0) { | |
10704 | if (use_json) | |
10705 | json_object_int_add(json_neigh, | |
10706 | "internalBgpNbrMaxHopsAway", | |
10707 | p->gtsm_hops); | |
10708 | else | |
10709 | vty_out(vty, | |
10710 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10711 | p->gtsm_hops); | |
10712 | } | |
10713 | } | |
10714 | ||
10715 | /* Local address. */ | |
10716 | if (p->su_local) { | |
10717 | if (use_json) { | |
10718 | json_object_string_add(json_neigh, "hostLocal", | |
10719 | sockunion2str(p->su_local, buf1, | |
10720 | SU_ADDRSTRLEN)); | |
10721 | json_object_int_add(json_neigh, "portLocal", | |
10722 | ntohs(p->su_local->sin.sin_port)); | |
10723 | } else | |
10724 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10725 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10726 | ntohs(p->su_local->sin.sin_port)); | |
10727 | } | |
10728 | ||
10729 | /* Remote address. */ | |
10730 | if (p->su_remote) { | |
10731 | if (use_json) { | |
10732 | json_object_string_add(json_neigh, "hostForeign", | |
10733 | sockunion2str(p->su_remote, buf1, | |
10734 | SU_ADDRSTRLEN)); | |
10735 | json_object_int_add(json_neigh, "portForeign", | |
10736 | ntohs(p->su_remote->sin.sin_port)); | |
10737 | } else | |
10738 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10739 | sockunion2str(p->su_remote, buf1, | |
10740 | SU_ADDRSTRLEN), | |
10741 | ntohs(p->su_remote->sin.sin_port)); | |
10742 | } | |
10743 | ||
10744 | /* Nexthop display. */ | |
10745 | if (p->su_local) { | |
10746 | if (use_json) { | |
10747 | json_object_string_add(json_neigh, "nexthop", | |
10748 | inet_ntop(AF_INET, | |
10749 | &p->nexthop.v4, buf1, | |
10750 | sizeof(buf1))); | |
10751 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10752 | inet_ntop(AF_INET6, | |
10753 | &p->nexthop.v6_global, | |
10754 | buf1, sizeof(buf1))); | |
10755 | json_object_string_add(json_neigh, "nexthopLocal", | |
10756 | inet_ntop(AF_INET6, | |
10757 | &p->nexthop.v6_local, | |
10758 | buf1, sizeof(buf1))); | |
10759 | if (p->shared_network) | |
10760 | json_object_string_add(json_neigh, | |
10761 | "bgpConnection", | |
10762 | "sharedNetwork"); | |
10763 | else | |
10764 | json_object_string_add(json_neigh, | |
10765 | "bgpConnection", | |
10766 | "nonSharedNetwork"); | |
10767 | } else { | |
10768 | vty_out(vty, "Nexthop: %s\n", | |
10769 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10770 | sizeof(buf1))); | |
10771 | vty_out(vty, "Nexthop global: %s\n", | |
10772 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10773 | sizeof(buf1))); | |
10774 | vty_out(vty, "Nexthop local: %s\n", | |
10775 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10776 | sizeof(buf1))); | |
10777 | vty_out(vty, "BGP connection: %s\n", | |
10778 | p->shared_network ? "shared network" | |
10779 | : "non shared network"); | |
10780 | } | |
10781 | } | |
10782 | ||
10783 | /* Timer information. */ | |
10784 | if (use_json) { | |
10785 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10786 | p->v_connect); | |
10787 | if (p->status == Established && p->rtt) | |
10788 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10789 | p->rtt); | |
10790 | if (p->t_start) | |
10791 | json_object_int_add( | |
10792 | json_neigh, "nextStartTimerDueInMsecs", | |
10793 | thread_timer_remain_second(p->t_start) * 1000); | |
10794 | if (p->t_connect) | |
10795 | json_object_int_add( | |
10796 | json_neigh, "nextConnectTimerDueInMsecs", | |
10797 | thread_timer_remain_second(p->t_connect) | |
10798 | * 1000); | |
10799 | if (p->t_routeadv) { | |
10800 | json_object_int_add(json_neigh, "mraiInterval", | |
10801 | p->v_routeadv); | |
10802 | json_object_int_add( | |
10803 | json_neigh, "mraiTimerExpireInMsecs", | |
10804 | thread_timer_remain_second(p->t_routeadv) | |
10805 | * 1000); | |
10806 | } | |
10807 | if (p->password) | |
10808 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10809 | 1); | |
10810 | ||
10811 | if (p->t_read) | |
10812 | json_object_string_add(json_neigh, "readThread", "on"); | |
10813 | else | |
10814 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10815 | |
10816 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10817 | json_object_string_add(json_neigh, "writeThread", "on"); |
10818 | else | |
10819 | json_object_string_add(json_neigh, "writeThread", | |
10820 | "off"); | |
10821 | } else { | |
10822 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10823 | p->v_connect); | |
10824 | if (p->status == Established && p->rtt) | |
10825 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10826 | p->rtt); | |
10827 | if (p->t_start) | |
10828 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10829 | thread_timer_remain_second(p->t_start)); | |
10830 | if (p->t_connect) | |
10831 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10832 | thread_timer_remain_second(p->t_connect)); | |
10833 | if (p->t_routeadv) | |
10834 | vty_out(vty, | |
10835 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10836 | p->v_routeadv, | |
10837 | thread_timer_remain_second(p->t_routeadv)); | |
10838 | if (p->password) | |
10839 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10840 | ||
10841 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10842 | p->t_read ? "on" : "off", |
10843 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10844 | ? "on" | |
10845 | : "off"); | |
d62a17ae | 10846 | } |
10847 | ||
10848 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10849 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10850 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10851 | ||
10852 | if (!use_json) | |
10853 | vty_out(vty, "\n"); | |
10854 | ||
10855 | /* BFD information. */ | |
10856 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10857 | ||
10858 | if (use_json) { | |
10859 | if (p->conf_if) /* Configured interface name. */ | |
10860 | json_object_object_add(json, p->conf_if, json_neigh); | |
10861 | else /* Configured IP address. */ | |
10862 | json_object_object_add(json, p->host, json_neigh); | |
10863 | } | |
10864 | } | |
10865 | ||
10866 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10867 | enum show_type type, union sockunion *su, | |
9f049418 | 10868 | const char *conf_if, bool use_json, |
d62a17ae | 10869 | json_object *json) |
10870 | { | |
10871 | struct listnode *node, *nnode; | |
10872 | struct peer *peer; | |
10873 | int find = 0; | |
9f049418 | 10874 | bool nbr_output = false; |
d62a17ae | 10875 | |
10876 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10877 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10878 | continue; | |
10879 | ||
10880 | switch (type) { | |
10881 | case show_all: | |
10882 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10883 | nbr_output = true; |
d62a17ae | 10884 | break; |
10885 | case show_peer: | |
10886 | if (conf_if) { | |
10887 | if ((peer->conf_if | |
10888 | && !strcmp(peer->conf_if, conf_if)) | |
10889 | || (peer->hostname | |
10890 | && !strcmp(peer->hostname, conf_if))) { | |
10891 | find = 1; | |
10892 | bgp_show_peer(vty, peer, use_json, | |
10893 | json); | |
10894 | } | |
10895 | } else { | |
10896 | if (sockunion_same(&peer->su, su)) { | |
10897 | find = 1; | |
10898 | bgp_show_peer(vty, peer, use_json, | |
10899 | json); | |
10900 | } | |
10901 | } | |
10902 | break; | |
10903 | } | |
10904 | } | |
10905 | ||
10906 | if (type == show_peer && !find) { | |
10907 | if (use_json) | |
10908 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10909 | else | |
88b7d255 | 10910 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10911 | } |
10912 | ||
9f049418 | 10913 | if (type != show_peer && !nbr_output && !use_json) |
94d4c685 | 10914 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 10915 | |
d62a17ae | 10916 | if (use_json) { |
996c9314 LB |
10917 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10918 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10919 | json_object_free(json); |
10920 | } else { | |
10921 | vty_out(vty, "\n"); | |
10922 | } | |
10923 | ||
10924 | return CMD_SUCCESS; | |
10925 | } | |
10926 | ||
10927 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10928 | enum show_type type, |
10929 | const char *ip_str, | |
9f049418 | 10930 | bool use_json) |
d62a17ae | 10931 | { |
0291c246 MK |
10932 | struct listnode *node, *nnode; |
10933 | struct bgp *bgp; | |
71aedaa3 | 10934 | union sockunion su; |
0291c246 | 10935 | json_object *json = NULL; |
71aedaa3 | 10936 | int ret, is_first = 1; |
9f049418 | 10937 | bool nbr_output = false; |
d62a17ae | 10938 | |
10939 | if (use_json) | |
10940 | vty_out(vty, "{\n"); | |
10941 | ||
10942 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10943 | nbr_output = true; |
d62a17ae | 10944 | if (use_json) { |
10945 | if (!(json = json_object_new_object())) { | |
af4c2728 | 10946 | flog_err( |
e50f7cfd | 10947 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 10948 | "Unable to allocate memory for JSON object"); |
10949 | vty_out(vty, | |
10950 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10951 | return; | |
10952 | } | |
10953 | ||
10954 | json_object_int_add(json, "vrfId", | |
10955 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10956 | ? -1 |
10957 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10958 | json_object_string_add( |
10959 | json, "vrfName", | |
10960 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10961 | ? VRF_DEFAULT_NAME |
d62a17ae | 10962 | : bgp->name); |
10963 | ||
10964 | if (!is_first) | |
10965 | vty_out(vty, ",\n"); | |
10966 | else | |
10967 | is_first = 0; | |
10968 | ||
10969 | vty_out(vty, "\"%s\":", | |
10970 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10971 | ? VRF_DEFAULT_NAME |
d62a17ae | 10972 | : bgp->name); |
10973 | } else { | |
10974 | vty_out(vty, "\nInstance %s:\n", | |
10975 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10976 | ? VRF_DEFAULT_NAME |
d62a17ae | 10977 | : bgp->name); |
10978 | } | |
71aedaa3 DS |
10979 | |
10980 | if (type == show_peer) { | |
10981 | ret = str2sockunion(ip_str, &su); | |
10982 | if (ret < 0) | |
10983 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10984 | use_json, json); | |
10985 | else | |
10986 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10987 | use_json, json); | |
10988 | } else { | |
10989 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
10990 | use_json, json); | |
10991 | } | |
d62a17ae | 10992 | } |
10993 | ||
10994 | if (use_json) | |
10995 | vty_out(vty, "}\n"); | |
9f049418 DS |
10996 | else if (!nbr_output) |
10997 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10998 | } |
10999 | ||
11000 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11001 | enum show_type type, const char *ip_str, | |
9f049418 | 11002 | bool use_json) |
d62a17ae | 11003 | { |
11004 | int ret; | |
11005 | struct bgp *bgp; | |
11006 | union sockunion su; | |
11007 | json_object *json = NULL; | |
11008 | ||
11009 | if (name) { | |
11010 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11011 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11012 | use_json); | |
d62a17ae | 11013 | return CMD_SUCCESS; |
11014 | } else { | |
11015 | bgp = bgp_lookup_by_name(name); | |
11016 | if (!bgp) { | |
11017 | if (use_json) { | |
11018 | json = json_object_new_object(); | |
d62a17ae | 11019 | vty_out(vty, "%s\n", |
11020 | json_object_to_json_string_ext( | |
11021 | json, | |
11022 | JSON_C_TO_STRING_PRETTY)); | |
11023 | json_object_free(json); | |
11024 | } else | |
11025 | vty_out(vty, | |
9f049418 | 11026 | "%% BGP instance not found\n"); |
d62a17ae | 11027 | |
11028 | return CMD_WARNING; | |
11029 | } | |
11030 | } | |
11031 | } else { | |
11032 | bgp = bgp_get_default(); | |
11033 | } | |
11034 | ||
11035 | if (bgp) { | |
11036 | json = json_object_new_object(); | |
11037 | if (ip_str) { | |
11038 | ret = str2sockunion(ip_str, &su); | |
11039 | if (ret < 0) | |
11040 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11041 | use_json, json); | |
11042 | else | |
11043 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11044 | use_json, json); | |
11045 | } else { | |
11046 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11047 | json); | |
11048 | } | |
11049 | json_object_free(json); | |
ca61fd25 DS |
11050 | } else { |
11051 | if (use_json) | |
11052 | vty_out(vty, "{}\n"); | |
11053 | else | |
11054 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11055 | } |
11056 | ||
11057 | return CMD_SUCCESS; | |
4fb25c53 DW |
11058 | } |
11059 | ||
716b2d8a | 11060 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11061 | DEFUN (show_ip_bgp_neighbors, |
11062 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11063 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11064 | SHOW_STR |
11065 | IP_STR | |
11066 | BGP_STR | |
f2a8972b | 11067 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11068 | "Address Family\n" |
11069 | "Address Family\n" | |
718e3744 | 11070 | "Detailed information on TCP and BGP neighbor connections\n" |
11071 | "Neighbor to display information about\n" | |
a80beece | 11072 | "Neighbor to display information about\n" |
91d37724 | 11073 | "Neighbor on BGP configured interface\n" |
9973d184 | 11074 | JSON_STR) |
718e3744 | 11075 | { |
d62a17ae | 11076 | char *vrf = NULL; |
11077 | char *sh_arg = NULL; | |
11078 | enum show_type sh_type; | |
718e3744 | 11079 | |
9f049418 | 11080 | bool uj = use_json(argc, argv); |
718e3744 | 11081 | |
d62a17ae | 11082 | int idx = 0; |
718e3744 | 11083 | |
9a8bdf1c PG |
11084 | /* [<vrf> VIEWVRFNAME] */ |
11085 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11086 | vrf = argv[idx + 1]->arg; | |
11087 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11088 | vrf = NULL; | |
11089 | } else if (argv_find(argv, argc, "view", &idx)) | |
11090 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11091 | vrf = argv[idx + 1]->arg; |
718e3744 | 11092 | |
d62a17ae | 11093 | idx++; |
11094 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
11095 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11096 | || argv_find(argv, argc, "WORD", &idx)) { | |
11097 | sh_type = show_peer; | |
11098 | sh_arg = argv[idx]->arg; | |
11099 | } else | |
11100 | sh_type = show_all; | |
856ca177 | 11101 | |
d62a17ae | 11102 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11103 | } |
11104 | ||
716b2d8a | 11105 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11106 | paths' and `show ip mbgp paths'. Those functions results are the |
11107 | same.*/ | |
f412b39a | 11108 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11109 | show_ip_bgp_paths_cmd, |
46f296b4 | 11110 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11111 | SHOW_STR |
11112 | IP_STR | |
11113 | BGP_STR | |
46f296b4 | 11114 | BGP_SAFI_HELP_STR |
718e3744 | 11115 | "Path information\n") |
11116 | { | |
d62a17ae | 11117 | vty_out(vty, "Address Refcnt Path\n"); |
11118 | aspath_print_all_vty(vty); | |
11119 | return CMD_SUCCESS; | |
718e3744 | 11120 | } |
11121 | ||
718e3744 | 11122 | #include "hash.h" |
11123 | ||
d62a17ae | 11124 | static void community_show_all_iterator(struct hash_backet *backet, |
11125 | struct vty *vty) | |
718e3744 | 11126 | { |
d62a17ae | 11127 | struct community *com; |
718e3744 | 11128 | |
d62a17ae | 11129 | com = (struct community *)backet->data; |
3f65c5b1 | 11130 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11131 | community_str(com, false)); |
718e3744 | 11132 | } |
11133 | ||
11134 | /* Show BGP's community internal data. */ | |
f412b39a | 11135 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11136 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11137 | "show [ip] bgp community-info", |
718e3744 | 11138 | SHOW_STR |
11139 | IP_STR | |
11140 | BGP_STR | |
11141 | "List all bgp community information\n") | |
11142 | { | |
d62a17ae | 11143 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11144 | |
d62a17ae | 11145 | hash_iterate(community_hash(), |
11146 | (void (*)(struct hash_backet *, | |
11147 | void *))community_show_all_iterator, | |
11148 | vty); | |
718e3744 | 11149 | |
d62a17ae | 11150 | return CMD_SUCCESS; |
718e3744 | 11151 | } |
11152 | ||
d62a17ae | 11153 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
11154 | struct vty *vty) | |
57d187bc | 11155 | { |
d62a17ae | 11156 | struct lcommunity *lcom; |
57d187bc | 11157 | |
d62a17ae | 11158 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 11159 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11160 | lcommunity_str(lcom, false)); |
57d187bc JS |
11161 | } |
11162 | ||
11163 | /* Show BGP's community internal data. */ | |
11164 | DEFUN (show_ip_bgp_lcommunity_info, | |
11165 | show_ip_bgp_lcommunity_info_cmd, | |
11166 | "show ip bgp large-community-info", | |
11167 | SHOW_STR | |
11168 | IP_STR | |
11169 | BGP_STR | |
11170 | "List all bgp large-community information\n") | |
11171 | { | |
d62a17ae | 11172 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11173 | |
d62a17ae | 11174 | hash_iterate(lcommunity_hash(), |
11175 | (void (*)(struct hash_backet *, | |
11176 | void *))lcommunity_show_all_iterator, | |
11177 | vty); | |
57d187bc | 11178 | |
d62a17ae | 11179 | return CMD_SUCCESS; |
57d187bc JS |
11180 | } |
11181 | ||
11182 | ||
f412b39a | 11183 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11184 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11185 | "show [ip] bgp attribute-info", |
718e3744 | 11186 | SHOW_STR |
11187 | IP_STR | |
11188 | BGP_STR | |
11189 | "List all bgp attribute information\n") | |
11190 | { | |
d62a17ae | 11191 | attr_show_all(vty); |
11192 | return CMD_SUCCESS; | |
718e3744 | 11193 | } |
6b0655a2 | 11194 | |
9f049418 DS |
11195 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, afi_t afi, |
11196 | safi_t safi, bool use_json) | |
53089bec | 11197 | { |
11198 | struct bgp *bgp; | |
11199 | struct listnode *node; | |
11200 | char *vname; | |
11201 | char buf1[INET6_ADDRSTRLEN]; | |
11202 | char *ecom_str; | |
11203 | vpn_policy_direction_t dir; | |
11204 | ||
b46dfd20 DS |
11205 | if (use_json) { |
11206 | json_object *json = NULL; | |
11207 | json_object *json_import_vrfs = NULL; | |
11208 | json_object *json_export_vrfs = NULL; | |
11209 | ||
11210 | json = json_object_new_object(); | |
b46dfd20 | 11211 | |
b46dfd20 DS |
11212 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11213 | ||
53089bec | 11214 | if (!bgp) { |
b46dfd20 DS |
11215 | vty_out(vty, "%s\n", |
11216 | json_object_to_json_string_ext( | |
11217 | json, | |
11218 | JSON_C_TO_STRING_PRETTY)); | |
11219 | json_object_free(json); | |
11220 | ||
53089bec | 11221 | return CMD_WARNING; |
11222 | } | |
b46dfd20 | 11223 | |
94d4c685 DS |
11224 | /* Provide context for the block */ |
11225 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11226 | json_object_string_add(json, "afiSafi", | |
11227 | afi_safi_print(afi, safi)); | |
11228 | ||
b46dfd20 DS |
11229 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11230 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11231 | json_object_string_add(json, "importFromVrfs", "none"); | |
11232 | json_object_string_add(json, "importRts", "none"); | |
11233 | } else { | |
6ce24e52 DS |
11234 | json_import_vrfs = json_object_new_array(); |
11235 | ||
b46dfd20 DS |
11236 | for (ALL_LIST_ELEMENTS_RO( |
11237 | bgp->vpn_policy[afi].import_vrf, | |
11238 | node, vname)) | |
11239 | json_object_array_add(json_import_vrfs, | |
11240 | json_object_new_string(vname)); | |
11241 | ||
11242 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11243 | ecom_str = ecommunity_ecom2str( | |
11244 | bgp->vpn_policy[afi].rtlist[dir], | |
11245 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11246 | json_object_object_add(json, "importFromVrfs", | |
11247 | json_import_vrfs); | |
11248 | json_object_string_add(json, "importRts", ecom_str); | |
11249 | ||
11250 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11251 | } | |
11252 | ||
11253 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11254 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11255 | json_object_string_add(json, "exportToVrfs", "none"); | |
11256 | json_object_string_add(json, "routeDistinguisher", | |
11257 | "none"); | |
11258 | json_object_string_add(json, "exportRts", "none"); | |
11259 | } else { | |
6ce24e52 DS |
11260 | json_export_vrfs = json_object_new_array(); |
11261 | ||
b46dfd20 DS |
11262 | for (ALL_LIST_ELEMENTS_RO( |
11263 | bgp->vpn_policy[afi].export_vrf, | |
11264 | node, vname)) | |
11265 | json_object_array_add(json_export_vrfs, | |
11266 | json_object_new_string(vname)); | |
11267 | json_object_object_add(json, "exportToVrfs", | |
11268 | json_export_vrfs); | |
11269 | json_object_string_add(json, "routeDistinguisher", | |
11270 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11271 | buf1, RD_ADDRSTRLEN)); | |
11272 | ||
11273 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11274 | ecom_str = ecommunity_ecom2str( | |
11275 | bgp->vpn_policy[afi].rtlist[dir], | |
11276 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11277 | json_object_string_add(json, "exportRts", ecom_str); | |
11278 | ||
11279 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11280 | } | |
11281 | ||
11282 | vty_out(vty, "%s\n", | |
11283 | json_object_to_json_string_ext(json, | |
11284 | JSON_C_TO_STRING_PRETTY)); | |
11285 | json_object_free(json); | |
11286 | ||
53089bec | 11287 | } else { |
b46dfd20 DS |
11288 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11289 | ||
53089bec | 11290 | if (!bgp) { |
b46dfd20 | 11291 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11292 | return CMD_WARNING; |
11293 | } | |
53089bec | 11294 | |
b46dfd20 DS |
11295 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11296 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11297 | vty_out(vty, | |
11298 | "This VRF is not importing %s routes from any other VRF\n", | |
11299 | afi_safi_print(afi, safi)); | |
11300 | else { | |
11301 | vty_out(vty, | |
11302 | "This VRF is importing %s routes from the following VRFs:\n", | |
11303 | afi_safi_print(afi, safi)); | |
11304 | ||
11305 | for (ALL_LIST_ELEMENTS_RO( | |
11306 | bgp->vpn_policy[afi].import_vrf, | |
11307 | node, vname)) | |
11308 | vty_out(vty, " %s\n", vname); | |
11309 | ||
11310 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11311 | ecom_str = ecommunity_ecom2str( | |
11312 | bgp->vpn_policy[afi].rtlist[dir], | |
11313 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11314 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11315 | ||
11316 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11317 | } |
53089bec | 11318 | |
b46dfd20 DS |
11319 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11320 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11321 | vty_out(vty, | |
11322 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11323 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11324 | else { |
11325 | vty_out(vty, | |
04c9077f | 11326 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11327 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11328 | |
11329 | for (ALL_LIST_ELEMENTS_RO( | |
11330 | bgp->vpn_policy[afi].export_vrf, | |
11331 | node, vname)) | |
11332 | vty_out(vty, " %s\n", vname); | |
11333 | ||
11334 | vty_out(vty, "RD: %s\n", | |
11335 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11336 | buf1, RD_ADDRSTRLEN)); | |
11337 | ||
11338 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11339 | ecom_str = ecommunity_ecom2str( | |
11340 | bgp->vpn_policy[afi].rtlist[dir], | |
11341 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11342 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11343 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11344 | } |
53089bec | 11345 | } |
11346 | ||
11347 | return CMD_SUCCESS; | |
11348 | } | |
11349 | ||
11350 | /* "show [ip] bgp route-leak" command. */ | |
11351 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11352 | show_ip_bgp_route_leak_cmd, |
11353 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11354 | SHOW_STR |
11355 | IP_STR | |
11356 | BGP_STR | |
11357 | BGP_INSTANCE_HELP_STR | |
11358 | BGP_AFI_HELP_STR | |
11359 | BGP_SAFI_HELP_STR | |
11360 | "Route leaking information\n" | |
11361 | JSON_STR) | |
53089bec | 11362 | { |
11363 | char *vrf = NULL; | |
11364 | afi_t afi = AFI_MAX; | |
11365 | safi_t safi = SAFI_MAX; | |
11366 | ||
9f049418 | 11367 | bool uj = use_json(argc, argv); |
53089bec | 11368 | int idx = 0; |
11369 | ||
11370 | /* show [ip] bgp */ | |
11371 | if (argv_find(argv, argc, "ip", &idx)) { | |
11372 | afi = AFI_IP; | |
11373 | safi = SAFI_UNICAST; | |
11374 | } | |
11375 | /* [vrf VIEWVRFNAME] */ | |
11376 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11377 | vty_out(vty, |
11378 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11379 | return CMD_WARNING; |
11380 | } | |
11381 | ||
9a8bdf1c PG |
11382 | if (argv_find(argv, argc, "vrf", &idx)) { |
11383 | vrf = argv[idx + 1]->arg; | |
11384 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11385 | vrf = NULL; | |
11386 | } | |
53089bec | 11387 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11388 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11389 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11390 | } | |
11391 | ||
11392 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11393 | vty_out(vty, |
11394 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11395 | return CMD_WARNING; |
11396 | } | |
11397 | ||
b46dfd20 | 11398 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj); |
53089bec | 11399 | } |
11400 | ||
d62a17ae | 11401 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11402 | safi_t safi) | |
f186de26 | 11403 | { |
d62a17ae | 11404 | struct listnode *node, *nnode; |
11405 | struct bgp *bgp; | |
f186de26 | 11406 | |
d62a17ae | 11407 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11408 | vty_out(vty, "\nInstance %s:\n", | |
11409 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11410 | ? VRF_DEFAULT_NAME |
d62a17ae | 11411 | : bgp->name); |
11412 | update_group_show(bgp, afi, safi, vty, 0); | |
11413 | } | |
f186de26 | 11414 | } |
11415 | ||
d62a17ae | 11416 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11417 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11418 | { |
d62a17ae | 11419 | struct bgp *bgp; |
4fb25c53 | 11420 | |
d62a17ae | 11421 | if (name) { |
11422 | if (strmatch(name, "all")) { | |
11423 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11424 | return CMD_SUCCESS; | |
11425 | } else { | |
11426 | bgp = bgp_lookup_by_name(name); | |
11427 | } | |
11428 | } else { | |
11429 | bgp = bgp_get_default(); | |
11430 | } | |
4fb25c53 | 11431 | |
d62a17ae | 11432 | if (bgp) |
11433 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11434 | return CMD_SUCCESS; | |
4fb25c53 DW |
11435 | } |
11436 | ||
8fe8a7f6 DS |
11437 | DEFUN (show_ip_bgp_updgrps, |
11438 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11439 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11440 | SHOW_STR |
11441 | IP_STR | |
11442 | BGP_STR | |
11443 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11444 | BGP_AFI_HELP_STR |
9bedbb1e | 11445 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11446 | "Detailed info about dynamic update groups\n" |
11447 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11448 | { |
d62a17ae | 11449 | char *vrf = NULL; |
11450 | afi_t afi = AFI_IP6; | |
11451 | safi_t safi = SAFI_UNICAST; | |
11452 | uint64_t subgrp_id = 0; | |
11453 | ||
11454 | int idx = 0; | |
11455 | ||
11456 | /* show [ip] bgp */ | |
11457 | if (argv_find(argv, argc, "ip", &idx)) | |
11458 | afi = AFI_IP; | |
9a8bdf1c PG |
11459 | /* [<vrf> VIEWVRFNAME] */ |
11460 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11461 | vrf = argv[idx + 1]->arg; | |
11462 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11463 | vrf = NULL; | |
11464 | } else if (argv_find(argv, argc, "view", &idx)) | |
11465 | /* [<view> VIEWVRFNAME] */ | |
11466 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11467 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11468 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11469 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11470 | } | |
5bf15956 | 11471 | |
d62a17ae | 11472 | /* get subgroup id, if provided */ |
11473 | idx = argc - 1; | |
11474 | if (argv[idx]->type == VARIABLE_TKN) | |
11475 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11476 | |
d62a17ae | 11477 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11478 | } |
11479 | ||
f186de26 | 11480 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11481 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11482 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11483 | SHOW_STR |
716b2d8a | 11484 | IP_STR |
f186de26 | 11485 | BGP_STR |
11486 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11487 | "Detailed info about dynamic update groups\n") |
f186de26 | 11488 | { |
d62a17ae | 11489 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11490 | return CMD_SUCCESS; | |
f186de26 | 11491 | } |
11492 | ||
43d3f4fc DS |
11493 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11494 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11495 | "show [ip] bgp l2vpn evpn update-groups", | |
11496 | SHOW_STR | |
11497 | IP_STR | |
11498 | BGP_STR | |
11499 | "l2vpn address family\n" | |
11500 | "evpn sub-address family\n" | |
11501 | "Detailed info about dynamic update groups\n") | |
11502 | { | |
11503 | char *vrf = NULL; | |
11504 | uint64_t subgrp_id = 0; | |
11505 | ||
11506 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11507 | return CMD_SUCCESS; | |
11508 | } | |
11509 | ||
5bf15956 DW |
11510 | DEFUN (show_bgp_updgrps_stats, |
11511 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11512 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11513 | SHOW_STR |
716b2d8a | 11514 | IP_STR |
3f9c7369 | 11515 | BGP_STR |
0c7b1b01 | 11516 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11517 | "Statistics\n") |
11518 | { | |
d62a17ae | 11519 | struct bgp *bgp; |
3f9c7369 | 11520 | |
d62a17ae | 11521 | bgp = bgp_get_default(); |
11522 | if (bgp) | |
11523 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11524 | |
d62a17ae | 11525 | return CMD_SUCCESS; |
3f9c7369 DS |
11526 | } |
11527 | ||
8386ac43 | 11528 | DEFUN (show_bgp_instance_updgrps_stats, |
11529 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11530 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11531 | SHOW_STR |
716b2d8a | 11532 | IP_STR |
8386ac43 | 11533 | BGP_STR |
11534 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11535 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11536 | "Statistics\n") |
11537 | { | |
d62a17ae | 11538 | int idx_word = 3; |
11539 | struct bgp *bgp; | |
8386ac43 | 11540 | |
d62a17ae | 11541 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11542 | if (bgp) | |
11543 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11544 | |
d62a17ae | 11545 | return CMD_SUCCESS; |
8386ac43 | 11546 | } |
11547 | ||
d62a17ae | 11548 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11549 | afi_t afi, safi_t safi, | |
11550 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11551 | { |
d62a17ae | 11552 | struct bgp *bgp; |
8386ac43 | 11553 | |
d62a17ae | 11554 | if (name) |
11555 | bgp = bgp_lookup_by_name(name); | |
11556 | else | |
11557 | bgp = bgp_get_default(); | |
8386ac43 | 11558 | |
d62a17ae | 11559 | if (bgp) { |
11560 | if (!strcmp(what, "advertise-queue")) | |
11561 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11562 | subgrp_id); | |
11563 | else if (!strcmp(what, "advertised-routes")) | |
11564 | update_group_show_advertised(bgp, afi, safi, vty, | |
11565 | subgrp_id); | |
11566 | else if (!strcmp(what, "packet-queue")) | |
11567 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11568 | subgrp_id); | |
11569 | } | |
3f9c7369 DS |
11570 | } |
11571 | ||
dc64bdec QY |
11572 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11573 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11574 | "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", | |
11575 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11576 | BGP_SAFI_HELP_STR | |
11577 | "Detailed info about dynamic update groups\n" | |
11578 | "Specific subgroup to display info for\n" | |
11579 | "Advertisement queue\n" | |
11580 | "Announced routes\n" | |
11581 | "Packet queue\n") | |
3f9c7369 | 11582 | { |
dc64bdec QY |
11583 | uint64_t subgrp_id = 0; |
11584 | afi_t afiz; | |
11585 | safi_t safiz; | |
11586 | if (sgid) | |
11587 | subgrp_id = strtoull(sgid, NULL, 10); | |
11588 | ||
11589 | if (!ip && !afi) | |
11590 | afiz = AFI_IP6; | |
11591 | if (!ip && afi) | |
11592 | afiz = bgp_vty_afi_from_str(afi); | |
11593 | if (ip && !afi) | |
11594 | afiz = AFI_IP; | |
11595 | if (ip && afi) { | |
11596 | afiz = bgp_vty_afi_from_str(afi); | |
11597 | if (afiz != AFI_IP) | |
11598 | vty_out(vty, | |
11599 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11600 | return CMD_WARNING; | |
11601 | } | |
d62a17ae | 11602 | |
dc64bdec | 11603 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11604 | |
dc64bdec | 11605 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11606 | return CMD_SUCCESS; |
11607 | } | |
11608 | ||
d62a17ae | 11609 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11610 | { | |
11611 | struct listnode *node, *nnode; | |
11612 | struct prefix *range; | |
11613 | struct peer *conf; | |
11614 | struct peer *peer; | |
11615 | char buf[PREFIX2STR_BUFFER]; | |
11616 | afi_t afi; | |
11617 | safi_t safi; | |
11618 | const char *peer_status; | |
11619 | const char *af_str; | |
11620 | int lr_count; | |
11621 | int dynamic; | |
11622 | int af_cfgd; | |
11623 | ||
11624 | conf = group->conf; | |
11625 | ||
11626 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11627 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11628 | conf->as); | |
11629 | } else if (conf->as_type == AS_INTERNAL) { | |
11630 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11631 | group->bgp->as); | |
11632 | } else { | |
11633 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11634 | } | |
f14e6fdb | 11635 | |
d62a17ae | 11636 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11637 | vty_out(vty, " Peer-group type is internal\n"); | |
11638 | else | |
11639 | vty_out(vty, " Peer-group type is external\n"); | |
11640 | ||
11641 | /* Display AFs configured. */ | |
11642 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11643 | FOREACH_AFI_SAFI (afi, safi) { |
11644 | if (conf->afc[afi][safi]) { | |
11645 | af_cfgd = 1; | |
11646 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11647 | } |
05c7a1cc | 11648 | } |
d62a17ae | 11649 | if (!af_cfgd) |
11650 | vty_out(vty, " none\n"); | |
11651 | else | |
11652 | vty_out(vty, "\n"); | |
11653 | ||
11654 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11655 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11656 | if (afi == AFI_IP) | |
11657 | af_str = "IPv4"; | |
11658 | else if (afi == AFI_IP6) | |
11659 | af_str = "IPv6"; | |
11660 | else | |
11661 | af_str = "???"; | |
11662 | lr_count = listcount(group->listen_range[afi]); | |
11663 | if (lr_count) { | |
11664 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11665 | af_str); | |
11666 | ||
11667 | ||
11668 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11669 | nnode, range)) { | |
11670 | prefix2str(range, buf, sizeof(buf)); | |
11671 | vty_out(vty, " %s\n", buf); | |
11672 | } | |
11673 | } | |
11674 | } | |
f14e6fdb | 11675 | |
d62a17ae | 11676 | /* Display group members and their status */ |
11677 | if (listcount(group->peer)) { | |
11678 | vty_out(vty, " Peer-group members:\n"); | |
11679 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11680 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11681 | peer_status = "Idle (Admin)"; | |
11682 | else if (CHECK_FLAG(peer->sflags, | |
11683 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11684 | peer_status = "Idle (PfxCt)"; | |
11685 | else | |
11686 | peer_status = lookup_msg(bgp_status_msg, | |
11687 | peer->status, NULL); | |
11688 | ||
11689 | dynamic = peer_dynamic_neighbor(peer); | |
11690 | vty_out(vty, " %s %s %s \n", peer->host, | |
11691 | dynamic ? "(dynamic)" : "", peer_status); | |
11692 | } | |
11693 | } | |
f14e6fdb | 11694 | |
d62a17ae | 11695 | return CMD_SUCCESS; |
11696 | } | |
11697 | ||
ff9959b0 QY |
11698 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11699 | const char *group_name) | |
d62a17ae | 11700 | { |
ff9959b0 | 11701 | struct bgp *bgp; |
d62a17ae | 11702 | struct listnode *node, *nnode; |
11703 | struct peer_group *group; | |
ff9959b0 QY |
11704 | bool found = false; |
11705 | ||
11706 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11707 | ||
11708 | if (!bgp) { | |
9f049418 | 11709 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11710 | return CMD_WARNING; |
11711 | } | |
d62a17ae | 11712 | |
11713 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11714 | if (group_name) { |
11715 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11716 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11717 | found = true; |
11718 | break; | |
d62a17ae | 11719 | } |
ff9959b0 QY |
11720 | } else { |
11721 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11722 | } |
f14e6fdb | 11723 | } |
f14e6fdb | 11724 | |
ff9959b0 | 11725 | if (group_name && !found) |
d62a17ae | 11726 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11727 | |
d62a17ae | 11728 | return CMD_SUCCESS; |
f14e6fdb DS |
11729 | } |
11730 | ||
f14e6fdb DS |
11731 | DEFUN (show_ip_bgp_peer_groups, |
11732 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11733 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11734 | SHOW_STR |
11735 | IP_STR | |
11736 | BGP_STR | |
8386ac43 | 11737 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11738 | "Detailed information on BGP peer groups\n" |
11739 | "Peer group name\n") | |
f14e6fdb | 11740 | { |
d62a17ae | 11741 | char *vrf, *pg; |
d62a17ae | 11742 | int idx = 0; |
f14e6fdb | 11743 | |
a4d82a8a PZ |
11744 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11745 | : NULL; | |
d62a17ae | 11746 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11747 | |
ff9959b0 | 11748 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11749 | } |
3f9c7369 | 11750 | |
d6e3c605 | 11751 | |
718e3744 | 11752 | /* Redistribute VTY commands. */ |
11753 | ||
718e3744 | 11754 | DEFUN (bgp_redistribute_ipv4, |
11755 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11756 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11757 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11758 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11759 | { |
d62a17ae | 11760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11761 | int idx_protocol = 1; | |
11762 | int type; | |
718e3744 | 11763 | |
d62a17ae | 11764 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11765 | if (type < 0) { | |
11766 | vty_out(vty, "%% Invalid route type\n"); | |
11767 | return CMD_WARNING_CONFIG_FAILED; | |
11768 | } | |
7f323236 | 11769 | |
d62a17ae | 11770 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11771 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11772 | } |
11773 | ||
d62a17ae | 11774 | ALIAS_HIDDEN( |
11775 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11776 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11777 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11778 | |
718e3744 | 11779 | DEFUN (bgp_redistribute_ipv4_rmap, |
11780 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11781 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11782 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11783 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11784 | "Route map reference\n" |
11785 | "Pointer to route-map entries\n") | |
11786 | { | |
d62a17ae | 11787 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11788 | int idx_protocol = 1; | |
11789 | int idx_word = 3; | |
11790 | int type; | |
11791 | struct bgp_redist *red; | |
e923dd62 | 11792 | bool changed; |
1de27621 DA |
11793 | struct route_map *route_map = route_map_lookup_warn_noexist( |
11794 | vty, argv[idx_word]->arg); | |
718e3744 | 11795 | |
d62a17ae | 11796 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11797 | if (type < 0) { | |
11798 | vty_out(vty, "%% Invalid route type\n"); | |
11799 | return CMD_WARNING_CONFIG_FAILED; | |
11800 | } | |
718e3744 | 11801 | |
d62a17ae | 11802 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
11803 | changed = |
11804 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11805 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 11806 | } |
11807 | ||
d62a17ae | 11808 | ALIAS_HIDDEN( |
11809 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11810 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11811 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11812 | "Route map reference\n" | |
11813 | "Pointer to route-map entries\n") | |
596c17ba | 11814 | |
718e3744 | 11815 | DEFUN (bgp_redistribute_ipv4_metric, |
11816 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11817 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11818 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11819 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11820 | "Metric for redistributed routes\n" |
11821 | "Default metric\n") | |
11822 | { | |
d62a17ae | 11823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11824 | int idx_protocol = 1; | |
11825 | int idx_number = 3; | |
11826 | int type; | |
d7c0a89a | 11827 | uint32_t metric; |
d62a17ae | 11828 | struct bgp_redist *red; |
e923dd62 | 11829 | bool changed; |
d62a17ae | 11830 | |
11831 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11832 | if (type < 0) { | |
11833 | vty_out(vty, "%% Invalid route type\n"); | |
11834 | return CMD_WARNING_CONFIG_FAILED; | |
11835 | } | |
11836 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11837 | ||
11838 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11839 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11840 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11841 | } |
11842 | ||
11843 | ALIAS_HIDDEN( | |
11844 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11845 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11846 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11847 | "Metric for redistributed routes\n" | |
11848 | "Default metric\n") | |
596c17ba | 11849 | |
718e3744 | 11850 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11851 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11852 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11853 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11854 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11855 | "Route map reference\n" |
11856 | "Pointer to route-map entries\n" | |
11857 | "Metric for redistributed routes\n" | |
11858 | "Default metric\n") | |
11859 | { | |
d62a17ae | 11860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11861 | int idx_protocol = 1; | |
11862 | int idx_word = 3; | |
11863 | int idx_number = 5; | |
11864 | int type; | |
d7c0a89a | 11865 | uint32_t metric; |
d62a17ae | 11866 | struct bgp_redist *red; |
e923dd62 | 11867 | bool changed; |
1de27621 DA |
11868 | struct route_map *route_map = |
11869 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 11870 | |
11871 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11872 | if (type < 0) { | |
11873 | vty_out(vty, "%% Invalid route type\n"); | |
11874 | return CMD_WARNING_CONFIG_FAILED; | |
11875 | } | |
11876 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11877 | ||
11878 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
11879 | changed = |
11880 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11881 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11882 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11883 | } |
11884 | ||
11885 | ALIAS_HIDDEN( | |
11886 | bgp_redistribute_ipv4_rmap_metric, | |
11887 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11888 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11889 | " route-map WORD metric (0-4294967295)", | |
11890 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11891 | "Route map reference\n" | |
11892 | "Pointer to route-map entries\n" | |
11893 | "Metric for redistributed routes\n" | |
11894 | "Default metric\n") | |
596c17ba | 11895 | |
718e3744 | 11896 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11897 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11898 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11899 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11900 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11901 | "Metric for redistributed routes\n" |
11902 | "Default metric\n" | |
11903 | "Route map reference\n" | |
11904 | "Pointer to route-map entries\n") | |
11905 | { | |
d62a17ae | 11906 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11907 | int idx_protocol = 1; | |
11908 | int idx_number = 3; | |
11909 | int idx_word = 5; | |
11910 | int type; | |
d7c0a89a | 11911 | uint32_t metric; |
d62a17ae | 11912 | struct bgp_redist *red; |
e923dd62 | 11913 | bool changed; |
1de27621 DA |
11914 | struct route_map *route_map = |
11915 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 11916 | |
11917 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11918 | if (type < 0) { | |
11919 | vty_out(vty, "%% Invalid route type\n"); | |
11920 | return CMD_WARNING_CONFIG_FAILED; | |
11921 | } | |
11922 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11923 | ||
11924 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11925 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
11926 | changed |= |
11927 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11928 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 11929 | } |
11930 | ||
11931 | ALIAS_HIDDEN( | |
11932 | bgp_redistribute_ipv4_metric_rmap, | |
11933 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11934 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11935 | " metric (0-4294967295) route-map WORD", | |
11936 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11937 | "Metric for redistributed routes\n" | |
11938 | "Default metric\n" | |
11939 | "Route map reference\n" | |
11940 | "Pointer to route-map entries\n") | |
596c17ba | 11941 | |
7c8ff89e DS |
11942 | DEFUN (bgp_redistribute_ipv4_ospf, |
11943 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11944 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11945 | "Redistribute information from another routing protocol\n" |
11946 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11947 | "Non-main Kernel Routing Table\n" |
11948 | "Instance ID/Table ID\n") | |
7c8ff89e | 11949 | { |
d62a17ae | 11950 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11951 | int idx_ospf_table = 1; | |
11952 | int idx_number = 2; | |
d7c0a89a QY |
11953 | unsigned short instance; |
11954 | unsigned short protocol; | |
7c8ff89e | 11955 | |
d62a17ae | 11956 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11957 | |
d62a17ae | 11958 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11959 | protocol = ZEBRA_ROUTE_OSPF; | |
11960 | else | |
11961 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11962 | |
d62a17ae | 11963 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 11964 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
11965 | } |
11966 | ||
d62a17ae | 11967 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11968 | "redistribute <ospf|table> (1-65535)", | |
11969 | "Redistribute information from another routing protocol\n" | |
11970 | "Open Shortest Path First (OSPFv2)\n" | |
11971 | "Non-main Kernel Routing Table\n" | |
11972 | "Instance ID/Table ID\n") | |
596c17ba | 11973 | |
7c8ff89e DS |
11974 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11975 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11976 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11977 | "Redistribute information from another routing protocol\n" |
11978 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11979 | "Non-main Kernel Routing Table\n" |
11980 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11981 | "Route map reference\n" |
11982 | "Pointer to route-map entries\n") | |
11983 | { | |
d62a17ae | 11984 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11985 | int idx_ospf_table = 1; | |
11986 | int idx_number = 2; | |
11987 | int idx_word = 4; | |
11988 | struct bgp_redist *red; | |
d7c0a89a | 11989 | unsigned short instance; |
d62a17ae | 11990 | int protocol; |
e923dd62 | 11991 | bool changed; |
1de27621 DA |
11992 | struct route_map *route_map = |
11993 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 11994 | |
11995 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11996 | protocol = ZEBRA_ROUTE_OSPF; | |
11997 | else | |
11998 | protocol = ZEBRA_ROUTE_TABLE; | |
11999 | ||
12000 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12001 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12002 | changed = |
12003 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12004 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12005 | } |
12006 | ||
12007 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12008 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12009 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12010 | "Redistribute information from another routing protocol\n" | |
12011 | "Open Shortest Path First (OSPFv2)\n" | |
12012 | "Non-main Kernel Routing Table\n" | |
12013 | "Instance ID/Table ID\n" | |
12014 | "Route map reference\n" | |
12015 | "Pointer to route-map entries\n") | |
596c17ba | 12016 | |
7c8ff89e DS |
12017 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12018 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12019 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12020 | "Redistribute information from another routing protocol\n" |
12021 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12022 | "Non-main Kernel Routing Table\n" |
12023 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12024 | "Metric for redistributed routes\n" |
12025 | "Default metric\n") | |
12026 | { | |
d62a17ae | 12027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12028 | int idx_ospf_table = 1; | |
12029 | int idx_number = 2; | |
12030 | int idx_number_2 = 4; | |
d7c0a89a | 12031 | uint32_t metric; |
d62a17ae | 12032 | struct bgp_redist *red; |
d7c0a89a | 12033 | unsigned short instance; |
d62a17ae | 12034 | int protocol; |
e923dd62 | 12035 | bool changed; |
d62a17ae | 12036 | |
12037 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12038 | protocol = ZEBRA_ROUTE_OSPF; | |
12039 | else | |
12040 | protocol = ZEBRA_ROUTE_TABLE; | |
12041 | ||
12042 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12043 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12044 | ||
12045 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12046 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12047 | metric); | |
12048 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12049 | } |
12050 | ||
12051 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12052 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12053 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12054 | "Redistribute information from another routing protocol\n" | |
12055 | "Open Shortest Path First (OSPFv2)\n" | |
12056 | "Non-main Kernel Routing Table\n" | |
12057 | "Instance ID/Table ID\n" | |
12058 | "Metric for redistributed routes\n" | |
12059 | "Default metric\n") | |
596c17ba | 12060 | |
7c8ff89e DS |
12061 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12062 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12063 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12064 | "Redistribute information from another routing protocol\n" |
12065 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12066 | "Non-main Kernel Routing Table\n" |
12067 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12068 | "Route map reference\n" |
12069 | "Pointer to route-map entries\n" | |
12070 | "Metric for redistributed routes\n" | |
12071 | "Default metric\n") | |
12072 | { | |
d62a17ae | 12073 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12074 | int idx_ospf_table = 1; | |
12075 | int idx_number = 2; | |
12076 | int idx_word = 4; | |
12077 | int idx_number_2 = 6; | |
d7c0a89a | 12078 | uint32_t metric; |
d62a17ae | 12079 | struct bgp_redist *red; |
d7c0a89a | 12080 | unsigned short instance; |
d62a17ae | 12081 | int protocol; |
e923dd62 | 12082 | bool changed; |
1de27621 DA |
12083 | struct route_map *route_map = |
12084 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12085 | |
12086 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12087 | protocol = ZEBRA_ROUTE_OSPF; | |
12088 | else | |
12089 | protocol = ZEBRA_ROUTE_TABLE; | |
12090 | ||
12091 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12092 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12093 | ||
12094 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12095 | changed = |
12096 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12097 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12098 | metric); | |
12099 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12100 | } |
12101 | ||
12102 | ALIAS_HIDDEN( | |
12103 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12104 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12105 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12106 | "Redistribute information from another routing protocol\n" | |
12107 | "Open Shortest Path First (OSPFv2)\n" | |
12108 | "Non-main Kernel Routing Table\n" | |
12109 | "Instance ID/Table ID\n" | |
12110 | "Route map reference\n" | |
12111 | "Pointer to route-map entries\n" | |
12112 | "Metric for redistributed routes\n" | |
12113 | "Default metric\n") | |
596c17ba | 12114 | |
7c8ff89e DS |
12115 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12116 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12117 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12118 | "Redistribute information from another routing protocol\n" |
12119 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12120 | "Non-main Kernel Routing Table\n" |
12121 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12122 | "Metric for redistributed routes\n" |
12123 | "Default metric\n" | |
12124 | "Route map reference\n" | |
12125 | "Pointer to route-map entries\n") | |
12126 | { | |
d62a17ae | 12127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12128 | int idx_ospf_table = 1; | |
12129 | int idx_number = 2; | |
12130 | int idx_number_2 = 4; | |
12131 | int idx_word = 6; | |
d7c0a89a | 12132 | uint32_t metric; |
d62a17ae | 12133 | struct bgp_redist *red; |
d7c0a89a | 12134 | unsigned short instance; |
d62a17ae | 12135 | int protocol; |
e923dd62 | 12136 | bool changed; |
1de27621 DA |
12137 | struct route_map *route_map = |
12138 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12139 | |
12140 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12141 | protocol = ZEBRA_ROUTE_OSPF; | |
12142 | else | |
12143 | protocol = ZEBRA_ROUTE_TABLE; | |
12144 | ||
12145 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12146 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12147 | ||
12148 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12149 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12150 | metric); | |
1de27621 DA |
12151 | changed |= |
12152 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12153 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12154 | } |
12155 | ||
12156 | ALIAS_HIDDEN( | |
12157 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12158 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12159 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12160 | "Redistribute information from another routing protocol\n" | |
12161 | "Open Shortest Path First (OSPFv2)\n" | |
12162 | "Non-main Kernel Routing Table\n" | |
12163 | "Instance ID/Table ID\n" | |
12164 | "Metric for redistributed routes\n" | |
12165 | "Default metric\n" | |
12166 | "Route map reference\n" | |
12167 | "Pointer to route-map entries\n") | |
596c17ba | 12168 | |
7c8ff89e DS |
12169 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12170 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 12171 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
12172 | NO_STR |
12173 | "Redistribute information from another routing protocol\n" | |
12174 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12175 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12176 | "Instance ID/Table ID\n" |
12177 | "Metric for redistributed routes\n" | |
12178 | "Default metric\n" | |
12179 | "Route map reference\n" | |
12180 | "Pointer to route-map entries\n") | |
7c8ff89e | 12181 | { |
d62a17ae | 12182 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12183 | int idx_ospf_table = 2; | |
12184 | int idx_number = 3; | |
d7c0a89a | 12185 | unsigned short instance; |
d62a17ae | 12186 | int protocol; |
12187 | ||
12188 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12189 | protocol = ZEBRA_ROUTE_OSPF; | |
12190 | else | |
12191 | protocol = ZEBRA_ROUTE_TABLE; | |
12192 | ||
12193 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12194 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12195 | } | |
12196 | ||
12197 | ALIAS_HIDDEN( | |
12198 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
12199 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
12200 | NO_STR | |
12201 | "Redistribute information from another routing protocol\n" | |
12202 | "Open Shortest Path First (OSPFv2)\n" | |
12203 | "Non-main Kernel Routing Table\n" | |
12204 | "Instance ID/Table ID\n" | |
12205 | "Metric for redistributed routes\n" | |
12206 | "Default metric\n" | |
12207 | "Route map reference\n" | |
12208 | "Pointer to route-map entries\n") | |
596c17ba | 12209 | |
718e3744 | 12210 | DEFUN (no_bgp_redistribute_ipv4, |
12211 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12212 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12213 | NO_STR |
12214 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12215 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12216 | "Metric for redistributed routes\n" |
12217 | "Default metric\n" | |
12218 | "Route map reference\n" | |
12219 | "Pointer to route-map entries\n") | |
718e3744 | 12220 | { |
d62a17ae | 12221 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12222 | int idx_protocol = 2; | |
12223 | int type; | |
12224 | ||
12225 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12226 | if (type < 0) { | |
12227 | vty_out(vty, "%% Invalid route type\n"); | |
12228 | return CMD_WARNING_CONFIG_FAILED; | |
12229 | } | |
12230 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12231 | } | |
12232 | ||
12233 | ALIAS_HIDDEN( | |
12234 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12235 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
12236 | " [metric (0-4294967295)] [route-map WORD]", | |
12237 | NO_STR | |
12238 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12239 | "Metric for redistributed routes\n" | |
12240 | "Default metric\n" | |
12241 | "Route map reference\n" | |
12242 | "Pointer to route-map entries\n") | |
596c17ba | 12243 | |
718e3744 | 12244 | DEFUN (bgp_redistribute_ipv6, |
12245 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12246 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12247 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12248 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12249 | { |
d62a17ae | 12250 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12251 | int idx_protocol = 1; | |
12252 | int type; | |
718e3744 | 12253 | |
d62a17ae | 12254 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12255 | if (type < 0) { | |
12256 | vty_out(vty, "%% Invalid route type\n"); | |
12257 | return CMD_WARNING_CONFIG_FAILED; | |
12258 | } | |
718e3744 | 12259 | |
d62a17ae | 12260 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12261 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12262 | } |
12263 | ||
12264 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12265 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12266 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12267 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12268 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12269 | "Route map reference\n" |
12270 | "Pointer to route-map entries\n") | |
12271 | { | |
d62a17ae | 12272 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12273 | int idx_protocol = 1; | |
12274 | int idx_word = 3; | |
12275 | int type; | |
12276 | struct bgp_redist *red; | |
e923dd62 | 12277 | bool changed; |
1de27621 DA |
12278 | struct route_map *route_map = |
12279 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12280 | |
d62a17ae | 12281 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12282 | if (type < 0) { | |
12283 | vty_out(vty, "%% Invalid route type\n"); | |
12284 | return CMD_WARNING_CONFIG_FAILED; | |
12285 | } | |
718e3744 | 12286 | |
d62a17ae | 12287 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12288 | changed = |
12289 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12290 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12291 | } |
12292 | ||
12293 | DEFUN (bgp_redistribute_ipv6_metric, | |
12294 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12295 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12296 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12297 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12298 | "Metric for redistributed routes\n" |
12299 | "Default metric\n") | |
12300 | { | |
d62a17ae | 12301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12302 | int idx_protocol = 1; | |
12303 | int idx_number = 3; | |
12304 | int type; | |
d7c0a89a | 12305 | uint32_t metric; |
d62a17ae | 12306 | struct bgp_redist *red; |
e923dd62 | 12307 | bool changed; |
d62a17ae | 12308 | |
12309 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12310 | if (type < 0) { | |
12311 | vty_out(vty, "%% Invalid route type\n"); | |
12312 | return CMD_WARNING_CONFIG_FAILED; | |
12313 | } | |
12314 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12315 | |
d62a17ae | 12316 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12317 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12318 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12319 | } |
12320 | ||
12321 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12322 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12323 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12324 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12325 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12326 | "Route map reference\n" |
12327 | "Pointer to route-map entries\n" | |
12328 | "Metric for redistributed routes\n" | |
12329 | "Default metric\n") | |
12330 | { | |
d62a17ae | 12331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12332 | int idx_protocol = 1; | |
12333 | int idx_word = 3; | |
12334 | int idx_number = 5; | |
12335 | int type; | |
d7c0a89a | 12336 | uint32_t metric; |
d62a17ae | 12337 | struct bgp_redist *red; |
e923dd62 | 12338 | bool changed; |
1de27621 DA |
12339 | struct route_map *route_map = |
12340 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12341 | |
12342 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12343 | if (type < 0) { | |
12344 | vty_out(vty, "%% Invalid route type\n"); | |
12345 | return CMD_WARNING_CONFIG_FAILED; | |
12346 | } | |
12347 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12348 | |
d62a17ae | 12349 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12350 | changed = |
12351 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12352 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12353 | metric); | |
12354 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12355 | } |
12356 | ||
12357 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12358 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12359 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12360 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12361 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12362 | "Metric for redistributed routes\n" |
12363 | "Default metric\n" | |
12364 | "Route map reference\n" | |
12365 | "Pointer to route-map entries\n") | |
12366 | { | |
d62a17ae | 12367 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12368 | int idx_protocol = 1; | |
12369 | int idx_number = 3; | |
12370 | int idx_word = 5; | |
12371 | int type; | |
d7c0a89a | 12372 | uint32_t metric; |
d62a17ae | 12373 | struct bgp_redist *red; |
e923dd62 | 12374 | bool changed; |
1de27621 DA |
12375 | struct route_map *route_map = |
12376 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12377 | |
12378 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12379 | if (type < 0) { | |
12380 | vty_out(vty, "%% Invalid route type\n"); | |
12381 | return CMD_WARNING_CONFIG_FAILED; | |
12382 | } | |
12383 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12384 | |
d62a17ae | 12385 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12386 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12387 | metric); | |
1de27621 DA |
12388 | changed |= |
12389 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12390 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12391 | } |
12392 | ||
12393 | DEFUN (no_bgp_redistribute_ipv6, | |
12394 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12395 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12396 | NO_STR |
12397 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12398 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12399 | "Metric for redistributed routes\n" |
12400 | "Default metric\n" | |
12401 | "Route map reference\n" | |
12402 | "Pointer to route-map entries\n") | |
718e3744 | 12403 | { |
d62a17ae | 12404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12405 | int idx_protocol = 2; | |
12406 | int type; | |
718e3744 | 12407 | |
d62a17ae | 12408 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12409 | if (type < 0) { | |
12410 | vty_out(vty, "%% Invalid route type\n"); | |
12411 | return CMD_WARNING_CONFIG_FAILED; | |
12412 | } | |
718e3744 | 12413 | |
d62a17ae | 12414 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12415 | } | |
12416 | ||
2b791107 | 12417 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12418 | safi_t safi) |
d62a17ae | 12419 | { |
12420 | int i; | |
12421 | ||
12422 | /* Unicast redistribution only. */ | |
12423 | if (safi != SAFI_UNICAST) | |
2b791107 | 12424 | return; |
d62a17ae | 12425 | |
12426 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12427 | /* Redistribute BGP does not make sense. */ | |
12428 | if (i != ZEBRA_ROUTE_BGP) { | |
12429 | struct list *red_list; | |
12430 | struct listnode *node; | |
12431 | struct bgp_redist *red; | |
12432 | ||
12433 | red_list = bgp->redist[afi][i]; | |
12434 | if (!red_list) | |
12435 | continue; | |
12436 | ||
12437 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12438 | /* "redistribute" configuration. */ |
12439 | vty_out(vty, " redistribute %s", | |
12440 | zebra_route_string(i)); | |
12441 | if (red->instance) | |
12442 | vty_out(vty, " %d", red->instance); | |
12443 | if (red->redist_metric_flag) | |
12444 | vty_out(vty, " metric %u", | |
12445 | red->redist_metric); | |
12446 | if (red->rmap.name) | |
12447 | vty_out(vty, " route-map %s", | |
12448 | red->rmap.name); | |
12449 | vty_out(vty, "\n"); | |
12450 | } | |
12451 | } | |
12452 | } | |
718e3744 | 12453 | } |
6b0655a2 | 12454 | |
b9c7bc5a PZ |
12455 | /* This is part of the address-family block (unicast only) */ |
12456 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12457 | afi_t afi) |
12458 | { | |
b9c7bc5a | 12459 | int indent = 2; |
ddb5b488 | 12460 | |
8a066a70 PG |
12461 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12462 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12463 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12464 | bgp->vpn_policy[afi] | |
bb4f6190 | 12465 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12466 | else |
12467 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12468 | bgp->vpn_policy[afi] | |
12469 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12470 | } | |
12a844a5 DS |
12471 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12472 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12473 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12474 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12475 | return; | |
12476 | ||
e70e9f8e PZ |
12477 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12478 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12479 | ||
12480 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12481 | ||
12482 | } else { | |
12483 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12484 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12485 | bgp->vpn_policy[afi].tovpn_label); | |
12486 | } | |
ddb5b488 PZ |
12487 | } |
12488 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12489 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12490 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12491 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12492 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12493 | sizeof(buf))); | |
12494 | } | |
12495 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12496 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12497 | ||
12498 | char buf[PREFIX_STRLEN]; | |
12499 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12500 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12501 | sizeof(buf))) { | |
12502 | ||
b9c7bc5a PZ |
12503 | vty_out(vty, "%*snexthop vpn export %s\n", |
12504 | indent, "", buf); | |
ddb5b488 PZ |
12505 | } |
12506 | } | |
12507 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12508 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12509 | && ecommunity_cmp( | |
12510 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12511 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12512 | ||
12513 | char *b = ecommunity_ecom2str( | |
12514 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12515 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12516 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12517 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12518 | } else { | |
12519 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12520 | char *b = ecommunity_ecom2str( | |
12521 | bgp->vpn_policy[afi] | |
12522 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12523 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12524 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12525 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12526 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12527 | } | |
12528 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12529 | char *b = ecommunity_ecom2str( | |
12530 | bgp->vpn_policy[afi] | |
12531 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12532 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12533 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12534 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12535 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12536 | } | |
12537 | } | |
bb4f6190 DS |
12538 | |
12539 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12540 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12541 | bgp->vpn_policy[afi] |
12542 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12543 | |
301ad80a PG |
12544 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12545 | char *b = ecommunity_ecom2str( | |
12546 | bgp->vpn_policy[afi] | |
12547 | .import_redirect_rtlist, | |
12548 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12549 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12550 | |
301ad80a PG |
12551 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12552 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12553 | } | |
ddb5b488 PZ |
12554 | } |
12555 | ||
12556 | ||
718e3744 | 12557 | /* BGP node structure. */ |
d62a17ae | 12558 | static struct cmd_node bgp_node = { |
9d303b37 | 12559 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12560 | }; |
12561 | ||
d62a17ae | 12562 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12563 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12564 | }; |
12565 | ||
d62a17ae | 12566 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12567 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12568 | }; |
12569 | ||
d62a17ae | 12570 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12571 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12572 | }; |
12573 | ||
d62a17ae | 12574 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12575 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12576 | }; |
12577 | ||
d62a17ae | 12578 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12579 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12580 | }; |
12581 | ||
d62a17ae | 12582 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12583 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12584 | }; |
12585 | ||
d62a17ae | 12586 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12587 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12588 | |
d62a17ae | 12589 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12590 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12591 | |
d62a17ae | 12592 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12593 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12594 | |
d62a17ae | 12595 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12596 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12597 | |
7c40bf39 | 12598 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12599 | "%s(config-router-af)# ", 1}; | |
12600 | ||
12601 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12602 | "%s(config-router-af-vpnv6)# ", 1}; | |
12603 | ||
d62a17ae | 12604 | static void community_list_vty(void); |
1f8ae70b | 12605 | |
d62a17ae | 12606 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12607 | { |
d62a17ae | 12608 | struct bgp *bgp; |
12609 | struct peer *peer; | |
d62a17ae | 12610 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12611 | |
d62a17ae | 12612 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12613 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12614 | /* only provide suggestions on the appropriate input | |
12615 | * token type, | |
12616 | * they'll otherwise show up multiple times */ | |
12617 | enum cmd_token_type match_type; | |
12618 | char *name = peer->host; | |
d48ed3e0 | 12619 | |
d62a17ae | 12620 | if (peer->conf_if) { |
12621 | match_type = VARIABLE_TKN; | |
12622 | name = peer->conf_if; | |
12623 | } else if (strchr(peer->host, ':')) | |
12624 | match_type = IPV6_TKN; | |
12625 | else | |
12626 | match_type = IPV4_TKN; | |
d48ed3e0 | 12627 | |
d62a17ae | 12628 | if (token->type != match_type) |
12629 | continue; | |
d48ed3e0 | 12630 | |
d62a17ae | 12631 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12632 | } | |
d62a17ae | 12633 | } |
b8a815e5 DL |
12634 | } |
12635 | ||
12636 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12637 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12638 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12639 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12640 | {.completions = NULL}}; |
12641 | ||
47a306a0 DS |
12642 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12643 | { | |
12644 | struct bgp *bgp; | |
12645 | struct peer_group *group; | |
12646 | struct listnode *lnbgp, *lnpeer; | |
12647 | ||
12648 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12649 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12650 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12651 | group->name)); | |
12652 | } | |
12653 | } | |
12654 | ||
12655 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12656 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12657 | {.completions = NULL} }; | |
12658 | ||
d62a17ae | 12659 | void bgp_vty_init(void) |
12660 | { | |
12661 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12662 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12663 | |
12664 | /* Install bgp top node. */ | |
12665 | install_node(&bgp_node, bgp_config_write); | |
12666 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12667 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12668 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12669 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12670 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12671 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12672 | install_node(&bgp_vpnv4_node, NULL); | |
12673 | install_node(&bgp_vpnv6_node, NULL); | |
12674 | install_node(&bgp_evpn_node, NULL); | |
12675 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12676 | install_node(&bgp_flowspecv4_node, NULL); |
12677 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12678 | |
12679 | /* Install default VTY commands to new nodes. */ | |
12680 | install_default(BGP_NODE); | |
12681 | install_default(BGP_IPV4_NODE); | |
12682 | install_default(BGP_IPV4M_NODE); | |
12683 | install_default(BGP_IPV4L_NODE); | |
12684 | install_default(BGP_IPV6_NODE); | |
12685 | install_default(BGP_IPV6M_NODE); | |
12686 | install_default(BGP_IPV6L_NODE); | |
12687 | install_default(BGP_VPNV4_NODE); | |
12688 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12689 | install_default(BGP_FLOWSPECV4_NODE); |
12690 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12691 | install_default(BGP_EVPN_NODE); |
12692 | install_default(BGP_EVPN_VNI_NODE); | |
12693 | ||
12694 | /* "bgp multiple-instance" commands. */ | |
12695 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12696 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12697 | ||
12698 | /* "bgp config-type" commands. */ | |
12699 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12700 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12701 | ||
8029b216 AK |
12702 | /* "bgp local-mac" hidden commands. */ |
12703 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12704 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12705 | ||
d62a17ae | 12706 | /* bgp route-map delay-timer commands. */ |
12707 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12708 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12709 | ||
12710 | /* Dummy commands (Currently not supported) */ | |
12711 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12712 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12713 | ||
12714 | /* "router bgp" commands. */ | |
12715 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12716 | ||
12717 | /* "no router bgp" commands. */ | |
12718 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12719 | ||
12720 | /* "bgp router-id" commands. */ | |
12721 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12722 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12723 | ||
12724 | /* "bgp cluster-id" commands. */ | |
12725 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12726 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12727 | ||
12728 | /* "bgp confederation" commands. */ | |
12729 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12730 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12731 | ||
12732 | /* "bgp confederation peers" commands. */ | |
12733 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12734 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12735 | ||
12736 | /* bgp max-med command */ | |
12737 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12738 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12739 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12740 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12741 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12742 | ||
12743 | /* bgp disable-ebgp-connected-nh-check */ | |
12744 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12745 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12746 | ||
12747 | /* bgp update-delay command */ | |
12748 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12749 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12750 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12751 | ||
12752 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12753 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12754 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12755 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12756 | |
12757 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12758 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12759 | ||
12760 | /* "maximum-paths" commands. */ | |
12761 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12762 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12763 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12764 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12765 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12766 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12767 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12768 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12769 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12770 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12771 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12772 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12773 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12774 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12775 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12776 | ||
12777 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12778 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12779 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12780 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12781 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12782 | ||
12783 | /* "timers bgp" commands. */ | |
12784 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12785 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12786 | ||
12787 | /* route-map delay-timer commands - per instance for backwards compat. | |
12788 | */ | |
12789 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12790 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12791 | ||
12792 | /* "bgp client-to-client reflection" commands */ | |
12793 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12794 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12795 | ||
12796 | /* "bgp always-compare-med" commands */ | |
12797 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12798 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12799 | ||
12800 | /* "bgp deterministic-med" commands */ | |
12801 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12802 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12803 | ||
12804 | /* "bgp graceful-restart" commands */ | |
12805 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12806 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12807 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12808 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12809 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12810 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12811 | ||
12812 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12813 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12814 | ||
7f323236 DW |
12815 | /* "bgp graceful-shutdown" commands */ |
12816 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12817 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12818 | ||
d62a17ae | 12819 | /* "bgp fast-external-failover" commands */ |
12820 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12821 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12822 | ||
12823 | /* "bgp enforce-first-as" commands */ | |
12824 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 12825 | |
12826 | /* "bgp bestpath compare-routerid" commands */ | |
12827 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12828 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12829 | ||
12830 | /* "bgp bestpath as-path ignore" commands */ | |
12831 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12832 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12833 | ||
12834 | /* "bgp bestpath as-path confed" commands */ | |
12835 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12836 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12837 | ||
12838 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12839 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12840 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12841 | ||
12842 | /* "bgp log-neighbor-changes" commands */ | |
12843 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12844 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12845 | ||
12846 | /* "bgp bestpath med" commands */ | |
12847 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12848 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12849 | ||
12850 | /* "no bgp default ipv4-unicast" commands. */ | |
12851 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12852 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12853 | ||
12854 | /* "bgp network import-check" commands. */ | |
12855 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12856 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12857 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12858 | ||
12859 | /* "bgp default local-preference" commands. */ | |
12860 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12861 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12862 | ||
12863 | /* bgp default show-hostname */ | |
12864 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12865 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12866 | ||
12867 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12868 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12869 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12870 | ||
12871 | /* bgp ibgp-allow-policy-mods command */ | |
12872 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12873 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12874 | ||
12875 | /* "bgp listen limit" commands. */ | |
12876 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12877 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12878 | ||
12879 | /* "bgp listen range" commands. */ | |
12880 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12881 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12882 | ||
8175f54a | 12883 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12884 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12885 | ||
d62a17ae | 12886 | /* "neighbor remote-as" commands. */ |
12887 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12888 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12889 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12890 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12891 | install_element(BGP_NODE, | |
12892 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12893 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12894 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12895 | ||
12896 | /* "neighbor peer-group" commands. */ | |
12897 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12898 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12899 | install_element(BGP_NODE, | |
12900 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12901 | ||
12902 | /* "neighbor local-as" commands. */ | |
12903 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12904 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12905 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12906 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12907 | ||
12908 | /* "neighbor solo" commands. */ | |
12909 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12910 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12911 | ||
12912 | /* "neighbor password" commands. */ | |
12913 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12914 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12915 | ||
12916 | /* "neighbor activate" commands. */ | |
12917 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12918 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12919 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12920 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12921 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12922 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12923 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12924 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12925 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12926 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12927 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12928 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12929 | ||
12930 | /* "no neighbor activate" commands. */ | |
12931 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12932 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12933 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12934 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12935 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12936 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12937 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12938 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12939 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12940 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12941 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12942 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12943 | ||
12944 | /* "neighbor peer-group" set commands. */ | |
12945 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12946 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12947 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12948 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12949 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12950 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12951 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12952 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12953 | install_element(BGP_FLOWSPECV4_NODE, |
12954 | &neighbor_set_peer_group_hidden_cmd); | |
12955 | install_element(BGP_FLOWSPECV6_NODE, | |
12956 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12957 | |
12958 | /* "no neighbor peer-group unset" commands. */ | |
12959 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12960 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12961 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12962 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12963 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12964 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12965 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12966 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12967 | install_element(BGP_FLOWSPECV4_NODE, |
12968 | &no_neighbor_set_peer_group_hidden_cmd); | |
12969 | install_element(BGP_FLOWSPECV6_NODE, | |
12970 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12971 | |
12972 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12973 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12974 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12975 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12976 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12977 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12978 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12979 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12980 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12981 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12982 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12983 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12984 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12985 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12986 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12987 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12988 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12989 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12990 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 12991 | install_element(BGP_FLOWSPECV4_NODE, |
12992 | &neighbor_soft_reconfiguration_cmd); | |
12993 | install_element(BGP_FLOWSPECV4_NODE, | |
12994 | &no_neighbor_soft_reconfiguration_cmd); | |
12995 | install_element(BGP_FLOWSPECV6_NODE, | |
12996 | &neighbor_soft_reconfiguration_cmd); | |
12997 | install_element(BGP_FLOWSPECV6_NODE, | |
12998 | &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 12999 | |
13000 | /* "neighbor attribute-unchanged" commands. */ | |
13001 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13002 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13003 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13004 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13005 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13006 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13007 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13008 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13009 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13010 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13011 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13012 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13013 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13014 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13015 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13016 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13017 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13018 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13019 | ||
13020 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13021 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13022 | ||
13023 | /* "nexthop-local unchanged" commands */ | |
13024 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13025 | install_element(BGP_IPV6_NODE, | |
13026 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13027 | ||
13028 | /* "neighbor next-hop-self" commands. */ | |
13029 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13030 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13031 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13032 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13033 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13034 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13035 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13036 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13037 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13038 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13039 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13040 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13041 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13042 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13043 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13044 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13045 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13046 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13047 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13048 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13049 | |
13050 | /* "neighbor next-hop-self force" commands. */ | |
13051 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13052 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
13053 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13054 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13055 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13056 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13057 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13058 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13059 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13060 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13061 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13062 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13063 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13064 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13065 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13066 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13067 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13068 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13069 | ||
13070 | /* "neighbor as-override" commands. */ | |
13071 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13072 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13073 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13074 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13075 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13076 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13077 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13078 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13079 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13080 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13081 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13082 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13083 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13084 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13085 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13086 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13087 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13088 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13089 | ||
13090 | /* "neighbor remove-private-AS" commands. */ | |
13091 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13092 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13093 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13094 | install_element(BGP_NODE, | |
13095 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13096 | install_element(BGP_NODE, | |
13097 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13098 | install_element(BGP_NODE, | |
13099 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13100 | install_element(BGP_NODE, | |
13101 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13102 | install_element( | |
13103 | BGP_NODE, | |
13104 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13105 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13106 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13107 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13108 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13109 | install_element(BGP_IPV4_NODE, | |
13110 | &neighbor_remove_private_as_replace_as_cmd); | |
13111 | install_element(BGP_IPV4_NODE, | |
13112 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13113 | install_element(BGP_IPV4_NODE, | |
13114 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13115 | install_element(BGP_IPV4_NODE, | |
13116 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13117 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13118 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13119 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13120 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13121 | install_element(BGP_IPV4M_NODE, | |
13122 | &neighbor_remove_private_as_replace_as_cmd); | |
13123 | install_element(BGP_IPV4M_NODE, | |
13124 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13125 | install_element(BGP_IPV4M_NODE, | |
13126 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13127 | install_element(BGP_IPV4M_NODE, | |
13128 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13129 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13130 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13131 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13132 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13133 | install_element(BGP_IPV4L_NODE, | |
13134 | &neighbor_remove_private_as_replace_as_cmd); | |
13135 | install_element(BGP_IPV4L_NODE, | |
13136 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13137 | install_element(BGP_IPV4L_NODE, | |
13138 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13139 | install_element(BGP_IPV4L_NODE, | |
13140 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13141 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13142 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13143 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13144 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13145 | install_element(BGP_IPV6_NODE, | |
13146 | &neighbor_remove_private_as_replace_as_cmd); | |
13147 | install_element(BGP_IPV6_NODE, | |
13148 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13149 | install_element(BGP_IPV6_NODE, | |
13150 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13151 | install_element(BGP_IPV6_NODE, | |
13152 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13153 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13154 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13155 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13156 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13157 | install_element(BGP_IPV6M_NODE, | |
13158 | &neighbor_remove_private_as_replace_as_cmd); | |
13159 | install_element(BGP_IPV6M_NODE, | |
13160 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13161 | install_element(BGP_IPV6M_NODE, | |
13162 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13163 | install_element(BGP_IPV6M_NODE, | |
13164 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13165 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13166 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13167 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13168 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13169 | install_element(BGP_IPV6L_NODE, | |
13170 | &neighbor_remove_private_as_replace_as_cmd); | |
13171 | install_element(BGP_IPV6L_NODE, | |
13172 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13173 | install_element(BGP_IPV6L_NODE, | |
13174 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13175 | install_element(BGP_IPV6L_NODE, | |
13176 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13177 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13178 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13179 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13180 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13181 | install_element(BGP_VPNV4_NODE, | |
13182 | &neighbor_remove_private_as_replace_as_cmd); | |
13183 | install_element(BGP_VPNV4_NODE, | |
13184 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13185 | install_element(BGP_VPNV4_NODE, | |
13186 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13187 | install_element(BGP_VPNV4_NODE, | |
13188 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13189 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13190 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13191 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13192 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13193 | install_element(BGP_VPNV6_NODE, | |
13194 | &neighbor_remove_private_as_replace_as_cmd); | |
13195 | install_element(BGP_VPNV6_NODE, | |
13196 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13197 | install_element(BGP_VPNV6_NODE, | |
13198 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13199 | install_element(BGP_VPNV6_NODE, | |
13200 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13201 | ||
13202 | /* "neighbor send-community" commands.*/ | |
13203 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13204 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13205 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13206 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13207 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13208 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13209 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13210 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13211 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13212 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13213 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13214 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13215 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13216 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13217 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13218 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13219 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13220 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13221 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13222 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13223 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13224 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13225 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13226 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13227 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13228 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13229 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13230 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13231 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13232 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13233 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13234 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13235 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13236 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13237 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13238 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13239 | ||
13240 | /* "neighbor route-reflector" commands.*/ | |
13241 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13242 | install_element(BGP_NODE, | |
13243 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13244 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13245 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13246 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13247 | install_element(BGP_IPV4M_NODE, | |
13248 | &no_neighbor_route_reflector_client_cmd); | |
13249 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13250 | install_element(BGP_IPV4L_NODE, | |
13251 | &no_neighbor_route_reflector_client_cmd); | |
13252 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13253 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13254 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13255 | install_element(BGP_IPV6M_NODE, | |
13256 | &no_neighbor_route_reflector_client_cmd); | |
13257 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13258 | install_element(BGP_IPV6L_NODE, | |
13259 | &no_neighbor_route_reflector_client_cmd); | |
13260 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13261 | install_element(BGP_VPNV4_NODE, | |
13262 | &no_neighbor_route_reflector_client_cmd); | |
13263 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13264 | install_element(BGP_VPNV6_NODE, | |
13265 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13266 | install_element(BGP_FLOWSPECV4_NODE, |
13267 | &neighbor_route_reflector_client_cmd); | |
13268 | install_element(BGP_FLOWSPECV4_NODE, | |
13269 | &no_neighbor_route_reflector_client_cmd); | |
13270 | install_element(BGP_FLOWSPECV6_NODE, | |
13271 | &neighbor_route_reflector_client_cmd); | |
13272 | install_element(BGP_FLOWSPECV6_NODE, | |
13273 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13274 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13275 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13276 | ||
13277 | /* "neighbor route-server" commands.*/ | |
13278 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13279 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13280 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13281 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13282 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13283 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13284 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13285 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13286 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13287 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13288 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13289 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13290 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13291 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13292 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13293 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13294 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13295 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13296 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13297 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13298 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13299 | install_element(BGP_FLOWSPECV4_NODE, | |
13300 | &no_neighbor_route_server_client_cmd); | |
13301 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13302 | install_element(BGP_FLOWSPECV6_NODE, | |
13303 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13304 | |
13305 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13306 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13307 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13308 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13309 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13310 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13311 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13312 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13313 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13314 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13315 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13316 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13317 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13318 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13319 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13320 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13321 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13322 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13323 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13324 | ||
13325 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13326 | install_element(BGP_NODE, | |
13327 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13328 | install_element(BGP_NODE, | |
13329 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13330 | install_element(BGP_IPV4_NODE, | |
13331 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13332 | install_element(BGP_IPV4_NODE, | |
13333 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13334 | install_element(BGP_IPV4M_NODE, | |
13335 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13336 | install_element(BGP_IPV4M_NODE, | |
13337 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13338 | install_element(BGP_IPV4L_NODE, | |
13339 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13340 | install_element(BGP_IPV4L_NODE, | |
13341 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13342 | install_element(BGP_IPV6_NODE, | |
13343 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13344 | install_element(BGP_IPV6_NODE, | |
13345 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13346 | install_element(BGP_IPV6M_NODE, | |
13347 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13348 | install_element(BGP_IPV6M_NODE, | |
13349 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13350 | install_element(BGP_IPV6L_NODE, | |
13351 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13352 | install_element(BGP_IPV6L_NODE, | |
13353 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13354 | install_element(BGP_VPNV4_NODE, | |
13355 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13356 | install_element(BGP_VPNV4_NODE, | |
13357 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13358 | install_element(BGP_VPNV6_NODE, | |
13359 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13360 | install_element(BGP_VPNV6_NODE, | |
13361 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13362 | ||
13363 | /* "neighbor passive" commands. */ | |
13364 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13365 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13366 | ||
13367 | ||
13368 | /* "neighbor shutdown" commands. */ | |
13369 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13370 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13371 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13372 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13373 | ||
13374 | /* "neighbor capability extended-nexthop" commands.*/ | |
13375 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13376 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13377 | ||
13378 | /* "neighbor capability orf prefix-list" commands.*/ | |
13379 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13380 | install_element(BGP_NODE, | |
13381 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13382 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13383 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13384 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13385 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13386 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13387 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13388 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13389 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13390 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13391 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13392 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13393 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13394 | ||
13395 | /* "neighbor capability dynamic" commands.*/ | |
13396 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13397 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13398 | ||
13399 | /* "neighbor dont-capability-negotiate" commands. */ | |
13400 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13401 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13402 | ||
13403 | /* "neighbor ebgp-multihop" commands. */ | |
13404 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13405 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13406 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13407 | ||
13408 | /* "neighbor disable-connected-check" commands. */ | |
13409 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13410 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13411 | ||
47cbc09b PM |
13412 | /* "neighbor enforce-first-as" commands. */ |
13413 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13414 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13415 | ||
d62a17ae | 13416 | /* "neighbor description" commands. */ |
13417 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13418 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13419 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13420 | |
13421 | /* "neighbor update-source" commands. "*/ | |
13422 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13423 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13424 | ||
13425 | /* "neighbor default-originate" commands. */ | |
13426 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13427 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13428 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13429 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13430 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13431 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13432 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13433 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13434 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13435 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13436 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13437 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13438 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13439 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13440 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13441 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13442 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13443 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13444 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13445 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13446 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13447 | ||
13448 | /* "neighbor port" commands. */ | |
13449 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13450 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13451 | ||
13452 | /* "neighbor weight" commands. */ | |
13453 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13454 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13455 | ||
13456 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13457 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13458 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13459 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13460 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13461 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13462 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13463 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13464 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13465 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13466 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13467 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13468 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13469 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13470 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13471 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13472 | ||
13473 | /* "neighbor override-capability" commands. */ | |
13474 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13475 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13476 | ||
13477 | /* "neighbor strict-capability-match" commands. */ | |
13478 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13479 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13480 | ||
13481 | /* "neighbor timers" commands. */ | |
13482 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13483 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13484 | ||
13485 | /* "neighbor timers connect" commands. */ | |
13486 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13487 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13488 | ||
13489 | /* "neighbor advertisement-interval" commands. */ | |
13490 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13491 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13492 | ||
13493 | /* "neighbor interface" commands. */ | |
13494 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13495 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13496 | ||
13497 | /* "neighbor distribute" commands. */ | |
13498 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13499 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13500 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13501 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13502 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13503 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13504 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13505 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13506 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13507 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13508 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13509 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13510 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13511 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13512 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13513 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13514 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13515 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13516 | ||
13517 | /* "neighbor prefix-list" commands. */ | |
13518 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13519 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13520 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13521 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13522 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13523 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13524 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13525 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13526 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13527 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13528 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13529 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13530 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13531 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13532 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13533 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13534 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13535 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13536 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13537 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13538 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13539 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13540 | |
13541 | /* "neighbor filter-list" commands. */ | |
13542 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13543 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13544 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13545 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13546 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13547 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13548 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13549 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13550 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13551 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13552 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13553 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13554 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13555 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13556 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13557 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13558 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13559 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13560 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13561 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13562 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13563 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13564 | |
13565 | /* "neighbor route-map" commands. */ | |
13566 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13567 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13568 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13569 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13570 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13571 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13572 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13573 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13574 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13575 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13576 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13577 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13578 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13579 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13580 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13581 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13582 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13583 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13584 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13585 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13586 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13587 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13588 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13589 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13590 | |
13591 | /* "neighbor unsuppress-map" commands. */ | |
13592 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13593 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13594 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13595 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13596 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13597 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13598 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13599 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13600 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13601 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13602 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13603 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13604 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13605 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13606 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13607 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13608 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13609 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13610 | ||
13611 | /* "neighbor maximum-prefix" commands. */ | |
13612 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13613 | install_element(BGP_NODE, | |
13614 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13615 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13616 | install_element(BGP_NODE, | |
13617 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13618 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13619 | install_element(BGP_NODE, | |
13620 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13621 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13622 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13623 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13624 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13625 | install_element(BGP_IPV4_NODE, | |
13626 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13627 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13628 | install_element(BGP_IPV4_NODE, | |
13629 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13630 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13631 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13632 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13633 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13634 | install_element(BGP_IPV4M_NODE, | |
13635 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13636 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13637 | install_element(BGP_IPV4M_NODE, | |
13638 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13639 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13640 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13641 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13642 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13643 | install_element(BGP_IPV4L_NODE, | |
13644 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13645 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13646 | install_element(BGP_IPV4L_NODE, | |
13647 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13648 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13649 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13650 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13651 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13652 | install_element(BGP_IPV6_NODE, | |
13653 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13654 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13655 | install_element(BGP_IPV6_NODE, | |
13656 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13657 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13658 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13659 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13660 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13661 | install_element(BGP_IPV6M_NODE, | |
13662 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13663 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13664 | install_element(BGP_IPV6M_NODE, | |
13665 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13666 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13667 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13668 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13669 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13670 | install_element(BGP_IPV6L_NODE, | |
13671 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13672 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13673 | install_element(BGP_IPV6L_NODE, | |
13674 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13675 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13676 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13677 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13678 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13679 | install_element(BGP_VPNV4_NODE, | |
13680 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13681 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13682 | install_element(BGP_VPNV4_NODE, | |
13683 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13684 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13685 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13686 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13687 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13688 | install_element(BGP_VPNV6_NODE, | |
13689 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13690 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13691 | install_element(BGP_VPNV6_NODE, | |
13692 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13693 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13694 | ||
13695 | /* "neighbor allowas-in" */ | |
13696 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13697 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13698 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13699 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13700 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13701 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13702 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13703 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13704 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13705 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13706 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13707 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13708 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13709 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13710 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13711 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13712 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13713 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13714 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13715 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13716 | ||
13717 | /* address-family commands. */ | |
13718 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13719 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13720 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13721 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13722 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13723 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13724 | |
d62a17ae | 13725 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13726 | ||
13727 | /* "exit-address-family" command. */ | |
13728 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13729 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13730 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13731 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13732 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13733 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13734 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13735 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13736 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13737 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13738 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13739 | ||
13740 | /* "clear ip bgp commands" */ | |
13741 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13742 | ||
13743 | /* clear ip bgp prefix */ | |
13744 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13745 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13746 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13747 | ||
13748 | /* "show [ip] bgp summary" commands. */ | |
13749 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13750 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13751 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13752 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13753 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13754 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13755 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13756 | ||
13757 | /* "show [ip] bgp neighbors" commands. */ | |
13758 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13759 | ||
13760 | /* "show [ip] bgp peer-group" commands. */ | |
13761 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13762 | ||
13763 | /* "show [ip] bgp paths" commands. */ | |
13764 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13765 | ||
13766 | /* "show [ip] bgp community" commands. */ | |
13767 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13768 | ||
13769 | /* "show ip bgp large-community" commands. */ | |
13770 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13771 | /* "show [ip] bgp attribute-info" commands. */ | |
13772 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13773 | /* "show [ip] bgp route-leak" command */ |
13774 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13775 | |
13776 | /* "redistribute" commands. */ | |
13777 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13778 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13779 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13780 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13781 | install_element(BGP_NODE, | |
13782 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13783 | install_element(BGP_NODE, | |
13784 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13785 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13786 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13787 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13788 | install_element(BGP_NODE, | |
13789 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13790 | install_element(BGP_NODE, | |
13791 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13792 | install_element(BGP_NODE, | |
13793 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13794 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13795 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13796 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13797 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13798 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13799 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13800 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13801 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13802 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13803 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13804 | install_element(BGP_IPV4_NODE, | |
13805 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13806 | install_element(BGP_IPV4_NODE, | |
13807 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13808 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13809 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13810 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13811 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13812 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13813 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13814 | ||
b9c7bc5a PZ |
13815 | /* import|export vpn [route-map WORD] */ |
13816 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13817 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13818 | |
12a844a5 DS |
13819 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13820 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13821 | ||
d62a17ae | 13822 | /* ttl_security commands */ |
13823 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13824 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13825 | ||
13826 | /* "show [ip] bgp memory" commands. */ | |
13827 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13828 | ||
acf71666 MK |
13829 | /* "show bgp martian next-hop" */ |
13830 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13831 | ||
d62a17ae | 13832 | /* "show [ip] bgp views" commands. */ |
13833 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13834 | ||
13835 | /* "show [ip] bgp vrfs" commands. */ | |
13836 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13837 | ||
13838 | /* Community-list. */ | |
13839 | community_list_vty(); | |
ddb5b488 PZ |
13840 | |
13841 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13842 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13843 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13844 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13845 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13846 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13847 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13848 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13849 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13850 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13851 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13852 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13853 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13854 | |
301ad80a PG |
13855 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13856 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13857 | ||
b9c7bc5a PZ |
13858 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13859 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13860 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13861 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13862 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13863 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13864 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13865 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13866 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13867 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13868 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13869 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13870 | } |
6b0655a2 | 13871 | |
718e3744 | 13872 | #include "memory.h" |
13873 | #include "bgp_regex.h" | |
13874 | #include "bgp_clist.h" | |
13875 | #include "bgp_ecommunity.h" | |
13876 | ||
13877 | /* VTY functions. */ | |
13878 | ||
13879 | /* Direction value to string conversion. */ | |
d62a17ae | 13880 | static const char *community_direct_str(int direct) |
13881 | { | |
13882 | switch (direct) { | |
13883 | case COMMUNITY_DENY: | |
13884 | return "deny"; | |
13885 | case COMMUNITY_PERMIT: | |
13886 | return "permit"; | |
13887 | default: | |
13888 | return "unknown"; | |
13889 | } | |
718e3744 | 13890 | } |
13891 | ||
13892 | /* Display error string. */ | |
d62a17ae | 13893 | static void community_list_perror(struct vty *vty, int ret) |
13894 | { | |
13895 | switch (ret) { | |
13896 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13897 | vty_out(vty, "%% Can't find community-list\n"); | |
13898 | break; | |
13899 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13900 | vty_out(vty, "%% Malformed community-list value\n"); | |
13901 | break; | |
13902 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13903 | vty_out(vty, | |
13904 | "%% Community name conflict, previously defined as standard community\n"); | |
13905 | break; | |
13906 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13907 | vty_out(vty, | |
13908 | "%% Community name conflict, previously defined as expanded community\n"); | |
13909 | break; | |
13910 | } | |
718e3744 | 13911 | } |
13912 | ||
5bf15956 DW |
13913 | /* "community-list" keyword help string. */ |
13914 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13915 | ||
7336e101 SP |
13916 | /*community-list standard */ |
13917 | DEFUN (community_list_standard, | |
13918 | bgp_community_list_standard_cmd, | |
13919 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
13920 | BGP_STR | |
718e3744 | 13921 | COMMUNITY_LIST_STR |
13922 | "Community list number (standard)\n" | |
5bf15956 | 13923 | "Add an standard community-list entry\n" |
718e3744 | 13924 | "Community list name\n" |
13925 | "Specify community to reject\n" | |
13926 | "Specify community to accept\n" | |
13927 | COMMUNITY_VAL_STR) | |
13928 | { | |
d62a17ae | 13929 | char *cl_name_or_number = NULL; |
13930 | int direct = 0; | |
13931 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13932 | |
d62a17ae | 13933 | int idx = 0; |
7336e101 SP |
13934 | |
13935 | if (argv_find(argv, argc, "ip", &idx)) { | |
13936 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
13937 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
13938 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
13939 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
13940 | } | |
13941 | ||
d62a17ae | 13942 | argv_find(argv, argc, "(1-99)", &idx); |
13943 | argv_find(argv, argc, "WORD", &idx); | |
13944 | cl_name_or_number = argv[idx]->arg; | |
13945 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13946 | : COMMUNITY_DENY; | |
13947 | argv_find(argv, argc, "AA:NN", &idx); | |
13948 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13949 | |
d62a17ae | 13950 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13951 | style); | |
42f914d4 | 13952 | |
d62a17ae | 13953 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13954 | |
d62a17ae | 13955 | if (ret < 0) { |
13956 | /* Display error string. */ | |
13957 | community_list_perror(vty, ret); | |
13958 | return CMD_WARNING_CONFIG_FAILED; | |
13959 | } | |
42f914d4 | 13960 | |
d62a17ae | 13961 | return CMD_SUCCESS; |
718e3744 | 13962 | } |
13963 | ||
7336e101 SP |
13964 | #if CONFDATE > 20191005 |
13965 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
13966 | #endif | |
13967 | ALIAS (community_list_standard, | |
13968 | ip_community_list_standard_cmd, | |
13969 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 13970 | IP_STR |
13971 | COMMUNITY_LIST_STR | |
13972 | "Community list number (standard)\n" | |
5bf15956 DW |
13973 | "Add an standard community-list entry\n" |
13974 | "Community list name\n" | |
718e3744 | 13975 | "Specify community to reject\n" |
13976 | "Specify community to accept\n" | |
13977 | COMMUNITY_VAL_STR) | |
7336e101 SP |
13978 | |
13979 | DEFUN (no_community_list_standard_all, | |
13980 | no_bgp_community_list_standard_all_cmd, | |
13981 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
13982 | NO_STR | |
13983 | BGP_STR | |
13984 | COMMUNITY_LIST_STR | |
13985 | "Community list number (standard)\n" | |
13986 | "Add an standard community-list entry\n" | |
13987 | "Community list name\n" | |
13988 | "Specify community to reject\n" | |
13989 | "Specify community to accept\n" | |
13990 | COMMUNITY_VAL_STR) | |
718e3744 | 13991 | { |
d62a17ae | 13992 | char *cl_name_or_number = NULL; |
174b5cb9 | 13993 | char *str = NULL; |
d62a17ae | 13994 | int direct = 0; |
13995 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13996 | |
d62a17ae | 13997 | int idx = 0; |
7336e101 SP |
13998 | |
13999 | if (argv_find(argv, argc, "ip", &idx)) { | |
14000 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14001 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14002 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14003 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14004 | } | |
14005 | ||
174b5cb9 DA |
14006 | argv_find(argv, argc, "permit", &idx); |
14007 | argv_find(argv, argc, "deny", &idx); | |
14008 | ||
14009 | if (idx) { | |
14010 | direct = argv_find(argv, argc, "permit", &idx) | |
14011 | ? COMMUNITY_PERMIT | |
14012 | : COMMUNITY_DENY; | |
14013 | ||
14014 | idx = 0; | |
14015 | argv_find(argv, argc, "AA:NN", &idx); | |
14016 | str = argv_concat(argv, argc, idx); | |
14017 | } | |
14018 | ||
14019 | idx = 0; | |
d62a17ae | 14020 | argv_find(argv, argc, "(1-99)", &idx); |
14021 | argv_find(argv, argc, "WORD", &idx); | |
14022 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14023 | |
d62a17ae | 14024 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14025 | direct, style); |
42f914d4 | 14026 | |
d62a17ae | 14027 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14028 | |
d62a17ae | 14029 | if (ret < 0) { |
14030 | community_list_perror(vty, ret); | |
14031 | return CMD_WARNING_CONFIG_FAILED; | |
14032 | } | |
42f914d4 | 14033 | |
d62a17ae | 14034 | return CMD_SUCCESS; |
718e3744 | 14035 | } |
7336e101 SP |
14036 | ALIAS (no_community_list_standard_all, |
14037 | no_ip_community_list_standard_all_cmd, | |
14038 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14039 | NO_STR | |
718e3744 | 14040 | IP_STR |
14041 | COMMUNITY_LIST_STR | |
7336e101 SP |
14042 | "Community list number (standard)\n" |
14043 | "Add an standard community-list entry\n" | |
14044 | "Community list name\n" | |
14045 | "Specify community to reject\n" | |
14046 | "Specify community to accept\n" | |
14047 | COMMUNITY_VAL_STR) | |
14048 | ||
174b5cb9 DA |
14049 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14050 | "no bgp community-list <(1-99)|standard WORD>", | |
14051 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14052 | "Community list number (standard)\n" | |
14053 | "Add an standard community-list entry\n" | |
14054 | "Community list name\n") | |
14055 | ||
14056 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14057 | "no ip community-list <(1-99)|standard WORD>", | |
14058 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14059 | "Community list number (standard)\n" | |
14060 | "Add an standard community-list entry\n" | |
14061 | "Community list name\n") | |
14062 | ||
7336e101 SP |
14063 | /*community-list expanded */ |
14064 | DEFUN (community_list_expanded_all, | |
14065 | bgp_community_list_expanded_all_cmd, | |
14066 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14067 | BGP_STR | |
14068 | COMMUNITY_LIST_STR | |
718e3744 | 14069 | "Community list number (expanded)\n" |
5bf15956 | 14070 | "Add an expanded community-list entry\n" |
718e3744 | 14071 | "Community list name\n" |
14072 | "Specify community to reject\n" | |
14073 | "Specify community to accept\n" | |
14074 | COMMUNITY_VAL_STR) | |
14075 | { | |
d62a17ae | 14076 | char *cl_name_or_number = NULL; |
14077 | int direct = 0; | |
14078 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14079 | |
d62a17ae | 14080 | int idx = 0; |
7336e101 SP |
14081 | if (argv_find(argv, argc, "ip", &idx)) { |
14082 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14083 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14084 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14085 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14086 | } | |
d62a17ae | 14087 | argv_find(argv, argc, "(100-500)", &idx); |
14088 | argv_find(argv, argc, "WORD", &idx); | |
14089 | cl_name_or_number = argv[idx]->arg; | |
14090 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14091 | : COMMUNITY_DENY; | |
14092 | argv_find(argv, argc, "AA:NN", &idx); | |
14093 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14094 | |
d62a17ae | 14095 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14096 | style); | |
42f914d4 | 14097 | |
d62a17ae | 14098 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14099 | |
d62a17ae | 14100 | if (ret < 0) { |
14101 | /* Display error string. */ | |
14102 | community_list_perror(vty, ret); | |
14103 | return CMD_WARNING_CONFIG_FAILED; | |
14104 | } | |
42f914d4 | 14105 | |
d62a17ae | 14106 | return CMD_SUCCESS; |
718e3744 | 14107 | } |
14108 | ||
7336e101 SP |
14109 | ALIAS (community_list_expanded_all, |
14110 | ip_community_list_expanded_all_cmd, | |
14111 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14112 | IP_STR |
14113 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14114 | "Community list number (expanded)\n" |
14115 | "Add an expanded community-list entry\n" | |
718e3744 | 14116 | "Community list name\n" |
14117 | "Specify community to reject\n" | |
14118 | "Specify community to accept\n" | |
5bf15956 | 14119 | COMMUNITY_VAL_STR) |
7336e101 SP |
14120 | |
14121 | DEFUN (no_community_list_expanded_all, | |
14122 | no_bgp_community_list_expanded_all_cmd, | |
14123 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14124 | NO_STR | |
14125 | BGP_STR | |
14126 | COMMUNITY_LIST_STR | |
14127 | "Community list number (expanded)\n" | |
14128 | "Add an expanded community-list entry\n" | |
14129 | "Community list name\n" | |
14130 | "Specify community to reject\n" | |
14131 | "Specify community to accept\n" | |
14132 | COMMUNITY_VAL_STR) | |
718e3744 | 14133 | { |
d62a17ae | 14134 | char *cl_name_or_number = NULL; |
174b5cb9 | 14135 | char *str = NULL; |
d62a17ae | 14136 | int direct = 0; |
14137 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14138 | |
d62a17ae | 14139 | int idx = 0; |
7336e101 SP |
14140 | if (argv_find(argv, argc, "ip", &idx)) { |
14141 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14142 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14143 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14144 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14145 | } | |
14146 | ||
3c4b8fe2 | 14147 | idx = 0; |
174b5cb9 DA |
14148 | argv_find(argv, argc, "permit", &idx); |
14149 | argv_find(argv, argc, "deny", &idx); | |
14150 | ||
14151 | if (idx) { | |
14152 | direct = argv_find(argv, argc, "permit", &idx) | |
14153 | ? COMMUNITY_PERMIT | |
14154 | : COMMUNITY_DENY; | |
14155 | ||
14156 | idx = 0; | |
14157 | argv_find(argv, argc, "AA:NN", &idx); | |
14158 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14159 | } |
174b5cb9 DA |
14160 | |
14161 | idx = 0; | |
d62a17ae | 14162 | argv_find(argv, argc, "(100-500)", &idx); |
14163 | argv_find(argv, argc, "WORD", &idx); | |
14164 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14165 | |
d62a17ae | 14166 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14167 | direct, style); |
42f914d4 | 14168 | |
d62a17ae | 14169 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14170 | |
d62a17ae | 14171 | if (ret < 0) { |
14172 | community_list_perror(vty, ret); | |
14173 | return CMD_WARNING_CONFIG_FAILED; | |
14174 | } | |
42f914d4 | 14175 | |
d62a17ae | 14176 | return CMD_SUCCESS; |
718e3744 | 14177 | } |
14178 | ||
7336e101 SP |
14179 | ALIAS (no_community_list_expanded_all, |
14180 | no_ip_community_list_expanded_all_cmd, | |
14181 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14182 | NO_STR | |
14183 | IP_STR | |
14184 | COMMUNITY_LIST_STR | |
14185 | "Community list number (expanded)\n" | |
14186 | "Add an expanded community-list entry\n" | |
14187 | "Community list name\n" | |
14188 | "Specify community to reject\n" | |
14189 | "Specify community to accept\n" | |
14190 | COMMUNITY_VAL_STR) | |
14191 | ||
174b5cb9 DA |
14192 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14193 | "no bgp community-list <(100-500)|expanded WORD>", | |
14194 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14195 | "Community list number (expanded)\n" | |
14196 | "Add an expanded community-list entry\n" | |
14197 | "Community list name\n") | |
14198 | ||
14199 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14200 | "no ip community-list <(100-500)|expanded WORD>", | |
14201 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14202 | "Community list number (expanded)\n" | |
14203 | "Add an expanded community-list entry\n" | |
14204 | "Community list name\n") | |
14205 | ||
8d9b8ed9 PM |
14206 | /* Return configuration string of community-list entry. */ |
14207 | static const char *community_list_config_str(struct community_entry *entry) | |
14208 | { | |
14209 | const char *str; | |
14210 | ||
14211 | if (entry->any) | |
14212 | str = ""; | |
14213 | else { | |
14214 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14215 | str = community_str(entry->u.com, false); | |
14216 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14217 | str = lcommunity_str(entry->u.lcom, false); | |
14218 | else | |
14219 | str = entry->config; | |
14220 | } | |
14221 | return str; | |
14222 | } | |
14223 | ||
d62a17ae | 14224 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14225 | { |
d62a17ae | 14226 | struct community_entry *entry; |
718e3744 | 14227 | |
d62a17ae | 14228 | for (entry = list->head; entry; entry = entry->next) { |
14229 | if (entry == list->head) { | |
14230 | if (all_digit(list->name)) | |
14231 | vty_out(vty, "Community %s list %s\n", | |
14232 | entry->style == COMMUNITY_LIST_STANDARD | |
14233 | ? "standard" | |
14234 | : "(expanded) access", | |
14235 | list->name); | |
14236 | else | |
14237 | vty_out(vty, "Named Community %s list %s\n", | |
14238 | entry->style == COMMUNITY_LIST_STANDARD | |
14239 | ? "standard" | |
14240 | : "expanded", | |
14241 | list->name); | |
14242 | } | |
14243 | if (entry->any) | |
14244 | vty_out(vty, " %s\n", | |
14245 | community_direct_str(entry->direct)); | |
14246 | else | |
14247 | vty_out(vty, " %s %s\n", | |
14248 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14249 | community_list_config_str(entry)); |
d62a17ae | 14250 | } |
718e3744 | 14251 | } |
14252 | ||
7336e101 SP |
14253 | DEFUN (show_community_list, |
14254 | show_bgp_community_list_cmd, | |
14255 | "show bgp community-list", | |
718e3744 | 14256 | SHOW_STR |
7336e101 | 14257 | BGP_STR |
718e3744 | 14258 | "List community-list\n") |
14259 | { | |
d62a17ae | 14260 | struct community_list *list; |
14261 | struct community_list_master *cm; | |
718e3744 | 14262 | |
7336e101 SP |
14263 | int idx = 0; |
14264 | if (argv_find(argv, argc, "ip", &idx)) { | |
14265 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14266 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14267 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14268 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14269 | } | |
d62a17ae | 14270 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14271 | if (!cm) | |
14272 | return CMD_SUCCESS; | |
718e3744 | 14273 | |
d62a17ae | 14274 | for (list = cm->num.head; list; list = list->next) |
14275 | community_list_show(vty, list); | |
718e3744 | 14276 | |
d62a17ae | 14277 | for (list = cm->str.head; list; list = list->next) |
14278 | community_list_show(vty, list); | |
718e3744 | 14279 | |
d62a17ae | 14280 | return CMD_SUCCESS; |
718e3744 | 14281 | } |
14282 | ||
7336e101 SP |
14283 | ALIAS (show_community_list, |
14284 | show_ip_community_list_cmd, | |
14285 | "show ip community-list", | |
718e3744 | 14286 | SHOW_STR |
14287 | IP_STR | |
7336e101 SP |
14288 | "List community-list\n") |
14289 | ||
14290 | DEFUN (show_community_list_arg, | |
14291 | show_bgp_community_list_arg_cmd, | |
14292 | "show bgp community-list <(1-500)|WORD>", | |
14293 | SHOW_STR | |
14294 | BGP_STR | |
718e3744 | 14295 | "List community-list\n" |
14296 | "Community-list number\n" | |
14297 | "Community-list name\n") | |
14298 | { | |
d62a17ae | 14299 | int idx_comm_list = 3; |
14300 | struct community_list *list; | |
718e3744 | 14301 | |
7336e101 SP |
14302 | int idx = 0; |
14303 | if (argv_find(argv, argc, "ip", &idx)) { | |
14304 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14305 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14306 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14307 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14308 | } | |
d62a17ae | 14309 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
14310 | COMMUNITY_LIST_MASTER); | |
14311 | if (!list) { | |
14312 | vty_out(vty, "%% Can't find community-list\n"); | |
14313 | return CMD_WARNING; | |
14314 | } | |
718e3744 | 14315 | |
d62a17ae | 14316 | community_list_show(vty, list); |
718e3744 | 14317 | |
d62a17ae | 14318 | return CMD_SUCCESS; |
718e3744 | 14319 | } |
6b0655a2 | 14320 | |
7336e101 SP |
14321 | ALIAS (show_community_list_arg, |
14322 | show_ip_community_list_arg_cmd, | |
14323 | "show ip community-list <(1-500)|WORD>", | |
14324 | SHOW_STR | |
14325 | IP_STR | |
14326 | "List community-list\n" | |
14327 | "Community-list number\n" | |
14328 | "Community-list name\n") | |
14329 | ||
57d187bc JS |
14330 | /* |
14331 | * Large Community code. | |
14332 | */ | |
d62a17ae | 14333 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14334 | struct cmd_token **argv, int style, | |
14335 | int reject_all_digit_name) | |
14336 | { | |
14337 | int ret; | |
14338 | int direct; | |
14339 | char *str; | |
14340 | int idx = 0; | |
14341 | char *cl_name; | |
14342 | ||
7336e101 SP |
14343 | if (argv_find(argv, argc, "ip", &idx)) { |
14344 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14345 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14346 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14347 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14348 | } | |
d62a17ae | 14349 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14350 | : COMMUNITY_DENY; | |
14351 | ||
14352 | /* All digit name check. */ | |
14353 | idx = 0; | |
14354 | argv_find(argv, argc, "WORD", &idx); | |
14355 | argv_find(argv, argc, "(1-99)", &idx); | |
14356 | argv_find(argv, argc, "(100-500)", &idx); | |
14357 | cl_name = argv[idx]->arg; | |
14358 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14359 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14360 | return CMD_WARNING_CONFIG_FAILED; | |
14361 | } | |
14362 | ||
14363 | idx = 0; | |
14364 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14365 | argv_find(argv, argc, "LINE", &idx); | |
14366 | /* Concat community string argument. */ | |
14367 | if (idx) | |
14368 | str = argv_concat(argv, argc, idx); | |
14369 | else | |
14370 | str = NULL; | |
14371 | ||
14372 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14373 | ||
14374 | /* Free temporary community list string allocated by | |
14375 | argv_concat(). */ | |
14376 | if (str) | |
14377 | XFREE(MTYPE_TMP, str); | |
14378 | ||
14379 | if (ret < 0) { | |
14380 | community_list_perror(vty, ret); | |
14381 | return CMD_WARNING_CONFIG_FAILED; | |
14382 | } | |
14383 | return CMD_SUCCESS; | |
14384 | } | |
14385 | ||
14386 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14387 | struct cmd_token **argv, int style) | |
14388 | { | |
14389 | int ret; | |
14390 | int direct = 0; | |
14391 | char *str = NULL; | |
14392 | int idx = 0; | |
14393 | ||
7336e101 SP |
14394 | if (argv_find(argv, argc, "ip", &idx)) { |
14395 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14396 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14397 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14398 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14399 | } | |
d62a17ae | 14400 | argv_find(argv, argc, "permit", &idx); |
14401 | argv_find(argv, argc, "deny", &idx); | |
14402 | ||
14403 | if (idx) { | |
14404 | /* Check the list direct. */ | |
14405 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14406 | direct = COMMUNITY_PERMIT; | |
14407 | else | |
14408 | direct = COMMUNITY_DENY; | |
14409 | ||
14410 | idx = 0; | |
14411 | argv_find(argv, argc, "LINE", &idx); | |
14412 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14413 | /* Concat community string argument. */ | |
14414 | str = argv_concat(argv, argc, idx); | |
14415 | } | |
14416 | ||
14417 | idx = 0; | |
14418 | argv_find(argv, argc, "(1-99)", &idx); | |
14419 | argv_find(argv, argc, "(100-500)", &idx); | |
14420 | argv_find(argv, argc, "WORD", &idx); | |
14421 | ||
14422 | /* Unset community list. */ | |
14423 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14424 | style); | |
14425 | ||
14426 | /* Free temporary community list string allocated by | |
14427 | argv_concat(). */ | |
14428 | if (str) | |
14429 | XFREE(MTYPE_TMP, str); | |
14430 | ||
14431 | if (ret < 0) { | |
14432 | community_list_perror(vty, ret); | |
14433 | return CMD_WARNING_CONFIG_FAILED; | |
14434 | } | |
14435 | ||
14436 | return CMD_SUCCESS; | |
57d187bc JS |
14437 | } |
14438 | ||
14439 | /* "large-community-list" keyword help string. */ | |
14440 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14441 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14442 | ||
7336e101 SP |
14443 | #if CONFDATE > 20191005 |
14444 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14445 | #endif | |
14446 | DEFUN (lcommunity_list_standard, | |
14447 | bgp_lcommunity_list_standard_cmd, | |
14448 | "bgp large-community-list (1-99) <deny|permit>", | |
14449 | BGP_STR | |
14450 | LCOMMUNITY_LIST_STR | |
14451 | "Large Community list number (standard)\n" | |
14452 | "Specify large community to reject\n" | |
14453 | "Specify large community to accept\n") | |
14454 | { | |
14455 | return lcommunity_list_set_vty(vty, argc, argv, | |
14456 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14457 | } | |
14458 | ||
14459 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14460 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14461 | "ip large-community-list (1-99) <deny|permit>", |
14462 | IP_STR | |
14463 | LCOMMUNITY_LIST_STR | |
14464 | "Large Community list number (standard)\n" | |
14465 | "Specify large community to reject\n" | |
7111c1a0 | 14466 | "Specify large community to accept\n") |
7336e101 SP |
14467 | |
14468 | DEFUN (lcommunity_list_standard1, | |
14469 | bgp_lcommunity_list_standard1_cmd, | |
14470 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14471 | BGP_STR | |
14472 | LCOMMUNITY_LIST_STR | |
14473 | "Large Community list number (standard)\n" | |
14474 | "Specify large community to reject\n" | |
14475 | "Specify large community to accept\n" | |
14476 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14477 | { |
d62a17ae | 14478 | return lcommunity_list_set_vty(vty, argc, argv, |
14479 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14480 | } |
14481 | ||
7336e101 | 14482 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14483 | ip_lcommunity_list_standard1_cmd, |
14484 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14485 | IP_STR |
14486 | LCOMMUNITY_LIST_STR | |
14487 | "Large Community list number (standard)\n" | |
14488 | "Specify large community to reject\n" | |
14489 | "Specify large community to accept\n" | |
14490 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14491 | |
14492 | DEFUN (lcommunity_list_expanded, | |
14493 | bgp_lcommunity_list_expanded_cmd, | |
14494 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14495 | BGP_STR | |
14496 | LCOMMUNITY_LIST_STR | |
14497 | "Large Community list number (expanded)\n" | |
14498 | "Specify large community to reject\n" | |
14499 | "Specify large community to accept\n" | |
14500 | "An ordered list as a regular-expression\n") | |
57d187bc | 14501 | { |
d62a17ae | 14502 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14503 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14504 | } |
14505 | ||
7336e101 | 14506 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14507 | ip_lcommunity_list_expanded_cmd, |
14508 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14509 | IP_STR | |
14510 | LCOMMUNITY_LIST_STR | |
14511 | "Large Community list number (expanded)\n" | |
14512 | "Specify large community to reject\n" | |
14513 | "Specify large community to accept\n" | |
14514 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14515 | |
14516 | DEFUN (lcommunity_list_name_standard, | |
14517 | bgp_lcommunity_list_name_standard_cmd, | |
14518 | "bgp large-community-list standard WORD <deny|permit>", | |
14519 | BGP_STR | |
14520 | LCOMMUNITY_LIST_STR | |
14521 | "Specify standard large-community-list\n" | |
14522 | "Large Community list name\n" | |
14523 | "Specify large community to reject\n" | |
14524 | "Specify large community to accept\n") | |
57d187bc | 14525 | { |
d62a17ae | 14526 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14527 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14528 | } |
14529 | ||
7336e101 | 14530 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14531 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14532 | "ip large-community-list standard WORD <deny|permit>", |
14533 | IP_STR | |
14534 | LCOMMUNITY_LIST_STR | |
14535 | "Specify standard large-community-list\n" | |
14536 | "Large Community list name\n" | |
14537 | "Specify large community to reject\n" | |
14538 | "Specify large community to accept\n") | |
7336e101 SP |
14539 | |
14540 | DEFUN (lcommunity_list_name_standard1, | |
14541 | bgp_lcommunity_list_name_standard1_cmd, | |
14542 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14543 | BGP_STR | |
14544 | LCOMMUNITY_LIST_STR | |
14545 | "Specify standard large-community-list\n" | |
14546 | "Large Community list name\n" | |
14547 | "Specify large community to reject\n" | |
14548 | "Specify large community to accept\n" | |
14549 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14550 | { |
d62a17ae | 14551 | return lcommunity_list_set_vty(vty, argc, argv, |
14552 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14553 | } |
14554 | ||
7336e101 | 14555 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14556 | ip_lcommunity_list_name_standard1_cmd, |
14557 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14558 | IP_STR |
14559 | LCOMMUNITY_LIST_STR | |
14560 | "Specify standard large-community-list\n" | |
14561 | "Large Community list name\n" | |
14562 | "Specify large community to reject\n" | |
14563 | "Specify large community to accept\n" | |
14564 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14565 | |
14566 | DEFUN (lcommunity_list_name_expanded, | |
14567 | bgp_lcommunity_list_name_expanded_cmd, | |
14568 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14569 | BGP_STR | |
14570 | LCOMMUNITY_LIST_STR | |
14571 | "Specify expanded large-community-list\n" | |
14572 | "Large Community list name\n" | |
14573 | "Specify large community to reject\n" | |
14574 | "Specify large community to accept\n" | |
14575 | "An ordered list as a regular-expression\n") | |
57d187bc | 14576 | { |
d62a17ae | 14577 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14578 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14579 | } |
14580 | ||
7336e101 | 14581 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14582 | ip_lcommunity_list_name_expanded_cmd, |
14583 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14584 | IP_STR | |
14585 | LCOMMUNITY_LIST_STR | |
14586 | "Specify expanded large-community-list\n" | |
14587 | "Large Community list name\n" | |
14588 | "Specify large community to reject\n" | |
14589 | "Specify large community to accept\n" | |
14590 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14591 | |
14592 | DEFUN (no_lcommunity_list_standard_all, | |
14593 | no_bgp_lcommunity_list_standard_all_cmd, | |
14594 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14595 | NO_STR | |
14596 | BGP_STR | |
14597 | LCOMMUNITY_LIST_STR | |
14598 | "Large Community list number (standard)\n" | |
14599 | "Large Community list number (expanded)\n" | |
14600 | "Large Community list name\n") | |
57d187bc | 14601 | { |
7336e101 SP |
14602 | return lcommunity_list_unset_vty(vty, argc, argv, |
14603 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14604 | } |
14605 | ||
7336e101 | 14606 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14607 | no_ip_lcommunity_list_standard_all_cmd, |
14608 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14609 | NO_STR | |
14610 | IP_STR | |
14611 | LCOMMUNITY_LIST_STR | |
14612 | "Large Community list number (standard)\n" | |
14613 | "Large Community list number (expanded)\n" | |
14614 | "Large Community list name\n") | |
7336e101 SP |
14615 | |
14616 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14617 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14618 | "no bgp large-community-list expanded WORD", | |
14619 | NO_STR | |
14620 | BGP_STR | |
14621 | LCOMMUNITY_LIST_STR | |
14622 | "Specify expanded large-community-list\n" | |
14623 | "Large Community list name\n") | |
57d187bc | 14624 | { |
d62a17ae | 14625 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14626 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14627 | } |
14628 | ||
7336e101 | 14629 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14630 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14631 | "no ip large-community-list expanded WORD", | |
14632 | NO_STR | |
14633 | IP_STR | |
14634 | LCOMMUNITY_LIST_STR | |
14635 | "Specify expanded large-community-list\n" | |
14636 | "Large Community list name\n") | |
7336e101 SP |
14637 | |
14638 | DEFUN (no_lcommunity_list_standard, | |
14639 | no_bgp_lcommunity_list_standard_cmd, | |
14640 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14641 | NO_STR | |
14642 | BGP_STR | |
14643 | LCOMMUNITY_LIST_STR | |
14644 | "Large Community list number (standard)\n" | |
14645 | "Specify large community to reject\n" | |
14646 | "Specify large community to accept\n" | |
14647 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14648 | { |
d62a17ae | 14649 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14650 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14651 | } |
14652 | ||
7336e101 | 14653 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14654 | no_ip_lcommunity_list_standard_cmd, |
14655 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14656 | NO_STR | |
14657 | IP_STR | |
14658 | LCOMMUNITY_LIST_STR | |
14659 | "Large Community list number (standard)\n" | |
14660 | "Specify large community to reject\n" | |
14661 | "Specify large community to accept\n" | |
14662 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14663 | |
14664 | DEFUN (no_lcommunity_list_expanded, | |
14665 | no_bgp_lcommunity_list_expanded_cmd, | |
14666 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14667 | NO_STR | |
14668 | BGP_STR | |
14669 | LCOMMUNITY_LIST_STR | |
14670 | "Large Community list number (expanded)\n" | |
14671 | "Specify large community to reject\n" | |
14672 | "Specify large community to accept\n" | |
14673 | "An ordered list as a regular-expression\n") | |
57d187bc | 14674 | { |
d62a17ae | 14675 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14676 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14677 | } |
14678 | ||
7336e101 | 14679 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14680 | no_ip_lcommunity_list_expanded_cmd, |
14681 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14682 | NO_STR | |
14683 | IP_STR | |
14684 | LCOMMUNITY_LIST_STR | |
14685 | "Large Community list number (expanded)\n" | |
14686 | "Specify large community to reject\n" | |
14687 | "Specify large community to accept\n" | |
14688 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14689 | |
14690 | DEFUN (no_lcommunity_list_name_standard, | |
14691 | no_bgp_lcommunity_list_name_standard_cmd, | |
14692 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14693 | NO_STR | |
14694 | BGP_STR | |
14695 | LCOMMUNITY_LIST_STR | |
14696 | "Specify standard large-community-list\n" | |
14697 | "Large Community list name\n" | |
14698 | "Specify large community to reject\n" | |
14699 | "Specify large community to accept\n" | |
14700 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14701 | { |
d62a17ae | 14702 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14703 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14704 | } |
14705 | ||
7336e101 | 14706 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14707 | no_ip_lcommunity_list_name_standard_cmd, |
14708 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14709 | NO_STR | |
14710 | IP_STR | |
14711 | LCOMMUNITY_LIST_STR | |
14712 | "Specify standard large-community-list\n" | |
14713 | "Large Community list name\n" | |
14714 | "Specify large community to reject\n" | |
14715 | "Specify large community to accept\n" | |
14716 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14717 | |
14718 | DEFUN (no_lcommunity_list_name_expanded, | |
14719 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14720 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14721 | NO_STR | |
14722 | BGP_STR | |
14723 | LCOMMUNITY_LIST_STR | |
14724 | "Specify expanded large-community-list\n" | |
14725 | "Large community list name\n" | |
14726 | "Specify large community to reject\n" | |
14727 | "Specify large community to accept\n" | |
14728 | "An ordered list as a regular-expression\n") | |
57d187bc | 14729 | { |
d62a17ae | 14730 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14731 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14732 | } |
14733 | ||
7336e101 | 14734 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14735 | no_ip_lcommunity_list_name_expanded_cmd, |
14736 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14737 | NO_STR | |
14738 | IP_STR | |
14739 | LCOMMUNITY_LIST_STR | |
14740 | "Specify expanded large-community-list\n" | |
14741 | "Large community list name\n" | |
14742 | "Specify large community to reject\n" | |
14743 | "Specify large community to accept\n" | |
14744 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14745 | |
14746 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14747 | { | |
14748 | struct community_entry *entry; | |
14749 | ||
14750 | for (entry = list->head; entry; entry = entry->next) { | |
14751 | if (entry == list->head) { | |
14752 | if (all_digit(list->name)) | |
14753 | vty_out(vty, "Large community %s list %s\n", | |
14754 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14755 | ? "standard" | |
14756 | : "(expanded) access", | |
14757 | list->name); | |
14758 | else | |
14759 | vty_out(vty, | |
14760 | "Named large community %s list %s\n", | |
14761 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14762 | ? "standard" | |
14763 | : "expanded", | |
14764 | list->name); | |
14765 | } | |
14766 | if (entry->any) | |
14767 | vty_out(vty, " %s\n", | |
14768 | community_direct_str(entry->direct)); | |
14769 | else | |
14770 | vty_out(vty, " %s %s\n", | |
14771 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14772 | community_list_config_str(entry)); |
d62a17ae | 14773 | } |
57d187bc JS |
14774 | } |
14775 | ||
7336e101 SP |
14776 | DEFUN (show_lcommunity_list, |
14777 | show_bgp_lcommunity_list_cmd, | |
14778 | "show bgp large-community-list", | |
57d187bc | 14779 | SHOW_STR |
7336e101 | 14780 | BGP_STR |
57d187bc JS |
14781 | "List large-community list\n") |
14782 | { | |
d62a17ae | 14783 | struct community_list *list; |
14784 | struct community_list_master *cm; | |
7336e101 SP |
14785 | int idx = 0; |
14786 | ||
14787 | if (argv_find(argv, argc, "ip", &idx)) { | |
14788 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14789 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14790 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14791 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14792 | } | |
57d187bc | 14793 | |
d62a17ae | 14794 | cm = community_list_master_lookup(bgp_clist, |
14795 | LARGE_COMMUNITY_LIST_MASTER); | |
14796 | if (!cm) | |
14797 | return CMD_SUCCESS; | |
57d187bc | 14798 | |
d62a17ae | 14799 | for (list = cm->num.head; list; list = list->next) |
14800 | lcommunity_list_show(vty, list); | |
57d187bc | 14801 | |
d62a17ae | 14802 | for (list = cm->str.head; list; list = list->next) |
14803 | lcommunity_list_show(vty, list); | |
57d187bc | 14804 | |
d62a17ae | 14805 | return CMD_SUCCESS; |
57d187bc JS |
14806 | } |
14807 | ||
7336e101 SP |
14808 | ALIAS (show_lcommunity_list, |
14809 | show_ip_lcommunity_list_cmd, | |
14810 | "show ip large-community-list", | |
57d187bc JS |
14811 | SHOW_STR |
14812 | IP_STR | |
7336e101 SP |
14813 | "List large-community list\n") |
14814 | ||
14815 | DEFUN (show_lcommunity_list_arg, | |
14816 | show_bgp_lcommunity_list_arg_cmd, | |
14817 | "show bgp large-community-list <(1-500)|WORD>", | |
14818 | SHOW_STR | |
14819 | BGP_STR | |
57d187bc JS |
14820 | "List large-community list\n" |
14821 | "large-community-list number\n" | |
14822 | "large-community-list name\n") | |
14823 | { | |
d62a17ae | 14824 | struct community_list *list; |
7336e101 SP |
14825 | int idx = 0; |
14826 | ||
14827 | if (argv_find(argv, argc, "ip", &idx)) { | |
14828 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14829 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14830 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14831 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14832 | } | |
57d187bc | 14833 | |
d62a17ae | 14834 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
14835 | LARGE_COMMUNITY_LIST_MASTER); | |
14836 | if (!list) { | |
14837 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14838 | return CMD_WARNING; | |
14839 | } | |
57d187bc | 14840 | |
d62a17ae | 14841 | lcommunity_list_show(vty, list); |
57d187bc | 14842 | |
d62a17ae | 14843 | return CMD_SUCCESS; |
57d187bc JS |
14844 | } |
14845 | ||
7336e101 SP |
14846 | ALIAS (show_lcommunity_list_arg, |
14847 | show_ip_lcommunity_list_arg_cmd, | |
14848 | "show ip large-community-list <(1-500)|WORD>", | |
14849 | SHOW_STR | |
14850 | IP_STR | |
14851 | "List large-community list\n" | |
14852 | "large-community-list number\n" | |
14853 | "large-community-list name\n") | |
14854 | ||
718e3744 | 14855 | /* "extcommunity-list" keyword help string. */ |
14856 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14857 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14858 | ||
7336e101 SP |
14859 | DEFUN (extcommunity_list_standard, |
14860 | bgp_extcommunity_list_standard_cmd, | |
14861 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14862 | BGP_STR | |
718e3744 | 14863 | EXTCOMMUNITY_LIST_STR |
14864 | "Extended Community list number (standard)\n" | |
718e3744 | 14865 | "Specify standard extcommunity-list\n" |
5bf15956 | 14866 | "Community list name\n" |
718e3744 | 14867 | "Specify community to reject\n" |
14868 | "Specify community to accept\n" | |
14869 | EXTCOMMUNITY_VAL_STR) | |
14870 | { | |
d62a17ae | 14871 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14872 | int direct = 0; | |
14873 | char *cl_number_or_name = NULL; | |
42f914d4 | 14874 | |
d62a17ae | 14875 | int idx = 0; |
7336e101 SP |
14876 | if (argv_find(argv, argc, "ip", &idx)) { |
14877 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14878 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14879 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
14880 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
14881 | } | |
d62a17ae | 14882 | argv_find(argv, argc, "(1-99)", &idx); |
14883 | argv_find(argv, argc, "WORD", &idx); | |
14884 | cl_number_or_name = argv[idx]->arg; | |
14885 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14886 | : COMMUNITY_DENY; | |
14887 | argv_find(argv, argc, "AA:NN", &idx); | |
14888 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14889 | |
d62a17ae | 14890 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14891 | direct, style); | |
42f914d4 | 14892 | |
d62a17ae | 14893 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14894 | |
d62a17ae | 14895 | if (ret < 0) { |
14896 | community_list_perror(vty, ret); | |
14897 | return CMD_WARNING_CONFIG_FAILED; | |
14898 | } | |
42f914d4 | 14899 | |
d62a17ae | 14900 | return CMD_SUCCESS; |
718e3744 | 14901 | } |
14902 | ||
7336e101 SP |
14903 | #if CONFDATE > 20191005 |
14904 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
14905 | #endif | |
14906 | ALIAS (extcommunity_list_standard, | |
14907 | ip_extcommunity_list_standard_cmd, | |
14908 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14909 | IP_STR |
14910 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
14911 | "Extended Community list number (standard)\n" |
14912 | "Specify standard extcommunity-list\n" | |
14913 | "Community list name\n" | |
14914 | "Specify community to reject\n" | |
14915 | "Specify community to accept\n" | |
14916 | EXTCOMMUNITY_VAL_STR) | |
14917 | ||
14918 | DEFUN (extcommunity_list_name_expanded, | |
14919 | bgp_extcommunity_list_name_expanded_cmd, | |
14920 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
14921 | BGP_STR | |
14922 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14923 | "Extended Community list number (expanded)\n" |
718e3744 | 14924 | "Specify expanded extcommunity-list\n" |
14925 | "Extended Community list name\n" | |
14926 | "Specify community to reject\n" | |
14927 | "Specify community to accept\n" | |
14928 | "An ordered list as a regular-expression\n") | |
14929 | { | |
d62a17ae | 14930 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14931 | int direct = 0; | |
14932 | char *cl_number_or_name = NULL; | |
42f914d4 | 14933 | |
d62a17ae | 14934 | int idx = 0; |
7336e101 SP |
14935 | if (argv_find(argv, argc, "ip", &idx)) { |
14936 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14937 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14938 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
14939 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
14940 | } | |
14941 | ||
d62a17ae | 14942 | argv_find(argv, argc, "(100-500)", &idx); |
14943 | argv_find(argv, argc, "WORD", &idx); | |
14944 | cl_number_or_name = argv[idx]->arg; | |
14945 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14946 | : COMMUNITY_DENY; | |
14947 | argv_find(argv, argc, "LINE", &idx); | |
14948 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14949 | |
d62a17ae | 14950 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14951 | direct, style); | |
42f914d4 | 14952 | |
d62a17ae | 14953 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14954 | |
d62a17ae | 14955 | if (ret < 0) { |
14956 | community_list_perror(vty, ret); | |
14957 | return CMD_WARNING_CONFIG_FAILED; | |
14958 | } | |
42f914d4 | 14959 | |
d62a17ae | 14960 | return CMD_SUCCESS; |
718e3744 | 14961 | } |
14962 | ||
7336e101 SP |
14963 | ALIAS (extcommunity_list_name_expanded, |
14964 | ip_extcommunity_list_name_expanded_cmd, | |
14965 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
14966 | IP_STR |
14967 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
14968 | "Extended Community list number (expanded)\n" |
14969 | "Specify expanded extcommunity-list\n" | |
14970 | "Extended Community list name\n" | |
14971 | "Specify community to reject\n" | |
14972 | "Specify community to accept\n" | |
14973 | "An ordered list as a regular-expression\n") | |
14974 | ||
14975 | DEFUN (no_extcommunity_list_standard_all, | |
14976 | no_bgp_extcommunity_list_standard_all_cmd, | |
14977 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14978 | NO_STR | |
14979 | BGP_STR | |
14980 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 14981 | "Extended Community list number (standard)\n" |
718e3744 | 14982 | "Specify standard extcommunity-list\n" |
5bf15956 | 14983 | "Community list name\n" |
718e3744 | 14984 | "Specify community to reject\n" |
14985 | "Specify community to accept\n" | |
14986 | EXTCOMMUNITY_VAL_STR) | |
14987 | { | |
d62a17ae | 14988 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14989 | int direct = 0; | |
14990 | char *cl_number_or_name = NULL; | |
42f914d4 | 14991 | |
d62a17ae | 14992 | int idx = 0; |
7336e101 SP |
14993 | if (argv_find(argv, argc, "ip", &idx)) { |
14994 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14995 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14996 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
14997 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
14998 | } | |
d62a17ae | 14999 | argv_find(argv, argc, "(1-99)", &idx); |
15000 | argv_find(argv, argc, "WORD", &idx); | |
15001 | cl_number_or_name = argv[idx]->arg; | |
15002 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15003 | : COMMUNITY_DENY; | |
15004 | argv_find(argv, argc, "AA:NN", &idx); | |
15005 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15006 | |
d62a17ae | 15007 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15008 | direct, style); |
42f914d4 | 15009 | |
d62a17ae | 15010 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15011 | |
d62a17ae | 15012 | if (ret < 0) { |
15013 | community_list_perror(vty, ret); | |
15014 | return CMD_WARNING_CONFIG_FAILED; | |
15015 | } | |
42f914d4 | 15016 | |
d62a17ae | 15017 | return CMD_SUCCESS; |
718e3744 | 15018 | } |
15019 | ||
7336e101 SP |
15020 | ALIAS (no_extcommunity_list_standard_all, |
15021 | no_ip_extcommunity_list_standard_all_cmd, | |
15022 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15023 | NO_STR |
15024 | IP_STR | |
15025 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15026 | "Extended Community list number (standard)\n" |
15027 | "Specify standard extcommunity-list\n" | |
15028 | "Community list name\n" | |
15029 | "Specify community to reject\n" | |
15030 | "Specify community to accept\n" | |
15031 | EXTCOMMUNITY_VAL_STR) | |
15032 | ||
15033 | DEFUN (no_extcommunity_list_expanded_all, | |
15034 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15035 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15036 | NO_STR | |
15037 | BGP_STR | |
15038 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15039 | "Extended Community list number (expanded)\n" |
718e3744 | 15040 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15041 | "Extended Community list name\n" |
718e3744 | 15042 | "Specify community to reject\n" |
15043 | "Specify community to accept\n" | |
15044 | "An ordered list as a regular-expression\n") | |
15045 | { | |
d62a17ae | 15046 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15047 | int direct = 0; | |
15048 | char *cl_number_or_name = NULL; | |
42f914d4 | 15049 | |
d62a17ae | 15050 | int idx = 0; |
7336e101 SP |
15051 | if (argv_find(argv, argc, "ip", &idx)) { |
15052 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15053 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15054 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15055 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15056 | } | |
d62a17ae | 15057 | argv_find(argv, argc, "(100-500)", &idx); |
15058 | argv_find(argv, argc, "WORD", &idx); | |
15059 | cl_number_or_name = argv[idx]->arg; | |
15060 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15061 | : COMMUNITY_DENY; | |
15062 | argv_find(argv, argc, "LINE", &idx); | |
15063 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15064 | |
d62a17ae | 15065 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15066 | direct, style); |
42f914d4 | 15067 | |
d62a17ae | 15068 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15069 | |
d62a17ae | 15070 | if (ret < 0) { |
15071 | community_list_perror(vty, ret); | |
15072 | return CMD_WARNING_CONFIG_FAILED; | |
15073 | } | |
42f914d4 | 15074 | |
d62a17ae | 15075 | return CMD_SUCCESS; |
718e3744 | 15076 | } |
15077 | ||
7336e101 SP |
15078 | ALIAS (no_extcommunity_list_expanded_all, |
15079 | no_ip_extcommunity_list_expanded_all_cmd, | |
15080 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15081 | NO_STR | |
15082 | IP_STR | |
15083 | EXTCOMMUNITY_LIST_STR | |
15084 | "Extended Community list number (expanded)\n" | |
15085 | "Specify expanded extcommunity-list\n" | |
15086 | "Extended Community list name\n" | |
15087 | "Specify community to reject\n" | |
15088 | "Specify community to accept\n" | |
15089 | "An ordered list as a regular-expression\n") | |
15090 | ||
d62a17ae | 15091 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15092 | { |
d62a17ae | 15093 | struct community_entry *entry; |
718e3744 | 15094 | |
d62a17ae | 15095 | for (entry = list->head; entry; entry = entry->next) { |
15096 | if (entry == list->head) { | |
15097 | if (all_digit(list->name)) | |
15098 | vty_out(vty, "Extended community %s list %s\n", | |
15099 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15100 | ? "standard" | |
15101 | : "(expanded) access", | |
15102 | list->name); | |
15103 | else | |
15104 | vty_out(vty, | |
15105 | "Named extended community %s list %s\n", | |
15106 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15107 | ? "standard" | |
15108 | : "expanded", | |
15109 | list->name); | |
15110 | } | |
15111 | if (entry->any) | |
15112 | vty_out(vty, " %s\n", | |
15113 | community_direct_str(entry->direct)); | |
15114 | else | |
15115 | vty_out(vty, " %s %s\n", | |
15116 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15117 | community_list_config_str(entry)); |
d62a17ae | 15118 | } |
718e3744 | 15119 | } |
15120 | ||
7336e101 SP |
15121 | DEFUN (show_extcommunity_list, |
15122 | show_bgp_extcommunity_list_cmd, | |
15123 | "show bgp extcommunity-list", | |
718e3744 | 15124 | SHOW_STR |
7336e101 | 15125 | BGP_STR |
718e3744 | 15126 | "List extended-community list\n") |
15127 | { | |
d62a17ae | 15128 | struct community_list *list; |
15129 | struct community_list_master *cm; | |
7336e101 | 15130 | int idx = 0; |
718e3744 | 15131 | |
7336e101 SP |
15132 | if (argv_find(argv, argc, "ip", &idx)) { |
15133 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15134 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15135 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15136 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15137 | } | |
d62a17ae | 15138 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15139 | if (!cm) | |
15140 | return CMD_SUCCESS; | |
718e3744 | 15141 | |
d62a17ae | 15142 | for (list = cm->num.head; list; list = list->next) |
15143 | extcommunity_list_show(vty, list); | |
718e3744 | 15144 | |
d62a17ae | 15145 | for (list = cm->str.head; list; list = list->next) |
15146 | extcommunity_list_show(vty, list); | |
718e3744 | 15147 | |
d62a17ae | 15148 | return CMD_SUCCESS; |
718e3744 | 15149 | } |
15150 | ||
7336e101 SP |
15151 | ALIAS (show_extcommunity_list, |
15152 | show_ip_extcommunity_list_cmd, | |
15153 | "show ip extcommunity-list", | |
718e3744 | 15154 | SHOW_STR |
15155 | IP_STR | |
7336e101 SP |
15156 | "List extended-community list\n") |
15157 | ||
15158 | DEFUN (show_extcommunity_list_arg, | |
15159 | show_bgp_extcommunity_list_arg_cmd, | |
15160 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15161 | SHOW_STR | |
15162 | BGP_STR | |
718e3744 | 15163 | "List extended-community list\n" |
15164 | "Extcommunity-list number\n" | |
15165 | "Extcommunity-list name\n") | |
15166 | { | |
d62a17ae | 15167 | int idx_comm_list = 3; |
15168 | struct community_list *list; | |
7336e101 | 15169 | int idx = 0; |
718e3744 | 15170 | |
7336e101 SP |
15171 | if (argv_find(argv, argc, "ip", &idx)) { |
15172 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15173 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15174 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15175 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15176 | } | |
d62a17ae | 15177 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
15178 | EXTCOMMUNITY_LIST_MASTER); | |
15179 | if (!list) { | |
15180 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15181 | return CMD_WARNING; | |
15182 | } | |
718e3744 | 15183 | |
d62a17ae | 15184 | extcommunity_list_show(vty, list); |
718e3744 | 15185 | |
d62a17ae | 15186 | return CMD_SUCCESS; |
718e3744 | 15187 | } |
6b0655a2 | 15188 | |
7336e101 SP |
15189 | ALIAS (show_extcommunity_list_arg, |
15190 | show_ip_extcommunity_list_arg_cmd, | |
15191 | "show ip extcommunity-list <(1-500)|WORD>", | |
15192 | SHOW_STR | |
15193 | IP_STR | |
15194 | "List extended-community list\n" | |
15195 | "Extcommunity-list number\n" | |
15196 | "Extcommunity-list name\n") | |
15197 | ||
718e3744 | 15198 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15199 | static int community_list_config_write(struct vty *vty) |
15200 | { | |
15201 | struct community_list *list; | |
15202 | struct community_entry *entry; | |
15203 | struct community_list_master *cm; | |
15204 | int write = 0; | |
15205 | ||
15206 | /* Community-list. */ | |
15207 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15208 | ||
15209 | for (list = cm->num.head; list; list = list->next) | |
15210 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15211 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15212 | community_direct_str(entry->direct), |
15213 | community_list_config_str(entry)); | |
15214 | write++; | |
15215 | } | |
15216 | for (list = cm->str.head; list; list = list->next) | |
15217 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15218 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15219 | entry->style == COMMUNITY_LIST_STANDARD |
15220 | ? "standard" | |
15221 | : "expanded", | |
15222 | list->name, community_direct_str(entry->direct), | |
15223 | community_list_config_str(entry)); | |
15224 | write++; | |
15225 | } | |
15226 | ||
15227 | /* Extcommunity-list. */ | |
15228 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15229 | ||
15230 | for (list = cm->num.head; list; list = list->next) | |
15231 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15232 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15233 | list->name, community_direct_str(entry->direct), |
15234 | community_list_config_str(entry)); | |
15235 | write++; | |
15236 | } | |
15237 | for (list = cm->str.head; list; list = list->next) | |
15238 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15239 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15240 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15241 | ? "standard" | |
15242 | : "expanded", | |
15243 | list->name, community_direct_str(entry->direct), | |
15244 | community_list_config_str(entry)); | |
15245 | write++; | |
15246 | } | |
15247 | ||
15248 | ||
15249 | /* lcommunity-list. */ | |
15250 | cm = community_list_master_lookup(bgp_clist, | |
15251 | LARGE_COMMUNITY_LIST_MASTER); | |
15252 | ||
15253 | for (list = cm->num.head; list; list = list->next) | |
15254 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15255 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15256 | list->name, community_direct_str(entry->direct), |
15257 | community_list_config_str(entry)); | |
15258 | write++; | |
15259 | } | |
15260 | for (list = cm->str.head; list; list = list->next) | |
15261 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15262 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15263 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15264 | ? "standard" | |
15265 | : "expanded", | |
15266 | list->name, community_direct_str(entry->direct), | |
15267 | community_list_config_str(entry)); | |
15268 | write++; | |
15269 | } | |
15270 | ||
15271 | return write; | |
15272 | } | |
15273 | ||
15274 | static struct cmd_node community_list_node = { | |
15275 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15276 | }; |
15277 | ||
d62a17ae | 15278 | static void community_list_vty(void) |
15279 | { | |
15280 | install_node(&community_list_node, community_list_config_write); | |
15281 | ||
15282 | /* Community-list. */ | |
7336e101 SP |
15283 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15284 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15285 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15286 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15287 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15288 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15289 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15290 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15291 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15292 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15293 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15294 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15295 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15296 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15297 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15298 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15299 | ||
15300 | /* Extcommunity-list. */ | |
7336e101 SP |
15301 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15302 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15303 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
15304 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); | |
15305 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); | |
15306 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15307 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15308 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15309 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
15310 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
15311 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
15312 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15313 | ||
15314 | /* Large Community List */ | |
7336e101 SP |
15315 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15316 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15317 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15318 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15319 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15320 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15321 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15322 | install_element(CONFIG_NODE, | |
15323 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15324 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15325 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15326 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15327 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15328 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15329 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15330 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15331 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15332 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15333 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15334 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15335 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15336 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15337 | install_element(CONFIG_NODE, | |
15338 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15339 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15340 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15341 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15342 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15343 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15344 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15345 | } |