]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
2 | Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
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" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
718e3744 | 48 | #include "bgpd/bgp_mplsvpn.h" |
4bf6a362 | 49 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 50 | #include "bgpd/bgp_open.h" |
4bf6a362 | 51 | #include "bgpd/bgp_regex.h" |
718e3744 | 52 | #include "bgpd/bgp_route.h" |
53 | #include "bgpd/bgp_zebra.h" | |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
718e3744 | 60 | |
20eb8864 | 61 | static struct peer_group * |
62 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); | |
63 | ||
718e3744 | 64 | /* Utility function to get address family from current node. */ |
65 | afi_t | |
66 | bgp_node_afi (struct vty *vty) | |
67 | { | |
4e851f1f LB |
68 | afi_t afi; |
69 | switch (vty->node) | |
70 | { | |
71 | case BGP_IPV6_NODE: | |
72 | case BGP_IPV6M_NODE: | |
73 | case BGP_VPNV6_NODE: | |
74 | case BGP_ENCAPV6_NODE: | |
75 | afi = AFI_IP6; | |
76 | break; | |
77 | default: | |
78 | afi = AFI_IP; | |
79 | break; | |
80 | } | |
81 | return afi; | |
718e3744 | 82 | } |
83 | ||
84 | /* Utility function to get subsequent address family from current | |
85 | node. */ | |
86 | safi_t | |
87 | bgp_node_safi (struct vty *vty) | |
88 | { | |
4e851f1f LB |
89 | safi_t safi; |
90 | switch (vty->node) | |
91 | { | |
92 | case BGP_ENCAP_NODE: | |
93 | case BGP_ENCAPV6_NODE: | |
94 | safi = SAFI_ENCAP; | |
95 | break; | |
96 | case BGP_VPNV4_NODE: | |
97 | case BGP_VPNV6_NODE: | |
98 | safi = SAFI_MPLS_VPN; | |
99 | break; | |
100 | case BGP_IPV4M_NODE: | |
101 | case BGP_IPV6M_NODE: | |
102 | safi = SAFI_MULTICAST; | |
103 | break; | |
104 | default: | |
105 | safi = SAFI_UNICAST; | |
106 | break; | |
107 | } | |
108 | return safi; | |
718e3744 | 109 | } |
110 | ||
46f296b4 LB |
111 | /* supports <ipv4|ipv6> */ |
112 | afi_t | |
113 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 114 | { |
46f296b4 LB |
115 | afi_t afi = AFI_MAX; /* unknown */ |
116 | if (!strcmp(afi_str, "ipv4")) { | |
117 | afi = AFI_IP; | |
8b1fb8be | 118 | } |
46f296b4 LB |
119 | else if (!strcmp(afi_str, "ipv6")) { |
120 | afi = AFI_IP6; | |
121 | } | |
46f296b4 LB |
122 | return afi; |
123 | } | |
124 | ||
125 | int | |
126 | bgp_parse_afi(const char *str, afi_t *afi) | |
127 | { | |
128 | *afi = bgp_vty_afi_from_arg(str); | |
129 | if (*afi != AFI_MAX) | |
130 | return 0; | |
131 | else | |
8b1fb8be LB |
132 | return -1; |
133 | } | |
134 | ||
46f296b4 LB |
135 | int |
136 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
137 | { | |
138 | int ret = 0; | |
139 | if (argv_find (argv, argc, "ipv4", index)) | |
140 | { | |
141 | ret = 1; | |
142 | if (afi) | |
143 | *afi = AFI_IP; | |
144 | } | |
145 | else if (argv_find (argv, argc, "ipv6", index)) | |
146 | { | |
147 | ret = 1; | |
148 | if (afi) | |
149 | *afi = AFI_IP6; | |
150 | } | |
151 | return ret; | |
152 | } | |
153 | ||
154 | /* supports <unicast|multicast|vpn|encap> */ | |
ccbb332a | 155 | safi_t |
3b14d86e | 156 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
157 | { |
158 | safi_t safi = SAFI_MAX; /* unknown */ | |
159 | if (strncmp (safi_str, "m", 1) == 0) | |
160 | safi = SAFI_MULTICAST; | |
161 | else if (strncmp (safi_str, "u", 1) == 0) | |
162 | safi = SAFI_UNICAST; | |
163 | else if (strncmp (safi_str, "e", 1) == 0) | |
164 | safi = SAFI_ENCAP; | |
165 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 166 | safi = SAFI_MPLS_VPN; |
ccbb332a LB |
167 | return safi; |
168 | } | |
169 | ||
8b1fb8be LB |
170 | int |
171 | bgp_parse_safi(const char *str, safi_t *safi) | |
172 | { | |
ccbb332a LB |
173 | *safi = bgp_vty_safi_from_arg(str); |
174 | if (*safi != SAFI_MAX) | |
175 | return 0; | |
3b14d86e | 176 | else |
8b1fb8be LB |
177 | return -1; |
178 | } | |
179 | ||
46f296b4 LB |
180 | int |
181 | argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t *safi) | |
182 | { | |
183 | int ret = 0; | |
184 | if (argv_find (argv, argc, "unicast", index)) | |
185 | { | |
186 | ret = 1; | |
187 | if (safi) | |
188 | *safi = SAFI_UNICAST; | |
189 | } | |
190 | else if (argv_find (argv, argc, "multicast", index)) | |
191 | { | |
192 | ret = 1; | |
193 | if (safi) | |
194 | *safi = SAFI_MULTICAST; | |
195 | } | |
196 | else if (argv_find (argv, argc, "vpn", index)) | |
197 | { | |
198 | ret = 1; | |
199 | if (safi) | |
200 | *safi = SAFI_MPLS_VPN; | |
201 | } | |
202 | else if (argv_find (argv, argc, "encap", index)) | |
203 | { | |
204 | ret = 1; | |
205 | if (safi) | |
206 | *safi = SAFI_ENCAP; | |
207 | } | |
208 | return ret; | |
209 | } | |
210 | ||
94f2b392 | 211 | static int |
6aeb9e78 | 212 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 213 | { |
214 | struct interface *ifp = NULL; | |
215 | ||
216 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 217 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 218 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 219 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 220 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 221 | |
222 | if (ifp) | |
223 | return 1; | |
224 | ||
225 | return 0; | |
226 | } | |
227 | ||
228 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
229 | /* This is used only for configuration, so disallow if attempted on |
230 | * a dynamic neighbor. | |
231 | */ | |
94f2b392 | 232 | static struct peer * |
fd79ac91 | 233 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 234 | { |
cdc2d765 | 235 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 236 | int ret; |
718e3744 | 237 | union sockunion su; |
238 | struct peer *peer; | |
239 | ||
cdc2d765 DL |
240 | if (!bgp) { |
241 | return NULL; | |
242 | } | |
718e3744 | 243 | |
244 | ret = str2sockunion (ip_str, &su); | |
245 | if (ret < 0) | |
246 | { | |
a80beece DS |
247 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
248 | if (!peer) | |
249 | { | |
04b6bdc0 DW |
250 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
251 | { | |
252 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
253 | return NULL; | |
254 | } | |
a80beece | 255 | } |
718e3744 | 256 | } |
a80beece | 257 | else |
718e3744 | 258 | { |
a80beece DS |
259 | peer = peer_lookup (bgp, &su); |
260 | if (! peer) | |
261 | { | |
262 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
263 | VTY_NEWLINE); | |
264 | return NULL; | |
265 | } | |
f14e6fdb DS |
266 | if (peer_dynamic_neighbor (peer)) |
267 | { | |
268 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
269 | VTY_NEWLINE); | |
270 | return NULL; | |
271 | } | |
272 | ||
718e3744 | 273 | } |
274 | return peer; | |
275 | } | |
276 | ||
277 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
278 | /* This is used only for configuration, so disallow if attempted on |
279 | * a dynamic neighbor. | |
280 | */ | |
c43ed2e4 | 281 | struct peer * |
fd79ac91 | 282 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 283 | { |
cdc2d765 | 284 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 285 | int ret; |
718e3744 | 286 | union sockunion su; |
f14e6fdb DS |
287 | struct peer *peer = NULL; |
288 | struct peer_group *group = NULL; | |
718e3744 | 289 | |
cdc2d765 DL |
290 | if (!bgp) { |
291 | return NULL; | |
292 | } | |
718e3744 | 293 | |
294 | ret = str2sockunion (peer_str, &su); | |
295 | if (ret == 0) | |
296 | { | |
f14e6fdb | 297 | /* IP address, locate peer. */ |
718e3744 | 298 | peer = peer_lookup (bgp, &su); |
718e3744 | 299 | } |
300 | else | |
301 | { | |
f14e6fdb | 302 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 303 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
304 | if (!peer) |
305 | group = peer_group_lookup (bgp, peer_str); | |
306 | } | |
a80beece | 307 | |
f14e6fdb DS |
308 | if (peer) |
309 | { | |
310 | if (peer_dynamic_neighbor (peer)) | |
311 | { | |
312 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
313 | VTY_NEWLINE); | |
314 | return NULL; | |
315 | } | |
316 | ||
317 | return peer; | |
718e3744 | 318 | } |
319 | ||
f14e6fdb DS |
320 | if (group) |
321 | return group->conf; | |
322 | ||
718e3744 | 323 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
324 | VTY_NEWLINE); | |
325 | ||
326 | return NULL; | |
327 | } | |
328 | ||
c43ed2e4 | 329 | int |
718e3744 | 330 | bgp_vty_return (struct vty *vty, int ret) |
331 | { | |
fd79ac91 | 332 | const char *str = NULL; |
718e3744 | 333 | |
334 | switch (ret) | |
335 | { | |
336 | case BGP_ERR_INVALID_VALUE: | |
337 | str = "Invalid value"; | |
338 | break; | |
339 | case BGP_ERR_INVALID_FLAG: | |
340 | str = "Invalid flag"; | |
341 | break; | |
718e3744 | 342 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
343 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
344 | break; | |
718e3744 | 345 | case BGP_ERR_PEER_FLAG_CONFLICT: |
346 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
347 | break; | |
718e3744 | 348 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
349 | str = "Specify remote-as or peer-group remote AS first"; | |
350 | break; | |
351 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
352 | str = "Cannot change the peer-group. Deconfigure first"; | |
353 | break; | |
354 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 355 | str = "Peer is not a member of this peer-group"; |
718e3744 | 356 | break; |
357 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
358 | str = "Prefix/distribute list can not co-exist"; | |
359 | break; | |
360 | case BGP_ERR_NOT_INTERNAL_PEER: | |
361 | str = "Invalid command. Not an internal neighbor"; | |
362 | break; | |
363 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 364 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 365 | break; |
366 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
367 | str = "Local-AS allowed only for EBGP peers"; | |
368 | break; | |
369 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
370 | str = "Cannot have local-as same as BGP AS number"; | |
371 | break; | |
0df7c91f PJ |
372 | case BGP_ERR_TCPSIG_FAILED: |
373 | str = "Error while applying TCP-Sig to session(s)"; | |
374 | break; | |
fa411a21 NH |
375 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
376 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
377 | break; | |
f5a4827d SH |
378 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
379 | str = "ttl-security only allowed for EBGP peers"; | |
380 | break; | |
c7122e14 DS |
381 | case BGP_ERR_AS_OVERRIDE: |
382 | str = "as-override cannot be configured for IBGP peers"; | |
383 | break; | |
f14e6fdb DS |
384 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
385 | str = "Invalid limit for number of dynamic neighbors"; | |
386 | break; | |
387 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
388 | str = "Dynamic neighbor listen range already exists"; | |
389 | break; | |
390 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
391 | str = "Operation not allowed on a dynamic neighbor"; | |
392 | break; | |
63fa10b5 QY |
393 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
394 | str = "Operation not allowed on a directly connected neighbor"; | |
395 | break; | |
718e3744 | 396 | } |
397 | if (str) | |
398 | { | |
399 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
400 | return CMD_WARNING; | |
401 | } | |
402 | return CMD_SUCCESS; | |
403 | } | |
404 | ||
7aafcaca DS |
405 | /* BGP clear sort. */ |
406 | enum clear_sort | |
407 | { | |
408 | clear_all, | |
409 | clear_peer, | |
410 | clear_group, | |
411 | clear_external, | |
412 | clear_as | |
413 | }; | |
414 | ||
7aafcaca DS |
415 | static void |
416 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
417 | safi_t safi, int error) | |
418 | { | |
419 | switch (error) | |
420 | { | |
421 | case BGP_ERR_AF_UNCONFIGURED: | |
422 | vty_out (vty, | |
46f296b4 LB |
423 | "%%BGP: Enable %s address family for the neighbor %s%s", |
424 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
425 | break; |
426 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
427 | vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE); | |
428 | break; | |
429 | default: | |
430 | break; | |
431 | } | |
432 | } | |
433 | ||
434 | /* `clear ip bgp' functions. */ | |
435 | static int | |
436 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
437 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
438 | { | |
439 | int ret; | |
440 | struct peer *peer; | |
441 | struct listnode *node, *nnode; | |
442 | ||
443 | /* Clear all neighbors. */ | |
444 | /* | |
445 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
446 | * on the BGP instance as that may get freed if it is a doppelganger | |
447 | */ | |
448 | if (sort == clear_all) | |
449 | { | |
450 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
451 | { | |
452 | if (stype == BGP_CLEAR_SOFT_NONE) | |
453 | ret = peer_clear (peer, &nnode); | |
454 | else if (peer->afc[afi][safi]) | |
455 | ret = peer_clear_soft (peer, afi, safi, stype); | |
456 | else | |
457 | ret = 0; | |
458 | ||
459 | if (ret < 0) | |
460 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
461 | } | |
462 | ||
463 | /* This is to apply read-only mode on this clear. */ | |
464 | if (stype == BGP_CLEAR_SOFT_NONE) | |
465 | bgp->update_delay_over = 0; | |
466 | ||
467 | return CMD_SUCCESS; | |
468 | } | |
469 | ||
470 | /* Clear specified neighbors. */ | |
471 | if (sort == clear_peer) | |
472 | { | |
473 | union sockunion su; | |
474 | int ret; | |
475 | ||
476 | /* Make sockunion for lookup. */ | |
477 | ret = str2sockunion (arg, &su); | |
478 | if (ret < 0) | |
479 | { | |
480 | peer = peer_lookup_by_conf_if (bgp, arg); | |
481 | if (!peer) | |
482 | { | |
04b6bdc0 DW |
483 | peer = peer_lookup_by_hostname(bgp, arg); |
484 | if (!peer) | |
485 | { | |
486 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
487 | return CMD_WARNING; | |
488 | } | |
7aafcaca DS |
489 | } |
490 | } | |
491 | else | |
492 | { | |
493 | peer = peer_lookup (bgp, &su); | |
494 | if (! peer) | |
495 | { | |
496 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
497 | return CMD_WARNING; | |
498 | } | |
499 | } | |
500 | ||
501 | if (stype == BGP_CLEAR_SOFT_NONE) | |
502 | ret = peer_clear (peer, NULL); | |
503 | else | |
504 | ret = peer_clear_soft (peer, afi, safi, stype); | |
505 | ||
506 | if (ret < 0) | |
507 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
508 | ||
509 | return CMD_SUCCESS; | |
510 | } | |
511 | ||
512 | /* Clear all peer-group members. */ | |
513 | if (sort == clear_group) | |
514 | { | |
515 | struct peer_group *group; | |
516 | ||
517 | group = peer_group_lookup (bgp, arg); | |
518 | if (! group) | |
519 | { | |
520 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
521 | return CMD_WARNING; | |
522 | } | |
523 | ||
524 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
525 | { | |
526 | if (stype == BGP_CLEAR_SOFT_NONE) | |
527 | { | |
18f1dc06 | 528 | peer_clear (peer, NULL); |
7aafcaca DS |
529 | continue; |
530 | } | |
531 | ||
c8560b44 | 532 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
533 | continue; |
534 | ||
535 | ret = peer_clear_soft (peer, afi, safi, stype); | |
536 | ||
537 | if (ret < 0) | |
538 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
539 | } | |
540 | return CMD_SUCCESS; | |
541 | } | |
542 | ||
543 | if (sort == clear_external) | |
544 | { | |
545 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
546 | { | |
547 | if (peer->sort == BGP_PEER_IBGP) | |
548 | continue; | |
549 | ||
550 | if (stype == BGP_CLEAR_SOFT_NONE) | |
551 | ret = peer_clear (peer, &nnode); | |
552 | else | |
553 | ret = peer_clear_soft (peer, afi, safi, stype); | |
554 | ||
555 | if (ret < 0) | |
556 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
557 | } | |
558 | return CMD_SUCCESS; | |
559 | } | |
560 | ||
561 | if (sort == clear_as) | |
562 | { | |
563 | as_t as; | |
564 | int find = 0; | |
565 | ||
566 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
567 | ||
568 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
569 | { | |
570 | if (peer->as != as) | |
571 | continue; | |
572 | ||
573 | find = 1; | |
574 | if (stype == BGP_CLEAR_SOFT_NONE) | |
575 | ret = peer_clear (peer, &nnode); | |
576 | else | |
577 | ret = peer_clear_soft (peer, afi, safi, stype); | |
578 | ||
579 | if (ret < 0) | |
580 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
581 | } | |
582 | if (! find) | |
583 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
584 | VTY_NEWLINE); | |
585 | return CMD_SUCCESS; | |
586 | } | |
587 | ||
588 | return CMD_SUCCESS; | |
589 | } | |
590 | ||
591 | static int | |
592 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
593 | enum clear_sort sort, enum bgp_clear_type stype, | |
594 | const char *arg) | |
595 | { | |
596 | struct bgp *bgp; | |
597 | ||
598 | /* BGP structure lookup. */ | |
599 | if (name) | |
600 | { | |
601 | bgp = bgp_lookup_by_name (name); | |
602 | if (bgp == NULL) | |
603 | { | |
6aeb9e78 | 604 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
605 | return CMD_WARNING; |
606 | } | |
607 | } | |
608 | else | |
609 | { | |
f31fa004 | 610 | bgp = bgp_get_default (); |
7aafcaca DS |
611 | if (bgp == NULL) |
612 | { | |
613 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
614 | return CMD_WARNING; | |
615 | } | |
616 | } | |
617 | ||
618 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
619 | } | |
620 | ||
621 | /* clear soft inbound */ | |
622 | static void | |
f31fa004 | 623 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 624 | { |
b09b5ae0 | 625 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 626 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 627 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 628 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
629 | } |
630 | ||
631 | /* clear soft outbound */ | |
632 | static void | |
f31fa004 | 633 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 634 | { |
f31fa004 | 635 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 636 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 637 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 638 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
639 | } |
640 | ||
641 | ||
718e3744 | 642 | /* BGP global configuration. */ |
643 | ||
644 | DEFUN (bgp_multiple_instance_func, | |
645 | bgp_multiple_instance_cmd, | |
646 | "bgp multiple-instance", | |
647 | BGP_STR | |
648 | "Enable bgp multiple instance\n") | |
649 | { | |
650 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
651 | return CMD_SUCCESS; | |
652 | } | |
653 | ||
654 | DEFUN (no_bgp_multiple_instance, | |
655 | no_bgp_multiple_instance_cmd, | |
656 | "no bgp multiple-instance", | |
657 | NO_STR | |
658 | BGP_STR | |
659 | "BGP multiple instance\n") | |
660 | { | |
661 | int ret; | |
662 | ||
663 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
664 | if (ret < 0) | |
665 | { | |
666 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
667 | return CMD_WARNING; | |
668 | } | |
669 | return CMD_SUCCESS; | |
670 | } | |
671 | ||
672 | DEFUN (bgp_config_type, | |
673 | bgp_config_type_cmd, | |
6147e2c6 | 674 | "bgp config-type <cisco|zebra>", |
718e3744 | 675 | BGP_STR |
676 | "Configuration type\n" | |
677 | "cisco\n" | |
678 | "zebra\n") | |
679 | { | |
c500ae40 DW |
680 | int idx_vendor = 2; |
681 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 682 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
683 | else | |
684 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
685 | ||
686 | return CMD_SUCCESS; | |
687 | } | |
688 | ||
689 | DEFUN (no_bgp_config_type, | |
690 | no_bgp_config_type_cmd, | |
c7178fe7 | 691 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 692 | NO_STR |
693 | BGP_STR | |
838758ac DW |
694 | "Display configuration type\n" |
695 | "cisco\n" | |
696 | "zebra\n") | |
718e3744 | 697 | { |
698 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
699 | return CMD_SUCCESS; | |
700 | } | |
701 | ||
813d4307 | 702 | |
718e3744 | 703 | DEFUN (no_synchronization, |
704 | no_synchronization_cmd, | |
705 | "no synchronization", | |
706 | NO_STR | |
707 | "Perform IGP synchronization\n") | |
708 | { | |
709 | return CMD_SUCCESS; | |
710 | } | |
711 | ||
712 | DEFUN (no_auto_summary, | |
713 | no_auto_summary_cmd, | |
714 | "no auto-summary", | |
715 | NO_STR | |
716 | "Enable automatic network number summarization\n") | |
717 | { | |
718 | return CMD_SUCCESS; | |
719 | } | |
3d515fd9 | 720 | |
718e3744 | 721 | /* "router bgp" commands. */ |
f412b39a DW |
722 | DEFUN (router_bgp, |
723 | router_bgp_cmd, | |
31500417 | 724 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 725 | ROUTER_STR |
726 | BGP_STR | |
31500417 DW |
727 | AS_STR |
728 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 729 | { |
31500417 DW |
730 | int idx_asn = 2; |
731 | int idx_view_vrf = 3; | |
732 | int idx_vrf = 4; | |
718e3744 | 733 | int ret; |
734 | as_t as; | |
735 | struct bgp *bgp; | |
fd79ac91 | 736 | const char *name = NULL; |
ad4cbda1 | 737 | enum bgp_instance_type inst_type; |
718e3744 | 738 | |
2385a876 | 739 | // "router bgp" without an ASN |
31500417 | 740 | if (argc == 2) |
2385a876 | 741 | { |
6aeb9e78 | 742 | //Pending: Make VRF option available for ASN less config |
2385a876 | 743 | bgp = bgp_get_default(); |
718e3744 | 744 | |
2385a876 DW |
745 | if (bgp == NULL) |
746 | { | |
747 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
748 | return CMD_WARNING; | |
749 | } | |
718e3744 | 750 | |
2385a876 DW |
751 | if (listcount(bm->bgp) > 1) |
752 | { | |
753 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
754 | return CMD_WARNING; | |
755 | } | |
756 | } | |
757 | ||
758 | // "router bgp X" | |
759 | else | |
718e3744 | 760 | { |
31500417 | 761 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 762 | |
ad4cbda1 | 763 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 764 | if (argc > 3) |
ad4cbda1 | 765 | { |
31500417 DW |
766 | name = argv[idx_vrf]->arg; |
767 | ||
e52702f2 | 768 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 769 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 770 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 771 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
772 | } | |
2385a876 | 773 | |
ad4cbda1 | 774 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
775 | switch (ret) |
776 | { | |
777 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
778 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
779 | VTY_NEWLINE); | |
780 | return CMD_WARNING; | |
781 | case BGP_ERR_AS_MISMATCH: | |
782 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
783 | return CMD_WARNING; | |
784 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 785 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
786 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
787 | as, VTY_NEWLINE); | |
788 | return CMD_WARNING; | |
789 | } | |
6aeb9e78 DS |
790 | |
791 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 792 | } |
793 | ||
cdc2d765 | 794 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 795 | |
796 | return CMD_SUCCESS; | |
797 | } | |
798 | ||
718e3744 | 799 | /* "no router bgp" commands. */ |
800 | DEFUN (no_router_bgp, | |
801 | no_router_bgp_cmd, | |
31500417 | 802 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 803 | NO_STR |
804 | ROUTER_STR | |
805 | BGP_STR | |
31500417 DW |
806 | AS_STR |
807 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 808 | { |
31500417 | 809 | int idx_asn = 3; |
31500417 | 810 | int idx_vrf = 5; |
718e3744 | 811 | as_t as; |
812 | struct bgp *bgp; | |
fd79ac91 | 813 | const char *name = NULL; |
718e3744 | 814 | |
7fb21a9f | 815 | // "no router bgp" without an ASN |
31500417 | 816 | if (argc == 3) |
7fb21a9f QY |
817 | { |
818 | //Pending: Make VRF option available for ASN less config | |
819 | bgp = bgp_get_default(); | |
718e3744 | 820 | |
7fb21a9f QY |
821 | if (bgp == NULL) |
822 | { | |
823 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
824 | return CMD_WARNING; | |
825 | } | |
826 | ||
827 | if (listcount(bm->bgp) > 1) | |
828 | { | |
829 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
830 | return CMD_WARNING; | |
831 | } | |
832 | } | |
833 | else | |
718e3744 | 834 | { |
31500417 | 835 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 836 | |
31500417 DW |
837 | if (argc > 4) |
838 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
839 | |
840 | /* Lookup bgp structure. */ | |
841 | bgp = bgp_lookup (as, name); | |
842 | if (! bgp) | |
843 | { | |
844 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
845 | return CMD_WARNING; | |
846 | } | |
718e3744 | 847 | } |
848 | ||
849 | bgp_delete (bgp); | |
850 | ||
851 | return CMD_SUCCESS; | |
852 | } | |
853 | ||
6b0655a2 | 854 | |
7fb21a9f | 855 | |
718e3744 | 856 | /* BGP router-id. */ |
857 | ||
858 | DEFUN (bgp_router_id, | |
859 | bgp_router_id_cmd, | |
860 | "bgp router-id A.B.C.D", | |
861 | BGP_STR | |
862 | "Override configured router identifier\n" | |
863 | "Manually configured router identifier\n") | |
864 | { | |
cdc2d765 | 865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 866 | int idx_ipv4 = 2; |
718e3744 | 867 | int ret; |
868 | struct in_addr id; | |
718e3744 | 869 | |
c500ae40 | 870 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 871 | if (! ret) |
872 | { | |
873 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
874 | return CMD_WARNING; | |
875 | } | |
876 | ||
0e6cb743 | 877 | bgp_router_id_static_set (bgp, id); |
718e3744 | 878 | |
879 | return CMD_SUCCESS; | |
880 | } | |
881 | ||
882 | DEFUN (no_bgp_router_id, | |
883 | no_bgp_router_id_cmd, | |
31500417 | 884 | "no bgp router-id [A.B.C.D]", |
718e3744 | 885 | NO_STR |
886 | BGP_STR | |
31500417 DW |
887 | "Override configured router identifier\n" |
888 | "Manually configured router identifier\n") | |
718e3744 | 889 | { |
cdc2d765 | 890 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 891 | int idx_router_id = 3; |
718e3744 | 892 | int ret; |
893 | struct in_addr id; | |
718e3744 | 894 | |
31500417 | 895 | if (argc > idx_router_id) |
718e3744 | 896 | { |
31500417 | 897 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 898 | if (! ret) |
e018c7cc SK |
899 | { |
900 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
901 | return CMD_WARNING; | |
902 | } | |
718e3744 | 903 | |
18a6dce6 | 904 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
905 | { |
906 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
907 | return CMD_WARNING; | |
908 | } | |
718e3744 | 909 | } |
910 | ||
0e6cb743 DL |
911 | id.s_addr = 0; |
912 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 913 | |
914 | return CMD_SUCCESS; | |
915 | } | |
916 | ||
6b0655a2 | 917 | |
718e3744 | 918 | /* BGP Cluster ID. */ |
718e3744 | 919 | DEFUN (bgp_cluster_id, |
920 | bgp_cluster_id_cmd, | |
838758ac | 921 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 922 | BGP_STR |
923 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
924 | "Route-Reflector Cluster-id in IP address format\n" |
925 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 926 | { |
cdc2d765 | 927 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 928 | int idx_ipv4 = 2; |
718e3744 | 929 | int ret; |
718e3744 | 930 | struct in_addr cluster; |
931 | ||
c500ae40 | 932 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 933 | if (! ret) |
934 | { | |
935 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
936 | return CMD_WARNING; | |
937 | } | |
938 | ||
939 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 940 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 941 | |
942 | return CMD_SUCCESS; | |
943 | } | |
944 | ||
718e3744 | 945 | DEFUN (no_bgp_cluster_id, |
946 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 947 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 948 | NO_STR |
949 | BGP_STR | |
838758ac DW |
950 | "Configure Route-Reflector Cluster-id\n" |
951 | "Route-Reflector Cluster-id in IP address format\n" | |
952 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 953 | { |
cdc2d765 | 954 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 955 | bgp_cluster_id_unset (bgp); |
f31fa004 | 956 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 957 | |
958 | return CMD_SUCCESS; | |
959 | } | |
960 | ||
718e3744 | 961 | DEFUN (bgp_confederation_identifier, |
962 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 963 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 964 | "BGP specific commands\n" |
965 | "AS confederation parameters\n" | |
966 | "AS number\n" | |
967 | "Set routing domain confederation AS\n") | |
968 | { | |
cdc2d765 | 969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 970 | int idx_number = 3; |
718e3744 | 971 | as_t as; |
972 | ||
c500ae40 | 973 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 974 | |
975 | bgp_confederation_id_set (bgp, as); | |
976 | ||
977 | return CMD_SUCCESS; | |
978 | } | |
979 | ||
980 | DEFUN (no_bgp_confederation_identifier, | |
981 | no_bgp_confederation_identifier_cmd, | |
838758ac | 982 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 983 | NO_STR |
984 | "BGP specific commands\n" | |
985 | "AS confederation parameters\n" | |
3a2d747c QY |
986 | "AS number\n" |
987 | "Set routing domain confederation AS\n") | |
718e3744 | 988 | { |
cdc2d765 | 989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 990 | bgp_confederation_id_unset (bgp); |
991 | ||
992 | return CMD_SUCCESS; | |
993 | } | |
994 | ||
718e3744 | 995 | DEFUN (bgp_confederation_peers, |
996 | bgp_confederation_peers_cmd, | |
12dcf78e | 997 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 998 | "BGP specific commands\n" |
999 | "AS confederation parameters\n" | |
1000 | "Peer ASs in BGP confederation\n" | |
1001 | AS_STR) | |
1002 | { | |
cdc2d765 | 1003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1004 | int idx_asn = 3; |
718e3744 | 1005 | as_t as; |
1006 | int i; | |
1007 | ||
58749582 | 1008 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1009 | { |
afec25d9 | 1010 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1011 | |
1012 | if (bgp->as == as) | |
1013 | { | |
1014 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1015 | VTY_NEWLINE); | |
1016 | continue; | |
1017 | } | |
1018 | ||
1019 | bgp_confederation_peers_add (bgp, as); | |
1020 | } | |
1021 | return CMD_SUCCESS; | |
1022 | } | |
1023 | ||
1024 | DEFUN (no_bgp_confederation_peers, | |
1025 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1026 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1027 | NO_STR |
1028 | "BGP specific commands\n" | |
1029 | "AS confederation parameters\n" | |
1030 | "Peer ASs in BGP confederation\n" | |
1031 | AS_STR) | |
1032 | { | |
cdc2d765 | 1033 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1034 | int idx_asn = 4; |
718e3744 | 1035 | as_t as; |
1036 | int i; | |
1037 | ||
58749582 | 1038 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1039 | { |
afec25d9 | 1040 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1041 | |
718e3744 | 1042 | bgp_confederation_peers_remove (bgp, as); |
1043 | } | |
1044 | return CMD_SUCCESS; | |
1045 | } | |
6b0655a2 | 1046 | |
5e242b0d DS |
1047 | /** |
1048 | * Central routine for maximum-paths configuration. | |
1049 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1050 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1051 | */ | |
ffd0c037 DS |
1052 | static int |
1053 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1054 | u_int16_t options, int set) |
165b5fff | 1055 | { |
cdc2d765 | 1056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1057 | u_int16_t maxpaths = 0; |
165b5fff | 1058 | int ret; |
5e242b0d DS |
1059 | afi_t afi; |
1060 | safi_t safi; | |
165b5fff | 1061 | |
5e242b0d DS |
1062 | afi = bgp_node_afi (vty); |
1063 | safi = bgp_node_safi (vty); | |
165b5fff | 1064 | |
5e242b0d | 1065 | if (set) |
4c9dee98 | 1066 | { |
c59f2066 | 1067 | maxpaths = strtol(mpaths, NULL, 10); |
dff6764a | 1068 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1069 | } |
5e242b0d DS |
1070 | else |
1071 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1072 | |
165b5fff JB |
1073 | if (ret < 0) |
1074 | { | |
1075 | vty_out (vty, | |
5e242b0d DS |
1076 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1077 | (set == 1) ? "" : "un", | |
1078 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1079 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1080 | return CMD_WARNING; |
1081 | } | |
1082 | ||
7aafcaca DS |
1083 | bgp_recalculate_all_bestpaths (bgp); |
1084 | ||
165b5fff JB |
1085 | return CMD_SUCCESS; |
1086 | } | |
1087 | ||
abc920f8 DS |
1088 | DEFUN (bgp_maxmed_admin, |
1089 | bgp_maxmed_admin_cmd, | |
1090 | "bgp max-med administrative ", | |
1091 | BGP_STR | |
1092 | "Advertise routes with max-med\n" | |
1093 | "Administratively applied, for an indefinite period\n") | |
1094 | { | |
cdc2d765 | 1095 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1096 | |
1097 | bgp->v_maxmed_admin = 1; | |
1098 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1099 | ||
1100 | bgp_maxmed_update(bgp); | |
1101 | ||
1102 | return CMD_SUCCESS; | |
1103 | } | |
1104 | ||
1105 | DEFUN (bgp_maxmed_admin_medv, | |
1106 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1107 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1108 | BGP_STR |
1109 | "Advertise routes with max-med\n" | |
1110 | "Administratively applied, for an indefinite period\n" | |
1111 | "Max MED value to be used\n") | |
1112 | { | |
cdc2d765 | 1113 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1114 | int idx_number = 3; |
abc920f8 DS |
1115 | |
1116 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1117 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1118 | |
1119 | bgp_maxmed_update(bgp); | |
1120 | ||
1121 | return CMD_SUCCESS; | |
1122 | } | |
1123 | ||
1124 | DEFUN (no_bgp_maxmed_admin, | |
1125 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1126 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1127 | NO_STR |
1128 | BGP_STR | |
1129 | "Advertise routes with max-med\n" | |
838758ac DW |
1130 | "Administratively applied, for an indefinite period\n" |
1131 | "Max MED value to be used\n") | |
abc920f8 | 1132 | { |
cdc2d765 | 1133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1134 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1135 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1136 | bgp_maxmed_update(bgp); |
1137 | ||
1138 | return CMD_SUCCESS; | |
1139 | } | |
1140 | ||
abc920f8 DS |
1141 | DEFUN (bgp_maxmed_onstartup, |
1142 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1143 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1144 | BGP_STR |
1145 | "Advertise routes with max-med\n" | |
1146 | "Effective on a startup\n" | |
1147 | "Time (seconds) period for max-med\n") | |
1148 | { | |
cdc2d765 | 1149 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1150 | int idx_number = 3; |
c500ae40 | 1151 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1152 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1153 | bgp_maxmed_update(bgp); |
1154 | ||
1155 | return CMD_SUCCESS; | |
1156 | } | |
1157 | ||
1158 | DEFUN (bgp_maxmed_onstartup_medv, | |
1159 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1160 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1161 | BGP_STR |
1162 | "Advertise routes with max-med\n" | |
1163 | "Effective on a startup\n" | |
1164 | "Time (seconds) period for max-med\n" | |
1165 | "Max MED value to be used\n") | |
1166 | { | |
cdc2d765 | 1167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1168 | int idx_number = 3; |
1169 | int idx_number_2 = 4; | |
c500ae40 DW |
1170 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1171 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1172 | bgp_maxmed_update(bgp); |
1173 | ||
1174 | return CMD_SUCCESS; | |
1175 | } | |
1176 | ||
1177 | DEFUN (no_bgp_maxmed_onstartup, | |
1178 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1179 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1180 | NO_STR |
1181 | BGP_STR | |
1182 | "Advertise routes with max-med\n" | |
838758ac DW |
1183 | "Effective on a startup\n" |
1184 | "Time (seconds) period for max-med\n" | |
1185 | "Max MED value to be used\n") | |
abc920f8 | 1186 | { |
cdc2d765 | 1187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1188 | |
1189 | /* Cancel max-med onstartup if its on */ | |
1190 | if (bgp->t_maxmed_onstartup) | |
1191 | { | |
1192 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1193 | bgp->maxmed_onstartup_over = 1; | |
1194 | } | |
1195 | ||
1196 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1197 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1198 | ||
1199 | bgp_maxmed_update(bgp); | |
1200 | ||
1201 | return CMD_SUCCESS; | |
1202 | } | |
1203 | ||
f188f2c4 DS |
1204 | static int |
1205 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1206 | const char *wait) | |
1207 | { | |
cdc2d765 | 1208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1209 | u_int16_t update_delay; |
1210 | u_int16_t establish_wait; | |
1211 | ||
f188f2c4 DS |
1212 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1213 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1214 | ||
1215 | if (!wait) /* update-delay <delay> */ | |
1216 | { | |
1217 | bgp->v_update_delay = update_delay; | |
1218 | bgp->v_establish_wait = bgp->v_update_delay; | |
1219 | return CMD_SUCCESS; | |
1220 | } | |
1221 | ||
1222 | /* update-delay <delay> <establish-wait> */ | |
1223 | establish_wait = atoi (wait); | |
1224 | if (update_delay < establish_wait) | |
1225 | { | |
1226 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1227 | VTY_NEWLINE); | |
1228 | return CMD_WARNING; | |
1229 | } | |
1230 | ||
1231 | bgp->v_update_delay = update_delay; | |
1232 | bgp->v_establish_wait = establish_wait; | |
1233 | ||
1234 | return CMD_SUCCESS; | |
1235 | } | |
1236 | ||
1237 | static int | |
1238 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1239 | { | |
cdc2d765 | 1240 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1241 | |
1242 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1243 | bgp->v_establish_wait = bgp->v_update_delay; | |
1244 | ||
1245 | return CMD_SUCCESS; | |
1246 | } | |
1247 | ||
1248 | int | |
1249 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1250 | { | |
1251 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1252 | { | |
1253 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1254 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1255 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1256 | vty_out (vty, "%s", VTY_NEWLINE); | |
1257 | } | |
1258 | ||
1259 | return 0; | |
1260 | } | |
1261 | ||
1262 | ||
1263 | /* Update-delay configuration */ | |
1264 | DEFUN (bgp_update_delay, | |
1265 | bgp_update_delay_cmd, | |
6147e2c6 | 1266 | "update-delay (0-3600)", |
f188f2c4 DS |
1267 | "Force initial delay for best-path and updates\n" |
1268 | "Seconds\n") | |
1269 | { | |
c500ae40 DW |
1270 | int idx_number = 1; |
1271 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1272 | } |
1273 | ||
1274 | DEFUN (bgp_update_delay_establish_wait, | |
1275 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1276 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1277 | "Force initial delay for best-path and updates\n" |
1278 | "Seconds\n" | |
1279 | "Wait for peers to be established\n" | |
1280 | "Seconds\n") | |
1281 | { | |
c500ae40 DW |
1282 | int idx_number = 1; |
1283 | int idx_number_2 = 2; | |
1284 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1285 | } |
1286 | ||
1287 | /* Update-delay deconfiguration */ | |
1288 | DEFUN (no_bgp_update_delay, | |
1289 | no_bgp_update_delay_cmd, | |
838758ac DW |
1290 | "no update-delay [(0-3600) [(1-3600)]]", |
1291 | NO_STR | |
f188f2c4 | 1292 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1293 | "Seconds\n" |
1294 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1295 | { |
1296 | return bgp_update_delay_deconfig_vty(vty); | |
1297 | } | |
1298 | ||
5e242b0d | 1299 | |
ffd0c037 DS |
1300 | static int |
1301 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1302 | { |
cdc2d765 | 1303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1304 | |
1305 | if (set) | |
1306 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1307 | 1, 10000); |
cb1faec9 DS |
1308 | else |
1309 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1310 | ||
1311 | return CMD_SUCCESS; | |
1312 | } | |
1313 | ||
1314 | int | |
1315 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1316 | { | |
1317 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1318 | vty_out (vty, " write-quanta %d%s", | |
1319 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1320 | ||
1321 | return 0; | |
1322 | } | |
1323 | ||
1324 | ||
1325 | /* Update-delay configuration */ | |
1326 | DEFUN (bgp_wpkt_quanta, | |
1327 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1328 | "write-quanta (1-10000)", |
cb1faec9 DS |
1329 | "How many packets to write to peer socket per run\n" |
1330 | "Number of packets\n") | |
1331 | { | |
c500ae40 DW |
1332 | int idx_number = 1; |
1333 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1334 | } |
1335 | ||
1336 | /* Update-delay deconfiguration */ | |
1337 | DEFUN (no_bgp_wpkt_quanta, | |
1338 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1339 | "no write-quanta (1-10000)", |
d7fa34c1 | 1340 | NO_STR |
cb1faec9 DS |
1341 | "How many packets to write to peer socket per run\n" |
1342 | "Number of packets\n") | |
1343 | { | |
c500ae40 DW |
1344 | int idx_number = 2; |
1345 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1346 | } |
1347 | ||
ffd0c037 | 1348 | static int |
3f9c7369 DS |
1349 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1350 | { | |
cdc2d765 | 1351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1352 | |
1353 | if (set) | |
1354 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1355 | 0, 4294967295); | |
1356 | else | |
1357 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1358 | ||
1359 | return CMD_SUCCESS; | |
1360 | } | |
1361 | ||
1362 | int | |
1363 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1364 | { | |
1365 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1366 | vty_out (vty, " coalesce-time %d%s", | |
1367 | bgp->coalesce_time, VTY_NEWLINE); | |
1368 | ||
1369 | return 0; | |
1370 | } | |
1371 | ||
1372 | ||
1373 | DEFUN (bgp_coalesce_time, | |
1374 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1375 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1376 | "Subgroup coalesce timer\n" |
1377 | "Subgroup coalesce timer value (in ms)\n") | |
1378 | { | |
c500ae40 DW |
1379 | int idx_number = 1; |
1380 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1381 | } |
1382 | ||
1383 | DEFUN (no_bgp_coalesce_time, | |
1384 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1385 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1386 | NO_STR |
3f9c7369 DS |
1387 | "Subgroup coalesce timer\n" |
1388 | "Subgroup coalesce timer value (in ms)\n") | |
1389 | { | |
c500ae40 DW |
1390 | int idx_number = 2; |
1391 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1392 | } |
1393 | ||
5e242b0d DS |
1394 | /* Maximum-paths configuration */ |
1395 | DEFUN (bgp_maxpaths, | |
1396 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1397 | "maximum-paths (1-255)", |
5e242b0d DS |
1398 | "Forward packets over multiple paths\n" |
1399 | "Number of paths\n") | |
1400 | { | |
c500ae40 DW |
1401 | int idx_number = 1; |
1402 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1403 | } |
1404 | ||
165b5fff JB |
1405 | DEFUN (bgp_maxpaths_ibgp, |
1406 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1407 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1408 | "Forward packets over multiple paths\n" |
1409 | "iBGP-multipath\n" | |
1410 | "Number of paths\n") | |
1411 | { | |
c500ae40 DW |
1412 | int idx_number = 2; |
1413 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1414 | } |
165b5fff | 1415 | |
5e242b0d DS |
1416 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1417 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1418 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1419 | "Forward packets over multiple paths\n" |
1420 | "iBGP-multipath\n" | |
1421 | "Number of paths\n" | |
1422 | "Match the cluster length\n") | |
1423 | { | |
c500ae40 DW |
1424 | int idx_number = 2; |
1425 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1426 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1427 | } |
1428 | ||
1429 | DEFUN (no_bgp_maxpaths, | |
1430 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1431 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1432 | NO_STR |
1433 | "Forward packets over multiple paths\n" | |
1434 | "Number of paths\n") | |
1435 | { | |
5e242b0d | 1436 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1437 | } |
1438 | ||
165b5fff JB |
1439 | DEFUN (no_bgp_maxpaths_ibgp, |
1440 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1441 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1442 | NO_STR |
1443 | "Forward packets over multiple paths\n" | |
1444 | "iBGP-multipath\n" | |
838758ac DW |
1445 | "Number of paths\n" |
1446 | "Match the cluster length\n") | |
165b5fff | 1447 | { |
5e242b0d | 1448 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1449 | } |
1450 | ||
165b5fff JB |
1451 | int |
1452 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1453 | safi_t safi, int *write) | |
1454 | { | |
d5b77cc2 | 1455 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1456 | { |
1457 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1458 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1459 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1460 | } | |
1461 | ||
d5b77cc2 | 1462 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1463 | { |
1464 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1465 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1466 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1467 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1468 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1469 | vty_out (vty, " equal-cluster-length"); | |
1470 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1471 | } |
1472 | ||
1473 | return 0; | |
1474 | } | |
6b0655a2 | 1475 | |
718e3744 | 1476 | /* BGP timers. */ |
1477 | ||
1478 | DEFUN (bgp_timers, | |
1479 | bgp_timers_cmd, | |
6147e2c6 | 1480 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1481 | "Adjust routing timers\n" |
1482 | "BGP timers\n" | |
1483 | "Keepalive interval\n" | |
1484 | "Holdtime\n") | |
1485 | { | |
cdc2d765 | 1486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1487 | int idx_number = 2; |
1488 | int idx_number_2 = 3; | |
718e3744 | 1489 | unsigned long keepalive = 0; |
1490 | unsigned long holdtime = 0; | |
1491 | ||
c500ae40 DW |
1492 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1493 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1494 | |
1495 | /* Holdtime value check. */ | |
1496 | if (holdtime < 3 && holdtime != 0) | |
1497 | { | |
1498 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1499 | VTY_NEWLINE); | |
1500 | return CMD_WARNING; | |
1501 | } | |
1502 | ||
1503 | bgp_timers_set (bgp, keepalive, holdtime); | |
1504 | ||
1505 | return CMD_SUCCESS; | |
1506 | } | |
1507 | ||
1508 | DEFUN (no_bgp_timers, | |
1509 | no_bgp_timers_cmd, | |
838758ac | 1510 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1511 | NO_STR |
1512 | "Adjust routing timers\n" | |
838758ac DW |
1513 | "BGP timers\n" |
1514 | "Keepalive interval\n" | |
1515 | "Holdtime\n") | |
718e3744 | 1516 | { |
cdc2d765 | 1517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1518 | bgp_timers_unset (bgp); |
1519 | ||
1520 | return CMD_SUCCESS; | |
1521 | } | |
1522 | ||
6b0655a2 | 1523 | |
718e3744 | 1524 | DEFUN (bgp_client_to_client_reflection, |
1525 | bgp_client_to_client_reflection_cmd, | |
1526 | "bgp client-to-client reflection", | |
1527 | "BGP specific commands\n" | |
1528 | "Configure client to client route reflection\n" | |
1529 | "reflection of routes allowed\n") | |
1530 | { | |
cdc2d765 | 1531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1532 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1533 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1534 | |
718e3744 | 1535 | return CMD_SUCCESS; |
1536 | } | |
1537 | ||
1538 | DEFUN (no_bgp_client_to_client_reflection, | |
1539 | no_bgp_client_to_client_reflection_cmd, | |
1540 | "no bgp client-to-client reflection", | |
1541 | NO_STR | |
1542 | "BGP specific commands\n" | |
1543 | "Configure client to client route reflection\n" | |
1544 | "reflection of routes allowed\n") | |
1545 | { | |
cdc2d765 | 1546 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1547 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1548 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1549 | |
718e3744 | 1550 | return CMD_SUCCESS; |
1551 | } | |
1552 | ||
1553 | /* "bgp always-compare-med" configuration. */ | |
1554 | DEFUN (bgp_always_compare_med, | |
1555 | bgp_always_compare_med_cmd, | |
1556 | "bgp always-compare-med", | |
1557 | "BGP specific commands\n" | |
1558 | "Allow comparing MED from different neighbors\n") | |
1559 | { | |
cdc2d765 | 1560 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1561 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1562 | bgp_recalculate_all_bestpaths (bgp); |
1563 | ||
718e3744 | 1564 | return CMD_SUCCESS; |
1565 | } | |
1566 | ||
1567 | DEFUN (no_bgp_always_compare_med, | |
1568 | no_bgp_always_compare_med_cmd, | |
1569 | "no bgp always-compare-med", | |
1570 | NO_STR | |
1571 | "BGP specific commands\n" | |
1572 | "Allow comparing MED from different neighbors\n") | |
1573 | { | |
cdc2d765 | 1574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1575 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1576 | bgp_recalculate_all_bestpaths (bgp); |
1577 | ||
718e3744 | 1578 | return CMD_SUCCESS; |
1579 | } | |
6b0655a2 | 1580 | |
718e3744 | 1581 | /* "bgp deterministic-med" configuration. */ |
1582 | DEFUN (bgp_deterministic_med, | |
1583 | bgp_deterministic_med_cmd, | |
1584 | "bgp deterministic-med", | |
1585 | "BGP specific commands\n" | |
1586 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1587 | { | |
cdc2d765 | 1588 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1589 | |
1590 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1591 | { | |
1592 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1593 | bgp_recalculate_all_bestpaths (bgp); | |
1594 | } | |
7aafcaca | 1595 | |
718e3744 | 1596 | return CMD_SUCCESS; |
1597 | } | |
1598 | ||
1599 | DEFUN (no_bgp_deterministic_med, | |
1600 | no_bgp_deterministic_med_cmd, | |
1601 | "no bgp deterministic-med", | |
1602 | NO_STR | |
1603 | "BGP specific commands\n" | |
1604 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1605 | { | |
cdc2d765 | 1606 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1607 | int bestpath_per_as_used; |
1608 | afi_t afi; | |
1609 | safi_t safi; | |
1610 | struct peer *peer; | |
1611 | struct listnode *node, *nnode; | |
718e3744 | 1612 | |
1475ac87 DW |
1613 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1614 | { | |
06370dac DW |
1615 | bestpath_per_as_used = 0; |
1616 | ||
1617 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1618 | { | |
1619 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1620 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1621 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1622 | { | |
1623 | bestpath_per_as_used = 1; | |
1624 | break; | |
1625 | } | |
1626 | ||
1627 | if (bestpath_per_as_used) | |
1628 | break; | |
1629 | } | |
1630 | ||
1631 | if (bestpath_per_as_used) | |
1632 | { | |
1633 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1634 | VTY_NEWLINE); | |
1635 | return CMD_WARNING; | |
1636 | } | |
1637 | else | |
1638 | { | |
1639 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1640 | bgp_recalculate_all_bestpaths (bgp); | |
1641 | } | |
1475ac87 | 1642 | } |
7aafcaca | 1643 | |
718e3744 | 1644 | return CMD_SUCCESS; |
1645 | } | |
538621f2 | 1646 | |
1647 | /* "bgp graceful-restart" configuration. */ | |
1648 | DEFUN (bgp_graceful_restart, | |
1649 | bgp_graceful_restart_cmd, | |
1650 | "bgp graceful-restart", | |
1651 | "BGP specific commands\n" | |
1652 | "Graceful restart capability parameters\n") | |
1653 | { | |
cdc2d765 | 1654 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1655 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1656 | return CMD_SUCCESS; | |
1657 | } | |
1658 | ||
1659 | DEFUN (no_bgp_graceful_restart, | |
1660 | no_bgp_graceful_restart_cmd, | |
1661 | "no bgp graceful-restart", | |
1662 | NO_STR | |
1663 | "BGP specific commands\n" | |
1664 | "Graceful restart capability parameters\n") | |
1665 | { | |
cdc2d765 | 1666 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1667 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1668 | return CMD_SUCCESS; | |
1669 | } | |
1670 | ||
93406d87 | 1671 | DEFUN (bgp_graceful_restart_stalepath_time, |
1672 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1673 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1674 | "BGP specific commands\n" |
1675 | "Graceful restart capability parameters\n" | |
1676 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1677 | "Delay value (seconds)\n") | |
1678 | { | |
cdc2d765 | 1679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1680 | int idx_number = 3; |
93406d87 | 1681 | u_int32_t stalepath; |
1682 | ||
c500ae40 | 1683 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1684 | bgp->stalepath_time = stalepath; |
1685 | return CMD_SUCCESS; | |
1686 | } | |
1687 | ||
eb6f1b41 PG |
1688 | DEFUN (bgp_graceful_restart_restart_time, |
1689 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1690 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1691 | "BGP specific commands\n" |
1692 | "Graceful restart capability parameters\n" | |
1693 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1694 | "Delay value (seconds)\n") | |
1695 | { | |
cdc2d765 | 1696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1697 | int idx_number = 3; |
eb6f1b41 PG |
1698 | u_int32_t restart; |
1699 | ||
c500ae40 | 1700 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1701 | bgp->restart_time = restart; |
1702 | return CMD_SUCCESS; | |
1703 | } | |
1704 | ||
93406d87 | 1705 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1706 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1707 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1708 | NO_STR |
1709 | "BGP specific commands\n" | |
1710 | "Graceful restart capability parameters\n" | |
838758ac DW |
1711 | "Set the max time to hold onto restarting peer's stale paths\n" |
1712 | "Delay value (seconds)\n") | |
93406d87 | 1713 | { |
cdc2d765 | 1714 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1715 | |
1716 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1717 | return CMD_SUCCESS; | |
1718 | } | |
1719 | ||
eb6f1b41 PG |
1720 | DEFUN (no_bgp_graceful_restart_restart_time, |
1721 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1722 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1723 | NO_STR |
1724 | "BGP specific commands\n" | |
1725 | "Graceful restart capability parameters\n" | |
838758ac DW |
1726 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1727 | "Delay value (seconds)\n") | |
eb6f1b41 | 1728 | { |
cdc2d765 | 1729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1730 | |
1731 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1732 | return CMD_SUCCESS; | |
1733 | } | |
1734 | ||
43fc21b3 JC |
1735 | DEFUN (bgp_graceful_restart_preserve_fw, |
1736 | bgp_graceful_restart_preserve_fw_cmd, | |
1737 | "bgp graceful-restart preserve-fw-state", | |
1738 | "BGP specific commands\n" | |
1739 | "Graceful restart capability parameters\n" | |
1740 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1741 | { | |
1742 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1743 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1744 | return CMD_SUCCESS; | |
1745 | } | |
1746 | ||
1747 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1748 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1749 | "no bgp graceful-restart preserve-fw-state", | |
1750 | NO_STR | |
1751 | "BGP specific commands\n" | |
1752 | "Graceful restart capability parameters\n" | |
1753 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1754 | { | |
1755 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1756 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1757 | return CMD_SUCCESS; | |
1758 | } | |
1759 | ||
718e3744 | 1760 | /* "bgp fast-external-failover" configuration. */ |
1761 | DEFUN (bgp_fast_external_failover, | |
1762 | bgp_fast_external_failover_cmd, | |
1763 | "bgp fast-external-failover", | |
1764 | BGP_STR | |
1765 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1766 | { | |
cdc2d765 | 1767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1768 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1769 | return CMD_SUCCESS; | |
1770 | } | |
1771 | ||
1772 | DEFUN (no_bgp_fast_external_failover, | |
1773 | no_bgp_fast_external_failover_cmd, | |
1774 | "no bgp fast-external-failover", | |
1775 | NO_STR | |
1776 | BGP_STR | |
1777 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1778 | { | |
cdc2d765 | 1779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1780 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1781 | return CMD_SUCCESS; | |
1782 | } | |
6b0655a2 | 1783 | |
718e3744 | 1784 | /* "bgp enforce-first-as" configuration. */ |
1785 | DEFUN (bgp_enforce_first_as, | |
1786 | bgp_enforce_first_as_cmd, | |
1787 | "bgp enforce-first-as", | |
1788 | BGP_STR | |
1789 | "Enforce the first AS for EBGP routes\n") | |
1790 | { | |
cdc2d765 | 1791 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1792 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1793 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1794 | |
718e3744 | 1795 | return CMD_SUCCESS; |
1796 | } | |
1797 | ||
1798 | DEFUN (no_bgp_enforce_first_as, | |
1799 | no_bgp_enforce_first_as_cmd, | |
1800 | "no bgp enforce-first-as", | |
1801 | NO_STR | |
1802 | BGP_STR | |
1803 | "Enforce the first AS for EBGP routes\n") | |
1804 | { | |
cdc2d765 | 1805 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1806 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1807 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1808 | |
718e3744 | 1809 | return CMD_SUCCESS; |
1810 | } | |
6b0655a2 | 1811 | |
718e3744 | 1812 | /* "bgp bestpath compare-routerid" configuration. */ |
1813 | DEFUN (bgp_bestpath_compare_router_id, | |
1814 | bgp_bestpath_compare_router_id_cmd, | |
1815 | "bgp bestpath compare-routerid", | |
1816 | "BGP specific commands\n" | |
1817 | "Change the default bestpath selection\n" | |
1818 | "Compare router-id for identical EBGP paths\n") | |
1819 | { | |
cdc2d765 | 1820 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1821 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1822 | bgp_recalculate_all_bestpaths (bgp); |
1823 | ||
718e3744 | 1824 | return CMD_SUCCESS; |
1825 | } | |
1826 | ||
1827 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1828 | no_bgp_bestpath_compare_router_id_cmd, | |
1829 | "no bgp bestpath compare-routerid", | |
1830 | NO_STR | |
1831 | "BGP specific commands\n" | |
1832 | "Change the default bestpath selection\n" | |
1833 | "Compare router-id for identical EBGP paths\n") | |
1834 | { | |
cdc2d765 | 1835 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1836 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1837 | bgp_recalculate_all_bestpaths (bgp); |
1838 | ||
718e3744 | 1839 | return CMD_SUCCESS; |
1840 | } | |
6b0655a2 | 1841 | |
718e3744 | 1842 | /* "bgp bestpath as-path ignore" configuration. */ |
1843 | DEFUN (bgp_bestpath_aspath_ignore, | |
1844 | bgp_bestpath_aspath_ignore_cmd, | |
1845 | "bgp bestpath as-path ignore", | |
1846 | "BGP specific commands\n" | |
1847 | "Change the default bestpath selection\n" | |
1848 | "AS-path attribute\n" | |
1849 | "Ignore as-path length in selecting a route\n") | |
1850 | { | |
cdc2d765 | 1851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1852 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1853 | bgp_recalculate_all_bestpaths (bgp); |
1854 | ||
718e3744 | 1855 | return CMD_SUCCESS; |
1856 | } | |
1857 | ||
1858 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1859 | no_bgp_bestpath_aspath_ignore_cmd, | |
1860 | "no bgp bestpath as-path ignore", | |
1861 | NO_STR | |
1862 | "BGP specific commands\n" | |
1863 | "Change the default bestpath selection\n" | |
1864 | "AS-path attribute\n" | |
1865 | "Ignore as-path length in selecting a route\n") | |
1866 | { | |
cdc2d765 | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1868 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1869 | bgp_recalculate_all_bestpaths (bgp); |
1870 | ||
718e3744 | 1871 | return CMD_SUCCESS; |
1872 | } | |
6b0655a2 | 1873 | |
6811845b | 1874 | /* "bgp bestpath as-path confed" configuration. */ |
1875 | DEFUN (bgp_bestpath_aspath_confed, | |
1876 | bgp_bestpath_aspath_confed_cmd, | |
1877 | "bgp bestpath as-path confed", | |
1878 | "BGP specific commands\n" | |
1879 | "Change the default bestpath selection\n" | |
1880 | "AS-path attribute\n" | |
1881 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1882 | { | |
cdc2d765 | 1883 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1884 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1885 | bgp_recalculate_all_bestpaths (bgp); |
1886 | ||
6811845b | 1887 | return CMD_SUCCESS; |
1888 | } | |
1889 | ||
1890 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1891 | no_bgp_bestpath_aspath_confed_cmd, | |
1892 | "no bgp bestpath as-path confed", | |
1893 | NO_STR | |
1894 | "BGP specific commands\n" | |
1895 | "Change the default bestpath selection\n" | |
1896 | "AS-path attribute\n" | |
1897 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1898 | { | |
cdc2d765 | 1899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1900 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1901 | bgp_recalculate_all_bestpaths (bgp); |
1902 | ||
6811845b | 1903 | return CMD_SUCCESS; |
1904 | } | |
6b0655a2 | 1905 | |
2fdd455c PM |
1906 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1907 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1908 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1909 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1910 | "BGP specific commands\n" |
1911 | "Change the default bestpath selection\n" | |
1912 | "AS-path attribute\n" | |
1913 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1914 | "Generate an AS_SET\n" |
16fc1eec DS |
1915 | "Do not generate an AS_SET\n") |
1916 | { | |
cdc2d765 | 1917 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 1918 | int idx = 0; |
16fc1eec | 1919 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
1920 | |
1921 | /* no-as-set is now the default behavior so we can silently | |
1922 | * ignore it */ | |
4c4ff4c1 | 1923 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
1924 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
1925 | else | |
1926 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
1927 | ||
7aafcaca DS |
1928 | bgp_recalculate_all_bestpaths (bgp); |
1929 | ||
16fc1eec DS |
1930 | return CMD_SUCCESS; |
1931 | } | |
1932 | ||
219178b6 DW |
1933 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1934 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1935 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1936 | NO_STR |
1937 | "BGP specific commands\n" | |
1938 | "Change the default bestpath selection\n" | |
1939 | "AS-path attribute\n" | |
1940 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1941 | "Generate an AS_SET\n" |
16fc1eec DS |
1942 | "Do not generate an AS_SET\n") |
1943 | { | |
cdc2d765 | 1944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 1945 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 1946 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
1947 | bgp_recalculate_all_bestpaths (bgp); |
1948 | ||
2fdd455c PM |
1949 | return CMD_SUCCESS; |
1950 | } | |
6b0655a2 | 1951 | |
848973c7 | 1952 | /* "bgp log-neighbor-changes" configuration. */ |
1953 | DEFUN (bgp_log_neighbor_changes, | |
1954 | bgp_log_neighbor_changes_cmd, | |
1955 | "bgp log-neighbor-changes", | |
1956 | "BGP specific commands\n" | |
1957 | "Log neighbor up/down and reset reason\n") | |
1958 | { | |
cdc2d765 | 1959 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1960 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1961 | return CMD_SUCCESS; | |
1962 | } | |
1963 | ||
1964 | DEFUN (no_bgp_log_neighbor_changes, | |
1965 | no_bgp_log_neighbor_changes_cmd, | |
1966 | "no bgp log-neighbor-changes", | |
1967 | NO_STR | |
1968 | "BGP specific commands\n" | |
1969 | "Log neighbor up/down and reset reason\n") | |
1970 | { | |
cdc2d765 | 1971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1972 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1973 | return CMD_SUCCESS; | |
1974 | } | |
6b0655a2 | 1975 | |
718e3744 | 1976 | /* "bgp bestpath med" configuration. */ |
1977 | DEFUN (bgp_bestpath_med, | |
1978 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 1979 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 1980 | "BGP specific commands\n" |
1981 | "Change the default bestpath selection\n" | |
1982 | "MED attribute\n" | |
1983 | "Compare MED among confederation paths\n" | |
838758ac DW |
1984 | "Treat missing MED as the least preferred one\n" |
1985 | "Treat missing MED as the least preferred one\n" | |
1986 | "Compare MED among confederation paths\n") | |
718e3744 | 1987 | { |
cdc2d765 | 1988 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
1989 | |
1990 | int idx = 0; | |
1991 | if (argv_find (argv, argc, "confed", &idx)) | |
1992 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
1993 | idx = 0; | |
1994 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
1995 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 1996 | |
7aafcaca DS |
1997 | bgp_recalculate_all_bestpaths (bgp); |
1998 | ||
718e3744 | 1999 | return CMD_SUCCESS; |
2000 | } | |
2001 | ||
718e3744 | 2002 | DEFUN (no_bgp_bestpath_med, |
2003 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2004 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2005 | NO_STR |
2006 | "BGP specific commands\n" | |
2007 | "Change the default bestpath selection\n" | |
2008 | "MED attribute\n" | |
2009 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2010 | "Treat missing MED as the least preferred one\n" |
2011 | "Treat missing MED as the least preferred one\n" | |
2012 | "Compare MED among confederation paths\n") | |
718e3744 | 2013 | { |
cdc2d765 | 2014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2015 | |
6cbd1915 QY |
2016 | int idx = 0; |
2017 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2018 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2019 | idx = 0; |
2020 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2021 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2022 | ||
7aafcaca DS |
2023 | bgp_recalculate_all_bestpaths (bgp); |
2024 | ||
718e3744 | 2025 | return CMD_SUCCESS; |
2026 | } | |
2027 | ||
718e3744 | 2028 | /* "no bgp default ipv4-unicast". */ |
2029 | DEFUN (no_bgp_default_ipv4_unicast, | |
2030 | no_bgp_default_ipv4_unicast_cmd, | |
2031 | "no bgp default ipv4-unicast", | |
2032 | NO_STR | |
2033 | "BGP specific commands\n" | |
2034 | "Configure BGP defaults\n" | |
2035 | "Activate ipv4-unicast for a peer by default\n") | |
2036 | { | |
cdc2d765 | 2037 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2038 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2039 | return CMD_SUCCESS; | |
2040 | } | |
2041 | ||
2042 | DEFUN (bgp_default_ipv4_unicast, | |
2043 | bgp_default_ipv4_unicast_cmd, | |
2044 | "bgp default ipv4-unicast", | |
2045 | "BGP specific commands\n" | |
2046 | "Configure BGP defaults\n" | |
2047 | "Activate ipv4-unicast for a peer by default\n") | |
2048 | { | |
cdc2d765 | 2049 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2050 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2051 | return CMD_SUCCESS; | |
2052 | } | |
6b0655a2 | 2053 | |
04b6bdc0 DW |
2054 | /* Display hostname in certain command outputs */ |
2055 | DEFUN (bgp_default_show_hostname, | |
2056 | bgp_default_show_hostname_cmd, | |
2057 | "bgp default show-hostname", | |
2058 | "BGP specific commands\n" | |
2059 | "Configure BGP defaults\n" | |
2060 | "Show hostname in certain command ouputs\n") | |
2061 | { | |
cdc2d765 | 2062 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2063 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2064 | return CMD_SUCCESS; | |
2065 | } | |
2066 | ||
2067 | DEFUN (no_bgp_default_show_hostname, | |
2068 | no_bgp_default_show_hostname_cmd, | |
2069 | "no bgp default show-hostname", | |
2070 | NO_STR | |
2071 | "BGP specific commands\n" | |
2072 | "Configure BGP defaults\n" | |
2073 | "Show hostname in certain command ouputs\n") | |
2074 | { | |
cdc2d765 | 2075 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2076 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2077 | return CMD_SUCCESS; | |
2078 | } | |
2079 | ||
8233ef81 | 2080 | /* "bgp network import-check" configuration. */ |
718e3744 | 2081 | DEFUN (bgp_network_import_check, |
2082 | bgp_network_import_check_cmd, | |
5623e905 | 2083 | "bgp network import-check", |
718e3744 | 2084 | "BGP specific commands\n" |
2085 | "BGP network command\n" | |
5623e905 | 2086 | "Check BGP network route exists in IGP\n") |
718e3744 | 2087 | { |
cdc2d765 | 2088 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2089 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2090 | { | |
2091 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2092 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2093 | } |
2094 | ||
718e3744 | 2095 | return CMD_SUCCESS; |
2096 | } | |
2097 | ||
8233ef81 DW |
2098 | ALIAS_HIDDEN (bgp_network_import_check, |
2099 | bgp_network_import_check_exact_cmd, | |
2100 | "bgp network import-check exact", | |
2101 | "BGP specific commands\n" | |
2102 | "BGP network command\n" | |
2103 | "Check BGP network route exists in IGP\n" | |
2104 | "Match route precisely\n") | |
2105 | ||
718e3744 | 2106 | DEFUN (no_bgp_network_import_check, |
2107 | no_bgp_network_import_check_cmd, | |
5623e905 | 2108 | "no bgp network import-check", |
718e3744 | 2109 | NO_STR |
2110 | "BGP specific commands\n" | |
2111 | "BGP network command\n" | |
2112 | "Check BGP network route exists in IGP\n") | |
2113 | { | |
cdc2d765 | 2114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2115 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2116 | { | |
2117 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2118 | bgp_static_redo_import_check(bgp); |
2119 | } | |
5623e905 | 2120 | |
718e3744 | 2121 | return CMD_SUCCESS; |
2122 | } | |
6b0655a2 | 2123 | |
718e3744 | 2124 | DEFUN (bgp_default_local_preference, |
2125 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2126 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2127 | "BGP specific commands\n" |
2128 | "Configure BGP defaults\n" | |
2129 | "local preference (higher=more preferred)\n" | |
2130 | "Configure default local preference value\n") | |
2131 | { | |
cdc2d765 | 2132 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2133 | int idx_number = 3; |
718e3744 | 2134 | u_int32_t local_pref; |
2135 | ||
c500ae40 | 2136 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2137 | |
2138 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2139 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2140 | |
2141 | return CMD_SUCCESS; | |
2142 | } | |
2143 | ||
2144 | DEFUN (no_bgp_default_local_preference, | |
2145 | no_bgp_default_local_preference_cmd, | |
838758ac | 2146 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2147 | NO_STR |
2148 | "BGP specific commands\n" | |
2149 | "Configure BGP defaults\n" | |
838758ac DW |
2150 | "local preference (higher=more preferred)\n" |
2151 | "Configure default local preference value\n") | |
718e3744 | 2152 | { |
cdc2d765 | 2153 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2154 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2155 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2156 | |
718e3744 | 2157 | return CMD_SUCCESS; |
2158 | } | |
2159 | ||
6b0655a2 | 2160 | |
3f9c7369 DS |
2161 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2162 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2163 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2164 | "BGP specific commands\n" |
2165 | "Configure BGP defaults\n" | |
2166 | "subgroup-pkt-queue-max\n" | |
2167 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2168 | { |
cdc2d765 | 2169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2170 | int idx_number = 3; |
3f9c7369 | 2171 | u_int32_t max_size; |
8bd9d948 | 2172 | |
c500ae40 | 2173 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2174 | |
2175 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2176 | ||
2177 | return CMD_SUCCESS; | |
2178 | } | |
2179 | ||
2180 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2181 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2182 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2183 | NO_STR |
2184 | "BGP specific commands\n" | |
2185 | "Configure BGP defaults\n" | |
838758ac DW |
2186 | "subgroup-pkt-queue-max\n" |
2187 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2188 | { |
cdc2d765 | 2189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2190 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2191 | return CMD_SUCCESS; | |
8bd9d948 DS |
2192 | } |
2193 | ||
813d4307 | 2194 | |
8bd9d948 DS |
2195 | DEFUN (bgp_rr_allow_outbound_policy, |
2196 | bgp_rr_allow_outbound_policy_cmd, | |
2197 | "bgp route-reflector allow-outbound-policy", | |
2198 | "BGP specific commands\n" | |
2199 | "Allow modifications made by out route-map\n" | |
2200 | "on ibgp neighbors\n") | |
2201 | { | |
cdc2d765 | 2202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2203 | |
2204 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2205 | { | |
2206 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2207 | update_group_announce_rrclients(bgp); |
f31fa004 | 2208 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2209 | } |
2210 | ||
2211 | return CMD_SUCCESS; | |
2212 | } | |
2213 | ||
2214 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2215 | no_bgp_rr_allow_outbound_policy_cmd, | |
2216 | "no bgp route-reflector allow-outbound-policy", | |
2217 | NO_STR | |
2218 | "BGP specific commands\n" | |
2219 | "Allow modifications made by out route-map\n" | |
2220 | "on ibgp neighbors\n") | |
2221 | { | |
cdc2d765 | 2222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2223 | |
2224 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2225 | { | |
2226 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2227 | update_group_announce_rrclients(bgp); |
f31fa004 | 2228 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2229 | } |
2230 | ||
2231 | return CMD_SUCCESS; | |
2232 | } | |
2233 | ||
f14e6fdb DS |
2234 | DEFUN (bgp_listen_limit, |
2235 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2236 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2237 | "BGP specific commands\n" |
2238 | "Configure BGP defaults\n" | |
2239 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2240 | "Configure Dynamic Neighbors listen limit value\n") | |
2241 | { | |
cdc2d765 | 2242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2243 | int idx_number = 3; |
f14e6fdb DS |
2244 | int listen_limit; |
2245 | ||
c500ae40 | 2246 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2247 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2248 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2249 | ||
2250 | bgp_listen_limit_set (bgp, listen_limit); | |
2251 | ||
2252 | return CMD_SUCCESS; | |
2253 | } | |
2254 | ||
2255 | DEFUN (no_bgp_listen_limit, | |
2256 | no_bgp_listen_limit_cmd, | |
838758ac | 2257 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2258 | "BGP specific commands\n" |
2259 | "Configure BGP defaults\n" | |
2260 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2261 | "Configure Dynamic Neighbors listen limit value to default\n" |
2262 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2263 | { |
cdc2d765 | 2264 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2265 | bgp_listen_limit_unset (bgp); |
2266 | return CMD_SUCCESS; | |
2267 | } | |
2268 | ||
2269 | ||
20eb8864 | 2270 | /* |
2271 | * Check if this listen range is already configured. Check for exact | |
2272 | * match or overlap based on input. | |
2273 | */ | |
2274 | static struct peer_group * | |
2275 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2276 | { | |
2277 | struct listnode *node, *nnode; | |
2278 | struct listnode *node1, *nnode1; | |
2279 | struct peer_group *group; | |
2280 | struct prefix *lr; | |
2281 | afi_t afi; | |
2282 | int match; | |
2283 | ||
2284 | afi = family2afi(range->family); | |
2285 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2286 | { | |
2287 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2288 | nnode1, lr)) | |
2289 | { | |
2290 | if (exact) | |
2291 | match = prefix_same (range, lr); | |
2292 | else | |
2293 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2294 | if (match) | |
2295 | return group; | |
2296 | } | |
2297 | } | |
2298 | ||
2299 | return NULL; | |
2300 | } | |
2301 | ||
f14e6fdb DS |
2302 | DEFUN (bgp_listen_range, |
2303 | bgp_listen_range_cmd, | |
9ccf14f7 | 2304 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2305 | "BGP specific commands\n" |
d7fa34c1 QY |
2306 | "Configure BGP dynamic neighbors listen range\n" |
2307 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2308 | NEIGHBOR_ADDR_STR |
2309 | "Member of the peer-group\n" | |
2310 | "Peer-group name\n") | |
f14e6fdb | 2311 | { |
cdc2d765 | 2312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2313 | struct prefix range; |
20eb8864 | 2314 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2315 | afi_t afi; |
2316 | int ret; | |
d7fa34c1 | 2317 | int idx = 0; |
f14e6fdb | 2318 | |
d7fa34c1 QY |
2319 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2320 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2321 | char *prefix = argv[idx]->arg; | |
2322 | argv_find (argv, argc, "WORD", &idx); | |
2323 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2324 | |
f14e6fdb | 2325 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2326 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2327 | if (! ret) |
2328 | { | |
2329 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2330 | return CMD_WARNING; | |
2331 | } | |
2332 | ||
2333 | afi = family2afi(range.family); | |
2334 | ||
f14e6fdb DS |
2335 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2336 | { | |
2337 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2338 | VTY_NEWLINE); | |
2339 | return CMD_WARNING; | |
2340 | } | |
f14e6fdb DS |
2341 | |
2342 | apply_mask (&range); | |
2343 | ||
20eb8864 | 2344 | /* Check if same listen range is already configured. */ |
2345 | existing_group = listen_range_exists (bgp, &range, 1); | |
2346 | if (existing_group) | |
2347 | { | |
d7fa34c1 | 2348 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2349 | return CMD_SUCCESS; |
2350 | else | |
2351 | { | |
2352 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2353 | existing_group->name, VTY_NEWLINE); | |
2354 | return CMD_WARNING; | |
2355 | } | |
2356 | } | |
2357 | ||
2358 | /* Check if an overlapping listen range exists. */ | |
2359 | if (listen_range_exists (bgp, &range, 0)) | |
2360 | { | |
2361 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2362 | VTY_NEWLINE); | |
2363 | return CMD_WARNING; | |
2364 | } | |
f14e6fdb | 2365 | |
d7fa34c1 | 2366 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2367 | if (! group) |
2368 | { | |
2369 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2370 | return CMD_WARNING; | |
2371 | } | |
2372 | ||
2373 | ret = peer_group_listen_range_add(group, &range); | |
2374 | return bgp_vty_return (vty, ret); | |
2375 | } | |
2376 | ||
2377 | DEFUN (no_bgp_listen_range, | |
2378 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2379 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2380 | NO_STR | |
f14e6fdb | 2381 | "BGP specific commands\n" |
d7fa34c1 QY |
2382 | "Unconfigure BGP dynamic neighbors listen range\n" |
2383 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2384 | NEIGHBOR_ADDR_STR | |
2385 | "Member of the peer-group\n" | |
2386 | "Peer-group name\n") | |
f14e6fdb | 2387 | { |
cdc2d765 | 2388 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2389 | struct prefix range; |
2390 | struct peer_group *group; | |
2391 | afi_t afi; | |
2392 | int ret; | |
d7fa34c1 QY |
2393 | int idx = 0; |
2394 | ||
2395 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2396 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2397 | char *prefix = argv[idx]->arg; | |
2398 | argv_find (argv, argc, "WORD", &idx); | |
2399 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2400 | |
c500ae40 | 2401 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2402 | |
2403 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2404 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2405 | if (! ret) |
2406 | { | |
2407 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2408 | return CMD_WARNING; | |
2409 | } | |
2410 | ||
2411 | afi = family2afi(range.family); | |
2412 | ||
f14e6fdb DS |
2413 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2414 | { | |
2415 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2416 | VTY_NEWLINE); | |
2417 | return CMD_WARNING; | |
2418 | } | |
f14e6fdb DS |
2419 | |
2420 | apply_mask (&range); | |
2421 | ||
d7fa34c1 | 2422 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2423 | if (! group) |
2424 | { | |
2425 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2426 | return CMD_WARNING; | |
2427 | } | |
2428 | ||
2429 | ret = peer_group_listen_range_del(group, &range); | |
2430 | return bgp_vty_return (vty, ret); | |
2431 | } | |
2432 | ||
2433 | int | |
2434 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2435 | { | |
2436 | struct peer_group *group; | |
2437 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2438 | struct prefix *range; | |
2439 | afi_t afi; | |
4690c7d7 | 2440 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2441 | |
2442 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2443 | vty_out (vty, " bgp listen limit %d%s", | |
2444 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2445 | ||
2446 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2447 | { | |
2448 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2449 | { | |
2450 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2451 | { | |
2452 | prefix2str(range, buf, sizeof(buf)); | |
2453 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2454 | buf, group->name, VTY_NEWLINE); | |
2455 | } | |
2456 | } | |
2457 | } | |
2458 | ||
2459 | return 0; | |
2460 | } | |
2461 | ||
2462 | ||
907f92c8 DS |
2463 | DEFUN (bgp_disable_connected_route_check, |
2464 | bgp_disable_connected_route_check_cmd, | |
2465 | "bgp disable-ebgp-connected-route-check", | |
2466 | "BGP specific commands\n" | |
2467 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2468 | { | |
cdc2d765 | 2469 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2470 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2471 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2472 | |
907f92c8 DS |
2473 | return CMD_SUCCESS; |
2474 | } | |
2475 | ||
2476 | DEFUN (no_bgp_disable_connected_route_check, | |
2477 | no_bgp_disable_connected_route_check_cmd, | |
2478 | "no bgp disable-ebgp-connected-route-check", | |
2479 | NO_STR | |
2480 | "BGP specific commands\n" | |
2481 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2482 | { | |
cdc2d765 | 2483 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2484 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2485 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2486 | |
907f92c8 DS |
2487 | return CMD_SUCCESS; |
2488 | } | |
2489 | ||
2490 | ||
718e3744 | 2491 | static int |
e52702f2 | 2492 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2493 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2494 | { |
cdc2d765 | 2495 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2496 | int ret; |
718e3744 | 2497 | as_t as; |
0299c004 | 2498 | int as_type = AS_SPECIFIED; |
718e3744 | 2499 | union sockunion su; |
2500 | ||
7ae5fc81 | 2501 | if (as_str[0] == 'i') |
0299c004 DS |
2502 | { |
2503 | as = 0; | |
2504 | as_type = AS_INTERNAL; | |
2505 | } | |
7ae5fc81 | 2506 | else if (as_str[0] == 'e') |
0299c004 DS |
2507 | { |
2508 | as = 0; | |
2509 | as_type = AS_EXTERNAL; | |
2510 | } | |
2511 | else | |
2512 | { | |
2513 | /* Get AS number. */ | |
2514 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2515 | } | |
718e3744 | 2516 | |
2517 | /* If peer is peer group, call proper function. */ | |
2518 | ret = str2sockunion (peer_str, &su); | |
2519 | if (ret < 0) | |
2520 | { | |
a80beece | 2521 | /* Check for peer by interface */ |
0299c004 | 2522 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2523 | if (ret < 0) |
a80beece | 2524 | { |
0299c004 | 2525 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2526 | if (ret < 0) |
2527 | { | |
2528 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2529 | VTY_NEWLINE); | |
2530 | return CMD_WARNING; | |
2531 | } | |
2532 | return CMD_SUCCESS; | |
2533 | } | |
718e3744 | 2534 | } |
a80beece | 2535 | else |
718e3744 | 2536 | { |
6aeb9e78 | 2537 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2538 | { |
2539 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2540 | VTY_NEWLINE); | |
2541 | return CMD_WARNING; | |
2542 | } | |
0299c004 | 2543 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2544 | } |
2545 | ||
718e3744 | 2546 | /* This peer belongs to peer group. */ |
2547 | switch (ret) | |
2548 | { | |
2549 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2550 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2551 | return CMD_WARNING; |
718e3744 | 2552 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2553 | vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE); |
718e3744 | 2554 | return CMD_WARNING; |
718e3744 | 2555 | } |
2556 | return bgp_vty_return (vty, ret); | |
2557 | } | |
2558 | ||
2559 | DEFUN (neighbor_remote_as, | |
2560 | neighbor_remote_as_cmd, | |
3a2d747c | 2561 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2562 | NEIGHBOR_STR |
2563 | NEIGHBOR_ADDR_STR2 | |
2564 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2565 | AS_STR |
3a2d747c QY |
2566 | "Internal BGP peer\n" |
2567 | "External BGP peer\n") | |
718e3744 | 2568 | { |
c500ae40 DW |
2569 | int idx_peer = 1; |
2570 | int idx_remote_as = 3; | |
2571 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2572 | } |
6b0655a2 | 2573 | |
4c48cf63 DW |
2574 | static int |
2575 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2576 | safi_t safi, int v6only, const char *peer_group_name, |
2577 | const char *as_str) | |
a80beece | 2578 | { |
cdc2d765 | 2579 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2580 | as_t as = 0; |
2581 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2582 | struct peer *peer; |
2583 | struct peer_group *group; | |
4c48cf63 DW |
2584 | int ret = 0; |
2585 | union sockunion su; | |
a80beece | 2586 | |
4c48cf63 DW |
2587 | group = peer_group_lookup (bgp, conf_if); |
2588 | ||
a80beece DS |
2589 | if (group) |
2590 | { | |
2591 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2592 | return CMD_WARNING; | |
2593 | } | |
2594 | ||
b3a39dc5 DD |
2595 | if (as_str) |
2596 | { | |
7ae5fc81 | 2597 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2598 | { |
2599 | as_type = AS_INTERNAL; | |
2600 | } | |
7ae5fc81 | 2601 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2602 | { |
2603 | as_type = AS_EXTERNAL; | |
2604 | } | |
2605 | else | |
2606 | { | |
2607 | /* Get AS number. */ | |
2608 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2609 | as_type = AS_SPECIFIED; | |
2610 | } | |
2611 | } | |
2612 | ||
4c48cf63 DW |
2613 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2614 | if (!peer) | |
2615 | { | |
2616 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2617 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2618 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2619 | NULL); | |
4c48cf63 | 2620 | else |
b3a39dc5 DD |
2621 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2622 | NULL); | |
4c48cf63 DW |
2623 | |
2624 | if (peer && v6only) | |
2625 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2626 | |
2627 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2628 | * any unnumbered peer in order to not worry about run-time transitions | |
2629 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2630 | * gets deleted later etc.) | |
2631 | */ | |
2632 | if (peer->ifp) | |
b3a39dc5 DD |
2633 | { |
2634 | bgp_zebra_initiate_radv (bgp, peer); | |
2635 | } | |
2636 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2637 | } |
2638 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2639 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2640 | { | |
2641 | if (v6only) | |
2642 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2643 | else | |
2644 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2645 | ||
2646 | /* v6only flag changed. Reset bgp seesion */ | |
2647 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2648 | { | |
2649 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2650 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2651 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2652 | } | |
2653 | else | |
2654 | bgp_session_reset(peer); | |
2655 | } | |
2656 | ||
a80beece DS |
2657 | if (!peer) |
2658 | return CMD_WARNING; | |
2659 | ||
4c48cf63 DW |
2660 | if (peer_group_name) |
2661 | { | |
2662 | group = peer_group_lookup (bgp, peer_group_name); | |
2663 | if (! group) | |
2664 | { | |
2665 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2666 | return CMD_WARNING; | |
2667 | } | |
2668 | ||
2669 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2670 | } | |
2671 | ||
2672 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2673 | } |
2674 | ||
4c48cf63 DW |
2675 | DEFUN (neighbor_interface_config, |
2676 | neighbor_interface_config_cmd, | |
31500417 | 2677 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2678 | NEIGHBOR_STR |
2679 | "Interface name or neighbor tag\n" | |
31500417 DW |
2680 | "Enable BGP on interface\n" |
2681 | "Member of the peer-group\n" | |
16cedbb0 | 2682 | "Peer-group name\n") |
4c48cf63 | 2683 | { |
c500ae40 | 2684 | int idx_word = 1; |
31500417 DW |
2685 | int idx_peer_group_word = 4; |
2686 | ||
2687 | if (argc > idx_peer_group_word) | |
c500ae40 | 2688 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2689 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2690 | else |
c500ae40 | 2691 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2692 | NULL, NULL); |
4c48cf63 DW |
2693 | } |
2694 | ||
4c48cf63 DW |
2695 | DEFUN (neighbor_interface_config_v6only, |
2696 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2697 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2698 | NEIGHBOR_STR |
2699 | "Interface name or neighbor tag\n" | |
2700 | "Enable BGP on interface\n" | |
31500417 DW |
2701 | "Enable BGP with v6 link-local only\n" |
2702 | "Member of the peer-group\n" | |
16cedbb0 | 2703 | "Peer-group name\n") |
4c48cf63 | 2704 | { |
c500ae40 | 2705 | int idx_word = 1; |
31500417 DW |
2706 | int idx_peer_group_word = 5; |
2707 | ||
2708 | if (argc > idx_peer_group_word) | |
2709 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2710 | argv[idx_peer_group_word]->arg, NULL); | |
2711 | ||
c500ae40 | 2712 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2713 | NULL, NULL); |
4c48cf63 DW |
2714 | } |
2715 | ||
a80beece | 2716 | |
b3a39dc5 DD |
2717 | DEFUN (neighbor_interface_config_remote_as, |
2718 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2719 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2720 | NEIGHBOR_STR |
2721 | "Interface name or neighbor tag\n" | |
2722 | "Enable BGP on interface\n" | |
3a2d747c | 2723 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2724 | AS_STR |
3a2d747c QY |
2725 | "Internal BGP peer\n" |
2726 | "External BGP peer\n") | |
b3a39dc5 | 2727 | { |
c500ae40 DW |
2728 | int idx_word = 1; |
2729 | int idx_remote_as = 4; | |
2730 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2731 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2732 | } |
2733 | ||
2734 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2735 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2736 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2737 | NEIGHBOR_STR |
2738 | "Interface name or neighbor tag\n" | |
3a2d747c | 2739 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2740 | "Enable BGP on interface\n" |
3a2d747c | 2741 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2742 | AS_STR |
3a2d747c QY |
2743 | "Internal BGP peer\n" |
2744 | "External BGP peer\n") | |
b3a39dc5 | 2745 | { |
c500ae40 DW |
2746 | int idx_word = 1; |
2747 | int idx_remote_as = 5; | |
2748 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2749 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2750 | } |
2751 | ||
718e3744 | 2752 | DEFUN (neighbor_peer_group, |
2753 | neighbor_peer_group_cmd, | |
2754 | "neighbor WORD peer-group", | |
2755 | NEIGHBOR_STR | |
a80beece | 2756 | "Interface name or neighbor tag\n" |
718e3744 | 2757 | "Configure peer-group\n") |
2758 | { | |
cdc2d765 | 2759 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2760 | int idx_word = 1; |
a80beece | 2761 | struct peer *peer; |
718e3744 | 2762 | struct peer_group *group; |
2763 | ||
c500ae40 | 2764 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2765 | if (peer) |
2766 | { | |
2767 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2768 | return CMD_WARNING; | |
2769 | } | |
718e3744 | 2770 | |
c500ae40 | 2771 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2772 | if (! group) |
2773 | return CMD_WARNING; | |
2774 | ||
2775 | return CMD_SUCCESS; | |
2776 | } | |
2777 | ||
2778 | DEFUN (no_neighbor, | |
2779 | no_neighbor_cmd, | |
a636c635 | 2780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> [remote-as <(1-4294967295)|internal|external>]", |
718e3744 | 2781 | NO_STR |
2782 | NEIGHBOR_STR | |
3a2d747c QY |
2783 | NEIGHBOR_ADDR_STR2 |
2784 | "Specify a BGP neighbor\n" | |
2785 | AS_STR | |
2786 | "Internal BGP peer\n" | |
2787 | "External BGP peer\n") | |
718e3744 | 2788 | { |
cdc2d765 | 2789 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2790 | int idx_peer = 2; |
718e3744 | 2791 | int ret; |
2792 | union sockunion su; | |
2793 | struct peer_group *group; | |
2794 | struct peer *peer; | |
1ff9a340 | 2795 | struct peer *other; |
718e3744 | 2796 | |
c500ae40 | 2797 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2798 | if (ret < 0) |
2799 | { | |
a80beece | 2800 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2801 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2802 | if (peer) |
2803 | { | |
4a04e5f7 | 2804 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2805 | if (peer->ifp) | |
2806 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2807 | peer_delete (peer); |
2808 | return CMD_SUCCESS; | |
2809 | } | |
2810 | ||
cdc2d765 | 2811 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2812 | if (group) |
2813 | peer_group_delete (group); | |
2814 | else | |
2815 | { | |
2816 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2817 | return CMD_WARNING; | |
2818 | } | |
2819 | } | |
2820 | else | |
2821 | { | |
cdc2d765 | 2822 | peer = peer_lookup (bgp, &su); |
718e3744 | 2823 | if (peer) |
1ff9a340 | 2824 | { |
f14e6fdb DS |
2825 | if (peer_dynamic_neighbor (peer)) |
2826 | { | |
2827 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2828 | VTY_NEWLINE); | |
2829 | return CMD_WARNING; | |
2830 | } | |
2831 | ||
1ff9a340 DS |
2832 | other = peer->doppelganger; |
2833 | peer_delete (peer); | |
2834 | if (other && other->status != Deleted) | |
2835 | peer_delete(other); | |
2836 | } | |
718e3744 | 2837 | } |
2838 | ||
2839 | return CMD_SUCCESS; | |
2840 | } | |
2841 | ||
a80beece DS |
2842 | DEFUN (no_neighbor_interface_config, |
2843 | no_neighbor_interface_config_cmd, | |
31500417 | 2844 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2845 | NO_STR |
2846 | NEIGHBOR_STR | |
2847 | "Interface name\n" | |
31500417 DW |
2848 | "Configure BGP on interface\n" |
2849 | "Enable BGP with v6 link-local only\n" | |
2850 | "Member of the peer-group\n" | |
16cedbb0 | 2851 | "Peer-group name\n" |
3a2d747c QY |
2852 | "Specify a BGP neighbor\n" |
2853 | AS_STR | |
2854 | "Internal BGP peer\n" | |
2855 | "External BGP peer\n") | |
a80beece | 2856 | { |
cdc2d765 | 2857 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2858 | int idx_word = 2; |
a80beece DS |
2859 | struct peer *peer; |
2860 | ||
2861 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2862 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2863 | if (peer) |
2864 | { | |
4a04e5f7 | 2865 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2866 | if (peer->ifp) | |
2867 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2868 | peer_delete (peer); |
2869 | } | |
2870 | else | |
2871 | { | |
2872 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2873 | return CMD_WARNING; | |
2874 | } | |
2875 | return CMD_SUCCESS; | |
2876 | } | |
2877 | ||
718e3744 | 2878 | DEFUN (no_neighbor_peer_group, |
2879 | no_neighbor_peer_group_cmd, | |
2880 | "no neighbor WORD peer-group", | |
2881 | NO_STR | |
2882 | NEIGHBOR_STR | |
2883 | "Neighbor tag\n" | |
2884 | "Configure peer-group\n") | |
2885 | { | |
cdc2d765 | 2886 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2887 | int idx_word = 2; |
718e3744 | 2888 | struct peer_group *group; |
2889 | ||
cdc2d765 | 2890 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2891 | if (group) |
2892 | peer_group_delete (group); | |
2893 | else | |
2894 | { | |
2895 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2896 | return CMD_WARNING; | |
2897 | } | |
2898 | return CMD_SUCCESS; | |
2899 | } | |
2900 | ||
a80beece DS |
2901 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2902 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2903 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2904 | NO_STR |
2905 | NEIGHBOR_STR | |
a80beece | 2906 | "Interface name or neighbor tag\n" |
718e3744 | 2907 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2908 | AS_STR |
2909 | "Internal BGP peer\n" | |
2910 | "External BGP peer\n") | |
718e3744 | 2911 | { |
cdc2d765 | 2912 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2913 | int idx_word = 2; |
718e3744 | 2914 | struct peer_group *group; |
a80beece DS |
2915 | struct peer *peer; |
2916 | ||
2917 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2918 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2919 | if (peer) |
2920 | { | |
0299c004 | 2921 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
2922 | return CMD_SUCCESS; |
2923 | } | |
718e3744 | 2924 | |
cdc2d765 | 2925 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2926 | if (group) |
2927 | peer_group_remote_as_delete (group); | |
2928 | else | |
2929 | { | |
a80beece | 2930 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 2931 | return CMD_WARNING; |
2932 | } | |
2933 | return CMD_SUCCESS; | |
2934 | } | |
6b0655a2 | 2935 | |
718e3744 | 2936 | DEFUN (neighbor_local_as, |
2937 | neighbor_local_as_cmd, | |
9ccf14f7 | 2938 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2939 | NEIGHBOR_STR |
2940 | NEIGHBOR_ADDR_STR2 | |
2941 | "Specify a local-as number\n" | |
2942 | "AS number used as local AS\n") | |
2943 | { | |
c500ae40 DW |
2944 | int idx_peer = 1; |
2945 | int idx_number = 3; | |
718e3744 | 2946 | struct peer *peer; |
2947 | int ret; | |
e14fda0f | 2948 | as_t as; |
718e3744 | 2949 | |
c500ae40 | 2950 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2951 | if (! peer) |
2952 | return CMD_WARNING; | |
2953 | ||
b6f1faf0 | 2954 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 2955 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 2956 | return bgp_vty_return (vty, ret); |
2957 | } | |
2958 | ||
2959 | DEFUN (neighbor_local_as_no_prepend, | |
2960 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2961 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2962 | NEIGHBOR_STR |
2963 | NEIGHBOR_ADDR_STR2 | |
2964 | "Specify a local-as number\n" | |
2965 | "AS number used as local AS\n" | |
2966 | "Do not prepend local-as to updates from ebgp peers\n") | |
2967 | { | |
c500ae40 DW |
2968 | int idx_peer = 1; |
2969 | int idx_number = 3; | |
718e3744 | 2970 | struct peer *peer; |
2971 | int ret; | |
e14fda0f | 2972 | as_t as; |
718e3744 | 2973 | |
c500ae40 | 2974 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2975 | if (! peer) |
2976 | return CMD_WARNING; | |
2977 | ||
b6f1faf0 | 2978 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 2979 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 2980 | return bgp_vty_return (vty, ret); |
2981 | } | |
2982 | ||
9d3f9705 AC |
2983 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2984 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2985 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2986 | NEIGHBOR_STR |
2987 | NEIGHBOR_ADDR_STR2 | |
2988 | "Specify a local-as number\n" | |
2989 | "AS number used as local AS\n" | |
2990 | "Do not prepend local-as to updates from ebgp peers\n" | |
2991 | "Do not prepend local-as to updates from ibgp peers\n") | |
2992 | { | |
c500ae40 DW |
2993 | int idx_peer = 1; |
2994 | int idx_number = 3; | |
9d3f9705 AC |
2995 | struct peer *peer; |
2996 | int ret; | |
e14fda0f | 2997 | as_t as; |
9d3f9705 | 2998 | |
c500ae40 | 2999 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3000 | if (! peer) |
3001 | return CMD_WARNING; | |
3002 | ||
b6f1faf0 | 3003 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3004 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3005 | return bgp_vty_return (vty, ret); |
3006 | } | |
3007 | ||
718e3744 | 3008 | DEFUN (no_neighbor_local_as, |
3009 | no_neighbor_local_as_cmd, | |
a636c635 | 3010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3011 | NO_STR |
3012 | NEIGHBOR_STR | |
3013 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3014 | "Specify a local-as number\n" |
3015 | "AS number used as local AS\n" | |
3016 | "Do not prepend local-as to updates from ebgp peers\n" | |
3017 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3018 | { |
c500ae40 | 3019 | int idx_peer = 2; |
718e3744 | 3020 | struct peer *peer; |
3021 | int ret; | |
3022 | ||
c500ae40 | 3023 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3024 | if (! peer) |
3025 | return CMD_WARNING; | |
3026 | ||
3027 | ret = peer_local_as_unset (peer); | |
3028 | return bgp_vty_return (vty, ret); | |
3029 | } | |
3030 | ||
718e3744 | 3031 | |
9d3f9705 | 3032 | |
6b0655a2 | 3033 | |
3f9c7369 DS |
3034 | DEFUN (neighbor_solo, |
3035 | neighbor_solo_cmd, | |
9ccf14f7 | 3036 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3037 | NEIGHBOR_STR |
3038 | NEIGHBOR_ADDR_STR2 | |
3039 | "Solo peer - part of its own update group\n") | |
3040 | { | |
c500ae40 | 3041 | int idx_peer = 1; |
3f9c7369 DS |
3042 | struct peer *peer; |
3043 | int ret; | |
3044 | ||
c500ae40 | 3045 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3046 | if (! peer) |
3047 | return CMD_WARNING; | |
3048 | ||
3049 | ret = update_group_adjust_soloness(peer, 1); | |
3050 | return bgp_vty_return (vty, ret); | |
3051 | } | |
3052 | ||
3053 | DEFUN (no_neighbor_solo, | |
3054 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3055 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3056 | NO_STR |
3057 | NEIGHBOR_STR | |
3058 | NEIGHBOR_ADDR_STR2 | |
3059 | "Solo peer - part of its own update group\n") | |
3060 | { | |
c500ae40 | 3061 | int idx_peer = 2; |
3f9c7369 DS |
3062 | struct peer *peer; |
3063 | int ret; | |
3064 | ||
c500ae40 | 3065 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3066 | if (! peer) |
3067 | return CMD_WARNING; | |
3068 | ||
3069 | ret = update_group_adjust_soloness(peer, 0); | |
3070 | return bgp_vty_return (vty, ret); | |
3071 | } | |
3072 | ||
0df7c91f PJ |
3073 | DEFUN (neighbor_password, |
3074 | neighbor_password_cmd, | |
9ccf14f7 | 3075 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3076 | NEIGHBOR_STR |
3077 | NEIGHBOR_ADDR_STR2 | |
3078 | "Set a password\n" | |
3079 | "The password\n") | |
3080 | { | |
c500ae40 DW |
3081 | int idx_peer = 1; |
3082 | int idx_line = 3; | |
0df7c91f PJ |
3083 | struct peer *peer; |
3084 | int ret; | |
3085 | ||
c500ae40 | 3086 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3087 | if (! peer) |
3088 | return CMD_WARNING; | |
3089 | ||
c500ae40 | 3090 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3091 | return bgp_vty_return (vty, ret); |
3092 | } | |
3093 | ||
3094 | DEFUN (no_neighbor_password, | |
3095 | no_neighbor_password_cmd, | |
a636c635 | 3096 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3097 | NO_STR |
3098 | NEIGHBOR_STR | |
3099 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3100 | "Set a password\n" |
3101 | "The password\n") | |
0df7c91f | 3102 | { |
c500ae40 | 3103 | int idx_peer = 2; |
0df7c91f PJ |
3104 | struct peer *peer; |
3105 | int ret; | |
3106 | ||
c500ae40 | 3107 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3108 | if (! peer) |
3109 | return CMD_WARNING; | |
3110 | ||
3111 | ret = peer_password_unset (peer); | |
3112 | return bgp_vty_return (vty, ret); | |
3113 | } | |
6b0655a2 | 3114 | |
813d4307 | 3115 | |
718e3744 | 3116 | DEFUN (neighbor_activate, |
3117 | neighbor_activate_cmd, | |
9ccf14f7 | 3118 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3119 | NEIGHBOR_STR |
3120 | NEIGHBOR_ADDR_STR2 | |
3121 | "Enable the Address Family for this Neighbor\n") | |
3122 | { | |
c500ae40 | 3123 | int idx_peer = 1; |
c8560b44 | 3124 | int ret; |
718e3744 | 3125 | struct peer *peer; |
3126 | ||
c500ae40 | 3127 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3128 | if (! peer) |
3129 | return CMD_WARNING; | |
3130 | ||
c8560b44 | 3131 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3132 | |
c8560b44 DW |
3133 | if (ret) |
3134 | return CMD_WARNING; | |
718e3744 | 3135 | return CMD_SUCCESS; |
3136 | } | |
3137 | ||
3138 | DEFUN (no_neighbor_activate, | |
3139 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3140 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3141 | NO_STR |
3142 | NEIGHBOR_STR | |
3143 | NEIGHBOR_ADDR_STR2 | |
3144 | "Enable the Address Family for this Neighbor\n") | |
3145 | { | |
c500ae40 | 3146 | int idx_peer = 2; |
718e3744 | 3147 | int ret; |
3148 | struct peer *peer; | |
3149 | ||
3150 | /* Lookup peer. */ | |
c500ae40 | 3151 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3152 | if (! peer) |
3153 | return CMD_WARNING; | |
3154 | ||
3155 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3156 | ||
c8560b44 DW |
3157 | if (ret) |
3158 | return CMD_WARNING; | |
3159 | return CMD_SUCCESS; | |
718e3744 | 3160 | } |
6b0655a2 | 3161 | |
718e3744 | 3162 | DEFUN (neighbor_set_peer_group, |
3163 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3164 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3165 | NEIGHBOR_STR |
a80beece | 3166 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3167 | "Member of the peer-group\n" |
16cedbb0 | 3168 | "Peer-group name\n") |
718e3744 | 3169 | { |
cdc2d765 | 3170 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3171 | int idx_peer = 1; |
3172 | int idx_word = 3; | |
718e3744 | 3173 | int ret; |
3174 | as_t as; | |
3175 | union sockunion su; | |
a80beece | 3176 | struct peer *peer; |
718e3744 | 3177 | struct peer_group *group; |
3178 | ||
a80beece | 3179 | peer = NULL; |
718e3744 | 3180 | |
c500ae40 | 3181 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3182 | if (ret < 0) |
3183 | { | |
c500ae40 | 3184 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3185 | if (!peer) |
3186 | { | |
c500ae40 | 3187 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3188 | return CMD_WARNING; |
3189 | } | |
3190 | } | |
3191 | else | |
3192 | { | |
6aeb9e78 | 3193 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3194 | { |
3195 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3196 | VTY_NEWLINE); | |
3197 | return CMD_WARNING; | |
3198 | } | |
f14e6fdb DS |
3199 | |
3200 | /* Disallow for dynamic neighbor. */ | |
3201 | peer = peer_lookup (bgp, &su); | |
3202 | if (peer && peer_dynamic_neighbor (peer)) | |
3203 | { | |
3204 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3205 | VTY_NEWLINE); | |
3206 | return CMD_WARNING; | |
3207 | } | |
718e3744 | 3208 | } |
3209 | ||
c500ae40 | 3210 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3211 | if (! group) |
3212 | { | |
3213 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3214 | return CMD_WARNING; | |
3215 | } | |
3216 | ||
c8560b44 | 3217 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3218 | |
3219 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3220 | { | |
aea339f7 | 3221 | vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE); |
718e3744 | 3222 | return CMD_WARNING; |
3223 | } | |
3224 | ||
3225 | return bgp_vty_return (vty, ret); | |
3226 | } | |
3227 | ||
3228 | DEFUN (no_neighbor_set_peer_group, | |
3229 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3230 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3231 | NO_STR |
3232 | NEIGHBOR_STR | |
a80beece | 3233 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3234 | "Member of the peer-group\n" |
16cedbb0 | 3235 | "Peer-group name\n") |
718e3744 | 3236 | { |
cdc2d765 | 3237 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3238 | int idx_peer = 2; |
3239 | int idx_word = 4; | |
718e3744 | 3240 | int ret; |
718e3744 | 3241 | struct peer *peer; |
3242 | struct peer_group *group; | |
3243 | ||
c500ae40 | 3244 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3245 | if (! peer) |
3246 | return CMD_WARNING; | |
3247 | ||
c500ae40 | 3248 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3249 | if (! group) |
3250 | { | |
3251 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3252 | return CMD_WARNING; | |
3253 | } | |
3254 | ||
c8560b44 | 3255 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3256 | |
3257 | return bgp_vty_return (vty, ret); | |
3258 | } | |
6b0655a2 | 3259 | |
94f2b392 | 3260 | static int |
e52702f2 | 3261 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3262 | u_int16_t flag, int set) |
718e3744 | 3263 | { |
3264 | int ret; | |
3265 | struct peer *peer; | |
3266 | ||
3267 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3268 | if (! peer) | |
3269 | return CMD_WARNING; | |
3270 | ||
8cdabf90 SK |
3271 | /* |
3272 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3273 | * we should not accept disable-connected-check. | |
3274 | */ | |
3275 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3276 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3277 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3278 | return CMD_WARNING; | |
3279 | } | |
3280 | ||
718e3744 | 3281 | if (set) |
3282 | ret = peer_flag_set (peer, flag); | |
3283 | else | |
3284 | ret = peer_flag_unset (peer, flag); | |
3285 | ||
3286 | return bgp_vty_return (vty, ret); | |
3287 | } | |
3288 | ||
94f2b392 | 3289 | static int |
fd79ac91 | 3290 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3291 | { |
3292 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3293 | } | |
3294 | ||
94f2b392 | 3295 | static int |
fd79ac91 | 3296 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3297 | { |
3298 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3299 | } | |
3300 | ||
3301 | /* neighbor passive. */ | |
3302 | DEFUN (neighbor_passive, | |
3303 | neighbor_passive_cmd, | |
9ccf14f7 | 3304 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3305 | NEIGHBOR_STR |
3306 | NEIGHBOR_ADDR_STR2 | |
3307 | "Don't send open messages to this neighbor\n") | |
3308 | { | |
c500ae40 DW |
3309 | int idx_peer = 1; |
3310 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3311 | } |
3312 | ||
3313 | DEFUN (no_neighbor_passive, | |
3314 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3316 | NO_STR |
3317 | NEIGHBOR_STR | |
3318 | NEIGHBOR_ADDR_STR2 | |
3319 | "Don't send open messages to this neighbor\n") | |
3320 | { | |
c500ae40 DW |
3321 | int idx_peer = 2; |
3322 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3323 | } |
6b0655a2 | 3324 | |
718e3744 | 3325 | /* neighbor shutdown. */ |
3326 | DEFUN (neighbor_shutdown, | |
3327 | neighbor_shutdown_cmd, | |
9ccf14f7 | 3328 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3329 | NEIGHBOR_STR |
3330 | NEIGHBOR_ADDR_STR2 | |
3331 | "Administratively shut down this neighbor\n") | |
3332 | { | |
c500ae40 DW |
3333 | int idx_peer = 1; |
3334 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3335 | } |
3336 | ||
3337 | DEFUN (no_neighbor_shutdown, | |
3338 | no_neighbor_shutdown_cmd, | |
9ccf14f7 | 3339 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3340 | NO_STR |
3341 | NEIGHBOR_STR | |
3342 | NEIGHBOR_ADDR_STR2 | |
3343 | "Administratively shut down this neighbor\n") | |
3344 | { | |
c500ae40 DW |
3345 | int idx_peer = 2; |
3346 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3347 | } |
6b0655a2 | 3348 | |
718e3744 | 3349 | /* neighbor capability dynamic. */ |
3350 | DEFUN (neighbor_capability_dynamic, | |
3351 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3352 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3353 | NEIGHBOR_STR |
3354 | NEIGHBOR_ADDR_STR2 | |
3355 | "Advertise capability to the peer\n" | |
3356 | "Advertise dynamic capability to this neighbor\n") | |
3357 | { | |
c500ae40 DW |
3358 | int idx_peer = 1; |
3359 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3360 | } |
3361 | ||
3362 | DEFUN (no_neighbor_capability_dynamic, | |
3363 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3364 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3365 | NO_STR |
3366 | NEIGHBOR_STR | |
3367 | NEIGHBOR_ADDR_STR2 | |
3368 | "Advertise capability to the peer\n" | |
3369 | "Advertise dynamic capability to this neighbor\n") | |
3370 | { | |
c500ae40 DW |
3371 | int idx_peer = 2; |
3372 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3373 | } |
6b0655a2 | 3374 | |
718e3744 | 3375 | /* neighbor dont-capability-negotiate */ |
3376 | DEFUN (neighbor_dont_capability_negotiate, | |
3377 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3378 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3379 | NEIGHBOR_STR |
3380 | NEIGHBOR_ADDR_STR2 | |
3381 | "Do not perform capability negotiation\n") | |
3382 | { | |
c500ae40 DW |
3383 | int idx_peer = 1; |
3384 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3385 | } |
3386 | ||
3387 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3388 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3389 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3390 | NO_STR |
3391 | NEIGHBOR_STR | |
3392 | NEIGHBOR_ADDR_STR2 | |
3393 | "Do not perform capability negotiation\n") | |
3394 | { | |
c500ae40 DW |
3395 | int idx_peer = 2; |
3396 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3397 | } |
6b0655a2 | 3398 | |
8a92a8a0 DS |
3399 | /* neighbor capability extended next hop encoding */ |
3400 | DEFUN (neighbor_capability_enhe, | |
3401 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3402 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3403 | NEIGHBOR_STR |
3404 | NEIGHBOR_ADDR_STR2 | |
3405 | "Advertise capability to the peer\n" | |
3406 | "Advertise extended next-hop capability to the peer\n") | |
3407 | { | |
c500ae40 DW |
3408 | int idx_peer = 1; |
3409 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3410 | } |
3411 | ||
3412 | DEFUN (no_neighbor_capability_enhe, | |
3413 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3414 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3415 | NO_STR |
3416 | NEIGHBOR_STR | |
3417 | NEIGHBOR_ADDR_STR2 | |
3418 | "Advertise capability to the peer\n" | |
3419 | "Advertise extended next-hop capability to the peer\n") | |
3420 | { | |
c500ae40 DW |
3421 | int idx_peer = 2; |
3422 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3423 | } |
3424 | ||
94f2b392 | 3425 | static int |
fd79ac91 | 3426 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3427 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3428 | { |
3429 | int ret; | |
3430 | struct peer *peer; | |
3431 | ||
3432 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3433 | if (! peer) | |
3434 | return CMD_WARNING; | |
3435 | ||
3436 | if (set) | |
3437 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3438 | else | |
3439 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3440 | ||
3441 | return bgp_vty_return (vty, ret); | |
3442 | } | |
3443 | ||
94f2b392 | 3444 | static int |
fd79ac91 | 3445 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3446 | safi_t safi, u_int32_t flag) |
718e3744 | 3447 | { |
3448 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3449 | } | |
3450 | ||
94f2b392 | 3451 | static int |
fd79ac91 | 3452 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3453 | safi_t safi, u_int32_t flag) |
718e3744 | 3454 | { |
3455 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3456 | } | |
6b0655a2 | 3457 | |
718e3744 | 3458 | /* neighbor capability orf prefix-list. */ |
3459 | DEFUN (neighbor_capability_orf_prefix, | |
3460 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3461 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3462 | NEIGHBOR_STR |
3463 | NEIGHBOR_ADDR_STR2 | |
3464 | "Advertise capability to the peer\n" | |
3465 | "Advertise ORF capability to the peer\n" | |
3466 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3467 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3468 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3469 | "Capability to SEND the ORF to this neighbor\n") | |
3470 | { | |
c500ae40 DW |
3471 | int idx_peer = 1; |
3472 | int idx_send_recv = 5; | |
718e3744 | 3473 | u_int16_t flag = 0; |
3474 | ||
c500ae40 | 3475 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3476 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3477 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3478 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3479 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3480 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3481 | else | |
3482 | return CMD_WARNING; | |
3483 | ||
c500ae40 | 3484 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3485 | bgp_node_safi (vty), flag); |
3486 | } | |
3487 | ||
3488 | DEFUN (no_neighbor_capability_orf_prefix, | |
3489 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3490 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3491 | NO_STR |
3492 | NEIGHBOR_STR | |
3493 | NEIGHBOR_ADDR_STR2 | |
3494 | "Advertise capability to the peer\n" | |
3495 | "Advertise ORF capability to the peer\n" | |
3496 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3497 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3498 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3499 | "Capability to SEND the ORF to this neighbor\n") | |
3500 | { | |
c500ae40 DW |
3501 | int idx_peer = 2; |
3502 | int idx_send_recv = 6; | |
718e3744 | 3503 | u_int16_t flag = 0; |
3504 | ||
c500ae40 | 3505 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3506 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3507 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3508 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3509 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3510 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3511 | else | |
3512 | return CMD_WARNING; | |
3513 | ||
c500ae40 | 3514 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3515 | bgp_node_safi (vty), flag); |
3516 | } | |
6b0655a2 | 3517 | |
718e3744 | 3518 | /* neighbor next-hop-self. */ |
3519 | DEFUN (neighbor_nexthop_self, | |
3520 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3521 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3522 | NEIGHBOR_STR |
3523 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3524 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3525 | { |
c500ae40 DW |
3526 | int idx_peer = 1; |
3527 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3528 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3529 | } | |
9e7a53c1 | 3530 | |
a538debe DS |
3531 | /* neighbor next-hop-self. */ |
3532 | DEFUN (neighbor_nexthop_self_force, | |
3533 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3534 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3535 | NEIGHBOR_STR |
3536 | NEIGHBOR_ADDR_STR2 | |
3537 | "Disable the next hop calculation for this neighbor\n" | |
3538 | "Set the next hop to self for reflected routes\n") | |
3539 | { | |
c500ae40 DW |
3540 | int idx_peer = 1; |
3541 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3542 | bgp_node_safi (vty), |
88b8ed8d | 3543 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3544 | } |
3545 | ||
3546 | DEFUN (no_neighbor_nexthop_self, | |
3547 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3548 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3549 | NO_STR |
3550 | NEIGHBOR_STR | |
3551 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3552 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3553 | { |
c500ae40 DW |
3554 | int idx_peer = 2; |
3555 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3556 | bgp_node_safi (vty), |
88b8ed8d | 3557 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3558 | } |
6b0655a2 | 3559 | |
88b8ed8d | 3560 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3561 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3562 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3563 | NO_STR |
3564 | NEIGHBOR_STR | |
3565 | NEIGHBOR_ADDR_STR2 | |
3566 | "Disable the next hop calculation for this neighbor\n" | |
3567 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3568 | { |
c500ae40 DW |
3569 | int idx_peer = 2; |
3570 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3571 | bgp_node_safi (vty), |
3572 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3573 | } | |
a538debe | 3574 | |
c7122e14 DS |
3575 | /* neighbor as-override */ |
3576 | DEFUN (neighbor_as_override, | |
3577 | neighbor_as_override_cmd, | |
9ccf14f7 | 3578 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3579 | NEIGHBOR_STR |
3580 | NEIGHBOR_ADDR_STR2 | |
3581 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3582 | { | |
c500ae40 DW |
3583 | int idx_peer = 1; |
3584 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3585 | bgp_node_safi (vty), |
3586 | PEER_FLAG_AS_OVERRIDE); | |
3587 | } | |
3588 | ||
3589 | DEFUN (no_neighbor_as_override, | |
3590 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3592 | NO_STR |
3593 | NEIGHBOR_STR | |
3594 | NEIGHBOR_ADDR_STR2 | |
3595 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3596 | { | |
c500ae40 DW |
3597 | int idx_peer = 2; |
3598 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3599 | bgp_node_safi (vty), |
3600 | PEER_FLAG_AS_OVERRIDE); | |
3601 | } | |
3602 | ||
718e3744 | 3603 | /* neighbor remove-private-AS. */ |
3604 | DEFUN (neighbor_remove_private_as, | |
3605 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3606 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3607 | NEIGHBOR_STR |
3608 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3609 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3610 | { |
c500ae40 DW |
3611 | int idx_peer = 1; |
3612 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3613 | bgp_node_safi (vty), |
3614 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3615 | } | |
3616 | ||
5000f21c DS |
3617 | DEFUN (neighbor_remove_private_as_all, |
3618 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3619 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3620 | NEIGHBOR_STR |
3621 | NEIGHBOR_ADDR_STR2 | |
3622 | "Remove private ASNs in outbound updates\n" | |
3623 | "Apply to all AS numbers") | |
3624 | { | |
c500ae40 DW |
3625 | int idx_peer = 1; |
3626 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3627 | bgp_node_safi (vty), |
5000f21c DS |
3628 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3629 | } | |
3630 | ||
3631 | DEFUN (neighbor_remove_private_as_replace_as, | |
3632 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3633 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3634 | NEIGHBOR_STR |
3635 | NEIGHBOR_ADDR_STR2 | |
3636 | "Remove private ASNs in outbound updates\n" | |
3637 | "Replace private ASNs with our ASN in outbound updates\n") | |
3638 | { | |
c500ae40 DW |
3639 | int idx_peer = 1; |
3640 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3641 | bgp_node_safi (vty), |
5000f21c DS |
3642 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3643 | } | |
3644 | ||
3645 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3646 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3647 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3648 | NEIGHBOR_STR |
3649 | NEIGHBOR_ADDR_STR2 | |
3650 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3651 | "Apply to all AS numbers\n" |
5000f21c DS |
3652 | "Replace private ASNs with our ASN in outbound updates\n") |
3653 | { | |
c500ae40 DW |
3654 | int idx_peer = 1; |
3655 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3656 | bgp_node_safi (vty), |
88b8ed8d | 3657 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3658 | } |
3659 | ||
718e3744 | 3660 | DEFUN (no_neighbor_remove_private_as, |
3661 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3662 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3663 | NO_STR |
3664 | NEIGHBOR_STR | |
3665 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3666 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3667 | { |
c500ae40 DW |
3668 | int idx_peer = 2; |
3669 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3670 | bgp_node_safi (vty), |
88b8ed8d | 3671 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3672 | } |
6b0655a2 | 3673 | |
88b8ed8d | 3674 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3675 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3676 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3677 | NO_STR |
3678 | NEIGHBOR_STR | |
3679 | NEIGHBOR_ADDR_STR2 | |
3680 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3681 | "Apply to all AS numbers\n") |
88b8ed8d | 3682 | { |
c500ae40 DW |
3683 | int idx_peer = 2; |
3684 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3685 | bgp_node_safi (vty), |
3686 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3687 | } | |
5000f21c | 3688 | |
88b8ed8d | 3689 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3690 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3692 | NO_STR |
3693 | NEIGHBOR_STR | |
3694 | NEIGHBOR_ADDR_STR2 | |
3695 | "Remove private ASNs in outbound updates\n" | |
3696 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3697 | { |
c500ae40 DW |
3698 | int idx_peer = 2; |
3699 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3700 | bgp_node_safi (vty), |
3701 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3702 | } | |
5000f21c | 3703 | |
88b8ed8d | 3704 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3705 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3706 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3707 | NO_STR |
3708 | NEIGHBOR_STR | |
3709 | NEIGHBOR_ADDR_STR2 | |
3710 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3711 | "Apply to all AS numbers\n" |
5000f21c | 3712 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3713 | { |
c500ae40 DW |
3714 | int idx_peer = 2; |
3715 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3716 | bgp_node_safi (vty), |
3717 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3718 | } | |
5000f21c DS |
3719 | |
3720 | ||
718e3744 | 3721 | /* neighbor send-community. */ |
3722 | DEFUN (neighbor_send_community, | |
3723 | neighbor_send_community_cmd, | |
9ccf14f7 | 3724 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3725 | NEIGHBOR_STR |
3726 | NEIGHBOR_ADDR_STR2 | |
3727 | "Send Community attribute to this neighbor\n") | |
3728 | { | |
c500ae40 DW |
3729 | int idx_peer = 1; |
3730 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3731 | bgp_node_safi (vty), |
3732 | PEER_FLAG_SEND_COMMUNITY); | |
3733 | } | |
3734 | ||
3735 | DEFUN (no_neighbor_send_community, | |
3736 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3737 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3738 | NO_STR |
3739 | NEIGHBOR_STR | |
3740 | NEIGHBOR_ADDR_STR2 | |
3741 | "Send Community attribute to this neighbor\n") | |
3742 | { | |
c500ae40 DW |
3743 | int idx_peer = 2; |
3744 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3745 | bgp_node_safi (vty), |
3746 | PEER_FLAG_SEND_COMMUNITY); | |
3747 | } | |
6b0655a2 | 3748 | |
718e3744 | 3749 | /* neighbor send-community extended. */ |
3750 | DEFUN (neighbor_send_community_type, | |
3751 | neighbor_send_community_type_cmd, | |
57d187bc | 3752 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3753 | NEIGHBOR_STR |
3754 | NEIGHBOR_ADDR_STR2 | |
3755 | "Send Community attribute to this neighbor\n" | |
3756 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3757 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3758 | "Send Extended Community attributes\n" |
57d187bc JS |
3759 | "Send Standard Community attributes\n" |
3760 | "Send Large Community attributes\n") | |
718e3744 | 3761 | { |
4c4ff4c1 QY |
3762 | int idx = 0; |
3763 | u_int32_t flag = 0; | |
718e3744 | 3764 | |
4c4ff4c1 QY |
3765 | char *peer = argv[1]->arg; |
3766 | ||
3767 | if (argv_find (argv, argc, "standard", &idx)) | |
3768 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3769 | else if (argv_find (argv, argc, "extended", &idx)) | |
3770 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3771 | else if (argv_find (argv, argc, "large", &idx)) |
3772 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3773 | else if (argv_find (argv, argc, "both", &idx)) | |
3774 | { | |
3775 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3776 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3777 | } | |
4c4ff4c1 | 3778 | else |
57d187bc JS |
3779 | { |
3780 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3781 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3782 | SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3783 | } | |
4c4ff4c1 QY |
3784 | |
3785 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3786 | } |
3787 | ||
3788 | DEFUN (no_neighbor_send_community_type, | |
3789 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3790 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3791 | NO_STR |
3792 | NEIGHBOR_STR | |
3793 | NEIGHBOR_ADDR_STR2 | |
3794 | "Send Community attribute to this neighbor\n" | |
3795 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3796 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3797 | "Send Extended Community attributes\n" |
57d187bc JS |
3798 | "Send Standard Community attributes\n" |
3799 | "Send Large Community attributes\n") | |
718e3744 | 3800 | { |
c500ae40 DW |
3801 | int idx_peer = 2; |
3802 | int idx_type = 4; | |
3803 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3804 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3805 | bgp_node_safi (vty), |
3806 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3807 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3808 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3809 | bgp_node_safi (vty), |
3810 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
57d187bc JS |
3811 | if (strncmp (argv[idx_type]->arg, "l", 1) == 0) |
3812 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3813 | bgp_node_safi (vty), | |
3814 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3815 | if (strncmp (argv[idx_type]->arg, "b", 1) == 0) | |
3816 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
3817 | bgp_node_safi (vty), | |
3818 | PEER_FLAG_SEND_COMMUNITY | | |
3819 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
718e3744 | 3820 | |
c500ae40 | 3821 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3822 | bgp_node_safi (vty), |
3823 | (PEER_FLAG_SEND_COMMUNITY | | |
57d187bc JS |
3824 | PEER_FLAG_SEND_EXT_COMMUNITY| |
3825 | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
718e3744 | 3826 | } |
6b0655a2 | 3827 | |
718e3744 | 3828 | /* neighbor soft-reconfig. */ |
3829 | DEFUN (neighbor_soft_reconfiguration, | |
3830 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3831 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3832 | NEIGHBOR_STR |
3833 | NEIGHBOR_ADDR_STR2 | |
3834 | "Per neighbor soft reconfiguration\n" | |
3835 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3836 | { | |
c500ae40 DW |
3837 | int idx_peer = 1; |
3838 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3839 | bgp_node_afi (vty), bgp_node_safi (vty), |
3840 | PEER_FLAG_SOFT_RECONFIG); | |
3841 | } | |
3842 | ||
3843 | DEFUN (no_neighbor_soft_reconfiguration, | |
3844 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3845 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3846 | NO_STR |
3847 | NEIGHBOR_STR | |
3848 | NEIGHBOR_ADDR_STR2 | |
3849 | "Per neighbor soft reconfiguration\n" | |
3850 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3851 | { | |
c500ae40 DW |
3852 | int idx_peer = 2; |
3853 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3854 | bgp_node_afi (vty), bgp_node_safi (vty), |
3855 | PEER_FLAG_SOFT_RECONFIG); | |
3856 | } | |
6b0655a2 | 3857 | |
718e3744 | 3858 | DEFUN (neighbor_route_reflector_client, |
3859 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3860 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3861 | NEIGHBOR_STR |
3862 | NEIGHBOR_ADDR_STR2 | |
3863 | "Configure a neighbor as Route Reflector client\n") | |
3864 | { | |
c500ae40 | 3865 | int idx_peer = 1; |
718e3744 | 3866 | struct peer *peer; |
3867 | ||
3868 | ||
c500ae40 | 3869 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3870 | if (! peer) |
3871 | return CMD_WARNING; | |
3872 | ||
c500ae40 | 3873 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3874 | bgp_node_safi (vty), |
3875 | PEER_FLAG_REFLECTOR_CLIENT); | |
3876 | } | |
3877 | ||
3878 | DEFUN (no_neighbor_route_reflector_client, | |
3879 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3880 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3881 | NO_STR |
3882 | NEIGHBOR_STR | |
3883 | NEIGHBOR_ADDR_STR2 | |
3884 | "Configure a neighbor as Route Reflector client\n") | |
3885 | { | |
c500ae40 DW |
3886 | int idx_peer = 2; |
3887 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3888 | bgp_node_safi (vty), |
3889 | PEER_FLAG_REFLECTOR_CLIENT); | |
3890 | } | |
6b0655a2 | 3891 | |
718e3744 | 3892 | /* neighbor route-server-client. */ |
3893 | DEFUN (neighbor_route_server_client, | |
3894 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 3895 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3896 | NEIGHBOR_STR |
3897 | NEIGHBOR_ADDR_STR2 | |
3898 | "Configure a neighbor as Route Server client\n") | |
3899 | { | |
c500ae40 | 3900 | int idx_peer = 1; |
2a3d5731 DW |
3901 | struct peer *peer; |
3902 | ||
c500ae40 | 3903 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
3904 | if (! peer) |
3905 | return CMD_WARNING; | |
c500ae40 | 3906 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
3907 | bgp_node_safi (vty), |
3908 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 3909 | } |
3910 | ||
3911 | DEFUN (no_neighbor_route_server_client, | |
3912 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 3913 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3914 | NO_STR |
3915 | NEIGHBOR_STR | |
3916 | NEIGHBOR_ADDR_STR2 | |
3917 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 3918 | { |
c500ae40 DW |
3919 | int idx_peer = 2; |
3920 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
3921 | bgp_node_safi (vty), |
3922 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 3923 | } |
6b0655a2 | 3924 | |
fee0f4c6 | 3925 | DEFUN (neighbor_nexthop_local_unchanged, |
3926 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3927 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3928 | NEIGHBOR_STR |
3929 | NEIGHBOR_ADDR_STR2 | |
3930 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
3931 | "Leave link-local nexthop unchanged for this peer\n") | |
3932 | { | |
c500ae40 DW |
3933 | int idx_peer = 1; |
3934 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 3935 | bgp_node_safi (vty), |
3936 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
3937 | } | |
6b0655a2 | 3938 | |
fee0f4c6 | 3939 | DEFUN (no_neighbor_nexthop_local_unchanged, |
3940 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3941 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3942 | NO_STR |
3943 | NEIGHBOR_STR | |
3944 | NEIGHBOR_ADDR_STR2 | |
3945 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
3946 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 3947 | { |
c500ae40 DW |
3948 | int idx_peer = 2; |
3949 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3950 | bgp_node_safi (vty), |
fee0f4c6 | 3951 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 3952 | } |
6b0655a2 | 3953 | |
718e3744 | 3954 | DEFUN (neighbor_attr_unchanged, |
3955 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
3956 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3957 | [<\ | |
ddbaf941 QY |
3958 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3959 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3960 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3961 | >]", |
718e3744 | 3962 | NEIGHBOR_STR |
3963 | NEIGHBOR_ADDR_STR2 | |
3964 | "BGP attribute is propagated unchanged to this neighbor\n" | |
3965 | "As-path attribute\n" | |
3966 | "Nexthop attribute\n" | |
40e718b5 | 3967 | "Med attribute\n" |
1084263f QY |
3968 | "Med attribute\n" |
3969 | "Nexthop attribute\n" | |
3970 | "Nexthop attribute\n" | |
3971 | "As-path attribute\n" | |
3972 | "Med attribute\n" | |
40e718b5 | 3973 | "Med attribute\n" |
718e3744 | 3974 | "As-path attribute\n" |
1084263f QY |
3975 | "Med attribute\n" |
3976 | "As-path attribute\n" | |
3977 | "Nexthop attribute\n" | |
40e718b5 | 3978 | "Nexthop attribute\n" |
1084263f | 3979 | "As-path attribute\n") |
718e3744 | 3980 | { |
40e718b5 QY |
3981 | int idx = 0; |
3982 | char *peer = argv[1]->arg; | |
3983 | u_int16_t flags = 0; | |
718e3744 | 3984 | |
40e718b5 | 3985 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 3986 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
3987 | idx = 0; |
3988 | if (argv_find (argv, argc, "next-hop", &idx)) | |
3989 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
3990 | idx = 0; | |
3991 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 3992 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3993 | ||
40e718b5 QY |
3994 | if (!flags) // no flags means all of them! |
3995 | { | |
718e3744 | 3996 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 3997 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
3998 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3999 | } | |
718e3744 | 4000 | |
40e718b5 | 4001 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4002 | } |
4003 | ||
718e3744 | 4004 | DEFUN (no_neighbor_attr_unchanged, |
4005 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4006 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4007 | [<\ | |
ddbaf941 QY |
4008 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4009 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4010 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4011 | >]", |
e52702f2 | 4012 | NO_STR |
718e3744 | 4013 | NEIGHBOR_STR |
4014 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4015 | "BGP attribute is propagated unchanged to this neighbor\n" |
4016 | "As-path attribute\n" | |
40e718b5 | 4017 | "Nexthop attribute\n" |
31500417 | 4018 | "Med attribute\n" |
1084263f QY |
4019 | "Med attribute\n" |
4020 | "Nexthop attribute\n" | |
4021 | "Nexthop attribute\n" | |
4022 | "As-path attribute\n" | |
4023 | "Med attribute\n" | |
40e718b5 | 4024 | "Med attribute\n" |
718e3744 | 4025 | "As-path attribute\n" |
1084263f QY |
4026 | "Med attribute\n" |
4027 | "As-path attribute\n" | |
4028 | "Nexthop attribute\n" | |
718e3744 | 4029 | "Nexthop attribute\n" |
1084263f | 4030 | "As-path attribute\n") |
718e3744 | 4031 | { |
40e718b5 QY |
4032 | int idx = 0; |
4033 | char *peer = argv[2]->arg; | |
4034 | u_int16_t flags = 0; | |
718e3744 | 4035 | |
40e718b5 | 4036 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4037 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4038 | idx = 0; |
4039 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4040 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4041 | idx = 0; | |
4042 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4043 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4044 | ||
40e718b5 QY |
4045 | if (!flags) // no flags means all of them! |
4046 | { | |
718e3744 | 4047 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4048 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4049 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4050 | } | |
718e3744 | 4051 | |
40e718b5 | 4052 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4053 | } |
4054 | ||
718e3744 | 4055 | |
718e3744 | 4056 | /* EBGP multihop configuration. */ |
94f2b392 | 4057 | static int |
e52702f2 | 4058 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4059 | const char *ttl_str) |
718e3744 | 4060 | { |
4061 | struct peer *peer; | |
fd79ac91 | 4062 | unsigned int ttl; |
718e3744 | 4063 | |
4064 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4065 | if (! peer) | |
4066 | return CMD_WARNING; | |
4067 | ||
63fa10b5 QY |
4068 | if (peer->conf_if) |
4069 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4070 | ||
718e3744 | 4071 | if (! ttl_str) |
9b1be336 | 4072 | ttl = MAXTTL; |
718e3744 | 4073 | else |
9b1be336 | 4074 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4075 | |
89b6d1f8 | 4076 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4077 | } |
4078 | ||
94f2b392 | 4079 | static int |
e52702f2 | 4080 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4081 | { |
4082 | struct peer *peer; | |
4083 | ||
4084 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4085 | if (! peer) | |
4086 | return CMD_WARNING; | |
4087 | ||
89b6d1f8 | 4088 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4089 | } |
4090 | ||
4091 | /* neighbor ebgp-multihop. */ | |
4092 | DEFUN (neighbor_ebgp_multihop, | |
4093 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4094 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4095 | NEIGHBOR_STR |
4096 | NEIGHBOR_ADDR_STR2 | |
4097 | "Allow EBGP neighbors not on directly connected networks\n") | |
4098 | { | |
c500ae40 DW |
4099 | int idx_peer = 1; |
4100 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4101 | } |
4102 | ||
4103 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4104 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4105 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4106 | NEIGHBOR_STR |
4107 | NEIGHBOR_ADDR_STR2 | |
4108 | "Allow EBGP neighbors not on directly connected networks\n" | |
4109 | "maximum hop count\n") | |
4110 | { | |
c500ae40 DW |
4111 | int idx_peer = 1; |
4112 | int idx_number = 3; | |
4113 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4114 | } |
4115 | ||
4116 | DEFUN (no_neighbor_ebgp_multihop, | |
4117 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4118 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4119 | NO_STR |
4120 | NEIGHBOR_STR | |
4121 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4122 | "Allow EBGP neighbors not on directly connected networks\n" |
4123 | "maximum hop count\n") | |
718e3744 | 4124 | { |
c500ae40 DW |
4125 | int idx_peer = 2; |
4126 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4127 | } |
4128 | ||
6b0655a2 | 4129 | |
6ffd2079 | 4130 | /* disable-connected-check */ |
4131 | DEFUN (neighbor_disable_connected_check, | |
4132 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4133 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4134 | NEIGHBOR_STR |
4135 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4136 | "one-hop away EBGP peer using loopback address\n" |
4137 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4138 | { |
c500ae40 DW |
4139 | int idx_peer = 1; |
4140 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4141 | } |
4142 | ||
4143 | DEFUN (no_neighbor_disable_connected_check, | |
4144 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4145 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4146 | NO_STR |
4147 | NEIGHBOR_STR | |
4148 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4149 | "one-hop away EBGP peer using loopback address\n" |
4150 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4151 | { |
c500ae40 DW |
4152 | int idx_peer = 2; |
4153 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4154 | } |
4155 | ||
718e3744 | 4156 | DEFUN (neighbor_description, |
4157 | neighbor_description_cmd, | |
e961923c | 4158 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4159 | NEIGHBOR_STR |
4160 | NEIGHBOR_ADDR_STR2 | |
4161 | "Neighbor specific description\n" | |
4162 | "Up to 80 characters describing this neighbor\n") | |
4163 | { | |
c500ae40 | 4164 | int idx_peer = 1; |
58749582 | 4165 | int idx_line = 3; |
718e3744 | 4166 | struct peer *peer; |
718e3744 | 4167 | char *str; |
718e3744 | 4168 | |
c500ae40 | 4169 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4170 | if (! peer) |
4171 | return CMD_WARNING; | |
4172 | ||
58749582 | 4173 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4174 | |
4175 | peer_description_set (peer, str); | |
4176 | ||
3b8b1855 | 4177 | XFREE (MTYPE_TMP, str); |
718e3744 | 4178 | |
4179 | return CMD_SUCCESS; | |
4180 | } | |
4181 | ||
4182 | DEFUN (no_neighbor_description, | |
4183 | no_neighbor_description_cmd, | |
a636c635 | 4184 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4185 | NO_STR |
4186 | NEIGHBOR_STR | |
4187 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4188 | "Neighbor specific description\n" |
4189 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4190 | { |
c500ae40 | 4191 | int idx_peer = 2; |
718e3744 | 4192 | struct peer *peer; |
4193 | ||
c500ae40 | 4194 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4195 | if (! peer) |
4196 | return CMD_WARNING; | |
4197 | ||
4198 | peer_description_unset (peer); | |
4199 | ||
4200 | return CMD_SUCCESS; | |
4201 | } | |
4202 | ||
6b0655a2 | 4203 | |
718e3744 | 4204 | /* Neighbor update-source. */ |
94f2b392 | 4205 | static int |
e52702f2 | 4206 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4207 | const char *source_str) |
718e3744 | 4208 | { |
4209 | struct peer *peer; | |
718e3744 | 4210 | |
4211 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4212 | if (! peer) | |
4213 | return CMD_WARNING; | |
4214 | ||
a80beece DS |
4215 | if (peer->conf_if) |
4216 | return CMD_WARNING; | |
4217 | ||
718e3744 | 4218 | if (source_str) |
4219 | { | |
c63b83fe JBD |
4220 | union sockunion su; |
4221 | int ret = str2sockunion (source_str, &su); | |
4222 | ||
4223 | if (ret == 0) | |
4224 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4225 | else |
4226 | peer_update_source_if_set (peer, source_str); | |
4227 | } | |
4228 | else | |
4229 | peer_update_source_unset (peer); | |
4230 | ||
4231 | return CMD_SUCCESS; | |
4232 | } | |
4233 | ||
369688c0 PJ |
4234 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4235 | "IPv4 address\n" \ | |
9a1a331d PJ |
4236 | "IPv6 address\n" \ |
4237 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4238 | |
718e3744 | 4239 | DEFUN (neighbor_update_source, |
4240 | neighbor_update_source_cmd, | |
9ccf14f7 | 4241 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4242 | NEIGHBOR_STR |
4243 | NEIGHBOR_ADDR_STR2 | |
4244 | "Source of routing updates\n" | |
369688c0 | 4245 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4246 | { |
c500ae40 DW |
4247 | int idx_peer = 1; |
4248 | int idx_peer_2 = 3; | |
4249 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4250 | } |
4251 | ||
4252 | DEFUN (no_neighbor_update_source, | |
4253 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4255 | NO_STR |
4256 | NEIGHBOR_STR | |
4257 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4258 | "Source of routing updates\n" |
4259 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4260 | { |
c500ae40 DW |
4261 | int idx_peer = 2; |
4262 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4263 | } |
6b0655a2 | 4264 | |
94f2b392 | 4265 | static int |
e52702f2 QY |
4266 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4267 | afi_t afi, safi_t safi, | |
fd79ac91 | 4268 | const char *rmap, int set) |
718e3744 | 4269 | { |
4270 | int ret; | |
4271 | struct peer *peer; | |
4272 | ||
4273 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4274 | if (! peer) | |
4275 | return CMD_WARNING; | |
4276 | ||
4277 | if (set) | |
4278 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4279 | else | |
4280 | ret = peer_default_originate_unset (peer, afi, safi); | |
4281 | ||
4282 | return bgp_vty_return (vty, ret); | |
4283 | } | |
4284 | ||
4285 | /* neighbor default-originate. */ | |
4286 | DEFUN (neighbor_default_originate, | |
4287 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4288 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4289 | NEIGHBOR_STR |
4290 | NEIGHBOR_ADDR_STR2 | |
4291 | "Originate default route to this neighbor\n") | |
4292 | { | |
c500ae40 DW |
4293 | int idx_peer = 1; |
4294 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4295 | bgp_node_safi (vty), NULL, 1); |
4296 | } | |
4297 | ||
4298 | DEFUN (neighbor_default_originate_rmap, | |
4299 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4300 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4301 | NEIGHBOR_STR |
4302 | NEIGHBOR_ADDR_STR2 | |
4303 | "Originate default route to this neighbor\n" | |
4304 | "Route-map to specify criteria to originate default\n" | |
4305 | "route-map name\n") | |
4306 | { | |
c500ae40 DW |
4307 | int idx_peer = 1; |
4308 | int idx_word = 4; | |
4309 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4310 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4311 | } |
4312 | ||
4313 | DEFUN (no_neighbor_default_originate, | |
4314 | no_neighbor_default_originate_cmd, | |
a636c635 | 4315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4316 | NO_STR |
4317 | NEIGHBOR_STR | |
4318 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4319 | "Originate default route to this neighbor\n" |
4320 | "Route-map to specify criteria to originate default\n" | |
4321 | "route-map name\n") | |
718e3744 | 4322 | { |
c500ae40 DW |
4323 | int idx_peer = 2; |
4324 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4325 | bgp_node_safi (vty), NULL, 0); |
4326 | } | |
4327 | ||
6b0655a2 | 4328 | |
718e3744 | 4329 | /* Set neighbor's BGP port. */ |
94f2b392 | 4330 | static int |
e52702f2 | 4331 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4332 | const char *port_str) |
718e3744 | 4333 | { |
4334 | struct peer *peer; | |
4335 | u_int16_t port; | |
4336 | struct servent *sp; | |
4337 | ||
4338 | peer = peer_lookup_vty (vty, ip_str); | |
4339 | if (! peer) | |
4340 | return CMD_WARNING; | |
4341 | ||
4342 | if (! port_str) | |
e52702f2 | 4343 | { |
718e3744 | 4344 | sp = getservbyname ("bgp", "tcp"); |
4345 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4346 | } | |
4347 | else | |
4348 | { | |
4349 | VTY_GET_INTEGER("port", port, port_str); | |
4350 | } | |
4351 | ||
4352 | peer_port_set (peer, port); | |
4353 | ||
4354 | return CMD_SUCCESS; | |
4355 | } | |
4356 | ||
f418446b | 4357 | /* Set specified peer's BGP port. */ |
718e3744 | 4358 | DEFUN (neighbor_port, |
4359 | neighbor_port_cmd, | |
9ccf14f7 | 4360 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4361 | NEIGHBOR_STR |
4362 | NEIGHBOR_ADDR_STR | |
4363 | "Neighbor's BGP port\n" | |
4364 | "TCP port number\n") | |
4365 | { | |
c500ae40 DW |
4366 | int idx_ip = 1; |
4367 | int idx_number = 3; | |
4368 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4369 | } |
4370 | ||
4371 | DEFUN (no_neighbor_port, | |
4372 | no_neighbor_port_cmd, | |
9ccf14f7 | 4373 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4374 | NO_STR |
4375 | NEIGHBOR_STR | |
4376 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4377 | "Neighbor's BGP port\n" |
4378 | "TCP port number\n") | |
718e3744 | 4379 | { |
c500ae40 DW |
4380 | int idx_ip = 2; |
4381 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4382 | } |
4383 | ||
6b0655a2 | 4384 | |
718e3744 | 4385 | /* neighbor weight. */ |
94f2b392 | 4386 | static int |
e52702f2 | 4387 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4388 | afi_t afi, safi_t safi, |
fd79ac91 | 4389 | const char *weight_str) |
718e3744 | 4390 | { |
1f9a9fff | 4391 | int ret; |
718e3744 | 4392 | struct peer *peer; |
4393 | unsigned long weight; | |
4394 | ||
4395 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4396 | if (! peer) | |
4397 | return CMD_WARNING; | |
4398 | ||
4399 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4400 | ||
d93f7ffc | 4401 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4402 | return bgp_vty_return (vty, ret); |
718e3744 | 4403 | } |
4404 | ||
94f2b392 | 4405 | static int |
d93f7ffc DW |
4406 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4407 | afi_t afi, safi_t safi) | |
718e3744 | 4408 | { |
1f9a9fff | 4409 | int ret; |
718e3744 | 4410 | struct peer *peer; |
4411 | ||
4412 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4413 | if (! peer) | |
4414 | return CMD_WARNING; | |
4415 | ||
d93f7ffc | 4416 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4417 | return bgp_vty_return (vty, ret); |
718e3744 | 4418 | } |
4419 | ||
4420 | DEFUN (neighbor_weight, | |
4421 | neighbor_weight_cmd, | |
9ccf14f7 | 4422 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4423 | NEIGHBOR_STR |
4424 | NEIGHBOR_ADDR_STR2 | |
4425 | "Set default weight for routes from this neighbor\n" | |
4426 | "default weight\n") | |
4427 | { | |
c500ae40 DW |
4428 | int idx_peer = 1; |
4429 | int idx_number = 3; | |
e52702f2 QY |
4430 | return peer_weight_set_vty (vty, |
4431 | argv[idx_peer]->arg, | |
4432 | bgp_node_afi (vty), | |
4433 | bgp_node_safi (vty), | |
4434 | argv[idx_number]->arg); | |
718e3744 | 4435 | } |
4436 | ||
4437 | DEFUN (no_neighbor_weight, | |
4438 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4440 | NO_STR |
4441 | NEIGHBOR_STR | |
4442 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4443 | "Set default weight for routes from this neighbor\n" |
4444 | "default weight\n") | |
718e3744 | 4445 | { |
c500ae40 | 4446 | int idx_peer = 2; |
e52702f2 | 4447 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4448 | } |
4449 | ||
6b0655a2 | 4450 | |
718e3744 | 4451 | /* Override capability negotiation. */ |
4452 | DEFUN (neighbor_override_capability, | |
4453 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4454 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4455 | NEIGHBOR_STR |
4456 | NEIGHBOR_ADDR_STR2 | |
4457 | "Override capability negotiation result\n") | |
4458 | { | |
c500ae40 DW |
4459 | int idx_peer = 1; |
4460 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4461 | } |
4462 | ||
4463 | DEFUN (no_neighbor_override_capability, | |
4464 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4465 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4466 | NO_STR |
4467 | NEIGHBOR_STR | |
4468 | NEIGHBOR_ADDR_STR2 | |
4469 | "Override capability negotiation result\n") | |
4470 | { | |
c500ae40 DW |
4471 | int idx_peer = 2; |
4472 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4473 | } |
6b0655a2 | 4474 | |
718e3744 | 4475 | DEFUN (neighbor_strict_capability, |
4476 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4477 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4478 | NEIGHBOR_STR |
4479 | NEIGHBOR_ADDR_STR | |
4480 | "Strict capability negotiation match\n") | |
4481 | { | |
c500ae40 DW |
4482 | int idx_ip = 1; |
4483 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4484 | } |
4485 | ||
4486 | DEFUN (no_neighbor_strict_capability, | |
4487 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4488 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4489 | NO_STR |
4490 | NEIGHBOR_STR | |
4491 | NEIGHBOR_ADDR_STR | |
4492 | "Strict capability negotiation match\n") | |
4493 | { | |
c500ae40 DW |
4494 | int idx_ip = 2; |
4495 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4496 | } |
6b0655a2 | 4497 | |
94f2b392 | 4498 | static int |
e52702f2 | 4499 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4500 | const char *keep_str, const char *hold_str) |
718e3744 | 4501 | { |
4502 | int ret; | |
4503 | struct peer *peer; | |
4504 | u_int32_t keepalive; | |
4505 | u_int32_t holdtime; | |
4506 | ||
4507 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4508 | if (! peer) | |
4509 | return CMD_WARNING; | |
4510 | ||
4511 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4512 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4513 | ||
4514 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4515 | ||
4516 | return bgp_vty_return (vty, ret); | |
4517 | } | |
6b0655a2 | 4518 | |
94f2b392 | 4519 | static int |
fd79ac91 | 4520 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4521 | { |
4522 | int ret; | |
4523 | struct peer *peer; | |
4524 | ||
0c412461 | 4525 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4526 | if (! peer) |
4527 | return CMD_WARNING; | |
4528 | ||
4529 | ret = peer_timers_unset (peer); | |
4530 | ||
4531 | return bgp_vty_return (vty, ret); | |
4532 | } | |
4533 | ||
4534 | DEFUN (neighbor_timers, | |
4535 | neighbor_timers_cmd, | |
9ccf14f7 | 4536 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4537 | NEIGHBOR_STR |
4538 | NEIGHBOR_ADDR_STR2 | |
4539 | "BGP per neighbor timers\n" | |
4540 | "Keepalive interval\n" | |
4541 | "Holdtime\n") | |
4542 | { | |
c500ae40 DW |
4543 | int idx_peer = 1; |
4544 | int idx_number = 3; | |
4545 | int idx_number_2 = 4; | |
4546 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4547 | } |
4548 | ||
4549 | DEFUN (no_neighbor_timers, | |
4550 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4552 | NO_STR |
4553 | NEIGHBOR_STR | |
4554 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4555 | "BGP per neighbor timers\n" |
4556 | "Keepalive interval\n" | |
4557 | "Holdtime\n") | |
718e3744 | 4558 | { |
c500ae40 DW |
4559 | int idx_peer = 2; |
4560 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4561 | } |
6b0655a2 | 4562 | |
813d4307 | 4563 | |
94f2b392 | 4564 | static int |
e52702f2 | 4565 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4566 | const char *time_str) |
718e3744 | 4567 | { |
4568 | int ret; | |
4569 | struct peer *peer; | |
4570 | u_int32_t connect; | |
4571 | ||
966f821c | 4572 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4573 | if (! peer) |
4574 | return CMD_WARNING; | |
4575 | ||
4576 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4577 | ||
4578 | ret = peer_timers_connect_set (peer, connect); | |
4579 | ||
966f821c | 4580 | return bgp_vty_return (vty, ret); |
718e3744 | 4581 | } |
4582 | ||
94f2b392 | 4583 | static int |
fd79ac91 | 4584 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4585 | { |
4586 | int ret; | |
4587 | struct peer *peer; | |
4588 | ||
4589 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4590 | if (! peer) | |
4591 | return CMD_WARNING; | |
4592 | ||
4593 | ret = peer_timers_connect_unset (peer); | |
4594 | ||
966f821c | 4595 | return bgp_vty_return (vty, ret); |
718e3744 | 4596 | } |
4597 | ||
4598 | DEFUN (neighbor_timers_connect, | |
4599 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4600 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4601 | NEIGHBOR_STR |
966f821c | 4602 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4603 | "BGP per neighbor timers\n" |
4604 | "BGP connect timer\n" | |
4605 | "Connect timer\n") | |
4606 | { | |
c500ae40 DW |
4607 | int idx_peer = 1; |
4608 | int idx_number = 4; | |
4609 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4610 | } |
4611 | ||
4612 | DEFUN (no_neighbor_timers_connect, | |
4613 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4614 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4615 | NO_STR |
4616 | NEIGHBOR_STR | |
966f821c | 4617 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4618 | "BGP per neighbor timers\n" |
8334fd5a DW |
4619 | "BGP connect timer\n" |
4620 | "Connect timer\n") | |
718e3744 | 4621 | { |
c500ae40 DW |
4622 | int idx_peer = 2; |
4623 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4624 | } |
4625 | ||
6b0655a2 | 4626 | |
94f2b392 | 4627 | static int |
e52702f2 QY |
4628 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4629 | const char *time_str, int set) | |
718e3744 | 4630 | { |
4631 | int ret; | |
4632 | struct peer *peer; | |
4633 | u_int32_t routeadv = 0; | |
4634 | ||
966f821c | 4635 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4636 | if (! peer) |
4637 | return CMD_WARNING; | |
4638 | ||
4639 | if (time_str) | |
4640 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4641 | ||
4642 | if (set) | |
4643 | ret = peer_advertise_interval_set (peer, routeadv); | |
4644 | else | |
4645 | ret = peer_advertise_interval_unset (peer); | |
4646 | ||
966f821c | 4647 | return bgp_vty_return (vty, ret); |
718e3744 | 4648 | } |
4649 | ||
4650 | DEFUN (neighbor_advertise_interval, | |
4651 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4652 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4653 | NEIGHBOR_STR |
966f821c | 4654 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4655 | "Minimum interval between sending BGP routing updates\n" |
4656 | "time in seconds\n") | |
4657 | { | |
c500ae40 DW |
4658 | int idx_peer = 1; |
4659 | int idx_number = 3; | |
4660 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4661 | } |
4662 | ||
4663 | DEFUN (no_neighbor_advertise_interval, | |
4664 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4666 | NO_STR |
4667 | NEIGHBOR_STR | |
966f821c | 4668 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4669 | "Minimum interval between sending BGP routing updates\n" |
4670 | "time in seconds\n") | |
718e3744 | 4671 | { |
c500ae40 DW |
4672 | int idx_peer = 2; |
4673 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4674 | } |
4675 | ||
6b0655a2 | 4676 | |
518f0eb1 DS |
4677 | /* Time to wait before processing route-map updates */ |
4678 | DEFUN (bgp_set_route_map_delay_timer, | |
4679 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4680 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4681 | SET_STR |
4682 | "BGP route-map delay timer\n" | |
4683 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4684 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4685 | { |
c500ae40 | 4686 | int idx_number = 3; |
518f0eb1 | 4687 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4688 | |
c500ae40 | 4689 | if (argv[idx_number]->arg) |
518f0eb1 | 4690 | { |
c500ae40 | 4691 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4692 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4693 | |
4694 | /* if the dynamic update handling is being disabled, and a timer is | |
4695 | * running, stop the timer and act as if the timer has already fired. | |
4696 | */ | |
5fe9f963 | 4697 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4698 | { |
5fe9f963 | 4699 | BGP_TIMER_OFF(bm->t_rmap_update); |
4700 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4701 | } |
4702 | return CMD_SUCCESS; | |
4703 | } | |
4704 | else | |
ffd0c037 | 4705 | return CMD_WARNING; |
518f0eb1 DS |
4706 | } |
4707 | ||
4708 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4709 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4710 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4711 | NO_STR |
3a2d747c | 4712 | BGP_STR |
518f0eb1 | 4713 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4714 | "Reset to default time to wait for processing route-map changes\n" |
4715 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4716 | { |
518f0eb1 | 4717 | |
5fe9f963 | 4718 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4719 | |
4720 | return CMD_SUCCESS; | |
4721 | } | |
4722 | ||
f414725f | 4723 | |
718e3744 | 4724 | /* neighbor interface */ |
94f2b392 | 4725 | static int |
fd79ac91 | 4726 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4727 | { |
718e3744 | 4728 | struct peer *peer; |
4729 | ||
4730 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4731 | if (! peer || peer->conf_if) |
718e3744 | 4732 | return CMD_WARNING; |
4733 | ||
4734 | if (str) | |
ffd0c037 | 4735 | peer_interface_set (peer, str); |
718e3744 | 4736 | else |
ffd0c037 | 4737 | peer_interface_unset (peer); |
718e3744 | 4738 | |
4739 | return CMD_SUCCESS; | |
4740 | } | |
4741 | ||
4742 | DEFUN (neighbor_interface, | |
4743 | neighbor_interface_cmd, | |
9ccf14f7 | 4744 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4745 | NEIGHBOR_STR |
4746 | NEIGHBOR_ADDR_STR | |
4747 | "Interface\n" | |
4748 | "Interface name\n") | |
4749 | { | |
c500ae40 DW |
4750 | int idx_ip = 1; |
4751 | int idx_word = 3; | |
00d7d2d3 | 4752 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4753 | } |
4754 | ||
4755 | DEFUN (no_neighbor_interface, | |
4756 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4757 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4758 | NO_STR |
4759 | NEIGHBOR_STR | |
16cedbb0 | 4760 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4761 | "Interface\n" |
4762 | "Interface name\n") | |
4763 | { | |
c500ae40 DW |
4764 | int idx_peer = 2; |
4765 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4766 | } |
6b0655a2 | 4767 | |
718e3744 | 4768 | /* Set distribute list to the peer. */ |
94f2b392 | 4769 | static int |
e52702f2 | 4770 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4771 | afi_t afi, safi_t safi, |
4772 | const char *name_str, const char *direct_str) | |
718e3744 | 4773 | { |
4774 | int ret; | |
4775 | struct peer *peer; | |
4776 | int direct = FILTER_IN; | |
4777 | ||
4778 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4779 | if (! peer) | |
4780 | return CMD_WARNING; | |
4781 | ||
4782 | /* Check filter direction. */ | |
4783 | if (strncmp (direct_str, "i", 1) == 0) | |
4784 | direct = FILTER_IN; | |
4785 | else if (strncmp (direct_str, "o", 1) == 0) | |
4786 | direct = FILTER_OUT; | |
4787 | ||
4788 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4789 | ||
4790 | return bgp_vty_return (vty, ret); | |
4791 | } | |
4792 | ||
94f2b392 | 4793 | static int |
fd79ac91 | 4794 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4795 | safi_t safi, const char *direct_str) | |
718e3744 | 4796 | { |
4797 | int ret; | |
4798 | struct peer *peer; | |
4799 | int direct = FILTER_IN; | |
4800 | ||
4801 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4802 | if (! peer) | |
4803 | return CMD_WARNING; | |
4804 | ||
4805 | /* Check filter direction. */ | |
4806 | if (strncmp (direct_str, "i", 1) == 0) | |
4807 | direct = FILTER_IN; | |
4808 | else if (strncmp (direct_str, "o", 1) == 0) | |
4809 | direct = FILTER_OUT; | |
4810 | ||
4811 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
4812 | ||
4813 | return bgp_vty_return (vty, ret); | |
4814 | } | |
4815 | ||
4816 | DEFUN (neighbor_distribute_list, | |
4817 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4818 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4819 | NEIGHBOR_STR |
4820 | NEIGHBOR_ADDR_STR2 | |
4821 | "Filter updates to/from this neighbor\n" | |
4822 | "IP access-list number\n" | |
4823 | "IP access-list number (expanded range)\n" | |
4824 | "IP Access-list name\n" | |
4825 | "Filter incoming updates\n" | |
4826 | "Filter outgoing updates\n") | |
4827 | { | |
c500ae40 DW |
4828 | int idx_peer = 1; |
4829 | int idx_acl = 3; | |
4830 | int idx_in_out = 4; | |
4831 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4832 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4833 | } |
4834 | ||
4835 | DEFUN (no_neighbor_distribute_list, | |
4836 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4837 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4838 | NO_STR |
4839 | NEIGHBOR_STR | |
4840 | NEIGHBOR_ADDR_STR2 | |
4841 | "Filter updates to/from this neighbor\n" | |
4842 | "IP access-list number\n" | |
4843 | "IP access-list number (expanded range)\n" | |
4844 | "IP Access-list name\n" | |
4845 | "Filter incoming updates\n" | |
4846 | "Filter outgoing updates\n") | |
4847 | { | |
c500ae40 DW |
4848 | int idx_peer = 2; |
4849 | int idx_in_out = 5; | |
4850 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4851 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4852 | } |
6b0655a2 | 4853 | |
718e3744 | 4854 | /* Set prefix list to the peer. */ |
94f2b392 | 4855 | static int |
fd79ac91 | 4856 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4857 | safi_t safi, const char *name_str, |
fd79ac91 | 4858 | const char *direct_str) |
718e3744 | 4859 | { |
4860 | int ret; | |
4861 | struct peer *peer; | |
4862 | int direct = FILTER_IN; | |
4863 | ||
4864 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4865 | if (! peer) | |
4866 | return CMD_WARNING; | |
4867 | ||
4868 | /* Check filter direction. */ | |
4869 | if (strncmp (direct_str, "i", 1) == 0) | |
4870 | direct = FILTER_IN; | |
4871 | else if (strncmp (direct_str, "o", 1) == 0) | |
4872 | direct = FILTER_OUT; | |
4873 | ||
4874 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
4875 | ||
4876 | return bgp_vty_return (vty, ret); | |
4877 | } | |
4878 | ||
94f2b392 | 4879 | static int |
fd79ac91 | 4880 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4881 | safi_t safi, const char *direct_str) | |
718e3744 | 4882 | { |
4883 | int ret; | |
4884 | struct peer *peer; | |
4885 | int direct = FILTER_IN; | |
4886 | ||
4887 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4888 | if (! peer) | |
4889 | return CMD_WARNING; | |
e52702f2 | 4890 | |
718e3744 | 4891 | /* Check filter direction. */ |
4892 | if (strncmp (direct_str, "i", 1) == 0) | |
4893 | direct = FILTER_IN; | |
4894 | else if (strncmp (direct_str, "o", 1) == 0) | |
4895 | direct = FILTER_OUT; | |
4896 | ||
4897 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
4898 | ||
4899 | return bgp_vty_return (vty, ret); | |
4900 | } | |
4901 | ||
4902 | DEFUN (neighbor_prefix_list, | |
4903 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 4904 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4905 | NEIGHBOR_STR |
4906 | NEIGHBOR_ADDR_STR2 | |
4907 | "Filter updates to/from this neighbor\n" | |
4908 | "Name of a prefix list\n" | |
4909 | "Filter incoming updates\n" | |
4910 | "Filter outgoing updates\n") | |
4911 | { | |
c500ae40 DW |
4912 | int idx_peer = 1; |
4913 | int idx_word = 3; | |
4914 | int idx_in_out = 4; | |
4915 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4916 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4917 | } |
4918 | ||
4919 | DEFUN (no_neighbor_prefix_list, | |
4920 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 4921 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4922 | NO_STR |
4923 | NEIGHBOR_STR | |
4924 | NEIGHBOR_ADDR_STR2 | |
4925 | "Filter updates to/from this neighbor\n" | |
4926 | "Name of a prefix list\n" | |
4927 | "Filter incoming updates\n" | |
4928 | "Filter outgoing updates\n") | |
4929 | { | |
c500ae40 DW |
4930 | int idx_peer = 2; |
4931 | int idx_in_out = 5; | |
4932 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4933 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4934 | } |
6b0655a2 | 4935 | |
94f2b392 | 4936 | static int |
e52702f2 | 4937 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4938 | afi_t afi, safi_t safi, |
4939 | const char *name_str, const char *direct_str) | |
718e3744 | 4940 | { |
4941 | int ret; | |
4942 | struct peer *peer; | |
4943 | int direct = FILTER_IN; | |
4944 | ||
4945 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4946 | if (! peer) | |
4947 | return CMD_WARNING; | |
4948 | ||
4949 | /* Check filter direction. */ | |
4950 | if (strncmp (direct_str, "i", 1) == 0) | |
4951 | direct = FILTER_IN; | |
4952 | else if (strncmp (direct_str, "o", 1) == 0) | |
4953 | direct = FILTER_OUT; | |
4954 | ||
4955 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
4956 | ||
4957 | return bgp_vty_return (vty, ret); | |
4958 | } | |
4959 | ||
94f2b392 | 4960 | static int |
e52702f2 | 4961 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4962 | afi_t afi, safi_t safi, |
4963 | const char *direct_str) | |
718e3744 | 4964 | { |
4965 | int ret; | |
4966 | struct peer *peer; | |
4967 | int direct = FILTER_IN; | |
4968 | ||
4969 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4970 | if (! peer) | |
4971 | return CMD_WARNING; | |
4972 | ||
4973 | /* Check filter direction. */ | |
4974 | if (strncmp (direct_str, "i", 1) == 0) | |
4975 | direct = FILTER_IN; | |
4976 | else if (strncmp (direct_str, "o", 1) == 0) | |
4977 | direct = FILTER_OUT; | |
4978 | ||
4979 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
4980 | ||
4981 | return bgp_vty_return (vty, ret); | |
4982 | } | |
4983 | ||
4984 | DEFUN (neighbor_filter_list, | |
4985 | neighbor_filter_list_cmd, | |
9ccf14f7 | 4986 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 4987 | NEIGHBOR_STR |
4988 | NEIGHBOR_ADDR_STR2 | |
4989 | "Establish BGP filters\n" | |
4990 | "AS path access-list name\n" | |
4991 | "Filter incoming routes\n" | |
4992 | "Filter outgoing routes\n") | |
4993 | { | |
c500ae40 DW |
4994 | int idx_peer = 1; |
4995 | int idx_word = 3; | |
4996 | int idx_in_out = 4; | |
4997 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4998 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4999 | } |
5000 | ||
5001 | DEFUN (no_neighbor_filter_list, | |
5002 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5003 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5004 | NO_STR |
5005 | NEIGHBOR_STR | |
5006 | NEIGHBOR_ADDR_STR2 | |
5007 | "Establish BGP filters\n" | |
5008 | "AS path access-list name\n" | |
5009 | "Filter incoming routes\n" | |
5010 | "Filter outgoing routes\n") | |
5011 | { | |
c500ae40 DW |
5012 | int idx_peer = 2; |
5013 | int idx_in_out = 5; | |
5014 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5015 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5016 | } |
6b0655a2 | 5017 | |
718e3744 | 5018 | /* Set route-map to the peer. */ |
94f2b392 | 5019 | static int |
e52702f2 | 5020 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5021 | afi_t afi, safi_t safi, |
5022 | const char *name_str, const char *direct_str) | |
718e3744 | 5023 | { |
5024 | int ret; | |
5025 | struct peer *peer; | |
fee0f4c6 | 5026 | int direct = RMAP_IN; |
718e3744 | 5027 | |
5028 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5029 | if (! peer) | |
5030 | return CMD_WARNING; | |
5031 | ||
5032 | /* Check filter direction. */ | |
fee0f4c6 | 5033 | if (strncmp (direct_str, "in", 2) == 0) |
5034 | direct = RMAP_IN; | |
718e3744 | 5035 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5036 | direct = RMAP_OUT; |
718e3744 | 5037 | |
5038 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5039 | ||
5040 | return bgp_vty_return (vty, ret); | |
5041 | } | |
5042 | ||
94f2b392 | 5043 | static int |
fd79ac91 | 5044 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5045 | safi_t safi, const char *direct_str) | |
718e3744 | 5046 | { |
5047 | int ret; | |
5048 | struct peer *peer; | |
fee0f4c6 | 5049 | int direct = RMAP_IN; |
718e3744 | 5050 | |
5051 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5052 | if (! peer) | |
5053 | return CMD_WARNING; | |
5054 | ||
5055 | /* Check filter direction. */ | |
fee0f4c6 | 5056 | if (strncmp (direct_str, "in", 2) == 0) |
5057 | direct = RMAP_IN; | |
718e3744 | 5058 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5059 | direct = RMAP_OUT; |
718e3744 | 5060 | |
5061 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5062 | ||
5063 | return bgp_vty_return (vty, ret); | |
5064 | } | |
5065 | ||
5066 | DEFUN (neighbor_route_map, | |
5067 | neighbor_route_map_cmd, | |
9ccf14f7 | 5068 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5069 | NEIGHBOR_STR |
5070 | NEIGHBOR_ADDR_STR2 | |
5071 | "Apply route map to neighbor\n" | |
5072 | "Name of route map\n" | |
5073 | "Apply map to incoming routes\n" | |
2a3d5731 | 5074 | "Apply map to outbound routes\n") |
718e3744 | 5075 | { |
c500ae40 DW |
5076 | int idx_peer = 1; |
5077 | int idx_word = 3; | |
5078 | int idx_in_out = 4; | |
5079 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5080 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5081 | } |
5082 | ||
5083 | DEFUN (no_neighbor_route_map, | |
5084 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5085 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5086 | NO_STR |
5087 | NEIGHBOR_STR | |
5088 | NEIGHBOR_ADDR_STR2 | |
5089 | "Apply route map to neighbor\n" | |
5090 | "Name of route map\n" | |
5091 | "Apply map to incoming routes\n" | |
2a3d5731 | 5092 | "Apply map to outbound routes\n") |
718e3744 | 5093 | { |
c500ae40 DW |
5094 | int idx_peer = 2; |
5095 | int idx_in_out = 5; | |
5096 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5097 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5098 | } |
6b0655a2 | 5099 | |
718e3744 | 5100 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5101 | static int |
fd79ac91 | 5102 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5103 | safi_t safi, const char *name_str) | |
718e3744 | 5104 | { |
5105 | int ret; | |
5106 | struct peer *peer; | |
5107 | ||
5108 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5109 | if (! peer) | |
5110 | return CMD_WARNING; | |
5111 | ||
5112 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5113 | ||
5114 | return bgp_vty_return (vty, ret); | |
5115 | } | |
5116 | ||
5117 | /* Unset route-map from the peer. */ | |
94f2b392 | 5118 | static int |
fd79ac91 | 5119 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5120 | safi_t safi) |
5121 | { | |
5122 | int ret; | |
5123 | struct peer *peer; | |
5124 | ||
5125 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5126 | if (! peer) | |
5127 | return CMD_WARNING; | |
5128 | ||
5129 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5130 | ||
5131 | return bgp_vty_return (vty, ret); | |
5132 | } | |
5133 | ||
5134 | DEFUN (neighbor_unsuppress_map, | |
5135 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5136 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5137 | NEIGHBOR_STR |
5138 | NEIGHBOR_ADDR_STR2 | |
5139 | "Route-map to selectively unsuppress suppressed routes\n" | |
5140 | "Name of route map\n") | |
5141 | { | |
c500ae40 DW |
5142 | int idx_peer = 1; |
5143 | int idx_word = 3; | |
5144 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5145 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5146 | } |
5147 | ||
5148 | DEFUN (no_neighbor_unsuppress_map, | |
5149 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5151 | NO_STR |
5152 | NEIGHBOR_STR | |
5153 | NEIGHBOR_ADDR_STR2 | |
5154 | "Route-map to selectively unsuppress suppressed routes\n" | |
5155 | "Name of route map\n") | |
5156 | { | |
c500ae40 DW |
5157 | int idx_peer = 2; |
5158 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5159 | bgp_node_safi (vty)); |
5160 | } | |
6b0655a2 | 5161 | |
94f2b392 | 5162 | static int |
fd79ac91 | 5163 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5164 | safi_t safi, const char *num_str, |
0a486e5f | 5165 | const char *threshold_str, int warning, |
5166 | const char *restart_str) | |
718e3744 | 5167 | { |
5168 | int ret; | |
5169 | struct peer *peer; | |
5170 | u_int32_t max; | |
e0701b79 | 5171 | u_char threshold; |
0a486e5f | 5172 | u_int16_t restart; |
718e3744 | 5173 | |
5174 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5175 | if (! peer) | |
5176 | return CMD_WARNING; | |
5177 | ||
e6ec1c36 | 5178 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5179 | if (threshold_str) |
5180 | threshold = atoi (threshold_str); | |
5181 | else | |
5182 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5183 | |
0a486e5f | 5184 | if (restart_str) |
5185 | restart = atoi (restart_str); | |
5186 | else | |
5187 | restart = 0; | |
5188 | ||
5189 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5190 | |
5191 | return bgp_vty_return (vty, ret); | |
5192 | } | |
5193 | ||
94f2b392 | 5194 | static int |
fd79ac91 | 5195 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5196 | safi_t safi) |
5197 | { | |
5198 | int ret; | |
5199 | struct peer *peer; | |
5200 | ||
5201 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5202 | if (! peer) | |
5203 | return CMD_WARNING; | |
5204 | ||
5205 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5206 | ||
5207 | return bgp_vty_return (vty, ret); | |
5208 | } | |
5209 | ||
5210 | /* Maximum number of prefix configuration. prefix count is different | |
5211 | for each peer configuration. So this configuration can be set for | |
5212 | each peer configuration. */ | |
5213 | DEFUN (neighbor_maximum_prefix, | |
5214 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5215 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5216 | NEIGHBOR_STR |
5217 | NEIGHBOR_ADDR_STR2 | |
5218 | "Maximum number of prefix accept from this peer\n" | |
5219 | "maximum no. of prefix limit\n") | |
5220 | { | |
c500ae40 DW |
5221 | int idx_peer = 1; |
5222 | int idx_number = 3; | |
5223 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5224 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5225 | NULL); |
718e3744 | 5226 | } |
5227 | ||
e0701b79 | 5228 | DEFUN (neighbor_maximum_prefix_threshold, |
5229 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5230 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5231 | NEIGHBOR_STR |
5232 | NEIGHBOR_ADDR_STR2 | |
5233 | "Maximum number of prefix accept from this peer\n" | |
5234 | "maximum no. of prefix limit\n" | |
5235 | "Threshold value (%) at which to generate a warning msg\n") | |
5236 | { | |
c500ae40 DW |
5237 | int idx_peer = 1; |
5238 | int idx_number = 3; | |
5239 | int idx_number_2 = 4; | |
5240 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5241 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5242 | NULL); |
5243 | } | |
e0701b79 | 5244 | |
718e3744 | 5245 | DEFUN (neighbor_maximum_prefix_warning, |
5246 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5247 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5248 | NEIGHBOR_STR |
5249 | NEIGHBOR_ADDR_STR2 | |
5250 | "Maximum number of prefix accept from this peer\n" | |
5251 | "maximum no. of prefix limit\n" | |
5252 | "Only give warning message when limit is exceeded\n") | |
5253 | { | |
c500ae40 DW |
5254 | int idx_peer = 1; |
5255 | int idx_number = 3; | |
5256 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5257 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5258 | NULL); |
718e3744 | 5259 | } |
5260 | ||
e0701b79 | 5261 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5262 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5263 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5264 | NEIGHBOR_STR |
5265 | NEIGHBOR_ADDR_STR2 | |
5266 | "Maximum number of prefix accept from this peer\n" | |
5267 | "maximum no. of prefix limit\n" | |
5268 | "Threshold value (%) at which to generate a warning msg\n" | |
5269 | "Only give warning message when limit is exceeded\n") | |
5270 | { | |
c500ae40 DW |
5271 | int idx_peer = 1; |
5272 | int idx_number = 3; | |
5273 | int idx_number_2 = 4; | |
5274 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5275 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5276 | } |
5277 | ||
5278 | DEFUN (neighbor_maximum_prefix_restart, | |
5279 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5280 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5281 | NEIGHBOR_STR |
5282 | NEIGHBOR_ADDR_STR2 | |
5283 | "Maximum number of prefix accept from this peer\n" | |
5284 | "maximum no. of prefix limit\n" | |
5285 | "Restart bgp connection after limit is exceeded\n" | |
5286 | "Restart interval in minutes") | |
5287 | { | |
c500ae40 DW |
5288 | int idx_peer = 1; |
5289 | int idx_number = 3; | |
5290 | int idx_number_2 = 5; | |
5291 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5292 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5293 | } |
5294 | ||
5295 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5296 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5297 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5298 | NEIGHBOR_STR |
5299 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5300 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5301 | "maximum no. of prefix limit\n" |
5302 | "Threshold value (%) at which to generate a warning msg\n" | |
5303 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5304 | "Restart interval in minutes\n") |
0a486e5f | 5305 | { |
c500ae40 DW |
5306 | int idx_peer = 1; |
5307 | int idx_number = 3; | |
5308 | int idx_number_2 = 4; | |
5309 | int idx_number_3 = 6; | |
5310 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5311 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5312 | } |
e0701b79 | 5313 | |
718e3744 | 5314 | DEFUN (no_neighbor_maximum_prefix, |
5315 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5316 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5317 | NO_STR |
5318 | NEIGHBOR_STR | |
5319 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5320 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5321 | "maximum no. of prefix limit\n" |
5322 | "Threshold value (%) at which to generate a warning msg\n" | |
5323 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5324 | "Restart interval in minutes\n" |
31500417 | 5325 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5326 | { |
c500ae40 DW |
5327 | int idx_peer = 2; |
5328 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5329 | bgp_node_safi (vty)); |
5330 | } | |
e52702f2 | 5331 | |
718e3744 | 5332 | |
718e3744 | 5333 | /* "neighbor allowas-in" */ |
5334 | DEFUN (neighbor_allowas_in, | |
5335 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5336 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5337 | NEIGHBOR_STR |
5338 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5339 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5340 | "Number of occurances of AS number\n" |
5341 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5342 | { |
c500ae40 | 5343 | int idx_peer = 1; |
fd8503f5 | 5344 | int idx_number_origin = 3; |
718e3744 | 5345 | int ret; |
aac9ef6c | 5346 | int origin = 0; |
718e3744 | 5347 | struct peer *peer; |
aac9ef6c | 5348 | int allow_num = 0; |
718e3744 | 5349 | |
c500ae40 | 5350 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5351 | if (! peer) |
5352 | return CMD_WARNING; | |
5353 | ||
fd8503f5 | 5354 | if (argc <= idx_number_origin) |
718e3744 | 5355 | allow_num = 3; |
5356 | else | |
aac9ef6c | 5357 | { |
fd8503f5 | 5358 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5359 | origin = 1; |
5360 | else | |
fd8503f5 | 5361 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5362 | } |
718e3744 | 5363 | |
5364 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5365 | allow_num, origin); |
718e3744 | 5366 | |
5367 | return bgp_vty_return (vty, ret); | |
5368 | } | |
5369 | ||
718e3744 | 5370 | DEFUN (no_neighbor_allowas_in, |
5371 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5372 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5373 | NO_STR |
5374 | NEIGHBOR_STR | |
5375 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5376 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5377 | "Number of occurances of AS number\n" |
5378 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5379 | { |
c500ae40 | 5380 | int idx_peer = 2; |
718e3744 | 5381 | int ret; |
5382 | struct peer *peer; | |
5383 | ||
c500ae40 | 5384 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5385 | if (! peer) |
5386 | return CMD_WARNING; | |
5387 | ||
5388 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5389 | ||
5390 | return bgp_vty_return (vty, ret); | |
5391 | } | |
6b0655a2 | 5392 | |
fa411a21 NH |
5393 | DEFUN (neighbor_ttl_security, |
5394 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5395 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5396 | NEIGHBOR_STR |
5397 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5398 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5399 | "Specify the maximum number of hops to the BGP peer\n" |
5400 | "Number of hops to BGP peer\n") | |
fa411a21 | 5401 | { |
c500ae40 DW |
5402 | int idx_peer = 1; |
5403 | int idx_number = 4; | |
fa411a21 | 5404 | struct peer *peer; |
89b6d1f8 | 5405 | int gtsm_hops; |
fa411a21 | 5406 | |
c500ae40 | 5407 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5408 | if (! peer) |
5409 | return CMD_WARNING; | |
e52702f2 | 5410 | |
c500ae40 | 5411 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5412 | |
8cdabf90 SK |
5413 | /* |
5414 | * If 'neighbor swpX', then this is for directly connected peers, | |
5415 | * we should not accept a ttl-security hops value greater than 1. | |
5416 | */ | |
5417 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5418 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5419 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5420 | return CMD_WARNING; |
5421 | } | |
5422 | ||
89b6d1f8 | 5423 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5424 | } |
5425 | ||
5426 | DEFUN (no_neighbor_ttl_security, | |
5427 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5428 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5429 | NO_STR |
5430 | NEIGHBOR_STR | |
5431 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5432 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5433 | "Specify the maximum number of hops to the BGP peer\n" |
5434 | "Number of hops to BGP peer\n") | |
fa411a21 | 5435 | { |
c500ae40 | 5436 | int idx_peer = 2; |
fa411a21 | 5437 | struct peer *peer; |
fa411a21 | 5438 | |
c500ae40 | 5439 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5440 | if (! peer) |
5441 | return CMD_WARNING; | |
5442 | ||
89b6d1f8 | 5443 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5444 | } |
6b0655a2 | 5445 | |
adbac85e DW |
5446 | DEFUN (neighbor_addpath_tx_all_paths, |
5447 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5448 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5449 | NEIGHBOR_STR |
5450 | NEIGHBOR_ADDR_STR2 | |
5451 | "Use addpath to advertise all paths to a neighbor\n") | |
5452 | { | |
c500ae40 | 5453 | int idx_peer = 1; |
adbac85e DW |
5454 | struct peer *peer; |
5455 | ||
c500ae40 | 5456 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5457 | if (! peer) |
5458 | return CMD_WARNING; | |
5459 | ||
c500ae40 | 5460 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5461 | bgp_node_safi (vty), |
5462 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5463 | } | |
5464 | ||
5465 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5466 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5467 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5468 | NO_STR |
5469 | NEIGHBOR_STR | |
5470 | NEIGHBOR_ADDR_STR2 | |
5471 | "Use addpath to advertise all paths to a neighbor\n") | |
5472 | { | |
c500ae40 DW |
5473 | int idx_peer = 2; |
5474 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5475 | bgp_node_safi (vty), |
5476 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5477 | } | |
5478 | ||
06370dac DW |
5479 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5480 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5481 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5482 | NEIGHBOR_STR |
5483 | NEIGHBOR_ADDR_STR2 | |
5484 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5485 | { | |
c500ae40 | 5486 | int idx_peer = 1; |
06370dac DW |
5487 | struct peer *peer; |
5488 | ||
c500ae40 | 5489 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5490 | if (! peer) |
5491 | return CMD_WARNING; | |
5492 | ||
c500ae40 | 5493 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5494 | bgp_node_safi (vty), |
5495 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5496 | } | |
5497 | ||
5498 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5499 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5500 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5501 | NO_STR |
5502 | NEIGHBOR_STR | |
5503 | NEIGHBOR_ADDR_STR2 | |
5504 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5505 | { | |
c500ae40 DW |
5506 | int idx_peer = 2; |
5507 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5508 | bgp_node_safi (vty), |
5509 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5510 | } | |
5511 | ||
5512 | ||
8c3deaae | 5513 | /* Address Family configuration. */ |
718e3744 | 5514 | DEFUN (address_family_ipv4, |
5515 | address_family_ipv4_cmd, | |
5516 | "address-family ipv4", | |
5517 | "Enter Address Family command mode\n" | |
8c3deaae | 5518 | "Address Family\n") |
718e3744 | 5519 | { |
5520 | vty->node = BGP_IPV4_NODE; | |
5521 | return CMD_SUCCESS; | |
5522 | } | |
5523 | ||
5524 | DEFUN (address_family_ipv4_safi, | |
5525 | address_family_ipv4_safi_cmd, | |
46f296b4 | 5526 | "address-family ipv4 "BGP_SAFI_CMD_STR, |
718e3744 | 5527 | "Enter Address Family command mode\n" |
8c3deaae | 5528 | "Address Family\n" |
46f296b4 | 5529 | BGP_SAFI_HELP_STR) |
718e3744 | 5530 | { |
c500ae40 | 5531 | int idx_safi = 2; |
3b14d86e | 5532 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
ccbb332a LB |
5533 | { |
5534 | case SAFI_MULTICAST: | |
5535 | vty->node = BGP_IPV4M_NODE; | |
5536 | break; | |
5537 | case SAFI_ENCAP: | |
5538 | vty->node = BGP_ENCAP_NODE; | |
5539 | break; | |
5540 | case SAFI_MPLS_VPN: | |
5541 | vty->node = BGP_VPNV4_NODE; | |
5542 | break; | |
5543 | case SAFI_UNICAST: | |
5544 | default: | |
5545 | vty->node = BGP_IPV4_NODE; | |
5546 | break; | |
5547 | } | |
718e3744 | 5548 | |
5549 | return CMD_SUCCESS; | |
5550 | } | |
5551 | ||
25ffbdc1 | 5552 | DEFUN (address_family_ipv6, |
5553 | address_family_ipv6_cmd, | |
5554 | "address-family ipv6", | |
718e3744 | 5555 | "Enter Address Family command mode\n" |
8c3deaae | 5556 | "Address Family\n") |
718e3744 | 5557 | { |
5558 | vty->node = BGP_IPV6_NODE; | |
5559 | return CMD_SUCCESS; | |
5560 | } | |
5561 | ||
25ffbdc1 | 5562 | DEFUN (address_family_ipv6_safi, |
5563 | address_family_ipv6_safi_cmd, | |
46f296b4 | 5564 | "address-family ipv6 "BGP_SAFI_CMD_STR, |
718e3744 | 5565 | "Enter Address Family command mode\n" |
8c3deaae | 5566 | "Address Family\n" |
46f296b4 | 5567 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5568 | { |
c500ae40 | 5569 | int idx_safi = 2; |
46f296b4 LB |
5570 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5571 | { | |
5572 | case SAFI_MULTICAST: | |
5573 | vty->node = BGP_IPV6M_NODE; | |
5574 | break; | |
5575 | case SAFI_ENCAP: | |
5576 | vty->node = BGP_ENCAPV6_NODE; | |
5577 | break; | |
5578 | case SAFI_MPLS_VPN: | |
5579 | vty->node = BGP_VPNV6_NODE; | |
5580 | break; | |
5581 | case SAFI_UNICAST: | |
5582 | default: | |
5583 | vty->node = BGP_IPV6_NODE; | |
5584 | break; | |
5585 | } | |
25ffbdc1 | 5586 | |
5587 | return CMD_SUCCESS; | |
5588 | } | |
718e3744 | 5589 | |
5590 | DEFUN (address_family_vpnv4, | |
5591 | address_family_vpnv4_cmd, | |
8334fd5a | 5592 | "address-family vpnv4 [unicast]", |
718e3744 | 5593 | "Enter Address Family command mode\n" |
8c3deaae | 5594 | "Address Family\n" |
3a2d747c | 5595 | "Address Family modifier\n") |
718e3744 | 5596 | { |
5597 | vty->node = BGP_VPNV4_NODE; | |
5598 | return CMD_SUCCESS; | |
5599 | } | |
5600 | ||
8ecd3266 | 5601 | DEFUN (address_family_vpnv6, |
5602 | address_family_vpnv6_cmd, | |
8334fd5a | 5603 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5604 | "Enter Address Family command mode\n" |
8c3deaae | 5605 | "Address Family\n" |
3a2d747c | 5606 | "Address Family modifier\n") |
8ecd3266 | 5607 | { |
5608 | vty->node = BGP_VPNV6_NODE; | |
5609 | return CMD_SUCCESS; | |
5610 | } | |
5611 | ||
8b1fb8be LB |
5612 | DEFUN (address_family_encap, |
5613 | address_family_encap_cmd, | |
8334fd5a | 5614 | "address-family <encap|encapv4>", |
8b1fb8be | 5615 | "Enter Address Family command mode\n" |
8c3deaae QY |
5616 | "Address Family\n" |
5617 | "Address Family\n") | |
8b1fb8be LB |
5618 | { |
5619 | vty->node = BGP_ENCAP_NODE; | |
5620 | return CMD_SUCCESS; | |
5621 | } | |
5622 | ||
8b1fb8be LB |
5623 | |
5624 | DEFUN (address_family_encapv6, | |
5625 | address_family_encapv6_cmd, | |
5626 | "address-family encapv6", | |
5627 | "Enter Address Family command mode\n" | |
8c3deaae | 5628 | "Address Family\n") |
8b1fb8be LB |
5629 | { |
5630 | vty->node = BGP_ENCAPV6_NODE; | |
5631 | return CMD_SUCCESS; | |
5632 | } | |
5633 | ||
718e3744 | 5634 | DEFUN (exit_address_family, |
5635 | exit_address_family_cmd, | |
5636 | "exit-address-family", | |
5637 | "Exit from Address Family configuration mode\n") | |
5638 | { | |
a8a80d53 | 5639 | if (vty->node == BGP_IPV4_NODE |
5640 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5641 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5642 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5643 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5644 | || vty->node == BGP_VPNV6_NODE |
5645 | || vty->node == BGP_ENCAP_NODE | |
5646 | || vty->node == BGP_ENCAPV6_NODE) | |
718e3744 | 5647 | vty->node = BGP_NODE; |
5648 | return CMD_SUCCESS; | |
5649 | } | |
6b0655a2 | 5650 | |
8ad7271d DS |
5651 | /* Recalculate bestpath and re-advertise a prefix */ |
5652 | static int | |
01080f7c | 5653 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5654 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5655 | { | |
5656 | int ret; | |
5657 | struct prefix match; | |
5658 | struct bgp_node *rn; | |
5659 | struct bgp_node *rm; | |
8ad7271d DS |
5660 | struct bgp *bgp; |
5661 | struct bgp_table *table; | |
5662 | struct bgp_table *rib; | |
5663 | ||
5664 | /* BGP structure lookup. */ | |
5665 | if (view_name) | |
5666 | { | |
5667 | bgp = bgp_lookup_by_name (view_name); | |
5668 | if (bgp == NULL) | |
5669 | { | |
6aeb9e78 | 5670 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5671 | return CMD_WARNING; |
5672 | } | |
5673 | } | |
5674 | else | |
5675 | { | |
5676 | bgp = bgp_get_default (); | |
5677 | if (bgp == NULL) | |
5678 | { | |
5679 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5680 | return CMD_WARNING; | |
5681 | } | |
5682 | } | |
5683 | ||
5684 | /* Check IP address argument. */ | |
5685 | ret = str2prefix (ip_str, &match); | |
5686 | if (! ret) | |
5687 | { | |
5688 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5689 | return CMD_WARNING; | |
5690 | } | |
5691 | ||
5692 | match.family = afi2family (afi); | |
5693 | rib = bgp->rib[afi][safi]; | |
5694 | ||
5695 | if (safi == SAFI_MPLS_VPN) | |
5696 | { | |
5697 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5698 | { | |
5699 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5700 | continue; | |
5701 | ||
5702 | if ((table = rn->info) != NULL) | |
5703 | { | |
5704 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5705 | { | |
5706 | if (rm->p.prefixlen == match.prefixlen) | |
5707 | { | |
5708 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5709 | bgp_process (bgp, rm, afi, safi); | |
5710 | } | |
5711 | bgp_unlock_node (rm); | |
5712 | } | |
5713 | } | |
5714 | } | |
5715 | } | |
5716 | else | |
5717 | { | |
5718 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5719 | { | |
5720 | if (rn->p.prefixlen == match.prefixlen) | |
5721 | { | |
5722 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5723 | bgp_process (bgp, rn, afi, safi); | |
5724 | } | |
5725 | bgp_unlock_node (rn); | |
5726 | } | |
5727 | } | |
5728 | ||
5729 | return CMD_SUCCESS; | |
5730 | } | |
5731 | ||
b09b5ae0 | 5732 | /* one clear bgp command to rule them all */ |
718e3744 | 5733 | DEFUN (clear_ip_bgp_all, |
5734 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5735 | "clear [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_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 | 5736 | CLEAR_STR |
5737 | IP_STR | |
5738 | BGP_STR | |
838758ac | 5739 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5740 | "Clear all peers\n" |
5741 | "BGP neighbor address to clear\n" | |
a80beece | 5742 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5743 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5744 | "Clear peers with the AS number\n" |
5745 | "Clear all external peers\n" | |
718e3744 | 5746 | "Clear all members of peer-group\n" |
b09b5ae0 | 5747 | "BGP peer-group name\n" |
46f296b4 LB |
5748 | BGP_AFI_HELP_STR |
5749 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5750 | BGP_SOFT_STR |
5751 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5752 | BGP_SOFT_OUT_STR |
5753 | BGP_SOFT_IN_STR | |
5754 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5755 | BGP_SOFT_OUT_STR) |
718e3744 | 5756 | { |
cdc2d765 | 5757 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8334fd5a | 5758 | char *vrf = NULL; |
630a298c | 5759 | |
ae19d7dd QY |
5760 | afi_t afi = AFI_IP6; |
5761 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5762 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5763 | enum bgp_clear_type clr_type; |
5764 | char *clr_arg = NULL; | |
718e3744 | 5765 | |
ae19d7dd | 5766 | int idx = 0; |
01080f7c | 5767 | |
ae19d7dd QY |
5768 | /* clear [ip] bgp */ |
5769 | if (argv_find (argv, argc, "ip", &idx)) | |
5770 | afi = AFI_IP; | |
5771 | /* [<view|vrf> WORD] */ | |
5772 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5773 | { |
ae19d7dd QY |
5774 | vrf = argv[idx + 1]->arg; |
5775 | idx += 2; | |
838758ac | 5776 | } |
ae19d7dd QY |
5777 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5778 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5779 | { |
ae19d7dd | 5780 | clr_sort = clear_all; |
b09b5ae0 | 5781 | } |
ae19d7dd | 5782 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5783 | { |
5784 | clr_sort = clear_peer; | |
ae19d7dd | 5785 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5786 | } |
ae19d7dd | 5787 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5788 | { |
ae19d7dd QY |
5789 | clr_sort = clear_peer; |
5790 | clr_arg = argv[idx]->arg; | |
838758ac | 5791 | } |
ae19d7dd | 5792 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5793 | { |
5794 | clr_sort = clear_group; | |
ae19d7dd QY |
5795 | idx++; |
5796 | clr_arg = argv[idx]->arg; | |
718e3744 | 5797 | |
cdc2d765 | 5798 | if (! peer_group_lookup (bgp, clr_arg)) |
b09b5ae0 DW |
5799 | { |
5800 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5801 | return CMD_WARNING; |
b09b5ae0 DW |
5802 | } |
5803 | } | |
ae19d7dd | 5804 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5805 | { |
cdc2d765 | 5806 | if (peer_lookup_by_conf_if (bgp, argv[idx]->arg)) |
b09b5ae0 DW |
5807 | { |
5808 | clr_sort = clear_peer; | |
ae19d7dd | 5809 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5810 | } |
5811 | else | |
5812 | { | |
5813 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5814 | return CMD_WARNING; | |
5815 | } | |
5816 | } | |
ae19d7dd QY |
5817 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5818 | { | |
5819 | clr_sort = clear_as; | |
5820 | clr_arg = argv[idx]->arg; | |
5821 | } | |
5822 | else if (argv_find (argv, argc, "external", &idx)) | |
5823 | { | |
5824 | clr_sort = clear_external; | |
5825 | } | |
46f296b4 LB |
5826 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
5827 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 5828 | { |
46f296b4 | 5829 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
5830 | } |
5831 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5832 | if (argv_find (argv, argc, "soft", &idx)) | |
5833 | { | |
5834 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5835 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5836 | else | |
5837 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5838 | } | |
5839 | else if (argv_find (argv, argc, "in", &idx)) | |
5840 | { | |
5841 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5842 | } | |
5843 | else if (argv_find (argv, argc, "out", &idx)) | |
5844 | { | |
5daa3e5e | 5845 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5846 | } |
5847 | else | |
5848 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5849 | |
b09b5ae0 | 5850 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5851 | } |
01080f7c | 5852 | |
8ad7271d DS |
5853 | DEFUN (clear_ip_bgp_prefix, |
5854 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5855 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5856 | CLEAR_STR |
5857 | IP_STR | |
5858 | BGP_STR | |
838758ac | 5859 | BGP_INSTANCE_HELP_STR |
8ad7271d | 5860 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5861 | "IPv4 prefix\n") |
8ad7271d | 5862 | { |
8334fd5a | 5863 | char *vrf = NULL; |
630a298c | 5864 | char *prefix = NULL; |
8ad7271d | 5865 | |
630a298c | 5866 | int idx = 0; |
01080f7c | 5867 | |
630a298c QY |
5868 | /* [<view|vrf> WORD] */ |
5869 | if (argv_find (argv, argc, "WORD", &idx)) | |
5870 | vrf = argv[idx]->arg; | |
0c7b1b01 | 5871 | |
630a298c | 5872 | prefix = argv[argc-1]->arg; |
8ad7271d | 5873 | |
630a298c | 5874 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 5875 | } |
8ad7271d | 5876 | |
b09b5ae0 DW |
5877 | DEFUN (clear_bgp_ipv6_safi_prefix, |
5878 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 5879 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5880 | CLEAR_STR |
3a2d747c | 5881 | IP_STR |
718e3744 | 5882 | BGP_STR |
8c3deaae | 5883 | "Address Family\n" |
46f296b4 | 5884 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5885 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5886 | "IPv6 prefix\n") |
718e3744 | 5887 | { |
b09b5ae0 DW |
5888 | int idx_safi = 3; |
5889 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
5890 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5891 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 5892 | } |
01080f7c | 5893 | |
b09b5ae0 DW |
5894 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
5895 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 5896 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5897 | CLEAR_STR |
3a2d747c | 5898 | IP_STR |
718e3744 | 5899 | BGP_STR |
838758ac | 5900 | BGP_INSTANCE_HELP_STR |
8c3deaae | 5901 | "Address Family\n" |
46f296b4 | 5902 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5903 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5904 | "IPv6 prefix\n") |
718e3744 | 5905 | { |
b09b5ae0 | 5906 | int idx_word = 3; |
c500ae40 | 5907 | int idx_safi = 5; |
b09b5ae0 | 5908 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
5909 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5910 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 5911 | } |
5912 | ||
b09b5ae0 DW |
5913 | DEFUN (show_bgp_views, |
5914 | show_bgp_views_cmd, | |
d6e3c605 | 5915 | "show [ip] bgp views", |
b09b5ae0 | 5916 | SHOW_STR |
d6e3c605 | 5917 | IP_STR |
01080f7c | 5918 | BGP_STR |
b09b5ae0 | 5919 | "Show the defined BGP views\n") |
01080f7c | 5920 | { |
b09b5ae0 DW |
5921 | struct list *inst = bm->bgp; |
5922 | struct listnode *node; | |
5923 | struct bgp *bgp; | |
01080f7c | 5924 | |
b09b5ae0 DW |
5925 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
5926 | { | |
5927 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5928 | return CMD_WARNING; | |
5929 | } | |
e52702f2 | 5930 | |
b09b5ae0 DW |
5931 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
5932 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5933 | { | |
5934 | /* Skip VRFs. */ | |
5935 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
5936 | continue; | |
5937 | vty_out (vty, "\t%s (AS%u)%s", | |
5938 | bgp->name ? bgp->name : "(null)", | |
5939 | bgp->as, VTY_NEWLINE); | |
5940 | } | |
e52702f2 | 5941 | |
b09b5ae0 | 5942 | return CMD_SUCCESS; |
e0081f70 ML |
5943 | } |
5944 | ||
8386ac43 | 5945 | DEFUN (show_bgp_vrfs, |
5946 | show_bgp_vrfs_cmd, | |
d6e3c605 | 5947 | "show [ip] bgp vrfs [json]", |
8386ac43 | 5948 | SHOW_STR |
d6e3c605 | 5949 | IP_STR |
8386ac43 | 5950 | BGP_STR |
5951 | "Show BGP VRFs\n" | |
9973d184 | 5952 | JSON_STR) |
8386ac43 | 5953 | { |
5954 | struct list *inst = bm->bgp; | |
5955 | struct listnode *node; | |
5956 | struct bgp *bgp; | |
5957 | u_char uj = use_json(argc, argv); | |
5958 | json_object *json = NULL; | |
5959 | json_object *json_vrfs = NULL; | |
5960 | int count = 0; | |
5961 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
5962 | ||
5963 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
5964 | { | |
5965 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5966 | return CMD_WARNING; | |
5967 | } | |
5968 | ||
5969 | if (uj) | |
5970 | { | |
5971 | json = json_object_new_object(); | |
5972 | json_vrfs = json_object_new_object(); | |
5973 | } | |
5974 | ||
5975 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5976 | { | |
5977 | const char *name, *type; | |
5978 | struct peer *peer; | |
5979 | struct listnode *node, *nnode; | |
5980 | int peers_cfg, peers_estb; | |
5981 | json_object *json_vrf = NULL; | |
5c81a5f3 | 5982 | int vrf_id_ui; |
8386ac43 | 5983 | |
5984 | /* Skip Views. */ | |
5985 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
5986 | continue; | |
5987 | ||
5988 | count++; | |
5989 | if (!uj && count == 1) | |
5990 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
5991 | ||
5992 | peers_cfg = peers_estb = 0; | |
5993 | if (uj) | |
5994 | json_vrf = json_object_new_object(); | |
5995 | ||
5996 | ||
5997 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
5998 | { | |
5999 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6000 | continue; | |
6001 | peers_cfg++; | |
6002 | if (peer->status == Established) | |
6003 | peers_estb++; | |
6004 | } | |
6005 | ||
6006 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6007 | { | |
6008 | name = "Default"; | |
6009 | type = "DFLT"; | |
6010 | } | |
6011 | else | |
6012 | { | |
6013 | name = bgp->name; | |
6014 | type = "VRF"; | |
6015 | } | |
6016 | ||
5c81a5f3 | 6017 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6018 | if (uj) |
6019 | { | |
6020 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6021 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6022 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6023 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6024 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6025 | ||
6026 | json_object_object_add(json_vrfs, name, json_vrf); | |
6027 | } | |
6028 | else | |
5c81a5f3 | 6029 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6030 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6031 | peers_cfg, peers_estb, name, |
6032 | VTY_NEWLINE); | |
6033 | } | |
6034 | ||
6035 | if (uj) | |
6036 | { | |
6037 | json_object_object_add(json, "vrfs", json_vrfs); | |
6038 | ||
6039 | json_object_int_add(json, "totalVrfs", count); | |
6040 | ||
2aac5767 | 6041 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6042 | json_object_free(json); |
6043 | } | |
6044 | else | |
6045 | { | |
6046 | if (count) | |
6047 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6048 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6049 | } | |
6050 | ||
6051 | return CMD_SUCCESS; | |
6052 | } | |
6053 | ||
f412b39a | 6054 | DEFUN (show_bgp_memory, |
4bf6a362 | 6055 | show_bgp_memory_cmd, |
7fa12b13 | 6056 | "show [ip] bgp memory", |
4bf6a362 | 6057 | SHOW_STR |
3a2d747c | 6058 | IP_STR |
4bf6a362 PJ |
6059 | BGP_STR |
6060 | "Global BGP memory statistics\n") | |
6061 | { | |
6062 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6063 | unsigned long count; | |
e52702f2 | 6064 | |
4bf6a362 PJ |
6065 | /* RIB related usage stats */ |
6066 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6067 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6068 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6069 | count * sizeof (struct bgp_node)), | |
6070 | VTY_NEWLINE); | |
e52702f2 | 6071 | |
4bf6a362 PJ |
6072 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6073 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6074 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6075 | count * sizeof (struct bgp_info)), | |
6076 | VTY_NEWLINE); | |
fb982c25 PJ |
6077 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6078 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6079 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6080 | count * sizeof (struct bgp_info_extra)), | |
6081 | VTY_NEWLINE); | |
e52702f2 | 6082 | |
4bf6a362 PJ |
6083 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6084 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6085 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6086 | count * sizeof (struct bgp_static)), | |
6087 | VTY_NEWLINE); | |
3f9c7369 DS |
6088 | |
6089 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6090 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6091 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6092 | count * sizeof (struct bpacket)), | |
6093 | VTY_NEWLINE); | |
e52702f2 | 6094 | |
4bf6a362 PJ |
6095 | /* Adj-In/Out */ |
6096 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6097 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6098 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6099 | count * sizeof (struct bgp_adj_in)), | |
6100 | VTY_NEWLINE); | |
6101 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6102 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6103 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6104 | count * sizeof (struct bgp_adj_out)), | |
6105 | VTY_NEWLINE); | |
e52702f2 | 6106 | |
4bf6a362 PJ |
6107 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6108 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6109 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6110 | count * sizeof (struct bgp_nexthop_cache)), | |
6111 | VTY_NEWLINE); | |
6112 | ||
6113 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6114 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6115 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6116 | count * sizeof (struct bgp_damp_info)), | |
6117 | VTY_NEWLINE); | |
6118 | ||
6119 | /* Attributes */ | |
6120 | count = attr_count(); | |
e52702f2 QY |
6121 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6122 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6123 | count * sizeof(struct attr)), | |
4bf6a362 | 6124 | VTY_NEWLINE); |
fb982c25 | 6125 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6126 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6127 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6128 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6129 | VTY_NEWLINE); |
e52702f2 | 6130 | |
4bf6a362 PJ |
6131 | if ((count = attr_unknown_count())) |
6132 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6133 | |
4bf6a362 PJ |
6134 | /* AS_PATH attributes */ |
6135 | count = aspath_count (); | |
6136 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6137 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6138 | count * sizeof (struct aspath)), | |
6139 | VTY_NEWLINE); | |
e52702f2 | 6140 | |
4bf6a362 PJ |
6141 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6142 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6143 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6144 | count * sizeof (struct assegment)), | |
6145 | VTY_NEWLINE); | |
e52702f2 | 6146 | |
4bf6a362 PJ |
6147 | /* Other attributes */ |
6148 | if ((count = community_count ())) | |
6149 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6150 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6151 | count * sizeof (struct community)), | |
6152 | VTY_NEWLINE); | |
6153 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6154 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6155 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6156 | count * sizeof (struct ecommunity)), | |
6157 | VTY_NEWLINE); | |
57d187bc JS |
6158 | if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) |
6159 | vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", | |
6160 | count, | |
6161 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6162 | count * sizeof (struct lcommunity)), | |
6163 | VTY_NEWLINE); | |
e52702f2 | 6164 | |
4bf6a362 PJ |
6165 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6166 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6167 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6168 | count * sizeof (struct cluster_list)), | |
6169 | VTY_NEWLINE); | |
e52702f2 | 6170 | |
4bf6a362 PJ |
6171 | /* Peer related usage */ |
6172 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6173 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6174 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6175 | count * sizeof (struct peer)), | |
6176 | VTY_NEWLINE); | |
e52702f2 | 6177 | |
4a1ab8e4 | 6178 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6179 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6180 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6181 | count * sizeof (struct peer_group)), | |
6182 | VTY_NEWLINE); | |
e52702f2 | 6183 | |
4bf6a362 PJ |
6184 | /* Other */ |
6185 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6186 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6187 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6188 | count * sizeof (struct hash)), | |
6189 | VTY_NEWLINE); | |
6190 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6191 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6192 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6193 | count * sizeof (struct hash_backet)), | |
6194 | VTY_NEWLINE); | |
6195 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6196 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6197 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6198 | count * sizeof (regex_t)), | |
6199 | VTY_NEWLINE); | |
6200 | return CMD_SUCCESS; | |
6201 | } | |
fee0f4c6 | 6202 | |
718e3744 | 6203 | /* Show BGP peer's summary information. */ |
94f2b392 | 6204 | static int |
b05a1c8b | 6205 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6206 | u_char use_json, json_object *json) |
718e3744 | 6207 | { |
6208 | struct peer *peer; | |
1eb8ef25 | 6209 | struct listnode *node, *nnode; |
f14e6fdb DS |
6210 | unsigned int count = 0, dn_count = 0; |
6211 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6212 | char neighbor_buf[VTY_BUFSIZ]; |
6213 | int neighbor_col_default_width = 16; | |
718e3744 | 6214 | int len; |
f933309e | 6215 | int max_neighbor_width = 0; |
ffd0c037 DS |
6216 | json_object *json_peer = NULL; |
6217 | json_object *json_peers = NULL; | |
718e3744 | 6218 | |
b05a1c8b DS |
6219 | if (use_json) |
6220 | { | |
9f689658 DD |
6221 | if (json == NULL) |
6222 | json = json_object_new_object(); | |
6223 | ||
f1aa5d8a | 6224 | json_peers = json_object_new_object(); |
b05a1c8b | 6225 | } |
f933309e DW |
6226 | else |
6227 | { | |
6228 | /* Loop over all neighbors that will be displayed to determine how many | |
6229 | * characters are needed for the Neighbor column | |
6230 | */ | |
6231 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6232 | { | |
6233 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6234 | continue; | |
6235 | ||
6236 | if (peer->afc[afi][safi]) | |
6237 | { | |
c9d5bd27 DS |
6238 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6239 | if (peer_dynamic_neighbor(peer)) | |
6240 | dn_flag[0] = '*'; | |
6241 | ||
f933309e DW |
6242 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6243 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6244 | else | |
6245 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6246 | ||
6247 | len = strlen(neighbor_buf); | |
6248 | ||
6249 | if (len > max_neighbor_width) | |
6250 | max_neighbor_width = len; | |
6251 | } | |
6252 | } | |
6253 | ||
6254 | /* Originally we displayed the Neighbor column as 16 | |
6255 | * characters wide so make that the default | |
6256 | */ | |
6257 | if (max_neighbor_width < neighbor_col_default_width) | |
6258 | max_neighbor_width = neighbor_col_default_width; | |
6259 | } | |
b05a1c8b | 6260 | |
1eb8ef25 | 6261 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6262 | { |
1ff9a340 DS |
6263 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6264 | continue; | |
6265 | ||
718e3744 | 6266 | if (peer->afc[afi][safi]) |
6267 | { | |
b05a1c8b | 6268 | if (!count) |
4bf6a362 PJ |
6269 | { |
6270 | unsigned long ents; | |
6271 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6272 | int vrf_id_ui; |
6273 | ||
6274 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6275 | |
4bf6a362 | 6276 | /* Usage summary and header */ |
b05a1c8b DS |
6277 | if (use_json) |
6278 | { | |
62d6dca0 | 6279 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6280 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6281 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6282 | json_object_string_add(json, "vrfName", | |
6283 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6284 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6285 | } |
6286 | else | |
6287 | { | |
6288 | vty_out (vty, | |
5c81a5f3 | 6289 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6290 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6291 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6292 | } |
6293 | ||
f188f2c4 DS |
6294 | if (bgp_update_delay_configured(bgp)) |
6295 | { | |
b05a1c8b | 6296 | if (use_json) |
f188f2c4 | 6297 | { |
62d6dca0 | 6298 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6299 | |
6300 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6301 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6302 | |
6303 | if (bgp_update_delay_active(bgp)) | |
6304 | { | |
62d6dca0 DS |
6305 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6306 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6307 | } |
6308 | else | |
6309 | { | |
6310 | if (bgp->update_delay_over) | |
6311 | { | |
62d6dca0 | 6312 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6313 | bgp->update_delay_begin_time); |
62d6dca0 | 6314 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6315 | bgp->update_delay_end_time); |
62d6dca0 | 6316 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6317 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6318 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6319 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6320 | } |
6321 | } | |
f188f2c4 DS |
6322 | } |
6323 | else | |
6324 | { | |
b05a1c8b DS |
6325 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6326 | bgp->v_update_delay, VTY_NEWLINE); | |
6327 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6328 | vty_out (vty, " Establish wait: %d seconds%s", | |
6329 | bgp->v_establish_wait, VTY_NEWLINE); | |
6330 | ||
6331 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6332 | { |
6333 | vty_out (vty, " First neighbor established: %s%s", | |
6334 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6335 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6336 | } | |
6337 | else | |
6338 | { | |
6339 | if (bgp->update_delay_over) | |
6340 | { | |
6341 | vty_out (vty, " First neighbor established: %s%s", | |
6342 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6343 | vty_out (vty, " Best-paths resumed: %s%s", | |
6344 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6345 | vty_out (vty, " zebra update resumed: %s%s", | |
6346 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6347 | vty_out (vty, " peers update resumed: %s%s", | |
6348 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6349 | } | |
f188f2c4 DS |
6350 | } |
6351 | } | |
6352 | } | |
4bf6a362 | 6353 | |
b05a1c8b DS |
6354 | if (use_json) |
6355 | { | |
6356 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6357 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6358 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6359 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6360 | |
62d6dca0 | 6361 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6362 | |
6363 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6364 | json_object_int_add(json, "ribCount", ents); |
6365 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6366 | |
6367 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6368 | json_object_int_add(json, "peerCount", ents); |
6369 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6370 | |
b05a1c8b DS |
6371 | if ((ents = listcount (bgp->group))) |
6372 | { | |
62d6dca0 DS |
6373 | json_object_int_add(json, "peerGroupCount", ents); |
6374 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6375 | } |
3f9c7369 | 6376 | |
b05a1c8b | 6377 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6378 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6379 | } |
6380 | else | |
6381 | { | |
6382 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6383 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6384 | if (bgp->v_maxmed_admin) | |
6385 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6386 | ||
ffd0c037 | 6387 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6388 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6389 | ||
6390 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6391 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6392 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6393 | ents * sizeof (struct bgp_node)), | |
6394 | VTY_NEWLINE); | |
6395 | ||
6396 | /* Peer related usage */ | |
6397 | ents = listcount (bgp->peer); | |
6398 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6399 | ents, | |
6400 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6401 | ents * sizeof (struct peer)), | |
6402 | VTY_NEWLINE); | |
6403 | ||
b05a1c8b DS |
6404 | if ((ents = listcount (bgp->group))) |
6405 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6406 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6407 | ents * sizeof (struct peer_group)), | |
6408 | VTY_NEWLINE); | |
6409 | ||
6410 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6411 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6412 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6413 | |
6414 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6415 | vty_out (vty, "Neighbor"); | |
6416 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6417 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6418 | } |
4bf6a362 | 6419 | } |
e52702f2 | 6420 | |
b05a1c8b | 6421 | count++; |
718e3744 | 6422 | |
b05a1c8b DS |
6423 | if (use_json) |
6424 | { | |
6425 | json_peer = json_object_new_object(); | |
f14e6fdb | 6426 | |
b05a1c8b | 6427 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6428 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6429 | |
04b6bdc0 DW |
6430 | if (peer->hostname) |
6431 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6432 | ||
6433 | if (peer->domainname) | |
6434 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6435 | ||
62d6dca0 | 6436 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6437 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6438 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6439 | peer->open_in + peer->update_in + peer->keepalive_in |
6440 | + peer->notify_in + peer->refresh_in | |
6441 | + peer->dynamic_cap_in); | |
62d6dca0 | 6442 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6443 | peer->open_out + peer->update_out + peer->keepalive_out |
6444 | + peer->notify_out + peer->refresh_out | |
6445 | + peer->dynamic_cap_out); | |
6446 | ||
62d6dca0 | 6447 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6448 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6449 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6450 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6451 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6452 | |
6453 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6454 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6455 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6456 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6457 | else |
f1aa5d8a | 6458 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6459 | |
f1aa5d8a | 6460 | if (peer->conf_if) |
62d6dca0 | 6461 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6462 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6463 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6464 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6465 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6466 | |
f1aa5d8a | 6467 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6468 | } |
6469 | else | |
6470 | { | |
6471 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6472 | if (peer_dynamic_neighbor(peer)) | |
6473 | { | |
6474 | dn_count++; | |
6475 | dn_flag[0] = '*'; | |
6476 | } | |
6477 | ||
04b6bdc0 DW |
6478 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6479 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6480 | peer->host); | |
6481 | else | |
6482 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6483 | |
f933309e DW |
6484 | /* pad the neighbor column with spaces */ |
6485 | if (len < max_neighbor_width) | |
6486 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6487 | |
f933309e | 6488 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6489 | peer->as, |
6490 | peer->open_in + peer->update_in + peer->keepalive_in | |
6491 | + peer->notify_in + peer->refresh_in | |
6492 | + peer->dynamic_cap_in, | |
6493 | peer->open_out + peer->update_out + peer->keepalive_out | |
6494 | + peer->notify_out + peer->refresh_out | |
6495 | + peer->dynamic_cap_out, | |
6496 | peer->version[afi][safi], | |
6497 | 0, | |
f933309e | 6498 | peer->obuf->count, |
856ca177 | 6499 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6500 | |
6501 | if (peer->status == Established) | |
46f8c104 | 6502 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6503 | else |
6504 | { | |
6505 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6506 | vty_out (vty, " Idle (Admin)"); | |
6507 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6508 | vty_out (vty, " Idle (PfxCt)"); | |
6509 | else | |
f933309e | 6510 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6511 | } |
6512 | vty_out (vty, "%s", VTY_NEWLINE); | |
6513 | } | |
718e3744 | 6514 | } |
6515 | } | |
6516 | ||
b05a1c8b DS |
6517 | if (use_json) |
6518 | { | |
6519 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6520 | |
62d6dca0 DS |
6521 | json_object_int_add(json, "totalPeers", count); |
6522 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6523 | |
2aac5767 | 6524 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6525 | json_object_free(json); |
b05a1c8b DS |
6526 | } |
6527 | else | |
f14e6fdb | 6528 | { |
b05a1c8b DS |
6529 | if (count) |
6530 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6531 | count, VTY_NEWLINE); | |
6532 | else | |
9f689658 DD |
6533 | { |
6534 | if (use_json) | |
6535 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6536 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6537 | else |
6538 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6539 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6540 | } |
b05a1c8b | 6541 | |
9f689658 | 6542 | if (dn_count && ! use_json) |
b05a1c8b DS |
6543 | { |
6544 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6545 | vty_out(vty, | |
6546 | "%d dynamic neighbor(s), limit %d%s", | |
6547 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6548 | } | |
f14e6fdb DS |
6549 | } |
6550 | ||
718e3744 | 6551 | return CMD_SUCCESS; |
6552 | } | |
6553 | ||
27162734 LB |
6554 | static void |
6555 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6556 | u_char use_json, json_object *json) | |
6557 | { | |
6558 | int is_first = 1; | |
6559 | int afi_wildcard = (afi == AFI_MAX); | |
6560 | int safi_wildcard = (safi == SAFI_MAX); | |
6561 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
6562 | if (use_json && is_wildcard) | |
6563 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6564 | if (afi_wildcard) | |
6565 | afi = 1; /* AFI_IP */ | |
6566 | while (afi < AFI_MAX) | |
6567 | { | |
6568 | if (safi_wildcard) | |
6569 | safi = 1; /* SAFI_UNICAST */ | |
6570 | while (safi < SAFI_MAX) | |
6571 | { | |
6572 | if (is_wildcard) | |
6573 | { | |
6574 | if (use_json) | |
6575 | { | |
6576 | json = json_object_new_object(); | |
6577 | ||
6578 | if (! is_first) | |
6579 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6580 | else | |
6581 | is_first = 0; | |
6582 | ||
6583 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); | |
6584 | } | |
6585 | else | |
6586 | { | |
6587 | vty_out (vty, "%s%s Summary:%s", | |
6588 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6589 | } | |
6590 | } | |
6591 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); | |
6592 | if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */ | |
6593 | safi = SAFI_ENCAP; | |
6594 | else | |
6595 | safi++; | |
6596 | if (! safi_wildcard) | |
6597 | safi = SAFI_MAX; | |
6598 | } | |
6599 | afi++; | |
6600 | if (! afi_wildcard || | |
6601 | afi == AFI_ETHER) /* special case, not handled yet */ | |
6602 | afi = AFI_MAX; | |
6603 | } | |
6604 | ||
6605 | if (use_json && is_wildcard) | |
6606 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6607 | ||
6608 | } | |
6609 | ||
f186de26 | 6610 | static void |
6611 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6612 | u_char use_json) | |
6613 | { | |
6614 | struct listnode *node, *nnode; | |
6615 | struct bgp *bgp; | |
9f689658 DD |
6616 | json_object *json = NULL; |
6617 | int is_first = 1; | |
6618 | ||
6619 | if (use_json) | |
6620 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6621 | |
6622 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6623 | { | |
9f689658 DD |
6624 | if (use_json) |
6625 | { | |
4fb25c53 | 6626 | json = json_object_new_object(); |
9f689658 DD |
6627 | |
6628 | if (! is_first) | |
6629 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6630 | else | |
6631 | is_first = 0; | |
6632 | ||
6633 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6634 | ? "Default" : bgp->name); | |
6635 | } | |
6636 | else | |
6637 | { | |
6638 | vty_out (vty, "%sInstance %s:%s", | |
6639 | VTY_NEWLINE, | |
6640 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6641 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6642 | } | |
27162734 | 6643 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6644 | } |
9f689658 DD |
6645 | |
6646 | if (use_json) | |
6647 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6648 | ||
f186de26 | 6649 | } |
6650 | ||
4fb25c53 DW |
6651 | static int |
6652 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6653 | afi_t afi, safi_t safi, u_char use_json) | |
6654 | { | |
6655 | struct bgp *bgp; | |
6656 | ||
6657 | if (name) | |
6658 | { | |
6659 | if (strmatch(name, "all")) | |
6660 | { | |
6661 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6662 | return CMD_SUCCESS; | |
6663 | } | |
6664 | else | |
6665 | { | |
6666 | bgp = bgp_lookup_by_name (name); | |
6667 | ||
6668 | if (! bgp) | |
6669 | { | |
6670 | if (use_json) | |
6671 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6672 | else | |
6673 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6674 | return CMD_WARNING; | |
6675 | } | |
6676 | ||
27162734 | 6677 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6678 | return CMD_SUCCESS; |
6679 | } | |
6680 | } | |
6681 | ||
6682 | bgp = bgp_get_default (); | |
6683 | ||
6684 | if (bgp) | |
27162734 | 6685 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6686 | |
6687 | return CMD_SUCCESS; | |
6688 | } | |
6689 | ||
716b2d8a | 6690 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6691 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6692 | show_ip_bgp_summary_cmd, |
46f296b4 | 6693 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6694 | SHOW_STR |
6695 | IP_STR | |
6696 | BGP_STR | |
8386ac43 | 6697 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6698 | BGP_AFI_HELP_STR |
6699 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6700 | "Summary of BGP neighbor status\n" |
9973d184 | 6701 | JSON_STR) |
718e3744 | 6702 | { |
74ca3d33 | 6703 | char *vrf = NULL; |
27162734 LB |
6704 | afi_t afi = AFI_MAX; |
6705 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6706 | |
6707 | int idx = 0; | |
6708 | ||
6709 | /* show [ip] bgp */ | |
6710 | if (argv_find (argv, argc, "ip", &idx)) | |
6711 | afi = AFI_IP; | |
6712 | /* [<view|vrf> WORD] */ | |
6713 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6714 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6715 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6716 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6717 | { |
46f296b4 | 6718 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6719 | } |
6720 | ||
ae19d7dd | 6721 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6722 | |
6723 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6724 | } |
6725 | ||
fd79ac91 | 6726 | const char * |
538621f2 | 6727 | afi_safi_print (afi_t afi, safi_t safi) |
6728 | { | |
6729 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6730 | return "IPv4 Unicast"; | |
6731 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6732 | return "IPv4 Multicast"; | |
6733 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
46f296b4 | 6734 | return "IPv4 VPN"; |
8b1fb8be | 6735 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6736 | return "IPv4 Encap"; |
538621f2 | 6737 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6738 | return "IPv6 Unicast"; | |
6739 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6740 | return "IPv6 Multicast"; | |
945c8fe9 | 6741 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6742 | return "IPv6 VPN"; |
8b1fb8be | 6743 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6744 | return "IPv6 Encap"; |
538621f2 | 6745 | else |
6746 | return "Unknown"; | |
6747 | } | |
6748 | ||
27162734 LB |
6749 | const char * |
6750 | afi_safi_json (afi_t afi, safi_t safi) | |
6751 | { | |
6752 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6753 | return "IPv4Unicast"; | |
6754 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6755 | return "IPv4Multicast"; | |
6756 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
6757 | return "IPv4VPN"; | |
6758 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
6759 | return "IPv4Encap"; | |
6760 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
6761 | return "IPv6Unicast"; | |
6762 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6763 | return "IPv6Multicast"; | |
6764 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
6765 | return "IPv6VPN"; | |
6766 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
6767 | return "IPv6Encap"; | |
6768 | else | |
6769 | return "Unknown"; | |
6770 | } | |
6771 | ||
718e3744 | 6772 | /* Show BGP peer's information. */ |
6773 | enum show_type | |
6774 | { | |
6775 | show_all, | |
6776 | show_peer | |
6777 | }; | |
6778 | ||
94f2b392 | 6779 | static void |
856ca177 MS |
6780 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6781 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6782 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6783 | { |
6784 | /* Send-Mode */ | |
6785 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6786 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6787 | { | |
856ca177 MS |
6788 | if (use_json) |
6789 | { | |
6790 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6791 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6792 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6793 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6794 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6795 | json_object_string_add(json_pref, "sendMode", "received"); | |
6796 | } | |
6797 | else | |
6798 | { | |
6799 | vty_out (vty, " Send-mode: "); | |
6800 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6801 | vty_out (vty, "advertised"); | |
6802 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6803 | vty_out (vty, "%sreceived", | |
6804 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6805 | ", " : ""); | |
6806 | vty_out (vty, "%s", VTY_NEWLINE); | |
6807 | } | |
718e3744 | 6808 | } |
6809 | ||
6810 | /* Receive-Mode */ | |
6811 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6812 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6813 | { | |
856ca177 MS |
6814 | if (use_json) |
6815 | { | |
6816 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6817 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6818 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6819 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6820 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6821 | json_object_string_add(json_pref, "recvMode", "received"); | |
6822 | } | |
6823 | else | |
6824 | { | |
6825 | vty_out (vty, " Receive-mode: "); | |
6826 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6827 | vty_out (vty, "advertised"); | |
6828 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6829 | vty_out (vty, "%sreceived", | |
6830 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
6831 | ", " : ""); | |
6832 | vty_out (vty, "%s", VTY_NEWLINE); | |
6833 | } | |
718e3744 | 6834 | } |
6835 | } | |
6836 | ||
94f2b392 | 6837 | static void |
856ca177 MS |
6838 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6839 | u_char use_json, json_object *json_neigh) | |
718e3744 | 6840 | { |
6841 | struct bgp_filter *filter; | |
3f9c7369 | 6842 | struct peer_af *paf; |
718e3744 | 6843 | char orf_pfx_name[BUFSIZ]; |
6844 | int orf_pfx_count; | |
856ca177 MS |
6845 | json_object *json_af = NULL; |
6846 | json_object *json_prefA = NULL; | |
6847 | json_object *json_prefB = NULL; | |
6848 | json_object *json_addr = NULL; | |
718e3744 | 6849 | |
856ca177 MS |
6850 | if (use_json) |
6851 | { | |
6852 | json_addr = json_object_new_object(); | |
6853 | json_af = json_object_new_object(); | |
856ca177 | 6854 | filter = &p->filter[afi][safi]; |
718e3744 | 6855 | |
c8560b44 | 6856 | if (peer_group_active(p)) |
856ca177 | 6857 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 6858 | |
856ca177 MS |
6859 | paf = peer_af_find(p, afi, safi); |
6860 | if (paf && PAF_SUBGRP(paf)) | |
6861 | { | |
6862 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
6863 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
6864 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
6865 | } | |
6866 | ||
6867 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6868 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6869 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6870 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6871 | { | |
6872 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 6873 | json_prefA = json_object_new_object(); |
856ca177 MS |
6874 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6875 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6876 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6877 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6878 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
6879 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
6880 | } | |
6881 | ||
6882 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6883 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6884 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6885 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6886 | { | |
6887 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 6888 | json_prefB = json_object_new_object(); |
856ca177 MS |
6889 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6890 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6891 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6892 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6893 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
6894 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
6895 | } | |
6896 | ||
6897 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6898 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6899 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6900 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6901 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6902 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6903 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
6904 | else |
6905 | json_object_free(json_af); | |
856ca177 MS |
6906 | |
6907 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
6908 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
6909 | ||
6910 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
6911 | || orf_pfx_count) | |
6912 | { | |
6913 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
6914 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
6915 | if (orf_pfx_count) | |
6916 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
6917 | } | |
6918 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
6919 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
6920 | ||
6921 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
6922 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
6923 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6924 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
6925 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
6926 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
6927 | ||
88b8ed8d DW |
6928 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
6929 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
6930 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 6931 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
6932 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
6933 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
6934 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
6935 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
6936 | ||
adbac85e DW |
6937 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
6938 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
6939 | ||
06370dac DW |
6940 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
6941 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
6942 | ||
856ca177 MS |
6943 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
6944 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
6945 | ||
6946 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
6947 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
6948 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
6949 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
6950 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
6951 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
6952 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
6953 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
6954 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 6955 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
6956 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
6957 | { | |
6958 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
6959 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6960 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
6961 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6962 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
6963 | else | |
6964 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
6965 | } | |
6966 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
6967 | { | |
6968 | if (p->default_rmap[afi][safi].name) | |
6969 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
6970 | ||
6971 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
6972 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
6973 | else | |
6974 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
6975 | } | |
6976 | ||
6977 | if (filter->plist[FILTER_IN].name | |
6978 | || filter->dlist[FILTER_IN].name | |
6979 | || filter->aslist[FILTER_IN].name | |
6980 | || filter->map[RMAP_IN].name) | |
6981 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
6982 | if (filter->plist[FILTER_OUT].name | |
6983 | || filter->dlist[FILTER_OUT].name | |
6984 | || filter->aslist[FILTER_OUT].name | |
6985 | || filter->map[RMAP_OUT].name | |
6986 | || filter->usmap.name) | |
6987 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
6988 | |
6989 | /* prefix-list */ | |
6990 | if (filter->plist[FILTER_IN].name) | |
6991 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
6992 | if (filter->plist[FILTER_OUT].name) | |
6993 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
6994 | ||
6995 | /* distribute-list */ | |
6996 | if (filter->dlist[FILTER_IN].name) | |
6997 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
6998 | if (filter->dlist[FILTER_OUT].name) | |
6999 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
7000 | ||
7001 | /* filter-list. */ | |
7002 | if (filter->aslist[FILTER_IN].name) | |
7003 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
7004 | if (filter->aslist[FILTER_OUT].name) | |
7005 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7006 | ||
7007 | /* route-map. */ | |
7008 | if (filter->map[RMAP_IN].name) | |
7009 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7010 | if (filter->map[RMAP_OUT].name) | |
7011 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7012 | |
7013 | /* unsuppress-map */ | |
7014 | if (filter->usmap.name) | |
7015 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7016 | ||
7017 | /* Receive prefix count */ | |
7018 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7019 | ||
7020 | /* Maximum prefix */ | |
7021 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7022 | { | |
7023 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7024 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7025 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7026 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7027 | if (p->pmax_restart[afi][safi]) | |
7028 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7029 | } | |
7030 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7031 | ||
7032 | } | |
7033 | else | |
7034 | { | |
7035 | filter = &p->filter[afi][safi]; | |
7036 | ||
7037 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7038 | VTY_NEWLINE); | |
7039 | ||
c8560b44 | 7040 | if (peer_group_active(p)) |
856ca177 MS |
7041 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7042 | ||
7043 | paf = peer_af_find(p, afi, safi); | |
7044 | if (paf && PAF_SUBGRP(paf)) | |
7045 | { | |
7046 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7047 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7048 | vty_out (vty, " Packet Queue length %d%s", | |
7049 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7050 | } | |
718e3744 | 7051 | else |
856ca177 MS |
7052 | { |
7053 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7054 | } | |
7055 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7056 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7057 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7058 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7059 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7060 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7061 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7062 | ||
7063 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7064 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7065 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7066 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7067 | { | |
7068 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7069 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7070 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7071 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7072 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7073 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7074 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7075 | } | |
7076 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7077 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7078 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7079 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7080 | { | |
7081 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7082 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7083 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7084 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7085 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7086 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7087 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7088 | } | |
718e3744 | 7089 | |
856ca177 MS |
7090 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7091 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7092 | |
856ca177 MS |
7093 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7094 | || orf_pfx_count) | |
7095 | { | |
7096 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7097 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7098 | vty_out (vty, " sent;"); | |
7099 | if (orf_pfx_count) | |
7100 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7101 | vty_out (vty, "%s", VTY_NEWLINE); | |
7102 | } | |
7103 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7104 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7105 | ||
7106 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7107 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7108 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7109 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7110 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7111 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7112 | ||
88b8ed8d DW |
7113 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7114 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7115 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7116 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7117 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7118 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7119 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7120 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7121 | ||
adbac85e DW |
7122 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7123 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7124 | ||
06370dac DW |
7125 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7126 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7127 | ||
856ca177 MS |
7128 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7129 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7130 | ||
7131 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7132 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7133 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7134 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7135 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7136 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7137 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7138 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7139 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7140 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7141 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7142 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
856ca177 MS |
7143 | { |
7144 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7145 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
57d187bc JS |
7146 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) |
7147 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7148 | vty_out (vty, "(all)%s", VTY_NEWLINE); | |
7149 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7150 | vty_out (vty, "(large)%s", VTY_NEWLINE); | |
856ca177 MS |
7151 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
7152 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7153 | else | |
7154 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7155 | } | |
7156 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7157 | { | |
7158 | vty_out (vty, " Default information originate,"); | |
7159 | ||
7160 | if (p->default_rmap[afi][safi].name) | |
7161 | vty_out (vty, " default route-map %s%s,", | |
7162 | p->default_rmap[afi][safi].map ? "*" : "", | |
7163 | p->default_rmap[afi][safi].name); | |
7164 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7165 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7166 | else | |
7167 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7168 | } | |
718e3744 | 7169 | |
856ca177 MS |
7170 | if (filter->plist[FILTER_IN].name |
7171 | || filter->dlist[FILTER_IN].name | |
7172 | || filter->aslist[FILTER_IN].name | |
7173 | || filter->map[RMAP_IN].name) | |
7174 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7175 | if (filter->plist[FILTER_OUT].name | |
7176 | || filter->dlist[FILTER_OUT].name | |
7177 | || filter->aslist[FILTER_OUT].name | |
7178 | || filter->map[RMAP_OUT].name | |
7179 | || filter->usmap.name) | |
7180 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7181 | |
7182 | /* prefix-list */ | |
7183 | if (filter->plist[FILTER_IN].name) | |
7184 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7185 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7186 | filter->plist[FILTER_IN].name, | |
7187 | VTY_NEWLINE); | |
7188 | if (filter->plist[FILTER_OUT].name) | |
7189 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7190 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7191 | filter->plist[FILTER_OUT].name, | |
7192 | VTY_NEWLINE); | |
7193 | ||
7194 | /* distribute-list */ | |
7195 | if (filter->dlist[FILTER_IN].name) | |
7196 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7197 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7198 | filter->dlist[FILTER_IN].name, | |
7199 | VTY_NEWLINE); | |
7200 | if (filter->dlist[FILTER_OUT].name) | |
7201 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7202 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7203 | filter->dlist[FILTER_OUT].name, | |
7204 | VTY_NEWLINE); | |
7205 | ||
7206 | /* filter-list. */ | |
7207 | if (filter->aslist[FILTER_IN].name) | |
7208 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7209 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7210 | filter->aslist[FILTER_IN].name, | |
7211 | VTY_NEWLINE); | |
7212 | if (filter->aslist[FILTER_OUT].name) | |
7213 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7214 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7215 | filter->aslist[FILTER_OUT].name, | |
7216 | VTY_NEWLINE); | |
7217 | ||
7218 | /* route-map. */ | |
7219 | if (filter->map[RMAP_IN].name) | |
7220 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7221 | filter->map[RMAP_IN].map ? "*" : "", | |
7222 | filter->map[RMAP_IN].name, | |
7223 | VTY_NEWLINE); | |
7224 | if (filter->map[RMAP_OUT].name) | |
7225 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7226 | filter->map[RMAP_OUT].map ? "*" : "", | |
7227 | filter->map[RMAP_OUT].name, | |
7228 | VTY_NEWLINE); | |
856ca177 MS |
7229 | |
7230 | /* unsuppress-map */ | |
7231 | if (filter->usmap.name) | |
7232 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7233 | filter->usmap.map ? "*" : "", | |
7234 | filter->usmap.name, VTY_NEWLINE); | |
7235 | ||
7236 | /* Receive prefix count */ | |
7237 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7238 | ||
7239 | /* Maximum prefix */ | |
7240 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7241 | { | |
7242 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7243 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7244 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7245 | vty_out (vty, " Threshold for warning message %d%%", | |
7246 | p->pmax_threshold[afi][safi]); | |
7247 | if (p->pmax_restart[afi][safi]) | |
7248 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7249 | vty_out (vty, "%s", VTY_NEWLINE); | |
7250 | } | |
718e3744 | 7251 | |
0a486e5f | 7252 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7253 | } |
718e3744 | 7254 | } |
7255 | ||
94f2b392 | 7256 | static void |
e8f7da3a | 7257 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7258 | { |
7259 | struct bgp *bgp; | |
4690c7d7 | 7260 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7261 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7262 | char dn_flag[2]; |
3a8c7ba1 DW |
7263 | const char *subcode_str; |
7264 | const char *code_str; | |
538621f2 | 7265 | afi_t afi; |
7266 | safi_t safi; | |
d6661008 DS |
7267 | u_int16_t i; |
7268 | u_char *msg; | |
e8f7da3a | 7269 | json_object *json_neigh = NULL; |
718e3744 | 7270 | |
7271 | bgp = p->bgp; | |
7272 | ||
e8f7da3a DW |
7273 | if (use_json) |
7274 | json_neigh = json_object_new_object(); | |
7275 | ||
856ca177 | 7276 | if (!use_json) |
f14e6fdb | 7277 | { |
856ca177 MS |
7278 | if (p->conf_if) /* Configured interface name. */ |
7279 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7280 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7281 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7282 | else /* Configured IP address. */ | |
7283 | { | |
7284 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7285 | if (peer_dynamic_neighbor(p)) | |
7286 | dn_flag[0] = '*'; | |
f14e6fdb | 7287 | |
856ca177 MS |
7288 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
7289 | } | |
f14e6fdb DS |
7290 | } |
7291 | ||
856ca177 MS |
7292 | if (use_json) |
7293 | { | |
7294 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7295 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7296 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7297 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7298 | ||
7299 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7300 | ||
7301 | if (p->change_local_as) | |
7302 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7303 | else | |
7304 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7305 | ||
7306 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7307 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7308 | |
856ca177 MS |
7309 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7310 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7311 | } | |
7312 | else | |
7313 | { | |
f8cfafda DS |
7314 | if ((p->as_type == AS_SPECIFIED) || |
7315 | (p->as_type == AS_EXTERNAL) || | |
7316 | (p->as_type == AS_INTERNAL)) | |
7317 | vty_out (vty, "remote AS %u, ", p->as); | |
7318 | else | |
7319 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7320 | vty_out (vty, "local AS %u%s%s, ", |
7321 | p->change_local_as ? p->change_local_as : p->local_as, | |
7322 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7323 | " no-prepend" : "", | |
7324 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7325 | " replace-as" : ""); | |
7326 | } | |
66b199b2 DS |
7327 | /* peer type internal, external, confed-internal or confed-external */ |
7328 | if (p->as == p->local_as) | |
7329 | { | |
856ca177 MS |
7330 | if (use_json) |
7331 | { | |
7332 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7333 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7334 | else | |
7335 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7336 | } | |
66b199b2 | 7337 | else |
856ca177 MS |
7338 | { |
7339 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7340 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7341 | else | |
7342 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7343 | } | |
66b199b2 DS |
7344 | } |
7345 | else | |
7346 | { | |
856ca177 MS |
7347 | if (use_json) |
7348 | { | |
7349 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7350 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7351 | else | |
7352 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7353 | } | |
66b199b2 | 7354 | else |
856ca177 MS |
7355 | { |
7356 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7357 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7358 | else | |
7359 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7360 | } | |
66b199b2 | 7361 | } |
718e3744 | 7362 | |
7363 | /* Description. */ | |
7364 | if (p->desc) | |
856ca177 MS |
7365 | { |
7366 | if (use_json) | |
7367 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7368 | else | |
7369 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7370 | } | |
6410e93a | 7371 | |
04b6bdc0 DW |
7372 | if (p->hostname) |
7373 | { | |
d1570739 DW |
7374 | if (use_json) |
7375 | { | |
7376 | if (p->hostname) | |
7377 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7378 | ||
7379 | if (p->domainname) | |
7380 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7381 | } | |
04b6bdc0 | 7382 | else |
d1570739 DW |
7383 | { |
7384 | if (p->domainname && (p->domainname[0] != '\0')) | |
7385 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7386 | VTY_NEWLINE); | |
7387 | else | |
7388 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7389 | } | |
7390 | ||
04b6bdc0 DW |
7391 | } |
7392 | ||
c744aa9f | 7393 | /* Peer-group */ |
718e3744 | 7394 | if (p->group) |
f14e6fdb | 7395 | { |
856ca177 MS |
7396 | if (use_json) |
7397 | { | |
7398 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7399 | ||
7400 | if (dn_flag[0]) | |
7401 | { | |
40ee54a7 | 7402 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7403 | |
40ee54a7 TT |
7404 | sockunion2hostprefix(&(p->su), &prefix); |
7405 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7406 | |
7407 | if (range) | |
7408 | { | |
7409 | prefix2str(range, buf1, sizeof(buf1)); | |
7410 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7411 | } | |
7412 | } | |
7413 | } | |
7414 | else | |
f14e6fdb | 7415 | { |
856ca177 MS |
7416 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7417 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7418 | |
856ca177 | 7419 | if (dn_flag[0]) |
f14e6fdb | 7420 | { |
40ee54a7 | 7421 | struct prefix prefix, *range = NULL; |
856ca177 | 7422 | |
40ee54a7 TT |
7423 | sockunion2hostprefix(&(p->su), &prefix); |
7424 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7425 | |
7426 | if (range) | |
7427 | { | |
7428 | prefix2str(range, buf1, sizeof(buf1)); | |
7429 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7430 | } | |
f14e6fdb DS |
7431 | } |
7432 | } | |
7433 | } | |
718e3744 | 7434 | |
856ca177 MS |
7435 | if (use_json) |
7436 | { | |
7437 | /* Administrative shutdown. */ | |
7438 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7439 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7440 | |
856ca177 MS |
7441 | /* BGP Version. */ |
7442 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
7443 | json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ)); | |
718e3744 | 7444 | |
856ca177 MS |
7445 | /* Confederation */ |
7446 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7447 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7448 | ||
7449 | /* Status. */ | |
7450 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7451 | ||
7452 | if (p->status == Established) | |
7453 | { | |
7454 | time_t uptime; | |
7455 | struct tm *tm; | |
7456 | ||
7457 | uptime = bgp_clock(); | |
7458 | uptime -= p->uptime; | |
7459 | tm = gmtime(&uptime); | |
7460 | ||
7461 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7462 | } | |
7463 | ||
7464 | else if (p->status == Active) | |
7465 | { | |
7466 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7467 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7468 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7469 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7470 | } | |
7471 | ||
7472 | /* read timer */ | |
7473 | time_t uptime; | |
7474 | struct tm *tm; | |
7475 | ||
7476 | uptime = bgp_clock(); | |
7477 | uptime -= p->readtime; | |
7478 | tm = gmtime(&uptime); | |
7479 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7480 | ||
7481 | uptime = bgp_clock(); | |
7482 | uptime -= p->last_write; | |
7483 | tm = gmtime(&uptime); | |
39e871e6 ST |
7484 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7485 | ||
7486 | uptime = bgp_clock(); | |
7487 | uptime -= p->update_time; | |
7488 | tm = gmtime(&uptime); | |
7489 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7490 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7491 | |
7492 | /* Configured timer values. */ | |
7493 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7494 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7495 | ||
7496 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7497 | { | |
7498 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7499 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7500 | } | |
93406d87 | 7501 | } |
856ca177 MS |
7502 | else |
7503 | { | |
7504 | /* Administrative shutdown. */ | |
7505 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7506 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7507 | ||
7508 | /* BGP Version. */ | |
7509 | vty_out (vty, " BGP version 4"); | |
7510 | vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ), | |
7511 | VTY_NEWLINE); | |
7512 | ||
7513 | /* Confederation */ | |
7514 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7515 | && bgp_confederation_peers_check (bgp, p->as)) | |
7516 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7517 | |
856ca177 MS |
7518 | /* Status. */ |
7519 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7520 | |
856ca177 MS |
7521 | if (p->status == Established) |
7522 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7523 | ||
7524 | else if (p->status == Active) | |
7525 | { | |
7526 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7527 | vty_out (vty, " (passive)"); | |
7528 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7529 | vty_out (vty, " (NSF passive)"); | |
7530 | } | |
7531 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7532 | |
856ca177 MS |
7533 | /* read timer */ |
7534 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7535 | vty_out (vty, ", Last write %s%s", | |
7536 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7537 | ||
7538 | /* Configured timer values. */ | |
7539 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7540 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7541 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7542 | { | |
7543 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7544 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7545 | p->keepalive, VTY_NEWLINE); | |
7546 | } | |
7547 | } | |
718e3744 | 7548 | /* Capability. */ |
e52702f2 | 7549 | if (p->status == Established) |
718e3744 | 7550 | { |
538621f2 | 7551 | if (p->cap |
718e3744 | 7552 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7553 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7554 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7555 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7556 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7557 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7558 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7559 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7560 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7561 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7562 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7563 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7564 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7565 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7566 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7567 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7568 | { | |
856ca177 MS |
7569 | if (use_json) |
7570 | { | |
7571 | json_object *json_cap = NULL; | |
7572 | ||
7573 | json_cap = json_object_new_object(); | |
7574 | ||
7575 | /* AS4 */ | |
7576 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7577 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7578 | { | |
7579 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7580 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7581 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7582 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7583 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7584 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7585 | } | |
7586 | ||
7587 | /* AddPath */ | |
7588 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7589 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7590 | { | |
7591 | json_object *json_add = NULL; | |
7592 | const char *print_store; | |
718e3744 | 7593 | |
856ca177 | 7594 | json_add = json_object_new_object(); |
a82478b9 | 7595 | |
856ca177 MS |
7596 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7597 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7598 | { | |
7599 | json_object *json_sub = NULL; | |
7600 | json_sub = json_object_new_object(); | |
7601 | print_store = afi_safi_print (afi, safi); | |
7602 | ||
7603 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7604 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7605 | { | |
7606 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7607 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7608 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7609 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7610 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7611 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7612 | } | |
7613 | ||
7614 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7615 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7616 | { | |
7617 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7618 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7619 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7620 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7621 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7622 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7623 | } | |
7624 | ||
7625 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7626 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7627 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7628 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7629 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7630 | else |
7631 | json_object_free(json_sub); | |
856ca177 | 7632 | } |
a82478b9 | 7633 | |
856ca177 MS |
7634 | json_object_object_add(json_cap, "addPath", json_add); |
7635 | } | |
7636 | ||
7637 | /* Dynamic */ | |
7638 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7639 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7640 | { | |
7641 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7642 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7643 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7644 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7645 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7646 | json_object_string_add(json_cap, "dynamic", "received"); | |
7647 | } | |
7648 | ||
7649 | /* Extended nexthop */ | |
7650 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7651 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7652 | { | |
7653 | json_object *json_nxt = NULL; | |
7654 | const char *print_store; | |
7655 | ||
856ca177 MS |
7656 | |
7657 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7658 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7659 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7660 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7661 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7662 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7663 | ||
7664 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7665 | { | |
b6df4090 DS |
7666 | json_nxt = json_object_new_object(); |
7667 | ||
856ca177 MS |
7668 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7669 | { | |
7670 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7671 | { | |
7672 | print_store = afi_safi_print (AFI_IP, safi); | |
7673 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7674 | } | |
7675 | } | |
7676 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7677 | } | |
7678 | } | |
7679 | ||
7680 | /* Route Refresh */ | |
7681 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7682 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7683 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7684 | { | |
7685 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) && (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))) | |
7686 | { | |
7687 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7688 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7689 | else | |
7690 | { | |
7691 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7692 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7693 | else | |
7694 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7695 | } | |
7696 | } | |
7697 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7698 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7699 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7700 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7701 | } | |
7702 | ||
7703 | /* Multiprotocol Extensions */ | |
7704 | json_object *json_multi = NULL; | |
7705 | json_multi = json_object_new_object(); | |
7706 | ||
7707 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7708 | { | |
7709 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7710 | { | |
7711 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7712 | { | |
7713 | json_object *json_exten = NULL; | |
7714 | json_exten = json_object_new_object(); | |
7715 | ||
7716 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7717 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7718 | else if (p->afc_adv[afi][safi]) | |
7719 | json_object_boolean_true_add(json_exten, "advertised"); | |
7720 | else if (p->afc_recv[afi][safi]) | |
7721 | json_object_boolean_true_add(json_exten, "received"); | |
7722 | ||
7723 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7724 | } | |
7725 | } | |
7726 | } | |
7727 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7728 | ||
7729 | /* Gracefull Restart */ | |
7730 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7731 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7732 | { | |
7733 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7734 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7735 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7736 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7737 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7738 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7739 | ||
7740 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7741 | { | |
7742 | int restart_af_count = 0; | |
7743 | json_object *json_restart = NULL; | |
7744 | json_restart = json_object_new_object(); | |
7745 | ||
7746 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7747 | ||
7748 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7749 | { | |
7750 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7751 | { | |
7752 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7753 | { | |
7754 | json_object *json_sub = NULL; | |
7755 | json_sub = json_object_new_object(); | |
7756 | ||
7757 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7758 | json_object_boolean_true_add(json_sub, "preserved"); | |
7759 | restart_af_count++; | |
7760 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7761 | } | |
7762 | } | |
7763 | } | |
7764 | if (! restart_af_count) | |
b6df4090 | 7765 | { |
856ca177 | 7766 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7767 | json_object_free(json_restart); |
7768 | } | |
856ca177 MS |
7769 | else |
7770 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7771 | } | |
7772 | } | |
7773 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7774 | } | |
7775 | else | |
7776 | { | |
7777 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7778 | ||
7779 | /* AS4 */ | |
7780 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7781 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7782 | { | |
7783 | vty_out (vty, " 4 Byte AS:"); | |
7784 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7785 | vty_out (vty, " advertised"); | |
7786 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7787 | vty_out (vty, " %sreceived", | |
7788 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7789 | vty_out (vty, "%s", VTY_NEWLINE); | |
7790 | } | |
7791 | ||
7792 | /* AddPath */ | |
7793 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7794 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7795 | { | |
7796 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7797 | |
856ca177 MS |
7798 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7799 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7800 | { |
856ca177 MS |
7801 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7802 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7803 | { | |
7804 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7805 | |
856ca177 MS |
7806 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7807 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7808 | |
856ca177 MS |
7809 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7810 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7811 | |
856ca177 MS |
7812 | vty_out (vty, "%s", VTY_NEWLINE); |
7813 | } | |
a82478b9 | 7814 | |
856ca177 | 7815 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7816 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7817 | { |
7818 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7819 | |
856ca177 MS |
7820 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7821 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7822 | |
856ca177 MS |
7823 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7824 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7825 | |
856ca177 MS |
7826 | vty_out (vty, "%s", VTY_NEWLINE); |
7827 | } | |
a82478b9 | 7828 | } |
856ca177 | 7829 | } |
a82478b9 | 7830 | |
856ca177 MS |
7831 | /* Dynamic */ |
7832 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7833 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7834 | { | |
7835 | vty_out (vty, " Dynamic:"); | |
7836 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7837 | vty_out (vty, " advertised"); | |
7838 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7839 | vty_out (vty, " %sreceived", | |
7840 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
7841 | vty_out (vty, "%s", VTY_NEWLINE); | |
7842 | } | |
7843 | ||
7844 | /* Extended nexthop */ | |
7845 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7846 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7847 | { | |
7848 | vty_out (vty, " Extended nexthop:"); | |
7849 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7850 | vty_out (vty, " advertised"); | |
7851 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7852 | vty_out (vty, " %sreceived", | |
7853 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
7854 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7855 | |
856ca177 MS |
7856 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
7857 | { | |
7858 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7859 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7860 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7861 | vty_out (vty, " %s%s", | |
7862 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
7863 | } | |
7864 | } | |
8a92a8a0 | 7865 | |
856ca177 MS |
7866 | /* Route Refresh */ |
7867 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7868 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7869 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7870 | { | |
7871 | vty_out (vty, " Route refresh:"); | |
7872 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7873 | vty_out (vty, " advertised"); | |
7874 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7875 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7876 | vty_out (vty, " %sreceived(%s)", | |
7877 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
7878 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
7879 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
7880 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 7881 | |
856ca177 MS |
7882 | vty_out (vty, "%s", VTY_NEWLINE); |
7883 | } | |
718e3744 | 7884 | |
856ca177 MS |
7885 | /* Multiprotocol Extensions */ |
7886 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7887 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7888 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7889 | { | |
8c3deaae | 7890 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
7891 | if (p->afc_adv[afi][safi]) |
7892 | vty_out (vty, " advertised"); | |
7893 | if (p->afc_recv[afi][safi]) | |
7894 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
7895 | vty_out (vty, "%s", VTY_NEWLINE); | |
7896 | } | |
538621f2 | 7897 | |
04b6bdc0 DW |
7898 | /* Hostname capability */ |
7899 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
7900 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7901 | { | |
7902 | vty_out (vty, " Hostname Capability:"); | |
7903 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
7904 | vty_out (vty, " advertised"); | |
7905 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7906 | vty_out (vty, " %sreceived", | |
7907 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
7908 | vty_out (vty, "%s", VTY_NEWLINE); | |
7909 | } | |
7910 | ||
856ca177 MS |
7911 | /* Gracefull Restart */ |
7912 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7913 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7914 | { | |
7915 | vty_out (vty, " Graceful Restart Capabilty:"); | |
7916 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 7917 | vty_out (vty, " advertised"); |
856ca177 MS |
7918 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7919 | vty_out (vty, " %sreceived", | |
7920 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
7921 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 7922 | |
856ca177 MS |
7923 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7924 | { | |
7925 | int restart_af_count = 0; | |
7926 | ||
7927 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
7928 | p->v_gr_restart, VTY_NEWLINE); | |
7929 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7930 | ||
7931 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7932 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7933 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7934 | { | |
7935 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
7936 | afi_safi_print (afi, safi), | |
7937 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
7938 | "preserved" : "not preserved"); | |
7939 | restart_af_count++; | |
7940 | } | |
7941 | if (! restart_af_count) | |
7942 | vty_out (vty, "none"); | |
7943 | vty_out (vty, "%s", VTY_NEWLINE); | |
7944 | } | |
7945 | } | |
7946 | } | |
718e3744 | 7947 | } |
7948 | } | |
7949 | ||
93406d87 | 7950 | /* graceful restart information */ |
7951 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7952 | || p->t_gr_restart | |
7953 | || p->t_gr_stale) | |
7954 | { | |
856ca177 MS |
7955 | json_object *json_grace = NULL; |
7956 | json_object *json_grace_send = NULL; | |
7957 | json_object *json_grace_recv = NULL; | |
93406d87 | 7958 | int eor_send_af_count = 0; |
7959 | int eor_receive_af_count = 0; | |
7960 | ||
856ca177 MS |
7961 | if (use_json) |
7962 | { | |
7963 | json_grace = json_object_new_object(); | |
7964 | json_grace_send = json_object_new_object(); | |
7965 | json_grace_recv = json_object_new_object(); | |
7966 | ||
7967 | if (p->status == Established) | |
7968 | { | |
7969 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7970 | { | |
7971 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7972 | { | |
7973 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7974 | { | |
7975 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
7976 | eor_send_af_count++; | |
7977 | } | |
7978 | } | |
7979 | } | |
7980 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7981 | { | |
7982 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7983 | { | |
7984 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7985 | { | |
7986 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
7987 | eor_receive_af_count++; | |
7988 | } | |
7989 | } | |
7990 | } | |
7991 | } | |
7992 | ||
7993 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
7994 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
7995 | ||
7996 | if (p->t_gr_restart) | |
7997 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
7998 | ||
7999 | if (p->t_gr_stale) | |
8000 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
8001 | ||
8002 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
8003 | } | |
8004 | else | |
8005 | { | |
8006 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
8007 | if (p->status == Established) | |
8008 | { | |
8009 | vty_out (vty, " End-of-RIB send: "); | |
8010 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8011 | { | |
8012 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8013 | { | |
8014 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8015 | { | |
8016 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8017 | afi_safi_print (afi, safi)); | |
8018 | eor_send_af_count++; | |
8019 | } | |
8020 | } | |
8021 | } | |
8022 | vty_out (vty, "%s", VTY_NEWLINE); | |
8023 | vty_out (vty, " End-of-RIB received: "); | |
8024 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8025 | { | |
8026 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8027 | { | |
8028 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8029 | { | |
8030 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8031 | afi_safi_print (afi, safi)); | |
8032 | eor_receive_af_count++; | |
8033 | } | |
8034 | } | |
8035 | } | |
8036 | vty_out (vty, "%s", VTY_NEWLINE); | |
8037 | } | |
93406d87 | 8038 | |
856ca177 MS |
8039 | if (p->t_gr_restart) |
8040 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8041 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8042 | |
856ca177 MS |
8043 | if (p->t_gr_stale) |
8044 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8045 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8046 | } | |
8047 | } | |
8048 | if (use_json) | |
8049 | { | |
8050 | json_object *json_stat = NULL; | |
8051 | json_stat = json_object_new_object(); | |
8052 | /* Packet counts. */ | |
8053 | json_object_int_add(json_stat, "depthInq", 0); | |
8054 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8055 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8056 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8057 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8058 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8059 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8060 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8061 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8062 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8063 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8064 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8065 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8066 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8067 | json_object_int_add(json_stat, "totalSent", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out); | |
8068 | json_object_int_add(json_stat, "totalRecv", p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + p->dynamic_cap_in); | |
8069 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8070 | } | |
8071 | else | |
8072 | { | |
8073 | /* Packet counts. */ | |
8074 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8075 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8076 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8077 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8078 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8079 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8080 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8081 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8082 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8083 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8084 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8085 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8086 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8087 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8088 | } |
8089 | ||
856ca177 MS |
8090 | if (use_json) |
8091 | { | |
8092 | /* advertisement-interval */ | |
8093 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8094 | |
856ca177 MS |
8095 | /* Update-source. */ |
8096 | if (p->update_if || p->update_source) | |
8097 | { | |
8098 | if (p->update_if) | |
8099 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8100 | else if (p->update_source) | |
8101 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8102 | } | |
856ca177 MS |
8103 | } |
8104 | else | |
8105 | { | |
8106 | /* advertisement-interval */ | |
8107 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8108 | p->v_routeadv, VTY_NEWLINE); | |
8109 | ||
8110 | /* Update-source. */ | |
8111 | if (p->update_if || p->update_source) | |
8112 | { | |
8113 | vty_out (vty, " Update source is "); | |
8114 | if (p->update_if) | |
8115 | vty_out (vty, "%s", p->update_if); | |
8116 | else if (p->update_source) | |
8117 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8118 | vty_out (vty, "%s", VTY_NEWLINE); | |
8119 | } | |
8120 | ||
856ca177 MS |
8121 | vty_out (vty, "%s", VTY_NEWLINE); |
8122 | } | |
718e3744 | 8123 | |
8124 | /* Address Family Information */ | |
856ca177 MS |
8125 | json_object *json_hold = NULL; |
8126 | ||
8127 | if (use_json) | |
8128 | json_hold = json_object_new_object(); | |
8129 | ||
538621f2 | 8130 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8131 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8132 | if (p->afc[afi][safi]) | |
856ca177 | 8133 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8134 | |
856ca177 MS |
8135 | if (use_json) |
8136 | { | |
58433ae6 | 8137 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8138 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8139 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8140 | } |
8141 | else | |
8142 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8143 | VTY_NEWLINE); | |
718e3744 | 8144 | |
d6661008 | 8145 | if (! p->last_reset) |
856ca177 MS |
8146 | { |
8147 | if (use_json) | |
e08ac8b7 | 8148 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8149 | else |
8150 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8151 | } | |
e0701b79 | 8152 | else |
d6661008 | 8153 | { |
856ca177 MS |
8154 | if (use_json) |
8155 | { | |
8156 | time_t uptime; | |
8157 | struct tm *tm; | |
8158 | ||
8159 | uptime = bgp_clock(); | |
8160 | uptime -= p->resettime; | |
8161 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8162 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8163 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
856ca177 MS |
8164 | if (p->last_reset_cause_size) |
8165 | { | |
39e871e6 ST |
8166 | char errorcodesubcode_hexstr[5]; |
8167 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); | |
e08ac8b7 | 8168 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
856ca177 MS |
8169 | } |
8170 | } | |
8171 | else | |
d6661008 | 8172 | { |
3a8c7ba1 DW |
8173 | vty_out (vty, " Last reset %s, ", |
8174 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8175 | ||
8176 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8177 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8178 | { | |
8179 | code_str = bgp_notify_code_str(p->notify.code); | |
8180 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8181 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8182 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8183 | code_str, subcode_str, VTY_NEWLINE); | |
8184 | } | |
8185 | else | |
8186 | { | |
8187 | vty_out (vty, "due to %s%s", | |
8188 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8189 | } | |
856ca177 MS |
8190 | |
8191 | if (p->last_reset_cause_size) | |
d6661008 | 8192 | { |
856ca177 MS |
8193 | msg = p->last_reset_cause; |
8194 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8195 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8196 | { | |
8197 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8198 | |
856ca177 MS |
8199 | if (i != p->last_reset_cause_size) |
8200 | { | |
8201 | if (i % 16 == 0) | |
8202 | { | |
8203 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8204 | } | |
8205 | else if (i % 4 == 0) | |
8206 | { | |
8207 | vty_out(vty, " "); | |
8208 | } | |
8209 | } | |
8210 | } | |
8211 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8212 | } |
d6661008 DS |
8213 | } |
8214 | } | |
848973c7 | 8215 | |
718e3744 | 8216 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8217 | { | |
856ca177 | 8218 | if (use_json) |
e08ac8b7 | 8219 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8220 | else |
8221 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8222 | |
8223 | if (p->t_pmax_restart) | |
856ca177 MS |
8224 | { |
8225 | if (use_json) | |
8226 | { | |
e08ac8b7 DW |
8227 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8228 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8229 | } |
8230 | else | |
8231 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8232 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8233 | VTY_NEWLINE); | |
8234 | } | |
0a486e5f | 8235 | else |
856ca177 MS |
8236 | { |
8237 | if (use_json) | |
e08ac8b7 | 8238 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8239 | else |
8240 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8241 | p->host, VTY_NEWLINE); | |
8242 | } | |
718e3744 | 8243 | } |
8244 | ||
f5a4827d | 8245 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8246 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8247 | { |
856ca177 MS |
8248 | if (use_json) |
8249 | { | |
8250 | if (p->gtsm_hops > 0) | |
8251 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8252 | else if (p->ttl > 1) | |
8253 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8254 | } | |
8255 | else | |
8256 | { | |
8257 | if (p->gtsm_hops > 0) | |
8258 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8259 | p->gtsm_hops, VTY_NEWLINE); | |
8260 | else if (p->ttl > 1) | |
8261 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8262 | p->ttl, VTY_NEWLINE); | |
8263 | } | |
f5a4827d | 8264 | } |
5d804b43 PM |
8265 | else |
8266 | { | |
8267 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8268 | { |
8269 | if (use_json) | |
8270 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8271 | else | |
8272 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8273 | p->gtsm_hops, VTY_NEWLINE); | |
8274 | } | |
5d804b43 | 8275 | } |
718e3744 | 8276 | |
8277 | /* Local address. */ | |
8278 | if (p->su_local) | |
8279 | { | |
856ca177 MS |
8280 | if (use_json) |
8281 | { | |
8282 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8283 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8284 | } | |
8285 | else | |
8286 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8287 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8288 | ntohs (p->su_local->sin.sin_port), | |
8289 | VTY_NEWLINE); | |
718e3744 | 8290 | } |
e52702f2 | 8291 | |
718e3744 | 8292 | /* Remote address. */ |
8293 | if (p->su_remote) | |
8294 | { | |
856ca177 MS |
8295 | if (use_json) |
8296 | { | |
8297 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8298 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8299 | } | |
8300 | else | |
8301 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8302 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8303 | ntohs (p->su_remote->sin.sin_port), | |
8304 | VTY_NEWLINE); | |
8305 | } | |
8306 | ||
8307 | /* Nexthop display. */ | |
8308 | if (p->su_local) | |
8309 | { | |
856ca177 MS |
8310 | if (use_json) |
8311 | { | |
8312 | json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); | |
856ca177 MS |
8313 | json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); |
8314 | json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); | |
8315 | if (p->shared_network) | |
8316 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8317 | else | |
8318 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8319 | } |
8320 | else | |
8321 | { | |
8322 | vty_out (vty, "Nexthop: %s%s", | |
8323 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), | |
8324 | VTY_NEWLINE); | |
856ca177 MS |
8325 | vty_out (vty, "Nexthop global: %s%s", |
8326 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), | |
8327 | VTY_NEWLINE); | |
8328 | vty_out (vty, "Nexthop local: %s%s", | |
8329 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ), | |
8330 | VTY_NEWLINE); | |
8331 | vty_out (vty, "BGP connection: %s%s", | |
8332 | p->shared_network ? "shared network" : "non shared network", | |
8333 | VTY_NEWLINE); | |
856ca177 | 8334 | } |
718e3744 | 8335 | } |
8336 | ||
8337 | /* Timer information. */ | |
856ca177 MS |
8338 | if (use_json) |
8339 | { | |
39e871e6 | 8340 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8341 | if (p->status == Established && p->rtt) |
8342 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8343 | if (p->t_start) |
8344 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8345 | if (p->t_connect) | |
8346 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8347 | if (p->t_routeadv) | |
8348 | { | |
8349 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8350 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8351 | } | |
cb1faec9 | 8352 | |
856ca177 MS |
8353 | if (p->t_read) |
8354 | json_object_string_add(json_neigh, "readThread", "on"); | |
8355 | else | |
8356 | json_object_string_add(json_neigh, "readThread", "off"); | |
8357 | if (p->t_write) | |
8358 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8359 | else | |
8360 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8361 | } | |
8362 | else | |
8363 | { | |
39e871e6 ST |
8364 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8365 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8366 | if (p->status == Established && p->rtt) |
8367 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8368 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8369 | if (p->t_start) |
8370 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8371 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8372 | if (p->t_connect) | |
8373 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8374 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8375 | if (p->t_routeadv) | |
8376 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8377 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8378 | VTY_NEWLINE); | |
8379 | ||
8380 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8381 | p->t_read ? "on" : "off", | |
8382 | p->t_write ? "on" : "off", | |
8383 | VTY_NEWLINE); | |
8384 | } | |
718e3744 | 8385 | |
8386 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8387 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8388 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8389 | ||
8390 | if (!use_json) | |
8391 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8392 | |
8393 | /* BFD information. */ | |
856ca177 MS |
8394 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8395 | ||
8396 | if (use_json) | |
8397 | { | |
8398 | if (p->conf_if) /* Configured interface name. */ | |
8399 | json_object_object_add(json, p->conf_if, json_neigh); | |
8400 | else /* Configured IP address. */ | |
8401 | json_object_object_add(json, p->host, json_neigh); | |
8402 | } | |
718e3744 | 8403 | } |
8404 | ||
94f2b392 | 8405 | static int |
856ca177 MS |
8406 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8407 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8408 | { |
1eb8ef25 | 8409 | struct listnode *node, *nnode; |
718e3744 | 8410 | struct peer *peer; |
8411 | int find = 0; | |
8412 | ||
1eb8ef25 | 8413 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8414 | { |
1ff9a340 DS |
8415 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8416 | continue; | |
8417 | ||
718e3744 | 8418 | switch (type) |
856ca177 MS |
8419 | { |
8420 | case show_all: | |
e8f7da3a | 8421 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8422 | break; |
8423 | case show_peer: | |
8424 | if (conf_if) | |
8425 | { | |
4873b3b9 DW |
8426 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8427 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8428 | { |
8429 | find = 1; | |
e8f7da3a | 8430 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8431 | } |
8432 | } | |
8433 | else | |
8434 | { | |
8435 | if (sockunion_same (&peer->su, su)) | |
8436 | { | |
8437 | find = 1; | |
e8f7da3a | 8438 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8439 | } |
8440 | } | |
8441 | break; | |
718e3744 | 8442 | } |
8443 | } | |
8444 | ||
8445 | if (type == show_peer && ! find) | |
856ca177 MS |
8446 | { |
8447 | if (use_json) | |
8448 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8449 | else | |
8450 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8451 | } | |
8452 | ||
8453 | if (use_json) | |
8454 | { | |
2aac5767 | 8455 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8456 | json_object_free(json); |
8457 | } | |
8458 | else | |
8459 | { | |
8460 | vty_out (vty, "%s", VTY_NEWLINE); | |
8461 | } | |
8462 | ||
718e3744 | 8463 | return CMD_SUCCESS; |
8464 | } | |
8465 | ||
f186de26 | 8466 | static void |
8467 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8468 | { | |
8469 | struct listnode *node, *nnode; | |
8470 | struct bgp *bgp; | |
8471 | json_object *json = NULL; | |
9f689658 DD |
8472 | int is_first = 1; |
8473 | ||
8474 | if (use_json) | |
8475 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8476 | |
8477 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8478 | { | |
f186de26 | 8479 | if (use_json) |
9f689658 DD |
8480 | { |
8481 | if (!(json = json_object_new_object())) | |
8482 | { | |
8483 | zlog_err("Unable to allocate memory for JSON object"); | |
8484 | vty_out (vty, | |
8485 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8486 | VTY_NEWLINE); | |
8487 | return; | |
8488 | } | |
8489 | ||
8490 | json_object_int_add(json, "vrfId", | |
8491 | (bgp->vrf_id == VRF_UNKNOWN) | |
8492 | ? -1 : bgp->vrf_id); | |
8493 | json_object_string_add(json, "vrfName", | |
8494 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8495 | ? "Default" : bgp->name); | |
8496 | ||
8497 | if (! is_first) | |
8498 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8499 | else | |
8500 | is_first = 0; | |
8501 | ||
8502 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8503 | ? "Default" : bgp->name); | |
8504 | } | |
8505 | else | |
8506 | { | |
8507 | vty_out (vty, "%sInstance %s:%s", | |
8508 | VTY_NEWLINE, | |
8509 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8510 | ? "Default" : bgp->name, | |
8511 | VTY_NEWLINE); | |
8512 | } | |
f186de26 | 8513 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8514 | } | |
9f689658 DD |
8515 | |
8516 | if (use_json) | |
8517 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8518 | } |
8519 | ||
4fb25c53 DW |
8520 | static int |
8521 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8522 | enum show_type type, const char *ip_str, u_char use_json) | |
8523 | { | |
8524 | int ret; | |
8525 | struct bgp *bgp; | |
8526 | union sockunion su; | |
8527 | json_object *json = NULL; | |
8528 | ||
8529 | if (use_json) | |
8530 | json = json_object_new_object(); | |
8531 | ||
8532 | if (name) | |
8533 | { | |
8534 | if (strmatch(name, "all")) | |
8535 | { | |
8536 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8537 | return CMD_SUCCESS; | |
8538 | } | |
8539 | else | |
8540 | { | |
8541 | bgp = bgp_lookup_by_name (name); | |
8542 | if (! bgp) | |
8543 | { | |
8544 | if (use_json) | |
8545 | { | |
8546 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8547 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8548 | json_object_free(json); |
8549 | } | |
8550 | else | |
8551 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8552 | ||
8553 | return CMD_WARNING; | |
8554 | } | |
8555 | } | |
8556 | } | |
8557 | else | |
8558 | { | |
8559 | bgp = bgp_get_default (); | |
8560 | } | |
8561 | ||
8562 | if (bgp) | |
8563 | { | |
8564 | if (ip_str) | |
8565 | { | |
8566 | ret = str2sockunion (ip_str, &su); | |
8567 | if (ret < 0) | |
8568 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8569 | else | |
8570 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8571 | } | |
8572 | else | |
8573 | { | |
8574 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8575 | } | |
8576 | } | |
8577 | ||
8578 | return CMD_SUCCESS; | |
8579 | } | |
8580 | ||
716b2d8a | 8581 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8582 | DEFUN (show_ip_bgp_neighbors, |
8583 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8584 | "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 8585 | SHOW_STR |
8586 | IP_STR | |
8587 | BGP_STR | |
5bf15956 | 8588 | BGP_INSTANCE_ALL_HELP_STR |
8c3deaae QY |
8589 | "Address Family\n" |
8590 | "Address Family\n" | |
91d37724 QY |
8591 | "Address Family\n" |
8592 | "Display information about all VPNv4 NLRIs\n" | |
8593 | "Display information for a route distinguisher\n" | |
8594 | "VPN Route Distinguisher\n" | |
718e3744 | 8595 | "Detailed information on TCP and BGP neighbor connections\n" |
8596 | "Neighbor to display information about\n" | |
a80beece | 8597 | "Neighbor to display information about\n" |
91d37724 | 8598 | "Neighbor on BGP configured interface\n" |
9973d184 | 8599 | JSON_STR) |
718e3744 | 8600 | { |
5bf15956 DW |
8601 | char *vrf = NULL; |
8602 | char *sh_arg = NULL; | |
8603 | enum show_type sh_type; | |
718e3744 | 8604 | |
5bf15956 | 8605 | u_char uj = use_json(argc, argv); |
718e3744 | 8606 | |
630a298c | 8607 | int idx = 0; |
718e3744 | 8608 | |
630a298c QY |
8609 | if (argv_find (argv, argc, "WORD", &idx)) |
8610 | vrf = argv[idx]->arg; | |
718e3744 | 8611 | |
91d37724 QY |
8612 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8613 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8614 | argv_find (argv, argc, "WORD", &idx)) |
8615 | { | |
8616 | sh_type = show_peer; | |
8617 | sh_arg = argv[idx]->arg; | |
8618 | } | |
5bf15956 | 8619 | else |
630a298c | 8620 | sh_type = show_all; |
856ca177 | 8621 | |
5bf15956 | 8622 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8623 | } |
8624 | ||
716b2d8a | 8625 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8626 | paths' and `show ip mbgp paths'. Those functions results are the |
8627 | same.*/ | |
f412b39a | 8628 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8629 | show_ip_bgp_paths_cmd, |
46f296b4 | 8630 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8631 | SHOW_STR |
8632 | IP_STR | |
8633 | BGP_STR | |
46f296b4 | 8634 | BGP_SAFI_HELP_STR |
718e3744 | 8635 | "Path information\n") |
8636 | { | |
8637 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8638 | aspath_print_all_vty (vty); | |
8639 | return CMD_SUCCESS; | |
8640 | } | |
8641 | ||
718e3744 | 8642 | #include "hash.h" |
8643 | ||
94f2b392 | 8644 | static void |
718e3744 | 8645 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8646 | { | |
8647 | struct community *com; | |
8648 | ||
8649 | com = (struct community *) backet->data; | |
6c4f4e6e | 8650 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8651 | community_str (com), VTY_NEWLINE); |
8652 | } | |
8653 | ||
8654 | /* Show BGP's community internal data. */ | |
f412b39a | 8655 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8656 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8657 | "show [ip] bgp community-info", |
718e3744 | 8658 | SHOW_STR |
8659 | IP_STR | |
8660 | BGP_STR | |
8661 | "List all bgp community information\n") | |
8662 | { | |
8663 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8664 | ||
e52702f2 | 8665 | hash_iterate (community_hash (), |
718e3744 | 8666 | (void (*) (struct hash_backet *, void *)) |
8667 | community_show_all_iterator, | |
8668 | vty); | |
8669 | ||
8670 | return CMD_SUCCESS; | |
8671 | } | |
8672 | ||
57d187bc JS |
8673 | static void |
8674 | lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty) | |
8675 | { | |
8676 | struct lcommunity *lcom; | |
8677 | ||
8678 | lcom = (struct lcommunity *) backet->data; | |
8679 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, | |
8680 | lcommunity_str (lcom), VTY_NEWLINE); | |
8681 | } | |
8682 | ||
8683 | /* Show BGP's community internal data. */ | |
8684 | DEFUN (show_ip_bgp_lcommunity_info, | |
8685 | show_ip_bgp_lcommunity_info_cmd, | |
8686 | "show ip bgp large-community-info", | |
8687 | SHOW_STR | |
8688 | IP_STR | |
8689 | BGP_STR | |
8690 | "List all bgp large-community information\n") | |
8691 | { | |
8692 | vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); | |
8693 | ||
8694 | hash_iterate (lcommunity_hash (), | |
8695 | (void (*) (struct hash_backet *, void *)) | |
8696 | lcommunity_show_all_iterator, | |
8697 | vty); | |
8698 | ||
8699 | return CMD_SUCCESS; | |
8700 | } | |
8701 | ||
8702 | ||
f412b39a | 8703 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8704 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8705 | "show [ip] bgp attribute-info", |
718e3744 | 8706 | SHOW_STR |
8707 | IP_STR | |
8708 | BGP_STR | |
8709 | "List all bgp attribute information\n") | |
8710 | { | |
8711 | attr_show_all (vty); | |
8712 | return CMD_SUCCESS; | |
8713 | } | |
6b0655a2 | 8714 | |
f186de26 | 8715 | static void |
8716 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8717 | { | |
8718 | struct listnode *node, *nnode; | |
8719 | struct bgp *bgp; | |
8720 | ||
8721 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8722 | { | |
8723 | vty_out (vty, "%sInstance %s:%s", | |
8724 | VTY_NEWLINE, | |
8725 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8726 | VTY_NEWLINE); | |
8727 | update_group_show(bgp, afi, safi, vty, 0); | |
8728 | } | |
8729 | } | |
8730 | ||
4fb25c53 DW |
8731 | static int |
8732 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8733 | int afi, int safi, | |
8734 | uint64_t subgrp_id) | |
8735 | { | |
8736 | struct bgp *bgp; | |
8737 | ||
8738 | if (name) | |
8739 | { | |
8740 | if (strmatch (name, "all")) | |
8741 | { | |
8742 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8743 | return CMD_SUCCESS; | |
8744 | } | |
8745 | else | |
8746 | { | |
8747 | bgp = bgp_lookup_by_name (name); | |
8748 | } | |
8749 | } | |
8750 | else | |
8751 | { | |
8752 | bgp = bgp_get_default (); | |
8753 | } | |
8754 | ||
8755 | if (bgp) | |
8756 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8757 | return CMD_SUCCESS; | |
8758 | } | |
8759 | ||
8fe8a7f6 DS |
8760 | DEFUN (show_ip_bgp_updgrps, |
8761 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 8762 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 8763 | SHOW_STR |
8764 | IP_STR | |
8765 | BGP_STR | |
8766 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 8767 | BGP_AFI_HELP_STR |
46f296b4 | 8768 | BGP_SAFI_HELP_STR |
5bf15956 DW |
8769 | "Detailed info about dynamic update groups\n" |
8770 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8771 | { |
5bf15956 | 8772 | char *vrf = NULL; |
ae19d7dd QY |
8773 | afi_t afi = AFI_IP6; |
8774 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8775 | uint64_t subgrp_id = 0; |
8776 | ||
ae19d7dd QY |
8777 | int idx = 0; |
8778 | ||
8779 | /* show [ip] bgp */ | |
8780 | if (argv_find (argv, argc, "ip", &idx)) | |
8781 | afi = AFI_IP; | |
8782 | /* [<view|vrf> WORD] */ | |
8783 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8784 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
8785 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8786 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
8787 | { | |
8788 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
8789 | } | |
5bf15956 | 8790 | |
ae19d7dd QY |
8791 | /* get subgroup id, if provided */ |
8792 | idx = argc - 1; | |
8793 | if (argv[idx]->type == VARIABLE_TKN) | |
8794 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
8795 | |
8796 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
8797 | } |
8798 | ||
f186de26 | 8799 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
8800 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 8801 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 8802 | SHOW_STR |
716b2d8a | 8803 | IP_STR |
f186de26 | 8804 | BGP_STR |
8805 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 8806 | "Detailed info about dynamic update groups\n") |
f186de26 | 8807 | { |
8808 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
8809 | return CMD_SUCCESS; | |
8810 | } | |
8811 | ||
5bf15956 DW |
8812 | DEFUN (show_bgp_updgrps_stats, |
8813 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 8814 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 8815 | SHOW_STR |
716b2d8a | 8816 | IP_STR |
3f9c7369 | 8817 | BGP_STR |
0c7b1b01 | 8818 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8819 | "Statistics\n") |
8820 | { | |
8821 | struct bgp *bgp; | |
8822 | ||
8823 | bgp = bgp_get_default(); | |
8824 | if (bgp) | |
8825 | update_group_show_stats(bgp, vty); | |
8826 | ||
8827 | return CMD_SUCCESS; | |
8828 | } | |
8829 | ||
8386ac43 | 8830 | DEFUN (show_bgp_instance_updgrps_stats, |
8831 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 8832 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 8833 | SHOW_STR |
716b2d8a | 8834 | IP_STR |
8386ac43 | 8835 | BGP_STR |
8836 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8837 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8838 | "Statistics\n") |
8839 | { | |
c500ae40 | 8840 | int idx_word = 3; |
8386ac43 | 8841 | struct bgp *bgp; |
8842 | ||
c500ae40 | 8843 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 8844 | if (bgp) |
8845 | update_group_show_stats(bgp, vty); | |
8846 | ||
8847 | return CMD_SUCCESS; | |
8848 | } | |
8849 | ||
3f9c7369 | 8850 | static void |
8386ac43 | 8851 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
8852 | afi_t afi, safi_t safi, | |
f43e655e | 8853 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
8854 | { |
8855 | struct bgp *bgp; | |
8386ac43 | 8856 | |
8857 | if (name) | |
8858 | bgp = bgp_lookup_by_name (name); | |
8859 | else | |
8860 | bgp = bgp_get_default (); | |
8861 | ||
3f9c7369 DS |
8862 | if (bgp) |
8863 | { | |
8864 | if (!strcmp(what, "advertise-queue")) | |
8865 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
8866 | else if (!strcmp(what, "advertised-routes")) | |
8867 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
8868 | else if (!strcmp(what, "packet-queue")) | |
8869 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
8870 | } | |
8871 | } | |
8872 | ||
8873 | DEFUN (show_ip_bgp_updgrps_adj, | |
8874 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 8875 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8876 | SHOW_STR |
8877 | IP_STR | |
8878 | BGP_STR | |
0c7b1b01 | 8879 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8880 | "Advertisement queue\n" |
8881 | "Announced routes\n" | |
8882 | "Packet queue\n") | |
8fe8a7f6 | 8883 | |
3f9c7369 | 8884 | { |
c500ae40 DW |
8885 | int idx_type = 4; |
8886 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8887 | return CMD_SUCCESS; |
8888 | } | |
8889 | ||
8890 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
8891 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8892 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8893 | SHOW_STR |
8894 | IP_STR | |
8895 | BGP_STR | |
8896 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8897 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8898 | "Advertisement queue\n" |
8899 | "Announced routes\n" | |
8900 | "Packet queue\n") | |
8901 | ||
8902 | { | |
c500ae40 DW |
8903 | int idx_word = 4; |
8904 | int idx_type = 6; | |
8905 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8906 | return CMD_SUCCESS; |
8907 | } | |
8908 | ||
8909 | DEFUN (show_bgp_updgrps_afi_adj, | |
8910 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 8911 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8912 | SHOW_STR |
716b2d8a | 8913 | IP_STR |
3f9c7369 | 8914 | BGP_STR |
46f296b4 | 8915 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 8916 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8917 | "Advertisement queue\n" |
8918 | "Announced routes\n" | |
8fe8a7f6 DS |
8919 | "Packet queue\n" |
8920 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8921 | { |
c500ae40 DW |
8922 | int idx_afi = 2; |
8923 | int idx_safi = 3; | |
8924 | int idx_type = 5; | |
46f296b4 LB |
8925 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
8926 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
8927 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
8928 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 8929 | return CMD_SUCCESS; |
3f9c7369 DS |
8930 | } |
8931 | ||
8932 | DEFUN (show_bgp_updgrps_adj, | |
8933 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 8934 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8935 | SHOW_STR |
716b2d8a | 8936 | IP_STR |
3f9c7369 | 8937 | BGP_STR |
0c7b1b01 | 8938 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8939 | "Advertisement queue\n" |
8940 | "Announced routes\n" | |
8941 | "Packet queue\n") | |
8942 | { | |
c500ae40 DW |
8943 | int idx_type = 3; |
8944 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8945 | return CMD_SUCCESS; |
8946 | } | |
8947 | ||
8948 | DEFUN (show_bgp_instance_updgrps_adj, | |
8949 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8950 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8951 | SHOW_STR |
716b2d8a | 8952 | IP_STR |
8386ac43 | 8953 | BGP_STR |
8954 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8955 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8956 | "Advertisement queue\n" |
8957 | "Announced routes\n" | |
8958 | "Packet queue\n") | |
8959 | { | |
c500ae40 DW |
8960 | int idx_word = 3; |
8961 | int idx_type = 5; | |
8962 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8963 | return CMD_SUCCESS; |
8964 | } | |
8965 | ||
8966 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 8967 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 8968 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8969 | SHOW_STR |
8970 | IP_STR | |
8971 | BGP_STR | |
0c7b1b01 | 8972 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8973 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8974 | "Advertisement queue\n" |
8975 | "Announced routes\n" | |
8976 | "Packet queue\n") | |
3f9c7369 | 8977 | |
3f9c7369 | 8978 | { |
5bf15956 | 8979 | int idx_subgroup_id = 4; |
c500ae40 | 8980 | int idx_type = 5; |
f43e655e | 8981 | uint64_t subgrp_id; |
8fe8a7f6 | 8982 | |
5bf15956 | 8983 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8984 | |
5bf15956 | 8985 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 8986 | return CMD_SUCCESS; |
8987 | } | |
8988 | ||
8989 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
8990 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 8991 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8992 | SHOW_STR |
8993 | IP_STR | |
8994 | BGP_STR | |
8995 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8996 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8997 | "Specific subgroup to display info for\n" |
8998 | "Advertisement queue\n" | |
8999 | "Announced routes\n" | |
9000 | "Packet queue\n") | |
9001 | ||
9002 | { | |
5bf15956 DW |
9003 | int idx_vrf = 4; |
9004 | int idx_subgroup_id = 6; | |
c500ae40 | 9005 | int idx_type = 7; |
f43e655e | 9006 | uint64_t subgrp_id; |
8386ac43 | 9007 | |
5bf15956 | 9008 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9009 | |
5bf15956 | 9010 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
9011 | return CMD_SUCCESS; |
9012 | } | |
9013 | ||
8fe8a7f6 DS |
9014 | DEFUN (show_bgp_updgrps_afi_adj_s, |
9015 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 9016 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 9017 | SHOW_STR |
716b2d8a | 9018 | IP_STR |
3f9c7369 | 9019 | BGP_STR |
46f296b4 | 9020 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 9021 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 9022 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
9023 | "Advertisement queue\n" |
9024 | "Announced routes\n" | |
8fe8a7f6 DS |
9025 | "Packet queue\n" |
9026 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 9027 | { |
c500ae40 DW |
9028 | int idx_afi = 2; |
9029 | int idx_safi = 3; | |
5bf15956 | 9030 | int idx_subgroup_id = 5; |
c500ae40 | 9031 | int idx_type = 6; |
f43e655e | 9032 | uint64_t subgrp_id; |
3f9c7369 | 9033 | |
5bf15956 | 9034 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9035 | |
46f296b4 LB |
9036 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
9037 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
9038 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9039 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9040 | return CMD_SUCCESS; |
3f9c7369 DS |
9041 | } |
9042 | ||
8fe8a7f6 DS |
9043 | DEFUN (show_bgp_updgrps_adj_s, |
9044 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9045 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9046 | SHOW_STR |
716b2d8a | 9047 | IP_STR |
8fe8a7f6 | 9048 | BGP_STR |
0c7b1b01 | 9049 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9050 | "Specific subgroup to display info for\n" |
9051 | "Advertisement queue\n" | |
9052 | "Announced routes\n" | |
9053 | "Packet queue\n") | |
9054 | { | |
5bf15956 | 9055 | int idx_subgroup_id = 3; |
c500ae40 | 9056 | int idx_type = 4; |
f43e655e | 9057 | uint64_t subgrp_id; |
8fe8a7f6 | 9058 | |
5bf15956 | 9059 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9060 | |
5bf15956 | 9061 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9062 | return CMD_SUCCESS; |
9063 | } | |
9064 | ||
8386ac43 | 9065 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9066 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9067 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9068 | SHOW_STR |
716b2d8a | 9069 | IP_STR |
8386ac43 | 9070 | BGP_STR |
9071 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9072 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9073 | "Specific subgroup to display info for\n" |
9074 | "Advertisement queue\n" | |
9075 | "Announced routes\n" | |
9076 | "Packet queue\n") | |
9077 | { | |
5bf15956 DW |
9078 | int idx_vrf = 3; |
9079 | int idx_subgroup_id = 5; | |
c500ae40 | 9080 | int idx_type = 6; |
f43e655e | 9081 | uint64_t subgrp_id; |
8386ac43 | 9082 | |
5bf15956 | 9083 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9084 | |
5bf15956 | 9085 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9086 | return CMD_SUCCESS; |
9087 | } | |
9088 | ||
9089 | ||
8fe8a7f6 | 9090 | |
f14e6fdb DS |
9091 | static int |
9092 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9093 | { | |
9094 | struct listnode *node, *nnode; | |
9095 | struct prefix *range; | |
9096 | struct peer *conf; | |
9097 | struct peer *peer; | |
4690c7d7 | 9098 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9099 | afi_t afi; |
9100 | safi_t safi; | |
ffd0c037 DS |
9101 | const char *peer_status; |
9102 | const char *af_str; | |
f14e6fdb DS |
9103 | int lr_count; |
9104 | int dynamic; | |
9105 | int af_cfgd; | |
9106 | ||
9107 | conf = group->conf; | |
9108 | ||
0299c004 DS |
9109 | if (conf->as_type == AS_SPECIFIED || |
9110 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9111 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9112 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9113 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9114 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9115 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9116 | } else { |
9117 | vty_out (vty, "%sBGP peer-group %s%s", | |
9118 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9119 | } |
f14e6fdb | 9120 | |
0299c004 | 9121 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9122 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9123 | else | |
9124 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9125 | ||
9126 | /* Display AFs configured. */ | |
9127 | vty_out (vty, " Configured address-families:"); | |
9128 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9129 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9130 | { | |
9131 | if (conf->afc[afi][safi]) | |
9132 | { | |
9133 | af_cfgd = 1; | |
9134 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9135 | } | |
9136 | } | |
9137 | if (!af_cfgd) | |
9138 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9139 | else | |
9140 | vty_out (vty, "%s", VTY_NEWLINE); | |
9141 | ||
9142 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9143 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9144 | { | |
9145 | if (afi == AFI_IP) | |
9146 | af_str = "IPv4"; | |
9147 | else if (afi == AFI_IP6) | |
9148 | af_str = "IPv6"; | |
45ef4300 DL |
9149 | else |
9150 | af_str = "???"; | |
f14e6fdb DS |
9151 | lr_count = listcount(group->listen_range[afi]); |
9152 | if (lr_count) | |
9153 | { | |
9154 | vty_out(vty, | |
9155 | " %d %s listen range(s)%s", | |
9156 | lr_count, af_str, VTY_NEWLINE); | |
9157 | ||
9158 | ||
9159 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9160 | nnode, range)) | |
9161 | { | |
9162 | prefix2str(range, buf, sizeof(buf)); | |
9163 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9164 | } | |
9165 | } | |
9166 | } | |
9167 | ||
9168 | /* Display group members and their status */ | |
9169 | if (listcount(group->peer)) | |
9170 | { | |
9171 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9172 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9173 | { | |
9174 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9175 | peer_status = "Idle (Admin)"; | |
9176 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9177 | peer_status = "Idle (PfxCt)"; | |
9178 | else | |
9179 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9180 | ||
9181 | dynamic = peer_dynamic_neighbor(peer); | |
9182 | vty_out (vty, " %s %s %s %s", | |
9183 | peer->host, dynamic ? "(dynamic)" : "", | |
9184 | peer_status, VTY_NEWLINE); | |
9185 | } | |
9186 | } | |
9187 | ||
9188 | return CMD_SUCCESS; | |
9189 | } | |
9190 | ||
9191 | /* Show BGP peer group's information. */ | |
9192 | enum show_group_type | |
9193 | { | |
9194 | show_all_groups, | |
9195 | show_peer_group | |
9196 | }; | |
9197 | ||
9198 | static int | |
9199 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9200 | enum show_group_type type, const char *group_name) | |
9201 | { | |
9202 | struct listnode *node, *nnode; | |
9203 | struct peer_group *group; | |
9204 | int find = 0; | |
9205 | ||
9206 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9207 | { | |
9208 | switch (type) | |
9209 | { | |
9210 | case show_all_groups: | |
9211 | bgp_show_one_peer_group (vty, group); | |
9212 | break; | |
9213 | case show_peer_group: | |
9214 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9215 | { | |
9216 | find = 1; | |
9217 | bgp_show_one_peer_group (vty, group); | |
9218 | } | |
9219 | break; | |
9220 | } | |
9221 | } | |
9222 | ||
9223 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9224 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9225 | |
9226 | return CMD_SUCCESS; | |
9227 | } | |
9228 | ||
9229 | static int | |
9230 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9231 | enum show_group_type type, const char *group_name) | |
9232 | { | |
9233 | struct bgp *bgp; | |
9234 | int ret = CMD_SUCCESS; | |
9235 | ||
9236 | if (name) | |
8386ac43 | 9237 | bgp = bgp_lookup_by_name (name); |
9238 | else | |
9239 | bgp = bgp_get_default (); | |
f14e6fdb | 9240 | |
8386ac43 | 9241 | if (! bgp) |
9242 | { | |
9243 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9244 | return CMD_WARNING; | |
f14e6fdb DS |
9245 | } |
9246 | ||
8386ac43 | 9247 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9248 | |
9249 | return ret; | |
9250 | } | |
9251 | ||
9252 | DEFUN (show_ip_bgp_peer_groups, | |
9253 | show_ip_bgp_peer_groups_cmd, | |
d6e3c605 | 9254 | "show [ip] bgp [<view|vrf> VRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
9255 | SHOW_STR |
9256 | IP_STR | |
9257 | BGP_STR | |
8386ac43 | 9258 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9259 | "Detailed information on BGP peer groups\n" |
9260 | "Peer group name\n") | |
f14e6fdb | 9261 | { |
d6e3c605 QY |
9262 | char *vrf, *pg; |
9263 | vrf = pg = NULL; | |
9264 | int idx = 0; | |
f14e6fdb | 9265 | |
d6e3c605 QY |
9266 | vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; |
9267 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 9268 | |
d6e3c605 | 9269 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9270 | } |
3f9c7369 | 9271 | |
d6e3c605 | 9272 | |
718e3744 | 9273 | /* Redistribute VTY commands. */ |
9274 | ||
718e3744 | 9275 | DEFUN (bgp_redistribute_ipv4, |
9276 | bgp_redistribute_ipv4_cmd, | |
9ccf14f7 | 9277 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>", |
718e3744 | 9278 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9279 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9280 | { |
cdc2d765 | 9281 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9282 | int idx_protocol = 1; |
718e3744 | 9283 | int type; |
9284 | ||
6d681bd8 QY |
9285 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9286 | if (type < 0) | |
718e3744 | 9287 | { |
9288 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9289 | return CMD_WARNING; | |
9290 | } | |
cdc2d765 DL |
9291 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9292 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9293 | } |
9294 | ||
9295 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9296 | bgp_redistribute_ipv4_rmap_cmd, | |
9ccf14f7 | 9297 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD", |
718e3744 | 9298 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9299 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9300 | "Route map reference\n" |
9301 | "Pointer to route-map entries\n") | |
9302 | { | |
cdc2d765 | 9303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9304 | int idx_protocol = 1; |
9305 | int idx_word = 3; | |
718e3744 | 9306 | int type; |
7c8ff89e | 9307 | struct bgp_redist *red; |
718e3744 | 9308 | |
6d681bd8 QY |
9309 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9310 | if (type < 0) | |
718e3744 | 9311 | { |
9312 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9313 | return CMD_WARNING; | |
9314 | } | |
9315 | ||
cdc2d765 | 9316 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9317 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9318 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9319 | } |
9320 | ||
9321 | DEFUN (bgp_redistribute_ipv4_metric, | |
9322 | bgp_redistribute_ipv4_metric_cmd, | |
9ccf14f7 | 9323 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)", |
718e3744 | 9324 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9325 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9326 | "Metric for redistributed routes\n" |
9327 | "Default metric\n") | |
9328 | { | |
cdc2d765 | 9329 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9330 | int idx_protocol = 1; |
9331 | int idx_number = 3; | |
718e3744 | 9332 | int type; |
9333 | u_int32_t metric; | |
7c8ff89e | 9334 | struct bgp_redist *red; |
718e3744 | 9335 | |
6d681bd8 QY |
9336 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9337 | if (type < 0) | |
718e3744 | 9338 | { |
9339 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9340 | return CMD_WARNING; | |
9341 | } | |
c500ae40 | 9342 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9343 | |
cdc2d765 DL |
9344 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9345 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9346 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9347 | } |
9348 | ||
9349 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9350 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
9ccf14f7 | 9351 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9352 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9353 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9354 | "Route map reference\n" |
9355 | "Pointer to route-map entries\n" | |
9356 | "Metric for redistributed routes\n" | |
9357 | "Default metric\n") | |
9358 | { | |
cdc2d765 | 9359 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9360 | int idx_protocol = 1; |
9361 | int idx_word = 3; | |
9362 | int idx_number = 5; | |
718e3744 | 9363 | int type; |
9364 | u_int32_t metric; | |
7c8ff89e | 9365 | struct bgp_redist *red; |
718e3744 | 9366 | |
6d681bd8 QY |
9367 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9368 | if (type < 0) | |
718e3744 | 9369 | { |
9370 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9371 | return CMD_WARNING; | |
9372 | } | |
c500ae40 | 9373 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9374 | |
cdc2d765 | 9375 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9376 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9377 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9378 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9379 | } |
9380 | ||
9381 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9382 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
9ccf14f7 | 9383 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9384 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9385 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9386 | "Metric for redistributed routes\n" |
9387 | "Default metric\n" | |
9388 | "Route map reference\n" | |
9389 | "Pointer to route-map entries\n") | |
9390 | { | |
cdc2d765 | 9391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9392 | int idx_protocol = 1; |
9393 | int idx_number = 3; | |
9394 | int idx_word = 5; | |
718e3744 | 9395 | int type; |
9396 | u_int32_t metric; | |
7c8ff89e | 9397 | struct bgp_redist *red; |
718e3744 | 9398 | |
6d681bd8 QY |
9399 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9400 | if (type < 0) | |
718e3744 | 9401 | { |
9402 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9403 | return CMD_WARNING; | |
9404 | } | |
c500ae40 | 9405 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9406 | |
cdc2d765 DL |
9407 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9408 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9409 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9410 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9411 | } |
9412 | ||
7c8ff89e DS |
9413 | DEFUN (bgp_redistribute_ipv4_ospf, |
9414 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9415 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9416 | "Redistribute information from another routing protocol\n" |
9417 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9418 | "Non-main Kernel Routing Table\n" |
9419 | "Instance ID/Table ID\n") | |
7c8ff89e | 9420 | { |
cdc2d765 | 9421 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9422 | int idx_ospf_table = 1; |
9423 | int idx_number = 2; | |
7c8ff89e | 9424 | u_short instance; |
7a4bb9c5 | 9425 | u_short protocol; |
7c8ff89e | 9426 | |
c500ae40 | 9427 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9428 | |
c500ae40 | 9429 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9430 | protocol = ZEBRA_ROUTE_OSPF; |
9431 | else | |
9432 | protocol = ZEBRA_ROUTE_TABLE; | |
9433 | ||
cdc2d765 DL |
9434 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9435 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9436 | } |
9437 | ||
9438 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9439 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9440 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9441 | "Redistribute information from another routing protocol\n" |
9442 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9443 | "Non-main Kernel Routing Table\n" |
9444 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9445 | "Route map reference\n" |
9446 | "Pointer to route-map entries\n") | |
9447 | { | |
cdc2d765 | 9448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9449 | int idx_ospf_table = 1; |
9450 | int idx_number = 2; | |
9451 | int idx_word = 4; | |
7c8ff89e DS |
9452 | struct bgp_redist *red; |
9453 | u_short instance; | |
7a4bb9c5 | 9454 | int protocol; |
7c8ff89e | 9455 | |
c500ae40 | 9456 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9457 | protocol = ZEBRA_ROUTE_OSPF; |
9458 | else | |
9459 | protocol = ZEBRA_ROUTE_TABLE; | |
9460 | ||
c500ae40 | 9461 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9462 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9463 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9464 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9465 | } |
9466 | ||
9467 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9468 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9469 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9470 | "Redistribute information from another routing protocol\n" |
9471 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9472 | "Non-main Kernel Routing Table\n" |
9473 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9474 | "Metric for redistributed routes\n" |
9475 | "Default metric\n") | |
9476 | { | |
cdc2d765 | 9477 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9478 | int idx_ospf_table = 1; |
9479 | int idx_number = 2; | |
9480 | int idx_number_2 = 4; | |
7c8ff89e DS |
9481 | u_int32_t metric; |
9482 | struct bgp_redist *red; | |
9483 | u_short instance; | |
7a4bb9c5 | 9484 | int protocol; |
7c8ff89e | 9485 | |
c500ae40 | 9486 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9487 | protocol = ZEBRA_ROUTE_OSPF; |
9488 | else | |
9489 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9490 | |
c500ae40 DW |
9491 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9492 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9493 | |
cdc2d765 DL |
9494 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9495 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9496 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9497 | } |
9498 | ||
9499 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9500 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9501 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9502 | "Redistribute information from another routing protocol\n" |
9503 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9504 | "Non-main Kernel Routing Table\n" |
9505 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9506 | "Route map reference\n" |
9507 | "Pointer to route-map entries\n" | |
9508 | "Metric for redistributed routes\n" | |
9509 | "Default metric\n") | |
9510 | { | |
cdc2d765 | 9511 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9512 | int idx_ospf_table = 1; |
9513 | int idx_number = 2; | |
9514 | int idx_word = 4; | |
9515 | int idx_number_2 = 6; | |
7c8ff89e DS |
9516 | u_int32_t metric; |
9517 | struct bgp_redist *red; | |
9518 | u_short instance; | |
7a4bb9c5 | 9519 | int protocol; |
7c8ff89e | 9520 | |
c500ae40 | 9521 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9522 | protocol = ZEBRA_ROUTE_OSPF; |
9523 | else | |
9524 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9525 | |
c500ae40 DW |
9526 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9527 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9528 | |
cdc2d765 | 9529 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9530 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9531 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9532 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9533 | } |
9534 | ||
9535 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9536 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9537 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9538 | "Redistribute information from another routing protocol\n" |
9539 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9540 | "Non-main Kernel Routing Table\n" |
9541 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9542 | "Metric for redistributed routes\n" |
9543 | "Default metric\n" | |
9544 | "Route map reference\n" | |
9545 | "Pointer to route-map entries\n") | |
9546 | { | |
cdc2d765 | 9547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9548 | int idx_ospf_table = 1; |
9549 | int idx_number = 2; | |
9550 | int idx_number_2 = 4; | |
9551 | int idx_word = 6; | |
7c8ff89e DS |
9552 | u_int32_t metric; |
9553 | struct bgp_redist *red; | |
9554 | u_short instance; | |
7a4bb9c5 | 9555 | int protocol; |
7c8ff89e | 9556 | |
c500ae40 | 9557 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9558 | protocol = ZEBRA_ROUTE_OSPF; |
9559 | else | |
9560 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9561 | |
c500ae40 DW |
9562 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9563 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9564 | |
cdc2d765 DL |
9565 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9566 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9567 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9568 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9569 | } |
9570 | ||
9571 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9572 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9573 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9574 | NO_STR |
9575 | "Redistribute information from another routing protocol\n" | |
9576 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9577 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9578 | "Instance ID/Table ID\n" |
9579 | "Metric for redistributed routes\n" | |
9580 | "Default metric\n" | |
9581 | "Route map reference\n" | |
9582 | "Pointer to route-map entries\n") | |
7c8ff89e | 9583 | { |
cdc2d765 | 9584 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9585 | int idx_ospf_table = 2; |
9586 | int idx_number = 3; | |
7c8ff89e | 9587 | u_short instance; |
7a4bb9c5 DS |
9588 | int protocol; |
9589 | ||
c500ae40 | 9590 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9591 | protocol = ZEBRA_ROUTE_OSPF; |
9592 | else | |
9593 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9594 | |
c500ae40 | 9595 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9596 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9597 | } |
9598 | ||
718e3744 | 9599 | DEFUN (no_bgp_redistribute_ipv4, |
9600 | no_bgp_redistribute_ipv4_cmd, | |
d04c479d | 9601 | "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9602 | NO_STR |
9603 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9604 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9605 | "Metric for redistributed routes\n" |
9606 | "Default metric\n" | |
9607 | "Route map reference\n" | |
9608 | "Pointer to route-map entries\n") | |
718e3744 | 9609 | { |
cdc2d765 | 9610 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9611 | int idx_protocol = 2; |
718e3744 | 9612 | int type; |
9613 | ||
6d681bd8 QY |
9614 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9615 | if (type < 0) | |
718e3744 | 9616 | { |
9617 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9618 | return CMD_WARNING; | |
9619 | } | |
cdc2d765 | 9620 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9621 | } |
9622 | ||
718e3744 | 9623 | DEFUN (bgp_redistribute_ipv6, |
9624 | bgp_redistribute_ipv6_cmd, | |
9ccf14f7 | 9625 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table>", |
718e3744 | 9626 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9627 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9628 | { |
cdc2d765 | 9629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9630 | int idx_protocol = 1; |
718e3744 | 9631 | int type; |
9632 | ||
6d681bd8 QY |
9633 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9634 | if (type < 0) | |
718e3744 | 9635 | { |
9636 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9637 | return CMD_WARNING; | |
9638 | } | |
9639 | ||
cdc2d765 DL |
9640 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9641 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9642 | } |
9643 | ||
9644 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9645 | bgp_redistribute_ipv6_rmap_cmd, | |
9ccf14f7 | 9646 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD", |
718e3744 | 9647 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9648 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9649 | "Route map reference\n" |
9650 | "Pointer to route-map entries\n") | |
9651 | { | |
cdc2d765 | 9652 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9653 | int idx_protocol = 1; |
9654 | int idx_word = 3; | |
718e3744 | 9655 | int type; |
7c8ff89e | 9656 | struct bgp_redist *red; |
718e3744 | 9657 | |
6d681bd8 QY |
9658 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9659 | if (type < 0) | |
718e3744 | 9660 | { |
9661 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9662 | return CMD_WARNING; | |
9663 | } | |
9664 | ||
cdc2d765 | 9665 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9666 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9667 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9668 | } |
9669 | ||
9670 | DEFUN (bgp_redistribute_ipv6_metric, | |
9671 | bgp_redistribute_ipv6_metric_cmd, | |
9ccf14f7 | 9672 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)", |
718e3744 | 9673 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9674 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9675 | "Metric for redistributed routes\n" |
9676 | "Default metric\n") | |
9677 | { | |
cdc2d765 | 9678 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9679 | int idx_protocol = 1; |
9680 | int idx_number = 3; | |
718e3744 | 9681 | int type; |
9682 | u_int32_t metric; | |
7c8ff89e | 9683 | struct bgp_redist *red; |
718e3744 | 9684 | |
6d681bd8 QY |
9685 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9686 | if (type < 0) | |
718e3744 | 9687 | { |
9688 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9689 | return CMD_WARNING; | |
9690 | } | |
c500ae40 | 9691 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9692 | |
cdc2d765 DL |
9693 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9694 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9695 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9696 | } |
9697 | ||
9698 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9699 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
9ccf14f7 | 9700 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9701 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9702 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9703 | "Route map reference\n" |
9704 | "Pointer to route-map entries\n" | |
9705 | "Metric for redistributed routes\n" | |
9706 | "Default metric\n") | |
9707 | { | |
cdc2d765 | 9708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9709 | int idx_protocol = 1; |
9710 | int idx_word = 3; | |
9711 | int idx_number = 5; | |
718e3744 | 9712 | int type; |
9713 | u_int32_t metric; | |
7c8ff89e | 9714 | struct bgp_redist *red; |
718e3744 | 9715 | |
6d681bd8 QY |
9716 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9717 | if (type < 0) | |
718e3744 | 9718 | { |
9719 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9720 | return CMD_WARNING; | |
9721 | } | |
c500ae40 | 9722 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9723 | |
cdc2d765 | 9724 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9725 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9726 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9727 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9728 | } |
9729 | ||
9730 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9731 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
9ccf14f7 | 9732 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9733 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9734 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9735 | "Metric for redistributed routes\n" |
9736 | "Default metric\n" | |
9737 | "Route map reference\n" | |
9738 | "Pointer to route-map entries\n") | |
9739 | { | |
cdc2d765 | 9740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9741 | int idx_protocol = 1; |
9742 | int idx_number = 3; | |
9743 | int idx_word = 5; | |
718e3744 | 9744 | int type; |
9745 | u_int32_t metric; | |
7c8ff89e | 9746 | struct bgp_redist *red; |
718e3744 | 9747 | |
6d681bd8 QY |
9748 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9749 | if (type < 0) | |
718e3744 | 9750 | { |
9751 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9752 | return CMD_WARNING; | |
9753 | } | |
c500ae40 | 9754 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9755 | |
cdc2d765 DL |
9756 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9757 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 9758 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9759 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9760 | } |
9761 | ||
9762 | DEFUN (no_bgp_redistribute_ipv6, | |
9763 | no_bgp_redistribute_ipv6_cmd, | |
d04c479d | 9764 | "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9765 | NO_STR |
9766 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9767 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
9768 | "Metric for redistributed routes\n" |
9769 | "Default metric\n" | |
9770 | "Route map reference\n" | |
9771 | "Pointer to route-map entries\n") | |
718e3744 | 9772 | { |
cdc2d765 | 9773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9774 | int idx_protocol = 2; |
718e3744 | 9775 | int type; |
9776 | ||
6d681bd8 QY |
9777 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9778 | if (type < 0) | |
718e3744 | 9779 | { |
9780 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9781 | return CMD_WARNING; | |
9782 | } | |
9783 | ||
cdc2d765 | 9784 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 9785 | } |
6b0655a2 | 9786 | |
718e3744 | 9787 | int |
9788 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
9789 | safi_t safi, int *write) | |
9790 | { | |
9791 | int i; | |
718e3744 | 9792 | |
9793 | /* Unicast redistribution only. */ | |
9794 | if (safi != SAFI_UNICAST) | |
9795 | return 0; | |
9796 | ||
9797 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
9798 | { | |
9799 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 9800 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 9801 | { |
7c8ff89e DS |
9802 | struct list *red_list; |
9803 | struct listnode *node; | |
9804 | struct bgp_redist *red; | |
718e3744 | 9805 | |
7c8ff89e DS |
9806 | red_list = bgp->redist[afi][i]; |
9807 | if (!red_list) | |
9808 | continue; | |
718e3744 | 9809 | |
7c8ff89e DS |
9810 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
9811 | { | |
9812 | /* Display "address-family" when it is not yet diplayed. */ | |
9813 | bgp_config_write_family_header (vty, afi, safi, write); | |
9814 | ||
9815 | /* "redistribute" configuration. */ | |
0b960b4d | 9816 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
9817 | if (red->instance) |
9818 | vty_out (vty, " %d", red->instance); | |
9819 | if (red->redist_metric_flag) | |
9820 | vty_out (vty, " metric %u", red->redist_metric); | |
9821 | if (red->rmap.name) | |
9822 | vty_out (vty, " route-map %s", red->rmap.name); | |
9823 | vty_out (vty, "%s", VTY_NEWLINE); | |
9824 | } | |
718e3744 | 9825 | } |
9826 | } | |
9827 | return *write; | |
9828 | } | |
6b0655a2 | 9829 | |
718e3744 | 9830 | /* BGP node structure. */ |
7fc626de | 9831 | static struct cmd_node bgp_node = |
718e3744 | 9832 | { |
9833 | BGP_NODE, | |
9834 | "%s(config-router)# ", | |
9835 | 1, | |
9836 | }; | |
9837 | ||
7fc626de | 9838 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 9839 | { |
9840 | BGP_IPV4_NODE, | |
9841 | "%s(config-router-af)# ", | |
9842 | 1, | |
9843 | }; | |
9844 | ||
7fc626de | 9845 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 9846 | { |
9847 | BGP_IPV4M_NODE, | |
9848 | "%s(config-router-af)# ", | |
9849 | 1, | |
9850 | }; | |
9851 | ||
7fc626de | 9852 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 9853 | { |
9854 | BGP_IPV6_NODE, | |
9855 | "%s(config-router-af)# ", | |
9856 | 1, | |
9857 | }; | |
9858 | ||
7fc626de | 9859 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 9860 | { |
9861 | BGP_IPV6M_NODE, | |
9862 | "%s(config-router-af)# ", | |
9863 | 1, | |
9864 | }; | |
9865 | ||
7fc626de | 9866 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 9867 | { |
9868 | BGP_VPNV4_NODE, | |
9869 | "%s(config-router-af)# ", | |
9870 | 1 | |
9871 | }; | |
6b0655a2 | 9872 | |
8ecd3266 | 9873 | static struct cmd_node bgp_vpnv6_node = |
9874 | { | |
9875 | BGP_VPNV6_NODE, | |
9876 | "%s(config-router-af-vpnv6)# ", | |
9877 | 1 | |
9878 | }; | |
9879 | ||
8b1fb8be LB |
9880 | static struct cmd_node bgp_encap_node = |
9881 | { | |
9882 | BGP_ENCAP_NODE, | |
9883 | "%s(config-router-af-encap)# ", | |
9884 | 1 | |
9885 | }; | |
9886 | ||
9887 | static struct cmd_node bgp_encapv6_node = | |
9888 | { | |
9889 | BGP_ENCAPV6_NODE, | |
9890 | "%s(config-router-af-encapv6)# ", | |
9891 | 1 | |
9892 | }; | |
9893 | ||
1f8ae70b | 9894 | static void community_list_vty (void); |
9895 | ||
718e3744 | 9896 | void |
94f2b392 | 9897 | bgp_vty_init (void) |
718e3744 | 9898 | { |
718e3744 | 9899 | /* Install bgp top node. */ |
9900 | install_node (&bgp_node, bgp_config_write); | |
9901 | install_node (&bgp_ipv4_unicast_node, NULL); | |
9902 | install_node (&bgp_ipv4_multicast_node, NULL); | |
9903 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 9904 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 9905 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 9906 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
9907 | install_node (&bgp_encap_node, NULL); |
9908 | install_node (&bgp_encapv6_node, NULL); | |
718e3744 | 9909 | |
9910 | /* Install default VTY commands to new nodes. */ | |
9911 | install_default (BGP_NODE); | |
9912 | install_default (BGP_IPV4_NODE); | |
9913 | install_default (BGP_IPV4M_NODE); | |
9914 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 9915 | install_default (BGP_IPV6M_NODE); |
718e3744 | 9916 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 9917 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
9918 | install_default (BGP_ENCAP_NODE); |
9919 | install_default (BGP_ENCAPV6_NODE); | |
e52702f2 | 9920 | |
718e3744 | 9921 | /* "bgp multiple-instance" commands. */ |
9922 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
9923 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
9924 | ||
9925 | /* "bgp config-type" commands. */ | |
9926 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 9927 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 9928 | |
5fe9f963 | 9929 | /* bgp route-map delay-timer commands. */ |
9930 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
9931 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 9932 | |
718e3744 | 9933 | /* Dummy commands (Currently not supported) */ |
9934 | install_element (BGP_NODE, &no_synchronization_cmd); | |
9935 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
9936 | ||
9937 | /* "router bgp" commands. */ | |
9938 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 9939 | |
9940 | /* "no router bgp" commands. */ | |
9941 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 9942 | |
9943 | /* "bgp router-id" commands. */ | |
9944 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
9945 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 9946 | |
9947 | /* "bgp cluster-id" commands. */ | |
9948 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 9949 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 9950 | |
9951 | /* "bgp confederation" commands. */ | |
9952 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
9953 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 9954 | |
9955 | /* "bgp confederation peers" commands. */ | |
9956 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
9957 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
9958 | ||
abc920f8 DS |
9959 | /* bgp max-med command */ |
9960 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
9961 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
9962 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
9963 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
9964 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 9965 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 9966 | |
907f92c8 DS |
9967 | /* bgp disable-ebgp-connected-nh-check */ |
9968 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
9969 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
9970 | ||
f188f2c4 DS |
9971 | /* bgp update-delay command */ |
9972 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
9973 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
9974 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 9975 | |
cb1faec9 DS |
9976 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
9977 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
9978 | ||
3f9c7369 DS |
9979 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
9980 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
9981 | ||
165b5fff JB |
9982 | /* "maximum-paths" commands. */ |
9983 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
9984 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
9985 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
9986 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
9987 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
9988 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 9989 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9990 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9991 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9992 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9993 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9994 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 9995 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9996 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 9997 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9998 | |
718e3744 | 9999 | /* "timers bgp" commands. */ |
10000 | install_element (BGP_NODE, &bgp_timers_cmd); | |
10001 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 10002 | |
5fe9f963 | 10003 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
10004 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
10005 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
10006 | ||
718e3744 | 10007 | /* "bgp client-to-client reflection" commands */ |
10008 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
10009 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
10010 | ||
10011 | /* "bgp always-compare-med" commands */ | |
10012 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
10013 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 10014 | |
718e3744 | 10015 | /* "bgp deterministic-med" commands */ |
10016 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
10017 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 10018 | |
538621f2 | 10019 | /* "bgp graceful-restart" commands */ |
10020 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
10021 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 10022 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
10023 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
10024 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
10025 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 10026 | |
43fc21b3 JC |
10027 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
10028 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
10029 | ||
718e3744 | 10030 | /* "bgp fast-external-failover" commands */ |
10031 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
10032 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
10033 | ||
10034 | /* "bgp enforce-first-as" commands */ | |
10035 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
10036 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
10037 | ||
10038 | /* "bgp bestpath compare-routerid" commands */ | |
10039 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10040 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10041 | ||
10042 | /* "bgp bestpath as-path ignore" commands */ | |
10043 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10044 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10045 | ||
6811845b | 10046 | /* "bgp bestpath as-path confed" commands */ |
10047 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10048 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10049 | ||
2fdd455c PM |
10050 | /* "bgp bestpath as-path multipath-relax" commands */ |
10051 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10052 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10053 | ||
848973c7 | 10054 | /* "bgp log-neighbor-changes" commands */ |
10055 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10056 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10057 | ||
718e3744 | 10058 | /* "bgp bestpath med" commands */ |
10059 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10060 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10061 | |
10062 | /* "no bgp default ipv4-unicast" commands. */ | |
10063 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10064 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10065 | |
718e3744 | 10066 | /* "bgp network import-check" commands. */ |
10067 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10068 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10069 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10070 | ||
10071 | /* "bgp default local-preference" commands. */ | |
10072 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10073 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10074 | |
04b6bdc0 DW |
10075 | /* bgp default show-hostname */ |
10076 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10077 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10078 | ||
3f9c7369 DS |
10079 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10080 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10081 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10082 | ||
8bd9d948 DS |
10083 | /* bgp ibgp-allow-policy-mods command */ |
10084 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10085 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10086 | ||
f14e6fdb DS |
10087 | /* "bgp listen limit" commands. */ |
10088 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10089 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10090 | ||
10091 | /* "bgp listen range" commands. */ | |
10092 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10093 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10094 | ||
718e3744 | 10095 | /* "neighbor remote-as" commands. */ |
10096 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10097 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10098 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10099 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10100 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10101 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10102 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10103 | |
10104 | /* "neighbor peer-group" commands. */ | |
10105 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10106 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10107 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10108 | |
10109 | /* "neighbor local-as" commands. */ | |
10110 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10111 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10112 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10113 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10114 | |
3f9c7369 DS |
10115 | /* "neighbor solo" commands. */ |
10116 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10117 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10118 | ||
0df7c91f PJ |
10119 | /* "neighbor password" commands. */ |
10120 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10121 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10122 | ||
718e3744 | 10123 | /* "neighbor activate" commands. */ |
10124 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10125 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10126 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10127 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10128 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10129 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10130 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10131 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10132 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
718e3744 | 10133 | |
10134 | /* "no neighbor activate" commands. */ | |
10135 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10136 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10137 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10138 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10139 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10140 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10141 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10142 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10143 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
718e3744 | 10144 | |
c8560b44 DW |
10145 | /* "neighbor peer-group" set commands. |
10146 | * Long term we should only accept this command under BGP_NODE and not all of | |
10147 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10148 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10149 | * to their peer-group under each address-family sub-context. | |
10150 | */ | |
718e3744 | 10151 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10152 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10153 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10154 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10155 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10156 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10157 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10158 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10159 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10160 | |
718e3744 | 10161 | /* "no neighbor peer-group unset" commands. */ |
10162 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10163 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10164 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10165 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10166 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10167 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10168 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10169 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10170 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10171 | |
718e3744 | 10172 | /* "neighbor softreconfiguration inbound" commands.*/ |
10173 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10174 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10175 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10176 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10177 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10178 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10179 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10180 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10181 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10182 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10183 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10184 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10185 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10186 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10187 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10188 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10189 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10190 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10191 | |
10192 | /* "neighbor attribute-unchanged" commands. */ | |
10193 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10194 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10195 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10196 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10197 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10198 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10199 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10200 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10201 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10202 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10203 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10204 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10205 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10206 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10207 | |
8b1fb8be | 10208 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10209 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10210 | |
10211 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10212 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10213 | |
fee0f4c6 | 10214 | /* "nexthop-local unchanged" commands */ |
10215 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10216 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10217 | ||
718e3744 | 10218 | /* "neighbor next-hop-self" commands. */ |
10219 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10220 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10221 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10222 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10223 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10224 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10225 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10226 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10227 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10228 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10229 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10230 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10231 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10232 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10233 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10234 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10235 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10236 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10237 | |
a538debe DS |
10238 | /* "neighbor next-hop-self force" commands. */ |
10239 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10240 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10241 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10242 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10243 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10244 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10245 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10246 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10247 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10248 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10249 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10250 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10251 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10252 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10253 | |
c7122e14 DS |
10254 | /* "neighbor as-override" commands. */ |
10255 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10256 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10257 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10258 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10259 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10260 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10261 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10262 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10263 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10264 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10265 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10266 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10267 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10268 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10269 | |
718e3744 | 10270 | /* "neighbor remove-private-AS" commands. */ |
10271 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10272 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10273 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10274 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10275 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10276 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10277 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10278 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10279 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10280 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10281 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10282 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10283 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10284 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10285 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10286 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10287 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10288 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10289 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10290 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10291 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10292 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10293 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10294 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10295 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10296 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10297 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10298 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10299 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10300 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10301 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10302 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10303 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10304 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10305 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10306 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10307 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10308 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10309 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10310 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10311 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10312 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10313 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10314 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10315 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10316 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10317 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10318 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10319 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10320 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10321 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10322 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10323 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10324 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10325 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10326 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10327 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10328 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10329 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10330 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10331 | |
10332 | /* "neighbor send-community" commands.*/ | |
10333 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10334 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10335 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10336 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10337 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10338 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10339 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10340 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10341 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10342 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10343 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10344 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10345 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10346 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10347 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10348 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10349 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10350 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10351 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10352 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10353 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10354 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10355 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10356 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10357 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10358 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10359 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10360 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10361 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10362 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10363 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10364 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10365 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10366 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10367 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10368 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10369 | |
10370 | /* "neighbor route-reflector" commands.*/ | |
10371 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10372 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10373 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10374 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10375 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10376 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10377 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10378 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10379 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10380 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10381 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10382 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10383 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10384 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10385 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10386 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10387 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10388 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10389 | |
10390 | /* "neighbor route-server" commands.*/ | |
10391 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10392 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10393 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10394 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10395 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10396 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10397 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10398 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10399 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10400 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10401 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10402 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10403 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10404 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10405 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10406 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10407 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10408 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10409 | |
adbac85e DW |
10410 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10411 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10412 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10413 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10414 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10415 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10416 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10417 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10418 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10419 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10420 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10421 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10422 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10423 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10424 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10425 | |
06370dac DW |
10426 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10427 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10428 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10429 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10430 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10431 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10432 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10433 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10434 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10435 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10436 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10437 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10438 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10439 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10440 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10441 | |
718e3744 | 10442 | /* "neighbor passive" commands. */ |
10443 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10444 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10445 | ||
d5a5c8f0 | 10446 | |
718e3744 | 10447 | /* "neighbor shutdown" commands. */ |
10448 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10449 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
10450 | ||
8a92a8a0 DS |
10451 | /* "neighbor capability extended-nexthop" commands.*/ |
10452 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10453 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10454 | ||
718e3744 | 10455 | /* "neighbor capability orf prefix-list" commands.*/ |
10456 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10457 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10458 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10459 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10460 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10461 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10462 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10463 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10464 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10465 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10466 | |
10467 | /* "neighbor capability dynamic" commands.*/ | |
10468 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10469 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10470 | ||
10471 | /* "neighbor dont-capability-negotiate" commands. */ | |
10472 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10473 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10474 | ||
10475 | /* "neighbor ebgp-multihop" commands. */ | |
10476 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10477 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10478 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10479 | |
6ffd2079 | 10480 | /* "neighbor disable-connected-check" commands. */ |
10481 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10482 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10483 | |
10484 | /* "neighbor description" commands. */ | |
10485 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10486 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10487 | |
10488 | /* "neighbor update-source" commands. "*/ | |
10489 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10490 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10491 | ||
10492 | /* "neighbor default-originate" commands. */ | |
10493 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10494 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10495 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10496 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10497 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10498 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10499 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10500 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10501 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10502 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10503 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10504 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10505 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10506 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10507 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10508 | |
10509 | /* "neighbor port" commands. */ | |
10510 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10511 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10512 | |
10513 | /* "neighbor weight" commands. */ | |
10514 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10515 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10516 | |
d93f7ffc DW |
10517 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10518 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10519 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10520 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10521 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10522 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10523 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10524 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10525 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10526 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10527 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10528 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10529 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10530 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10531 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10532 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10533 | |
10534 | /* "neighbor override-capability" commands. */ | |
10535 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10536 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10537 | ||
10538 | /* "neighbor strict-capability-match" commands. */ | |
10539 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10540 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10541 | ||
10542 | /* "neighbor timers" commands. */ | |
10543 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10544 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10545 | ||
10546 | /* "neighbor timers connect" commands. */ | |
10547 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10548 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10549 | |
10550 | /* "neighbor advertisement-interval" commands. */ | |
10551 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10552 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10553 | |
718e3744 | 10554 | /* "neighbor interface" commands. */ |
10555 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10556 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10557 | ||
10558 | /* "neighbor distribute" commands. */ | |
10559 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10560 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10561 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10562 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10563 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10564 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10565 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10566 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10567 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10568 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10569 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10570 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10571 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10572 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10573 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10574 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10575 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10576 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10577 | |
10578 | /* "neighbor prefix-list" commands. */ | |
10579 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10580 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10581 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10582 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10583 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10584 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10585 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10586 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10587 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10588 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10589 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10590 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10591 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10592 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10593 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10594 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10595 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10596 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10597 | |
10598 | /* "neighbor filter-list" commands. */ | |
10599 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10600 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10601 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10602 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10603 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10604 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10605 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10606 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10607 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10608 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10609 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10610 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10611 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10612 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10613 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10614 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10615 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10616 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10617 | |
10618 | /* "neighbor route-map" commands. */ | |
10619 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10620 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10621 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10622 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10623 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10624 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10625 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10626 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10627 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10628 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10629 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10630 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10631 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10632 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10633 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10634 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10635 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10636 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10637 | |
10638 | /* "neighbor unsuppress-map" commands. */ | |
10639 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10640 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10641 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10642 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10643 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10644 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10645 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10646 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10647 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10648 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10649 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10650 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10651 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10652 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10653 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10654 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10655 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10656 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10657 | |
10658 | /* "neighbor maximum-prefix" commands. */ | |
10659 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10660 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10661 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10662 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10663 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10664 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10665 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10666 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10667 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10668 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10669 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10670 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10671 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10672 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10673 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10674 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10675 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10676 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10677 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10678 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10679 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10680 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10681 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10682 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10683 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10684 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10685 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10686 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10687 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10688 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10689 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10690 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10691 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10692 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10693 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10694 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10695 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10696 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10697 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10698 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10699 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10700 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10701 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10702 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10703 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10704 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10705 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10706 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10707 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10708 | |
8b1fb8be LB |
10709 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10710 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10711 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10712 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10713 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10714 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10715 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10716 | |
10717 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10718 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10719 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10720 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10721 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10722 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10723 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10724 | |
718e3744 | 10725 | /* "neighbor allowas-in" */ |
10726 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10727 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10728 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10729 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10730 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10731 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10732 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10733 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10734 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10735 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10736 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10737 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10738 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10739 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10740 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10741 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10742 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10743 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10744 | |
10745 | /* address-family commands. */ | |
10746 | install_element (BGP_NODE, &address_family_ipv4_cmd); | |
10747 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); | |
718e3744 | 10748 | install_element (BGP_NODE, &address_family_ipv6_cmd); |
25ffbdc1 | 10749 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
718e3744 | 10750 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
718e3744 | 10751 | |
8b1fb8be | 10752 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
8b1fb8be LB |
10753 | |
10754 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 10755 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 10756 | |
718e3744 | 10757 | /* "exit-address-family" command. */ |
10758 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10759 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10760 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10761 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10762 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10763 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10764 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10765 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
718e3744 | 10766 | |
10767 | /* "clear ip bgp commands" */ | |
10768 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 10769 | |
8ad7271d DS |
10770 | /* clear ip bgp prefix */ |
10771 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
10772 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 10773 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 10774 | |
716b2d8a | 10775 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 10776 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 10777 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 10778 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 10779 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 10780 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 10781 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 10782 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 10783 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 10784 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
10785 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
10786 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
10787 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
10788 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
10789 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
10790 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 10791 | |
716b2d8a | 10792 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10793 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 10794 | |
716b2d8a | 10795 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 10796 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 10797 | |
716b2d8a | 10798 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 10799 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 10800 | |
716b2d8a | 10801 | /* "show [ip] bgp community" commands. */ |
718e3744 | 10802 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 10803 | |
57d187bc JS |
10804 | /* "show ip bgp large-community" commands. */ |
10805 | install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
716b2d8a | 10806 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 10807 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 10808 | |
10809 | /* "redistribute" commands. */ | |
10810 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
10811 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10812 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 10813 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 10814 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10815 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
10816 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10817 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10818 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 10819 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 10820 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 10821 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
10822 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
10823 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10824 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 10825 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
10826 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10827 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
10828 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10829 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10830 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 10831 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 10832 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 10833 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 10834 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
10835 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
10836 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 10837 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 10838 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
10839 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 10840 | |
fa411a21 NH |
10841 | /* ttl_security commands */ |
10842 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
10843 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
10844 | ||
716b2d8a | 10845 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 10846 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 10847 | |
716b2d8a | 10848 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 10849 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 10850 | |
716b2d8a | 10851 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 10852 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 10853 | |
718e3744 | 10854 | /* Community-list. */ |
10855 | community_list_vty (); | |
10856 | } | |
6b0655a2 | 10857 | |
718e3744 | 10858 | #include "memory.h" |
10859 | #include "bgp_regex.h" | |
10860 | #include "bgp_clist.h" | |
10861 | #include "bgp_ecommunity.h" | |
10862 | ||
10863 | /* VTY functions. */ | |
10864 | ||
10865 | /* Direction value to string conversion. */ | |
94f2b392 | 10866 | static const char * |
718e3744 | 10867 | community_direct_str (int direct) |
10868 | { | |
10869 | switch (direct) | |
10870 | { | |
10871 | case COMMUNITY_DENY: | |
10872 | return "deny"; | |
718e3744 | 10873 | case COMMUNITY_PERMIT: |
10874 | return "permit"; | |
718e3744 | 10875 | default: |
10876 | return "unknown"; | |
718e3744 | 10877 | } |
10878 | } | |
10879 | ||
10880 | /* Display error string. */ | |
94f2b392 | 10881 | static void |
718e3744 | 10882 | community_list_perror (struct vty *vty, int ret) |
10883 | { | |
10884 | switch (ret) | |
10885 | { | |
10886 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 10887 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 10888 | break; |
10889 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
10890 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
10891 | break; | |
10892 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
10893 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
10894 | break; | |
10895 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
10896 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
10897 | break; | |
10898 | } | |
10899 | } | |
10900 | ||
5bf15956 DW |
10901 | /* "community-list" keyword help string. */ |
10902 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
10903 | ||
718e3744 | 10904 | |
5bf15956 | 10905 | /* ip community-list standard */ |
718e3744 | 10906 | DEFUN (ip_community_list_standard, |
10907 | ip_community_list_standard_cmd, | |
e961923c | 10908 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10909 | IP_STR |
10910 | COMMUNITY_LIST_STR | |
10911 | "Community list number (standard)\n" | |
5bf15956 | 10912 | "Add an standard community-list entry\n" |
718e3744 | 10913 | "Community list name\n" |
10914 | "Specify community to reject\n" | |
10915 | "Specify community to accept\n" | |
10916 | COMMUNITY_VAL_STR) | |
10917 | { | |
42f914d4 QY |
10918 | char *cl_name_or_number = NULL; |
10919 | int direct = 0; | |
10920 | int style = COMMUNITY_LIST_STANDARD; | |
10921 | ||
10922 | int idx = 0; | |
10923 | argv_find (argv, argc, "(1-99)", &idx); | |
10924 | argv_find (argv, argc, "WORD", &idx); | |
10925 | cl_name_or_number = argv[idx]->arg; | |
10926 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10927 | argv_find (argv, argc, "AA:NN", &idx); | |
10928 | char *str = argv_concat (argv, argc, idx); | |
10929 | ||
10930 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10931 | ||
10932 | XFREE (MTYPE_TMP, str); | |
10933 | ||
10934 | if (ret < 0) | |
10935 | { | |
10936 | /* Display error string. */ | |
10937 | community_list_perror (vty, ret); | |
10938 | return CMD_WARNING; | |
10939 | } | |
10940 | ||
10941 | return CMD_SUCCESS; | |
718e3744 | 10942 | } |
10943 | ||
fee6e4e4 | 10944 | DEFUN (no_ip_community_list_standard_all, |
10945 | no_ip_community_list_standard_all_cmd, | |
e961923c | 10946 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10947 | NO_STR |
10948 | IP_STR | |
10949 | COMMUNITY_LIST_STR | |
10950 | "Community list number (standard)\n" | |
5bf15956 DW |
10951 | "Add an standard community-list entry\n" |
10952 | "Community list name\n" | |
718e3744 | 10953 | "Specify community to reject\n" |
10954 | "Specify community to accept\n" | |
10955 | COMMUNITY_VAL_STR) | |
10956 | { | |
42f914d4 QY |
10957 | int delete_all = 0; |
10958 | ||
10959 | char *cl_name_or_number = NULL; | |
10960 | int direct = 0; | |
10961 | int style = COMMUNITY_LIST_STANDARD; | |
10962 | ||
10963 | int idx = 0; | |
10964 | argv_find (argv, argc, "(1-99)", &idx); | |
10965 | argv_find (argv, argc, "WORD", &idx); | |
10966 | cl_name_or_number = argv[idx]->arg; | |
10967 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10968 | argv_find (argv, argc, "AA:NN", &idx); | |
10969 | char *str = argv_concat (argv, argc, idx); | |
10970 | ||
10971 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10972 | ||
10973 | if (ret < 0) | |
10974 | { | |
10975 | community_list_perror (vty, ret); | |
10976 | return CMD_WARNING; | |
10977 | } | |
10978 | ||
10979 | return CMD_SUCCESS; | |
718e3744 | 10980 | } |
10981 | ||
5bf15956 DW |
10982 | /* ip community-list expanded */ |
10983 | DEFUN (ip_community_list_expanded_all, | |
10984 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 10985 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10986 | IP_STR |
10987 | COMMUNITY_LIST_STR | |
10988 | "Community list number (expanded)\n" | |
5bf15956 | 10989 | "Add an expanded community-list entry\n" |
718e3744 | 10990 | "Community list name\n" |
10991 | "Specify community to reject\n" | |
10992 | "Specify community to accept\n" | |
10993 | COMMUNITY_VAL_STR) | |
10994 | { | |
42f914d4 QY |
10995 | char *cl_name_or_number = NULL; |
10996 | int direct = 0; | |
10997 | int style = COMMUNITY_LIST_EXPANDED; | |
10998 | ||
10999 | int idx = 0; | |
11000 | argv_find (argv, argc, "(100-500)", &idx); | |
11001 | argv_find (argv, argc, "WORD", &idx); | |
11002 | cl_name_or_number = argv[idx]->arg; | |
11003 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11004 | argv_find (argv, argc, "AA:NN", &idx); | |
11005 | char *str = argv_concat (argv, argc, idx); | |
11006 | ||
11007 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
11008 | ||
11009 | XFREE (MTYPE_TMP, str); | |
11010 | ||
11011 | if (ret < 0) | |
11012 | { | |
11013 | /* Display error string. */ | |
11014 | community_list_perror (vty, ret); | |
11015 | return CMD_WARNING; | |
11016 | } | |
11017 | ||
11018 | return CMD_SUCCESS; | |
718e3744 | 11019 | } |
11020 | ||
5bf15956 DW |
11021 | DEFUN (no_ip_community_list_expanded_all, |
11022 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 11023 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 11024 | NO_STR |
11025 | IP_STR | |
11026 | COMMUNITY_LIST_STR | |
5bf15956 DW |
11027 | "Community list number (expanded)\n" |
11028 | "Add an expanded community-list entry\n" | |
718e3744 | 11029 | "Community list name\n" |
11030 | "Specify community to reject\n" | |
11031 | "Specify community to accept\n" | |
5bf15956 | 11032 | COMMUNITY_VAL_STR) |
718e3744 | 11033 | { |
42f914d4 QY |
11034 | int delete_all = 0; |
11035 | ||
11036 | char *cl_name_or_number = NULL; | |
11037 | int direct = 0; | |
11038 | int style = COMMUNITY_LIST_EXPANDED; | |
11039 | ||
11040 | int idx = 0; | |
11041 | argv_find (argv, argc, "(100-500)", &idx); | |
11042 | argv_find (argv, argc, "WORD", &idx); | |
11043 | cl_name_or_number = argv[idx]->arg; | |
11044 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11045 | argv_find (argv, argc, "AA:NN", &idx); | |
11046 | char *str = argv_concat (argv, argc, idx); | |
11047 | ||
11048 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11049 | ||
11050 | if (ret < 0) | |
11051 | { | |
11052 | community_list_perror (vty, ret); | |
11053 | return CMD_WARNING; | |
11054 | } | |
11055 | ||
11056 | return CMD_SUCCESS; | |
718e3744 | 11057 | } |
11058 | ||
94f2b392 | 11059 | static void |
718e3744 | 11060 | community_list_show (struct vty *vty, struct community_list *list) |
11061 | { | |
11062 | struct community_entry *entry; | |
11063 | ||
11064 | for (entry = list->head; entry; entry = entry->next) | |
11065 | { | |
11066 | if (entry == list->head) | |
11067 | { | |
11068 | if (all_digit (list->name)) | |
11069 | vty_out (vty, "Community %s list %s%s", | |
11070 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11071 | "standard" : "(expanded) access", | |
11072 | list->name, VTY_NEWLINE); | |
11073 | else | |
11074 | vty_out (vty, "Named Community %s list %s%s", | |
11075 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11076 | "standard" : "expanded", | |
11077 | list->name, VTY_NEWLINE); | |
11078 | } | |
11079 | if (entry->any) | |
11080 | vty_out (vty, " %s%s", | |
11081 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11082 | else | |
11083 | vty_out (vty, " %s %s%s", | |
11084 | community_direct_str (entry->direct), | |
11085 | entry->style == COMMUNITY_LIST_STANDARD | |
11086 | ? community_str (entry->u.com) : entry->config, | |
11087 | VTY_NEWLINE); | |
11088 | } | |
11089 | } | |
11090 | ||
11091 | DEFUN (show_ip_community_list, | |
11092 | show_ip_community_list_cmd, | |
11093 | "show ip community-list", | |
11094 | SHOW_STR | |
11095 | IP_STR | |
11096 | "List community-list\n") | |
11097 | { | |
11098 | struct community_list *list; | |
11099 | struct community_list_master *cm; | |
11100 | ||
fee6e4e4 | 11101 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11102 | if (! cm) |
11103 | return CMD_SUCCESS; | |
11104 | ||
11105 | for (list = cm->num.head; list; list = list->next) | |
11106 | community_list_show (vty, list); | |
11107 | ||
11108 | for (list = cm->str.head; list; list = list->next) | |
11109 | community_list_show (vty, list); | |
11110 | ||
11111 | return CMD_SUCCESS; | |
11112 | } | |
11113 | ||
11114 | DEFUN (show_ip_community_list_arg, | |
11115 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11116 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11117 | SHOW_STR |
11118 | IP_STR | |
11119 | "List community-list\n" | |
11120 | "Community-list number\n" | |
11121 | "Community-list name\n") | |
11122 | { | |
c500ae40 | 11123 | int idx_comm_list = 3; |
718e3744 | 11124 | struct community_list *list; |
11125 | ||
c500ae40 | 11126 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11127 | if (! list) |
11128 | { | |
b729294c | 11129 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11130 | return CMD_WARNING; |
11131 | } | |
11132 | ||
11133 | community_list_show (vty, list); | |
11134 | ||
11135 | return CMD_SUCCESS; | |
11136 | } | |
6b0655a2 | 11137 | |
57d187bc JS |
11138 | /* |
11139 | * Large Community code. | |
11140 | */ | |
11141 | static int | |
11142 | lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
11143 | int style, int reject_all_digit_name) | |
11144 | { | |
11145 | int ret; | |
11146 | int direct; | |
11147 | char *str; | |
11148 | int idx = 0; | |
11149 | char *cl_name; | |
11150 | ||
11151 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11152 | ||
11153 | /* All digit name check. */ | |
11154 | idx = 0; | |
11155 | argv_find (argv, argc, "WORD", &idx); | |
11156 | argv_find (argv, argc, "(1-99)", &idx); | |
11157 | argv_find (argv, argc, "(100-500)", &idx); | |
11158 | cl_name = argv[idx]->arg; | |
11159 | if (reject_all_digit_name && all_digit (cl_name)) | |
11160 | { | |
11161 | vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE); | |
11162 | return CMD_WARNING; | |
11163 | } | |
11164 | ||
11165 | argv_find (argv, argc, "AA:BB:CC", &idx); | |
11166 | argv_find (argv, argc, "LINE", &idx); | |
11167 | /* Concat community string argument. */ | |
11168 | if (idx) | |
11169 | str = argv_concat (argv, argc, idx); | |
11170 | else | |
11171 | str = NULL; | |
11172 | ||
11173 | ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style); | |
11174 | ||
11175 | /* Free temporary community list string allocated by | |
11176 | argv_concat(). */ | |
11177 | if (str) | |
11178 | XFREE (MTYPE_TMP, str); | |
11179 | ||
11180 | if (ret < 0) | |
11181 | { | |
11182 | community_list_perror (vty, ret); | |
11183 | return CMD_WARNING; | |
11184 | } | |
11185 | return CMD_SUCCESS; | |
11186 | } | |
11187 | ||
11188 | static int | |
11189 | lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, | |
11190 | int style) | |
11191 | { | |
11192 | int ret; | |
11193 | int direct = 0; | |
11194 | char *str = NULL; | |
11195 | int idx = 0; | |
11196 | ||
11197 | argv_find (argv, argc, "permit", &idx); | |
11198 | argv_find (argv, argc, "deny", &idx); | |
11199 | ||
11200 | if (idx) | |
11201 | { | |
11202 | /* Check the list direct. */ | |
11203 | if (strncmp (argv[idx]->arg, "p", 1) == 0) | |
11204 | direct = COMMUNITY_PERMIT; | |
11205 | else | |
11206 | direct = COMMUNITY_DENY; | |
11207 | ||
11208 | idx = 0; | |
11209 | argv_find (argv, argc, "LINE", &idx); | |
11210 | argv_find (argv, argc, "AA:AA:NN", &idx); | |
11211 | /* Concat community string argument. */ | |
11212 | str = argv_concat (argv, argc, idx); | |
11213 | } | |
11214 | ||
11215 | idx = 0; | |
11216 | argv_find (argv, argc, "(1-99)", &idx); | |
11217 | argv_find (argv, argc, "(100-500)", &idx); | |
11218 | argv_find (argv, argc, "WORD", &idx); | |
11219 | ||
11220 | /* Unset community list. */ | |
11221 | ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style); | |
11222 | ||
11223 | /* Free temporary community list string allocated by | |
11224 | argv_concat(). */ | |
11225 | if (str) | |
11226 | XFREE (MTYPE_TMP, str); | |
11227 | ||
11228 | if (ret < 0) | |
11229 | { | |
11230 | community_list_perror (vty, ret); | |
11231 | return CMD_WARNING; | |
11232 | } | |
11233 | ||
11234 | return CMD_SUCCESS; | |
11235 | } | |
11236 | ||
11237 | /* "large-community-list" keyword help string. */ | |
11238 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
11239 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
11240 | ||
11241 | DEFUN (ip_lcommunity_list_standard, | |
11242 | ip_lcommunity_list_standard_cmd, | |
11243 | "ip large-community-list (1-99) <deny|permit> [AA:BB:CC...]", | |
11244 | IP_STR | |
11245 | LCOMMUNITY_LIST_STR | |
11246 | "Large Community list number (standard)\n" | |
11247 | "Specify large community to reject\n" | |
11248 | "Specify large community to accept\n" | |
11249 | LCOMMUNITY_VAL_STR) | |
11250 | { | |
11251 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0); | |
11252 | } | |
11253 | ||
11254 | DEFUN (ip_lcommunity_list_expanded, | |
11255 | ip_lcommunity_list_expanded_cmd, | |
11256 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
11257 | IP_STR | |
11258 | LCOMMUNITY_LIST_STR | |
11259 | "Large Community list number (expanded)\n" | |
11260 | "Specify large community to reject\n" | |
11261 | "Specify large community to accept\n" | |
11262 | "An ordered list as a regular-expression\n") | |
11263 | { | |
11264 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
11265 | } | |
11266 | ||
11267 | DEFUN (ip_lcommunity_list_name_standard, | |
11268 | ip_lcommunity_list_name_standard_cmd, | |
11269 | "ip large-community-list standard WORD <deny|permit> [AA:BB.CC...]", | |
11270 | IP_STR | |
11271 | LCOMMUNITY_LIST_STR | |
11272 | "Specify standard large-community-list\n" | |
11273 | "Large Community list name\n" | |
11274 | "Specify large community to reject\n" | |
11275 | "Specify large community to accept\n" | |
11276 | LCOMMUNITY_VAL_STR) | |
11277 | { | |
11278 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1); | |
11279 | } | |
11280 | ||
11281 | DEFUN (ip_lcommunity_list_name_expanded, | |
11282 | ip_lcommunity_list_name_expanded_cmd, | |
11283 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
11284 | IP_STR | |
11285 | LCOMMUNITY_LIST_STR | |
11286 | "Specify expanded large-community-list\n" | |
11287 | "Large Community list name\n" | |
11288 | "Specify large community to reject\n" | |
11289 | "Specify large community to accept\n" | |
11290 | "An ordered list as a regular-expression\n") | |
11291 | { | |
11292 | return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
11293 | } | |
11294 | ||
11295 | DEFUN (no_ip_lcommunity_list_standard_all, | |
11296 | no_ip_lcommunity_list_standard_all_cmd, | |
11297 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
11298 | NO_STR | |
11299 | IP_STR | |
11300 | LCOMMUNITY_LIST_STR | |
11301 | "Large Community list number (standard)\n" | |
11302 | "Large Community list number (expanded)\n" | |
11303 | "Large Community list name\n") | |
11304 | { | |
11305 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11306 | } | |
11307 | ||
11308 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
11309 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
11310 | "no ip large-community-list expanded WORD", | |
11311 | NO_STR | |
11312 | IP_STR | |
11313 | LCOMMUNITY_LIST_STR | |
11314 | "Specify expanded large-community-list\n" | |
11315 | "Large Community list name\n") | |
11316 | { | |
11317 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11318 | } | |
11319 | ||
11320 | DEFUN (no_ip_lcommunity_list_standard, | |
11321 | no_ip_lcommunity_list_standard_cmd, | |
11322 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
11323 | NO_STR | |
11324 | IP_STR | |
11325 | LCOMMUNITY_LIST_STR | |
11326 | "Large Community list number (standard)\n" | |
11327 | "Specify large community to reject\n" | |
11328 | "Specify large community to accept\n" | |
11329 | LCOMMUNITY_VAL_STR) | |
11330 | { | |
11331 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11332 | } | |
11333 | ||
11334 | DEFUN (no_ip_lcommunity_list_expanded, | |
11335 | no_ip_lcommunity_list_expanded_cmd, | |
11336 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
11337 | NO_STR | |
11338 | IP_STR | |
11339 | LCOMMUNITY_LIST_STR | |
11340 | "Large Community list number (expanded)\n" | |
11341 | "Specify large community to reject\n" | |
11342 | "Specify large community to accept\n" | |
11343 | "An ordered list as a regular-expression\n") | |
11344 | { | |
11345 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11346 | } | |
11347 | ||
11348 | DEFUN (no_ip_lcommunity_list_name_standard, | |
11349 | no_ip_lcommunity_list_name_standard_cmd, | |
11350 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
11351 | NO_STR | |
11352 | IP_STR | |
11353 | LCOMMUNITY_LIST_STR | |
11354 | "Specify standard large-community-list\n" | |
11355 | "Large Community list name\n" | |
11356 | "Specify large community to reject\n" | |
11357 | "Specify large community to accept\n" | |
11358 | LCOMMUNITY_VAL_STR) | |
11359 | { | |
11360 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD); | |
11361 | } | |
11362 | ||
11363 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
11364 | no_ip_lcommunity_list_name_expanded_cmd, | |
11365 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
11366 | NO_STR | |
11367 | IP_STR | |
11368 | LCOMMUNITY_LIST_STR | |
11369 | "Specify expanded large-community-list\n" | |
11370 | "Large community list name\n" | |
11371 | "Specify large community to reject\n" | |
11372 | "Specify large community to accept\n" | |
11373 | "An ordered list as a regular-expression\n") | |
11374 | { | |
11375 | return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED); | |
11376 | } | |
11377 | ||
11378 | static void | |
11379 | lcommunity_list_show (struct vty *vty, struct community_list *list) | |
11380 | { | |
11381 | struct community_entry *entry; | |
11382 | ||
11383 | for (entry = list->head; entry; entry = entry->next) | |
11384 | { | |
11385 | if (entry == list->head) | |
11386 | { | |
11387 | if (all_digit (list->name)) | |
11388 | vty_out (vty, "Large community %s list %s%s", | |
11389 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11390 | "standard" : "(expanded) access", | |
11391 | list->name, VTY_NEWLINE); | |
11392 | else | |
11393 | vty_out (vty, "Named large community %s list %s%s", | |
11394 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11395 | "standard" : "expanded", | |
11396 | list->name, VTY_NEWLINE); | |
11397 | } | |
11398 | if (entry->any) | |
11399 | vty_out (vty, " %s%s", | |
11400 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11401 | else | |
11402 | vty_out (vty, " %s %s%s", | |
11403 | community_direct_str (entry->direct), | |
11404 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11405 | entry->u.ecom->str : entry->config, | |
11406 | VTY_NEWLINE); | |
11407 | } | |
11408 | } | |
11409 | ||
11410 | DEFUN (show_ip_lcommunity_list, | |
11411 | show_ip_lcommunity_list_cmd, | |
11412 | "show ip large-community-list", | |
11413 | SHOW_STR | |
11414 | IP_STR | |
11415 | "List large-community list\n") | |
11416 | { | |
11417 | struct community_list *list; | |
11418 | struct community_list_master *cm; | |
11419 | ||
11420 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11421 | if (! cm) | |
11422 | return CMD_SUCCESS; | |
11423 | ||
11424 | for (list = cm->num.head; list; list = list->next) | |
11425 | lcommunity_list_show (vty, list); | |
11426 | ||
11427 | for (list = cm->str.head; list; list = list->next) | |
11428 | lcommunity_list_show (vty, list); | |
11429 | ||
11430 | return CMD_SUCCESS; | |
11431 | } | |
11432 | ||
11433 | DEFUN (show_ip_lcommunity_list_arg, | |
11434 | show_ip_lcommunity_list_arg_cmd, | |
11435 | "show ip large-community-list <(1-500)|WORD>", | |
11436 | SHOW_STR | |
11437 | IP_STR | |
11438 | "List large-community list\n" | |
11439 | "large-community-list number\n" | |
11440 | "large-community-list name\n") | |
11441 | { | |
11442 | struct community_list *list; | |
11443 | ||
11444 | list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER); | |
11445 | if (! list) | |
11446 | { | |
11447 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); | |
11448 | return CMD_WARNING; | |
11449 | } | |
11450 | ||
11451 | lcommunity_list_show (vty, list); | |
11452 | ||
11453 | return CMD_SUCCESS; | |
11454 | } | |
11455 | ||
718e3744 | 11456 | /* "extcommunity-list" keyword help string. */ |
11457 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11458 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11459 | ||
11460 | DEFUN (ip_extcommunity_list_standard, | |
11461 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11462 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11463 | IP_STR |
11464 | EXTCOMMUNITY_LIST_STR | |
11465 | "Extended Community list number (standard)\n" | |
718e3744 | 11466 | "Specify standard extcommunity-list\n" |
5bf15956 | 11467 | "Community list name\n" |
718e3744 | 11468 | "Specify community to reject\n" |
11469 | "Specify community to accept\n" | |
11470 | EXTCOMMUNITY_VAL_STR) | |
11471 | { | |
42f914d4 QY |
11472 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11473 | int direct = 0; | |
11474 | char *cl_number_or_name = NULL; | |
11475 | ||
11476 | int idx = 0; | |
11477 | argv_find (argv, argc, "(1-99)", &idx); | |
11478 | argv_find (argv, argc, "WORD", &idx); | |
11479 | cl_number_or_name = argv[idx]->arg; | |
11480 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11481 | argv_find (argv, argc, "AA:NN", &idx); | |
11482 | char *str = argv_concat (argv, argc, idx); | |
11483 | ||
11484 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11485 | ||
11486 | XFREE (MTYPE_TMP, str); | |
11487 | ||
11488 | if (ret < 0) | |
11489 | { | |
11490 | community_list_perror (vty, ret); | |
11491 | return CMD_WARNING; | |
11492 | } | |
11493 | ||
11494 | return CMD_SUCCESS; | |
718e3744 | 11495 | } |
11496 | ||
718e3744 | 11497 | DEFUN (ip_extcommunity_list_name_expanded, |
11498 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11499 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11500 | IP_STR |
11501 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11502 | "Extended Community list number (expanded)\n" |
718e3744 | 11503 | "Specify expanded extcommunity-list\n" |
11504 | "Extended Community list name\n" | |
11505 | "Specify community to reject\n" | |
11506 | "Specify community to accept\n" | |
11507 | "An ordered list as a regular-expression\n") | |
11508 | { | |
42f914d4 QY |
11509 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11510 | int direct = 0; | |
11511 | char *cl_number_or_name = NULL; | |
11512 | ||
11513 | int idx = 0; | |
11514 | argv_find (argv, argc, "(100-500)", &idx); | |
11515 | argv_find (argv, argc, "WORD", &idx); | |
11516 | cl_number_or_name = argv[idx]->arg; | |
11517 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11518 | argv_find (argv, argc, "LINE", &idx); | |
11519 | char *str = argv_concat (argv, argc, idx); | |
11520 | ||
11521 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11522 | ||
11523 | XFREE (MTYPE_TMP, str); | |
11524 | ||
11525 | if (ret < 0) | |
11526 | { | |
11527 | community_list_perror (vty, ret); | |
11528 | return CMD_WARNING; | |
11529 | } | |
11530 | ||
11531 | return CMD_SUCCESS; | |
718e3744 | 11532 | } |
11533 | ||
fee6e4e4 | 11534 | DEFUN (no_ip_extcommunity_list_standard_all, |
11535 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11536 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11537 | NO_STR |
11538 | IP_STR | |
11539 | EXTCOMMUNITY_LIST_STR | |
11540 | "Extended Community list number (standard)\n" | |
718e3744 | 11541 | "Specify standard extcommunity-list\n" |
5bf15956 | 11542 | "Community list name\n" |
718e3744 | 11543 | "Specify community to reject\n" |
11544 | "Specify community to accept\n" | |
11545 | EXTCOMMUNITY_VAL_STR) | |
11546 | { | |
42f914d4 QY |
11547 | int deleteall = 0; |
11548 | ||
11549 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11550 | int direct = 0; | |
11551 | char *cl_number_or_name = NULL; | |
11552 | ||
11553 | int idx = 0; | |
11554 | argv_find (argv, argc, "(1-99)", &idx); | |
11555 | argv_find (argv, argc, "WORD", &idx); | |
11556 | cl_number_or_name = argv[idx]->arg; | |
11557 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11558 | argv_find (argv, argc, "AA:NN", &idx); | |
11559 | char *str = argv_concat (argv, argc, idx); | |
11560 | ||
11561 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11562 | ||
11563 | XFREE (MTYPE_TMP, str); | |
11564 | ||
11565 | if (ret < 0) | |
11566 | { | |
11567 | community_list_perror (vty, ret); | |
11568 | return CMD_WARNING; | |
11569 | } | |
11570 | ||
11571 | return CMD_SUCCESS; | |
718e3744 | 11572 | } |
11573 | ||
5bf15956 DW |
11574 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11575 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11576 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11577 | NO_STR |
11578 | IP_STR | |
11579 | EXTCOMMUNITY_LIST_STR | |
11580 | "Extended Community list number (expanded)\n" | |
718e3744 | 11581 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11582 | "Extended Community list name\n" |
718e3744 | 11583 | "Specify community to reject\n" |
11584 | "Specify community to accept\n" | |
11585 | "An ordered list as a regular-expression\n") | |
11586 | { | |
42f914d4 QY |
11587 | int deleteall = 0; |
11588 | ||
11589 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11590 | int direct = 0; | |
11591 | char *cl_number_or_name = NULL; | |
11592 | ||
11593 | int idx = 0; | |
11594 | argv_find (argv, argc, "(100-500)", &idx); | |
11595 | argv_find (argv, argc, "WORD", &idx); | |
11596 | cl_number_or_name = argv[idx]->arg; | |
11597 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11598 | argv_find (argv, argc, "LINE", &idx); | |
11599 | char *str = argv_concat (argv, argc, idx); | |
11600 | ||
11601 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11602 | ||
11603 | XFREE (MTYPE_TMP, str); | |
11604 | ||
11605 | if (ret < 0) | |
11606 | { | |
11607 | community_list_perror (vty, ret); | |
11608 | return CMD_WARNING; | |
11609 | } | |
11610 | ||
11611 | return CMD_SUCCESS; | |
718e3744 | 11612 | } |
11613 | ||
94f2b392 | 11614 | static void |
718e3744 | 11615 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11616 | { | |
11617 | struct community_entry *entry; | |
11618 | ||
11619 | for (entry = list->head; entry; entry = entry->next) | |
11620 | { | |
11621 | if (entry == list->head) | |
11622 | { | |
11623 | if (all_digit (list->name)) | |
11624 | vty_out (vty, "Extended community %s list %s%s", | |
11625 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11626 | "standard" : "(expanded) access", | |
11627 | list->name, VTY_NEWLINE); | |
11628 | else | |
11629 | vty_out (vty, "Named extended community %s list %s%s", | |
11630 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11631 | "standard" : "expanded", | |
11632 | list->name, VTY_NEWLINE); | |
11633 | } | |
11634 | if (entry->any) | |
11635 | vty_out (vty, " %s%s", | |
11636 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11637 | else | |
11638 | vty_out (vty, " %s %s%s", | |
11639 | community_direct_str (entry->direct), | |
11640 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11641 | entry->u.ecom->str : entry->config, | |
11642 | VTY_NEWLINE); | |
11643 | } | |
11644 | } | |
11645 | ||
11646 | DEFUN (show_ip_extcommunity_list, | |
11647 | show_ip_extcommunity_list_cmd, | |
11648 | "show ip extcommunity-list", | |
11649 | SHOW_STR | |
11650 | IP_STR | |
11651 | "List extended-community list\n") | |
11652 | { | |
11653 | struct community_list *list; | |
11654 | struct community_list_master *cm; | |
11655 | ||
fee6e4e4 | 11656 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11657 | if (! cm) |
11658 | return CMD_SUCCESS; | |
11659 | ||
11660 | for (list = cm->num.head; list; list = list->next) | |
11661 | extcommunity_list_show (vty, list); | |
11662 | ||
11663 | for (list = cm->str.head; list; list = list->next) | |
11664 | extcommunity_list_show (vty, list); | |
11665 | ||
11666 | return CMD_SUCCESS; | |
11667 | } | |
11668 | ||
11669 | DEFUN (show_ip_extcommunity_list_arg, | |
11670 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11671 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11672 | SHOW_STR |
11673 | IP_STR | |
11674 | "List extended-community list\n" | |
11675 | "Extcommunity-list number\n" | |
11676 | "Extcommunity-list name\n") | |
11677 | { | |
c500ae40 | 11678 | int idx_comm_list = 3; |
718e3744 | 11679 | struct community_list *list; |
11680 | ||
c500ae40 | 11681 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11682 | if (! list) |
11683 | { | |
b729294c | 11684 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11685 | return CMD_WARNING; |
11686 | } | |
11687 | ||
11688 | extcommunity_list_show (vty, list); | |
11689 | ||
11690 | return CMD_SUCCESS; | |
11691 | } | |
6b0655a2 | 11692 | |
718e3744 | 11693 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11694 | static const char * |
718e3744 | 11695 | community_list_config_str (struct community_entry *entry) |
11696 | { | |
fd79ac91 | 11697 | const char *str; |
718e3744 | 11698 | |
11699 | if (entry->any) | |
11700 | str = ""; | |
11701 | else | |
11702 | { | |
11703 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11704 | str = community_str (entry->u.com); | |
11705 | else | |
11706 | str = entry->config; | |
11707 | } | |
11708 | return str; | |
11709 | } | |
11710 | ||
11711 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11712 | static int |
718e3744 | 11713 | community_list_config_write (struct vty *vty) |
11714 | { | |
11715 | struct community_list *list; | |
11716 | struct community_entry *entry; | |
11717 | struct community_list_master *cm; | |
11718 | int write = 0; | |
11719 | ||
11720 | /* Community-list. */ | |
fee6e4e4 | 11721 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11722 | |
11723 | for (list = cm->num.head; list; list = list->next) | |
11724 | for (entry = list->head; entry; entry = entry->next) | |
11725 | { | |
fee6e4e4 | 11726 | vty_out (vty, "ip community-list %s %s %s%s", |
11727 | list->name, community_direct_str (entry->direct), | |
11728 | community_list_config_str (entry), | |
11729 | VTY_NEWLINE); | |
718e3744 | 11730 | write++; |
11731 | } | |
11732 | for (list = cm->str.head; list; list = list->next) | |
11733 | for (entry = list->head; entry; entry = entry->next) | |
11734 | { | |
11735 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11736 | entry->style == COMMUNITY_LIST_STANDARD | |
11737 | ? "standard" : "expanded", | |
11738 | list->name, community_direct_str (entry->direct), | |
11739 | community_list_config_str (entry), | |
11740 | VTY_NEWLINE); | |
11741 | write++; | |
11742 | } | |
11743 | ||
11744 | /* Extcommunity-list. */ | |
fee6e4e4 | 11745 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11746 | |
11747 | for (list = cm->num.head; list; list = list->next) | |
11748 | for (entry = list->head; entry; entry = entry->next) | |
11749 | { | |
fee6e4e4 | 11750 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
11751 | list->name, community_direct_str (entry->direct), | |
11752 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 11753 | write++; |
11754 | } | |
11755 | for (list = cm->str.head; list; list = list->next) | |
11756 | for (entry = list->head; entry; entry = entry->next) | |
11757 | { | |
11758 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
11759 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
11760 | ? "standard" : "expanded", | |
11761 | list->name, community_direct_str (entry->direct), | |
11762 | community_list_config_str (entry), VTY_NEWLINE); | |
11763 | write++; | |
11764 | } | |
57d187bc JS |
11765 | |
11766 | ||
11767 | /* lcommunity-list. */ | |
11768 | cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER); | |
11769 | ||
11770 | for (list = cm->num.head; list; list = list->next) | |
11771 | for (entry = list->head; entry; entry = entry->next) | |
11772 | { | |
11773 | vty_out (vty, "ip large-community-list %s %s %s%s", | |
11774 | list->name, community_direct_str (entry->direct), | |
11775 | community_list_config_str (entry), VTY_NEWLINE); | |
11776 | write++; | |
11777 | } | |
11778 | for (list = cm->str.head; list; list = list->next) | |
11779 | for (entry = list->head; entry; entry = entry->next) | |
11780 | { | |
11781 | vty_out (vty, "ip large-community-list %s %s %s %s%s", | |
11782 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
11783 | ? "standard" : "expanded", | |
11784 | list->name, community_direct_str (entry->direct), | |
11785 | community_list_config_str (entry), VTY_NEWLINE); | |
11786 | write++; | |
11787 | } | |
11788 | ||
718e3744 | 11789 | return write; |
11790 | } | |
11791 | ||
7fc626de | 11792 | static struct cmd_node community_list_node = |
718e3744 | 11793 | { |
11794 | COMMUNITY_LIST_NODE, | |
11795 | "", | |
11796 | 1 /* Export to vtysh. */ | |
11797 | }; | |
11798 | ||
94f2b392 | 11799 | static void |
11800 | community_list_vty (void) | |
718e3744 | 11801 | { |
11802 | install_node (&community_list_node, community_list_config_write); | |
11803 | ||
11804 | /* Community-list. */ | |
718e3744 | 11805 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 11806 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 11807 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
11808 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 11809 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
11810 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 11811 | |
11812 | /* Extcommunity-list. */ | |
11813 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 11814 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 11815 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
11816 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 11817 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
11818 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
57d187bc JS |
11819 | |
11820 | /* Large Community List */ | |
11821 | install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
11822 | install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
11823 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
11824 | install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
11825 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
11826 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd); | |
11827 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
11828 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
11829 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
11830 | install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
11831 | install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
11832 | install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 11833 | } |