]>
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 PJ |
43 | #include "bgpd/bgp_ecommunity.h" |
44 | #include "bgpd/bgp_damp.h" | |
718e3744 | 45 | #include "bgpd/bgp_debug.h" |
e0701b79 | 46 | #include "bgpd/bgp_fsm.h" |
718e3744 | 47 | #include "bgpd/bgp_mplsvpn.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
52 | #include "bgpd/bgp_zebra.h" | |
fee0f4c6 | 53 | #include "bgpd/bgp_table.h" |
94f2b392 | 54 | #include "bgpd/bgp_vty.h" |
165b5fff | 55 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 56 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 57 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 58 | #include "bgpd/bgp_bfd.h" |
718e3744 | 59 | |
20eb8864 | 60 | static struct peer_group * |
61 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); | |
62 | ||
718e3744 | 63 | /* Utility function to get address family from current node. */ |
64 | afi_t | |
65 | bgp_node_afi (struct vty *vty) | |
66 | { | |
4e851f1f LB |
67 | afi_t afi; |
68 | switch (vty->node) | |
69 | { | |
70 | case BGP_IPV6_NODE: | |
71 | case BGP_IPV6M_NODE: | |
72 | case BGP_VPNV6_NODE: | |
73 | case BGP_ENCAPV6_NODE: | |
74 | afi = AFI_IP6; | |
75 | break; | |
76 | default: | |
77 | afi = AFI_IP; | |
78 | break; | |
79 | } | |
80 | return afi; | |
718e3744 | 81 | } |
82 | ||
83 | /* Utility function to get subsequent address family from current | |
84 | node. */ | |
85 | safi_t | |
86 | bgp_node_safi (struct vty *vty) | |
87 | { | |
4e851f1f LB |
88 | safi_t safi; |
89 | switch (vty->node) | |
90 | { | |
91 | case BGP_ENCAP_NODE: | |
92 | case BGP_ENCAPV6_NODE: | |
93 | safi = SAFI_ENCAP; | |
94 | break; | |
95 | case BGP_VPNV4_NODE: | |
96 | case BGP_VPNV6_NODE: | |
97 | safi = SAFI_MPLS_VPN; | |
98 | break; | |
99 | case BGP_IPV4M_NODE: | |
100 | case BGP_IPV6M_NODE: | |
101 | safi = SAFI_MULTICAST; | |
102 | break; | |
103 | default: | |
104 | safi = SAFI_UNICAST; | |
105 | break; | |
106 | } | |
107 | return safi; | |
718e3744 | 108 | } |
109 | ||
46f296b4 LB |
110 | /* supports <ipv4|ipv6> */ |
111 | afi_t | |
112 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 113 | { |
46f296b4 LB |
114 | afi_t afi = AFI_MAX; /* unknown */ |
115 | if (!strcmp(afi_str, "ipv4")) { | |
116 | afi = AFI_IP; | |
8b1fb8be | 117 | } |
46f296b4 LB |
118 | else if (!strcmp(afi_str, "ipv6")) { |
119 | afi = AFI_IP6; | |
120 | } | |
46f296b4 LB |
121 | return afi; |
122 | } | |
123 | ||
124 | int | |
125 | bgp_parse_afi(const char *str, afi_t *afi) | |
126 | { | |
127 | *afi = bgp_vty_afi_from_arg(str); | |
128 | if (*afi != AFI_MAX) | |
129 | return 0; | |
130 | else | |
8b1fb8be LB |
131 | return -1; |
132 | } | |
133 | ||
46f296b4 LB |
134 | int |
135 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
136 | { | |
137 | int ret = 0; | |
138 | if (argv_find (argv, argc, "ipv4", index)) | |
139 | { | |
140 | ret = 1; | |
141 | if (afi) | |
142 | *afi = AFI_IP; | |
143 | } | |
144 | else if (argv_find (argv, argc, "ipv6", index)) | |
145 | { | |
146 | ret = 1; | |
147 | if (afi) | |
148 | *afi = AFI_IP6; | |
149 | } | |
150 | return ret; | |
151 | } | |
152 | ||
153 | /* supports <unicast|multicast|vpn|encap> */ | |
ccbb332a | 154 | safi_t |
3b14d86e | 155 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
156 | { |
157 | safi_t safi = SAFI_MAX; /* unknown */ | |
158 | if (strncmp (safi_str, "m", 1) == 0) | |
159 | safi = SAFI_MULTICAST; | |
160 | else if (strncmp (safi_str, "u", 1) == 0) | |
161 | safi = SAFI_UNICAST; | |
162 | else if (strncmp (safi_str, "e", 1) == 0) | |
163 | safi = SAFI_ENCAP; | |
164 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 165 | safi = SAFI_MPLS_VPN; |
ccbb332a LB |
166 | return safi; |
167 | } | |
168 | ||
8b1fb8be LB |
169 | int |
170 | bgp_parse_safi(const char *str, safi_t *safi) | |
171 | { | |
ccbb332a LB |
172 | *safi = bgp_vty_safi_from_arg(str); |
173 | if (*safi != SAFI_MAX) | |
174 | return 0; | |
3b14d86e | 175 | else |
8b1fb8be LB |
176 | return -1; |
177 | } | |
178 | ||
46f296b4 LB |
179 | int |
180 | argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t *safi) | |
181 | { | |
182 | int ret = 0; | |
183 | if (argv_find (argv, argc, "unicast", index)) | |
184 | { | |
185 | ret = 1; | |
186 | if (safi) | |
187 | *safi = SAFI_UNICAST; | |
188 | } | |
189 | else if (argv_find (argv, argc, "multicast", index)) | |
190 | { | |
191 | ret = 1; | |
192 | if (safi) | |
193 | *safi = SAFI_MULTICAST; | |
194 | } | |
195 | else if (argv_find (argv, argc, "vpn", index)) | |
196 | { | |
197 | ret = 1; | |
198 | if (safi) | |
199 | *safi = SAFI_MPLS_VPN; | |
200 | } | |
201 | else if (argv_find (argv, argc, "encap", index)) | |
202 | { | |
203 | ret = 1; | |
204 | if (safi) | |
205 | *safi = SAFI_ENCAP; | |
206 | } | |
207 | return ret; | |
208 | } | |
209 | ||
94f2b392 | 210 | static int |
6aeb9e78 | 211 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 212 | { |
213 | struct interface *ifp = NULL; | |
214 | ||
215 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 216 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 217 | else if (su->sa.sa_family == AF_INET6) |
f2345335 | 218 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 219 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 220 | |
221 | if (ifp) | |
222 | return 1; | |
223 | ||
224 | return 0; | |
225 | } | |
226 | ||
227 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
228 | /* This is used only for configuration, so disallow if attempted on |
229 | * a dynamic neighbor. | |
230 | */ | |
94f2b392 | 231 | static struct peer * |
fd79ac91 | 232 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 233 | { |
cdc2d765 | 234 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 235 | int ret; |
718e3744 | 236 | union sockunion su; |
237 | struct peer *peer; | |
238 | ||
cdc2d765 DL |
239 | if (!bgp) { |
240 | return NULL; | |
241 | } | |
718e3744 | 242 | |
243 | ret = str2sockunion (ip_str, &su); | |
244 | if (ret < 0) | |
245 | { | |
a80beece DS |
246 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
247 | if (!peer) | |
248 | { | |
04b6bdc0 DW |
249 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
250 | { | |
251 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
252 | return NULL; | |
253 | } | |
a80beece | 254 | } |
718e3744 | 255 | } |
a80beece | 256 | else |
718e3744 | 257 | { |
a80beece DS |
258 | peer = peer_lookup (bgp, &su); |
259 | if (! peer) | |
260 | { | |
261 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
262 | VTY_NEWLINE); | |
263 | return NULL; | |
264 | } | |
f14e6fdb DS |
265 | if (peer_dynamic_neighbor (peer)) |
266 | { | |
267 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
268 | VTY_NEWLINE); | |
269 | return NULL; | |
270 | } | |
271 | ||
718e3744 | 272 | } |
273 | return peer; | |
274 | } | |
275 | ||
276 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
277 | /* This is used only for configuration, so disallow if attempted on |
278 | * a dynamic neighbor. | |
279 | */ | |
c43ed2e4 | 280 | struct peer * |
fd79ac91 | 281 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 282 | { |
cdc2d765 | 283 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 284 | int ret; |
718e3744 | 285 | union sockunion su; |
f14e6fdb DS |
286 | struct peer *peer = NULL; |
287 | struct peer_group *group = NULL; | |
718e3744 | 288 | |
cdc2d765 DL |
289 | if (!bgp) { |
290 | return NULL; | |
291 | } | |
718e3744 | 292 | |
293 | ret = str2sockunion (peer_str, &su); | |
294 | if (ret == 0) | |
295 | { | |
f14e6fdb | 296 | /* IP address, locate peer. */ |
718e3744 | 297 | peer = peer_lookup (bgp, &su); |
718e3744 | 298 | } |
299 | else | |
300 | { | |
f14e6fdb | 301 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 302 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
303 | if (!peer) |
304 | group = peer_group_lookup (bgp, peer_str); | |
305 | } | |
a80beece | 306 | |
f14e6fdb DS |
307 | if (peer) |
308 | { | |
309 | if (peer_dynamic_neighbor (peer)) | |
310 | { | |
311 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
312 | VTY_NEWLINE); | |
313 | return NULL; | |
314 | } | |
315 | ||
316 | return peer; | |
718e3744 | 317 | } |
318 | ||
f14e6fdb DS |
319 | if (group) |
320 | return group->conf; | |
321 | ||
718e3744 | 322 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
323 | VTY_NEWLINE); | |
324 | ||
325 | return NULL; | |
326 | } | |
327 | ||
c43ed2e4 | 328 | int |
718e3744 | 329 | bgp_vty_return (struct vty *vty, int ret) |
330 | { | |
fd79ac91 | 331 | const char *str = NULL; |
718e3744 | 332 | |
333 | switch (ret) | |
334 | { | |
335 | case BGP_ERR_INVALID_VALUE: | |
336 | str = "Invalid value"; | |
337 | break; | |
338 | case BGP_ERR_INVALID_FLAG: | |
339 | str = "Invalid flag"; | |
340 | break; | |
718e3744 | 341 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
342 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
343 | break; | |
718e3744 | 344 | case BGP_ERR_PEER_FLAG_CONFLICT: |
345 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
346 | break; | |
718e3744 | 347 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
348 | str = "Specify remote-as or peer-group remote AS first"; | |
349 | break; | |
350 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
351 | str = "Cannot change the peer-group. Deconfigure first"; | |
352 | break; | |
353 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 354 | str = "Peer is not a member of this peer-group"; |
718e3744 | 355 | break; |
356 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
357 | str = "Prefix/distribute list can not co-exist"; | |
358 | break; | |
359 | case BGP_ERR_NOT_INTERNAL_PEER: | |
360 | str = "Invalid command. Not an internal neighbor"; | |
361 | break; | |
362 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 363 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 364 | break; |
365 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
366 | str = "Local-AS allowed only for EBGP peers"; | |
367 | break; | |
368 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
369 | str = "Cannot have local-as same as BGP AS number"; | |
370 | break; | |
0df7c91f PJ |
371 | case BGP_ERR_TCPSIG_FAILED: |
372 | str = "Error while applying TCP-Sig to session(s)"; | |
373 | break; | |
fa411a21 NH |
374 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
375 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
376 | break; | |
f5a4827d SH |
377 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
378 | str = "ttl-security only allowed for EBGP peers"; | |
379 | break; | |
c7122e14 DS |
380 | case BGP_ERR_AS_OVERRIDE: |
381 | str = "as-override cannot be configured for IBGP peers"; | |
382 | break; | |
f14e6fdb DS |
383 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
384 | str = "Invalid limit for number of dynamic neighbors"; | |
385 | break; | |
386 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
387 | str = "Dynamic neighbor listen range already exists"; | |
388 | break; | |
389 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
390 | str = "Operation not allowed on a dynamic neighbor"; | |
391 | break; | |
63fa10b5 QY |
392 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
393 | str = "Operation not allowed on a directly connected neighbor"; | |
394 | break; | |
718e3744 | 395 | } |
396 | if (str) | |
397 | { | |
398 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
399 | return CMD_WARNING; | |
400 | } | |
401 | return CMD_SUCCESS; | |
402 | } | |
403 | ||
7aafcaca DS |
404 | /* BGP clear sort. */ |
405 | enum clear_sort | |
406 | { | |
407 | clear_all, | |
408 | clear_peer, | |
409 | clear_group, | |
410 | clear_external, | |
411 | clear_as | |
412 | }; | |
413 | ||
7aafcaca DS |
414 | static void |
415 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
416 | safi_t safi, int error) | |
417 | { | |
418 | switch (error) | |
419 | { | |
420 | case BGP_ERR_AF_UNCONFIGURED: | |
421 | vty_out (vty, | |
46f296b4 LB |
422 | "%%BGP: Enable %s address family for the neighbor %s%s", |
423 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
424 | break; |
425 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
426 | 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); | |
427 | break; | |
428 | default: | |
429 | break; | |
430 | } | |
431 | } | |
432 | ||
433 | /* `clear ip bgp' functions. */ | |
434 | static int | |
435 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
436 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
437 | { | |
438 | int ret; | |
439 | struct peer *peer; | |
440 | struct listnode *node, *nnode; | |
441 | ||
442 | /* Clear all neighbors. */ | |
443 | /* | |
444 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
445 | * on the BGP instance as that may get freed if it is a doppelganger | |
446 | */ | |
447 | if (sort == clear_all) | |
448 | { | |
449 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
450 | { | |
451 | if (stype == BGP_CLEAR_SOFT_NONE) | |
452 | ret = peer_clear (peer, &nnode); | |
453 | else if (peer->afc[afi][safi]) | |
454 | ret = peer_clear_soft (peer, afi, safi, stype); | |
455 | else | |
456 | ret = 0; | |
457 | ||
458 | if (ret < 0) | |
459 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
460 | } | |
461 | ||
462 | /* This is to apply read-only mode on this clear. */ | |
463 | if (stype == BGP_CLEAR_SOFT_NONE) | |
464 | bgp->update_delay_over = 0; | |
465 | ||
466 | return CMD_SUCCESS; | |
467 | } | |
468 | ||
469 | /* Clear specified neighbors. */ | |
470 | if (sort == clear_peer) | |
471 | { | |
472 | union sockunion su; | |
473 | int ret; | |
474 | ||
475 | /* Make sockunion for lookup. */ | |
476 | ret = str2sockunion (arg, &su); | |
477 | if (ret < 0) | |
478 | { | |
479 | peer = peer_lookup_by_conf_if (bgp, arg); | |
480 | if (!peer) | |
481 | { | |
04b6bdc0 DW |
482 | peer = peer_lookup_by_hostname(bgp, arg); |
483 | if (!peer) | |
484 | { | |
485 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
486 | return CMD_WARNING; | |
487 | } | |
7aafcaca DS |
488 | } |
489 | } | |
490 | else | |
491 | { | |
492 | peer = peer_lookup (bgp, &su); | |
493 | if (! peer) | |
494 | { | |
495 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
496 | return CMD_WARNING; | |
497 | } | |
498 | } | |
499 | ||
500 | if (stype == BGP_CLEAR_SOFT_NONE) | |
501 | ret = peer_clear (peer, NULL); | |
502 | else | |
503 | ret = peer_clear_soft (peer, afi, safi, stype); | |
504 | ||
505 | if (ret < 0) | |
506 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
507 | ||
508 | return CMD_SUCCESS; | |
509 | } | |
510 | ||
511 | /* Clear all peer-group members. */ | |
512 | if (sort == clear_group) | |
513 | { | |
514 | struct peer_group *group; | |
515 | ||
516 | group = peer_group_lookup (bgp, arg); | |
517 | if (! group) | |
518 | { | |
519 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
520 | return CMD_WARNING; | |
521 | } | |
522 | ||
523 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
524 | { | |
525 | if (stype == BGP_CLEAR_SOFT_NONE) | |
526 | { | |
18f1dc06 | 527 | peer_clear (peer, NULL); |
7aafcaca DS |
528 | continue; |
529 | } | |
530 | ||
c8560b44 | 531 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
532 | continue; |
533 | ||
534 | ret = peer_clear_soft (peer, afi, safi, stype); | |
535 | ||
536 | if (ret < 0) | |
537 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
538 | } | |
539 | return CMD_SUCCESS; | |
540 | } | |
541 | ||
542 | if (sort == clear_external) | |
543 | { | |
544 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
545 | { | |
546 | if (peer->sort == BGP_PEER_IBGP) | |
547 | continue; | |
548 | ||
549 | if (stype == BGP_CLEAR_SOFT_NONE) | |
550 | ret = peer_clear (peer, &nnode); | |
551 | else | |
552 | ret = peer_clear_soft (peer, afi, safi, stype); | |
553 | ||
554 | if (ret < 0) | |
555 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
556 | } | |
557 | return CMD_SUCCESS; | |
558 | } | |
559 | ||
560 | if (sort == clear_as) | |
561 | { | |
562 | as_t as; | |
563 | int find = 0; | |
564 | ||
565 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
566 | ||
567 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
568 | { | |
569 | if (peer->as != as) | |
570 | continue; | |
571 | ||
572 | find = 1; | |
573 | if (stype == BGP_CLEAR_SOFT_NONE) | |
574 | ret = peer_clear (peer, &nnode); | |
575 | else | |
576 | ret = peer_clear_soft (peer, afi, safi, stype); | |
577 | ||
578 | if (ret < 0) | |
579 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
580 | } | |
581 | if (! find) | |
582 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
583 | VTY_NEWLINE); | |
584 | return CMD_SUCCESS; | |
585 | } | |
586 | ||
587 | return CMD_SUCCESS; | |
588 | } | |
589 | ||
590 | static int | |
591 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
592 | enum clear_sort sort, enum bgp_clear_type stype, | |
593 | const char *arg) | |
594 | { | |
595 | struct bgp *bgp; | |
596 | ||
597 | /* BGP structure lookup. */ | |
598 | if (name) | |
599 | { | |
600 | bgp = bgp_lookup_by_name (name); | |
601 | if (bgp == NULL) | |
602 | { | |
6aeb9e78 | 603 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
604 | return CMD_WARNING; |
605 | } | |
606 | } | |
607 | else | |
608 | { | |
f31fa004 | 609 | bgp = bgp_get_default (); |
7aafcaca DS |
610 | if (bgp == NULL) |
611 | { | |
612 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
613 | return CMD_WARNING; | |
614 | } | |
615 | } | |
616 | ||
617 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
618 | } | |
619 | ||
620 | /* clear soft inbound */ | |
621 | static void | |
f31fa004 | 622 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 623 | { |
b09b5ae0 | 624 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 625 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 626 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 627 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
628 | } |
629 | ||
630 | /* clear soft outbound */ | |
631 | static void | |
f31fa004 | 632 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 633 | { |
f31fa004 | 634 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 635 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 636 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 637 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
638 | } |
639 | ||
640 | ||
718e3744 | 641 | /* BGP global configuration. */ |
642 | ||
643 | DEFUN (bgp_multiple_instance_func, | |
644 | bgp_multiple_instance_cmd, | |
645 | "bgp multiple-instance", | |
646 | BGP_STR | |
647 | "Enable bgp multiple instance\n") | |
648 | { | |
649 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
650 | return CMD_SUCCESS; | |
651 | } | |
652 | ||
653 | DEFUN (no_bgp_multiple_instance, | |
654 | no_bgp_multiple_instance_cmd, | |
655 | "no bgp multiple-instance", | |
656 | NO_STR | |
657 | BGP_STR | |
658 | "BGP multiple instance\n") | |
659 | { | |
660 | int ret; | |
661 | ||
662 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
663 | if (ret < 0) | |
664 | { | |
665 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
666 | return CMD_WARNING; | |
667 | } | |
668 | return CMD_SUCCESS; | |
669 | } | |
670 | ||
671 | DEFUN (bgp_config_type, | |
672 | bgp_config_type_cmd, | |
6147e2c6 | 673 | "bgp config-type <cisco|zebra>", |
718e3744 | 674 | BGP_STR |
675 | "Configuration type\n" | |
676 | "cisco\n" | |
677 | "zebra\n") | |
678 | { | |
c500ae40 DW |
679 | int idx_vendor = 2; |
680 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 681 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
682 | else | |
683 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
684 | ||
685 | return CMD_SUCCESS; | |
686 | } | |
687 | ||
688 | DEFUN (no_bgp_config_type, | |
689 | no_bgp_config_type_cmd, | |
c7178fe7 | 690 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 691 | NO_STR |
692 | BGP_STR | |
838758ac DW |
693 | "Display configuration type\n" |
694 | "cisco\n" | |
695 | "zebra\n") | |
718e3744 | 696 | { |
697 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
698 | return CMD_SUCCESS; | |
699 | } | |
700 | ||
813d4307 | 701 | |
718e3744 | 702 | DEFUN (no_synchronization, |
703 | no_synchronization_cmd, | |
704 | "no synchronization", | |
705 | NO_STR | |
706 | "Perform IGP synchronization\n") | |
707 | { | |
708 | return CMD_SUCCESS; | |
709 | } | |
710 | ||
711 | DEFUN (no_auto_summary, | |
712 | no_auto_summary_cmd, | |
713 | "no auto-summary", | |
714 | NO_STR | |
715 | "Enable automatic network number summarization\n") | |
716 | { | |
717 | return CMD_SUCCESS; | |
718 | } | |
3d515fd9 | 719 | |
718e3744 | 720 | /* "router bgp" commands. */ |
f412b39a DW |
721 | DEFUN (router_bgp, |
722 | router_bgp_cmd, | |
31500417 | 723 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 724 | ROUTER_STR |
725 | BGP_STR | |
31500417 DW |
726 | AS_STR |
727 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 728 | { |
31500417 DW |
729 | int idx_asn = 2; |
730 | int idx_view_vrf = 3; | |
731 | int idx_vrf = 4; | |
718e3744 | 732 | int ret; |
733 | as_t as; | |
734 | struct bgp *bgp; | |
fd79ac91 | 735 | const char *name = NULL; |
ad4cbda1 | 736 | enum bgp_instance_type inst_type; |
718e3744 | 737 | |
2385a876 | 738 | // "router bgp" without an ASN |
31500417 | 739 | if (argc == 2) |
2385a876 | 740 | { |
6aeb9e78 | 741 | //Pending: Make VRF option available for ASN less config |
2385a876 | 742 | bgp = bgp_get_default(); |
718e3744 | 743 | |
2385a876 DW |
744 | if (bgp == NULL) |
745 | { | |
746 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
747 | return CMD_WARNING; | |
748 | } | |
718e3744 | 749 | |
2385a876 DW |
750 | if (listcount(bm->bgp) > 1) |
751 | { | |
752 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
753 | return CMD_WARNING; | |
754 | } | |
755 | } | |
756 | ||
757 | // "router bgp X" | |
758 | else | |
718e3744 | 759 | { |
31500417 | 760 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 761 | |
ad4cbda1 | 762 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 763 | if (argc > 3) |
ad4cbda1 | 764 | { |
31500417 DW |
765 | name = argv[idx_vrf]->arg; |
766 | ||
e52702f2 | 767 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 768 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 769 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 770 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
771 | } | |
2385a876 | 772 | |
ad4cbda1 | 773 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
774 | switch (ret) |
775 | { | |
776 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
777 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
778 | VTY_NEWLINE); | |
779 | return CMD_WARNING; | |
780 | case BGP_ERR_AS_MISMATCH: | |
781 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
782 | return CMD_WARNING; | |
783 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 784 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
785 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
786 | as, VTY_NEWLINE); | |
787 | return CMD_WARNING; | |
788 | } | |
6aeb9e78 DS |
789 | |
790 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 791 | } |
792 | ||
cdc2d765 | 793 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 794 | |
795 | return CMD_SUCCESS; | |
796 | } | |
797 | ||
718e3744 | 798 | /* "no router bgp" commands. */ |
799 | DEFUN (no_router_bgp, | |
800 | no_router_bgp_cmd, | |
31500417 | 801 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 802 | NO_STR |
803 | ROUTER_STR | |
804 | BGP_STR | |
31500417 DW |
805 | AS_STR |
806 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 807 | { |
31500417 | 808 | int idx_asn = 3; |
31500417 | 809 | int idx_vrf = 5; |
718e3744 | 810 | as_t as; |
811 | struct bgp *bgp; | |
fd79ac91 | 812 | const char *name = NULL; |
718e3744 | 813 | |
7fb21a9f | 814 | // "no router bgp" without an ASN |
31500417 | 815 | if (argc == 3) |
7fb21a9f QY |
816 | { |
817 | //Pending: Make VRF option available for ASN less config | |
818 | bgp = bgp_get_default(); | |
718e3744 | 819 | |
7fb21a9f QY |
820 | if (bgp == NULL) |
821 | { | |
822 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
823 | return CMD_WARNING; | |
824 | } | |
825 | ||
826 | if (listcount(bm->bgp) > 1) | |
827 | { | |
828 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
829 | return CMD_WARNING; | |
830 | } | |
831 | } | |
832 | else | |
718e3744 | 833 | { |
31500417 | 834 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 835 | |
31500417 DW |
836 | if (argc > 4) |
837 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
838 | |
839 | /* Lookup bgp structure. */ | |
840 | bgp = bgp_lookup (as, name); | |
841 | if (! bgp) | |
842 | { | |
843 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
844 | return CMD_WARNING; | |
845 | } | |
718e3744 | 846 | } |
847 | ||
848 | bgp_delete (bgp); | |
849 | ||
850 | return CMD_SUCCESS; | |
851 | } | |
852 | ||
6b0655a2 | 853 | |
7fb21a9f | 854 | |
718e3744 | 855 | /* BGP router-id. */ |
856 | ||
857 | DEFUN (bgp_router_id, | |
858 | bgp_router_id_cmd, | |
859 | "bgp router-id A.B.C.D", | |
860 | BGP_STR | |
861 | "Override configured router identifier\n" | |
862 | "Manually configured router identifier\n") | |
863 | { | |
cdc2d765 | 864 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 865 | int idx_ipv4 = 2; |
718e3744 | 866 | int ret; |
867 | struct in_addr id; | |
718e3744 | 868 | |
c500ae40 | 869 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 870 | if (! ret) |
871 | { | |
872 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
873 | return CMD_WARNING; | |
874 | } | |
875 | ||
0e6cb743 | 876 | bgp_router_id_static_set (bgp, id); |
718e3744 | 877 | |
878 | return CMD_SUCCESS; | |
879 | } | |
880 | ||
881 | DEFUN (no_bgp_router_id, | |
882 | no_bgp_router_id_cmd, | |
31500417 | 883 | "no bgp router-id [A.B.C.D]", |
718e3744 | 884 | NO_STR |
885 | BGP_STR | |
31500417 DW |
886 | "Override configured router identifier\n" |
887 | "Manually configured router identifier\n") | |
718e3744 | 888 | { |
cdc2d765 | 889 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 890 | int idx_router_id = 3; |
718e3744 | 891 | int ret; |
892 | struct in_addr id; | |
718e3744 | 893 | |
31500417 | 894 | if (argc > idx_router_id) |
718e3744 | 895 | { |
31500417 | 896 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 897 | if (! ret) |
e018c7cc SK |
898 | { |
899 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
900 | return CMD_WARNING; | |
901 | } | |
718e3744 | 902 | |
18a6dce6 | 903 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
904 | { |
905 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
906 | return CMD_WARNING; | |
907 | } | |
718e3744 | 908 | } |
909 | ||
0e6cb743 DL |
910 | id.s_addr = 0; |
911 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 912 | |
913 | return CMD_SUCCESS; | |
914 | } | |
915 | ||
6b0655a2 | 916 | |
718e3744 | 917 | /* BGP Cluster ID. */ |
718e3744 | 918 | DEFUN (bgp_cluster_id, |
919 | bgp_cluster_id_cmd, | |
838758ac | 920 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 921 | BGP_STR |
922 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
923 | "Route-Reflector Cluster-id in IP address format\n" |
924 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 925 | { |
cdc2d765 | 926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 927 | int idx_ipv4 = 2; |
718e3744 | 928 | int ret; |
718e3744 | 929 | struct in_addr cluster; |
930 | ||
c500ae40 | 931 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 932 | if (! ret) |
933 | { | |
934 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
935 | return CMD_WARNING; | |
936 | } | |
937 | ||
938 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 939 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 940 | |
941 | return CMD_SUCCESS; | |
942 | } | |
943 | ||
718e3744 | 944 | DEFUN (no_bgp_cluster_id, |
945 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 946 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 947 | NO_STR |
948 | BGP_STR | |
838758ac DW |
949 | "Configure Route-Reflector Cluster-id\n" |
950 | "Route-Reflector Cluster-id in IP address format\n" | |
951 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 952 | { |
cdc2d765 | 953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 954 | bgp_cluster_id_unset (bgp); |
f31fa004 | 955 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 956 | |
957 | return CMD_SUCCESS; | |
958 | } | |
959 | ||
718e3744 | 960 | DEFUN (bgp_confederation_identifier, |
961 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 962 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 963 | "BGP specific commands\n" |
964 | "AS confederation parameters\n" | |
965 | "AS number\n" | |
966 | "Set routing domain confederation AS\n") | |
967 | { | |
cdc2d765 | 968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 969 | int idx_number = 3; |
718e3744 | 970 | as_t as; |
971 | ||
c500ae40 | 972 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 973 | |
974 | bgp_confederation_id_set (bgp, as); | |
975 | ||
976 | return CMD_SUCCESS; | |
977 | } | |
978 | ||
979 | DEFUN (no_bgp_confederation_identifier, | |
980 | no_bgp_confederation_identifier_cmd, | |
838758ac | 981 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 982 | NO_STR |
983 | "BGP specific commands\n" | |
984 | "AS confederation parameters\n" | |
3a2d747c QY |
985 | "AS number\n" |
986 | "Set routing domain confederation AS\n") | |
718e3744 | 987 | { |
cdc2d765 | 988 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 989 | bgp_confederation_id_unset (bgp); |
990 | ||
991 | return CMD_SUCCESS; | |
992 | } | |
993 | ||
718e3744 | 994 | DEFUN (bgp_confederation_peers, |
995 | bgp_confederation_peers_cmd, | |
12dcf78e | 996 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 997 | "BGP specific commands\n" |
998 | "AS confederation parameters\n" | |
999 | "Peer ASs in BGP confederation\n" | |
1000 | AS_STR) | |
1001 | { | |
cdc2d765 | 1002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1003 | int idx_asn = 3; |
718e3744 | 1004 | as_t as; |
1005 | int i; | |
1006 | ||
58749582 | 1007 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1008 | { |
afec25d9 | 1009 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1010 | |
1011 | if (bgp->as == as) | |
1012 | { | |
1013 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1014 | VTY_NEWLINE); | |
1015 | continue; | |
1016 | } | |
1017 | ||
1018 | bgp_confederation_peers_add (bgp, as); | |
1019 | } | |
1020 | return CMD_SUCCESS; | |
1021 | } | |
1022 | ||
1023 | DEFUN (no_bgp_confederation_peers, | |
1024 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1025 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1026 | NO_STR |
1027 | "BGP specific commands\n" | |
1028 | "AS confederation parameters\n" | |
1029 | "Peer ASs in BGP confederation\n" | |
1030 | AS_STR) | |
1031 | { | |
cdc2d765 | 1032 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1033 | int idx_asn = 4; |
718e3744 | 1034 | as_t as; |
1035 | int i; | |
1036 | ||
58749582 | 1037 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1038 | { |
afec25d9 | 1039 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1040 | |
718e3744 | 1041 | bgp_confederation_peers_remove (bgp, as); |
1042 | } | |
1043 | return CMD_SUCCESS; | |
1044 | } | |
6b0655a2 | 1045 | |
5e242b0d DS |
1046 | /** |
1047 | * Central routine for maximum-paths configuration. | |
1048 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1049 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1050 | */ | |
ffd0c037 DS |
1051 | static int |
1052 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1053 | u_int16_t options, int set) |
165b5fff | 1054 | { |
cdc2d765 | 1055 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1056 | u_int16_t maxpaths = 0; |
165b5fff | 1057 | int ret; |
5e242b0d DS |
1058 | afi_t afi; |
1059 | safi_t safi; | |
165b5fff | 1060 | |
5e242b0d DS |
1061 | afi = bgp_node_afi (vty); |
1062 | safi = bgp_node_safi (vty); | |
165b5fff | 1063 | |
5e242b0d | 1064 | if (set) |
4c9dee98 | 1065 | { |
c59f2066 | 1066 | maxpaths = strtol(mpaths, NULL, 10); |
dff6764a | 1067 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1068 | } |
5e242b0d DS |
1069 | else |
1070 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1071 | |
165b5fff JB |
1072 | if (ret < 0) |
1073 | { | |
1074 | vty_out (vty, | |
5e242b0d DS |
1075 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1076 | (set == 1) ? "" : "un", | |
1077 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1078 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1079 | return CMD_WARNING; |
1080 | } | |
1081 | ||
7aafcaca DS |
1082 | bgp_recalculate_all_bestpaths (bgp); |
1083 | ||
165b5fff JB |
1084 | return CMD_SUCCESS; |
1085 | } | |
1086 | ||
abc920f8 DS |
1087 | DEFUN (bgp_maxmed_admin, |
1088 | bgp_maxmed_admin_cmd, | |
1089 | "bgp max-med administrative ", | |
1090 | BGP_STR | |
1091 | "Advertise routes with max-med\n" | |
1092 | "Administratively applied, for an indefinite period\n") | |
1093 | { | |
cdc2d765 | 1094 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1095 | |
1096 | bgp->v_maxmed_admin = 1; | |
1097 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1098 | ||
1099 | bgp_maxmed_update(bgp); | |
1100 | ||
1101 | return CMD_SUCCESS; | |
1102 | } | |
1103 | ||
1104 | DEFUN (bgp_maxmed_admin_medv, | |
1105 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1106 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1107 | BGP_STR |
1108 | "Advertise routes with max-med\n" | |
1109 | "Administratively applied, for an indefinite period\n" | |
1110 | "Max MED value to be used\n") | |
1111 | { | |
cdc2d765 | 1112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1113 | int idx_number = 3; |
abc920f8 DS |
1114 | |
1115 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1116 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1117 | |
1118 | bgp_maxmed_update(bgp); | |
1119 | ||
1120 | return CMD_SUCCESS; | |
1121 | } | |
1122 | ||
1123 | DEFUN (no_bgp_maxmed_admin, | |
1124 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1125 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1126 | NO_STR |
1127 | BGP_STR | |
1128 | "Advertise routes with max-med\n" | |
838758ac DW |
1129 | "Administratively applied, for an indefinite period\n" |
1130 | "Max MED value to be used\n") | |
abc920f8 | 1131 | { |
cdc2d765 | 1132 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1133 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1134 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1135 | bgp_maxmed_update(bgp); |
1136 | ||
1137 | return CMD_SUCCESS; | |
1138 | } | |
1139 | ||
abc920f8 DS |
1140 | DEFUN (bgp_maxmed_onstartup, |
1141 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1142 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1143 | BGP_STR |
1144 | "Advertise routes with max-med\n" | |
1145 | "Effective on a startup\n" | |
1146 | "Time (seconds) period for max-med\n") | |
1147 | { | |
cdc2d765 | 1148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1149 | int idx_number = 3; |
c500ae40 | 1150 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1151 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1152 | bgp_maxmed_update(bgp); |
1153 | ||
1154 | return CMD_SUCCESS; | |
1155 | } | |
1156 | ||
1157 | DEFUN (bgp_maxmed_onstartup_medv, | |
1158 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1159 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1160 | BGP_STR |
1161 | "Advertise routes with max-med\n" | |
1162 | "Effective on a startup\n" | |
1163 | "Time (seconds) period for max-med\n" | |
1164 | "Max MED value to be used\n") | |
1165 | { | |
cdc2d765 | 1166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1167 | int idx_number = 3; |
1168 | int idx_number_2 = 4; | |
c500ae40 DW |
1169 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1170 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1171 | bgp_maxmed_update(bgp); |
1172 | ||
1173 | return CMD_SUCCESS; | |
1174 | } | |
1175 | ||
1176 | DEFUN (no_bgp_maxmed_onstartup, | |
1177 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1178 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1179 | NO_STR |
1180 | BGP_STR | |
1181 | "Advertise routes with max-med\n" | |
838758ac DW |
1182 | "Effective on a startup\n" |
1183 | "Time (seconds) period for max-med\n" | |
1184 | "Max MED value to be used\n") | |
abc920f8 | 1185 | { |
cdc2d765 | 1186 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1187 | |
1188 | /* Cancel max-med onstartup if its on */ | |
1189 | if (bgp->t_maxmed_onstartup) | |
1190 | { | |
1191 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1192 | bgp->maxmed_onstartup_over = 1; | |
1193 | } | |
1194 | ||
1195 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1196 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1197 | ||
1198 | bgp_maxmed_update(bgp); | |
1199 | ||
1200 | return CMD_SUCCESS; | |
1201 | } | |
1202 | ||
f188f2c4 DS |
1203 | static int |
1204 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1205 | const char *wait) | |
1206 | { | |
cdc2d765 | 1207 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1208 | u_int16_t update_delay; |
1209 | u_int16_t establish_wait; | |
1210 | ||
f188f2c4 DS |
1211 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1212 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1213 | ||
1214 | if (!wait) /* update-delay <delay> */ | |
1215 | { | |
1216 | bgp->v_update_delay = update_delay; | |
1217 | bgp->v_establish_wait = bgp->v_update_delay; | |
1218 | return CMD_SUCCESS; | |
1219 | } | |
1220 | ||
1221 | /* update-delay <delay> <establish-wait> */ | |
1222 | establish_wait = atoi (wait); | |
1223 | if (update_delay < establish_wait) | |
1224 | { | |
1225 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1226 | VTY_NEWLINE); | |
1227 | return CMD_WARNING; | |
1228 | } | |
1229 | ||
1230 | bgp->v_update_delay = update_delay; | |
1231 | bgp->v_establish_wait = establish_wait; | |
1232 | ||
1233 | return CMD_SUCCESS; | |
1234 | } | |
1235 | ||
1236 | static int | |
1237 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1238 | { | |
cdc2d765 | 1239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1240 | |
1241 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1242 | bgp->v_establish_wait = bgp->v_update_delay; | |
1243 | ||
1244 | return CMD_SUCCESS; | |
1245 | } | |
1246 | ||
1247 | int | |
1248 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1249 | { | |
1250 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1251 | { | |
1252 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1253 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1254 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1255 | vty_out (vty, "%s", VTY_NEWLINE); | |
1256 | } | |
1257 | ||
1258 | return 0; | |
1259 | } | |
1260 | ||
1261 | ||
1262 | /* Update-delay configuration */ | |
1263 | DEFUN (bgp_update_delay, | |
1264 | bgp_update_delay_cmd, | |
6147e2c6 | 1265 | "update-delay (0-3600)", |
f188f2c4 DS |
1266 | "Force initial delay for best-path and updates\n" |
1267 | "Seconds\n") | |
1268 | { | |
c500ae40 DW |
1269 | int idx_number = 1; |
1270 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1271 | } |
1272 | ||
1273 | DEFUN (bgp_update_delay_establish_wait, | |
1274 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1275 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1276 | "Force initial delay for best-path and updates\n" |
1277 | "Seconds\n" | |
1278 | "Wait for peers to be established\n" | |
1279 | "Seconds\n") | |
1280 | { | |
c500ae40 DW |
1281 | int idx_number = 1; |
1282 | int idx_number_2 = 2; | |
1283 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1284 | } |
1285 | ||
1286 | /* Update-delay deconfiguration */ | |
1287 | DEFUN (no_bgp_update_delay, | |
1288 | no_bgp_update_delay_cmd, | |
838758ac DW |
1289 | "no update-delay [(0-3600) [(1-3600)]]", |
1290 | NO_STR | |
f188f2c4 | 1291 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1292 | "Seconds\n" |
1293 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1294 | { |
1295 | return bgp_update_delay_deconfig_vty(vty); | |
1296 | } | |
1297 | ||
5e242b0d | 1298 | |
ffd0c037 DS |
1299 | static int |
1300 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1301 | { |
cdc2d765 | 1302 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1303 | |
1304 | if (set) | |
1305 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1306 | 1, 10000); |
cb1faec9 DS |
1307 | else |
1308 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1309 | ||
1310 | return CMD_SUCCESS; | |
1311 | } | |
1312 | ||
1313 | int | |
1314 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1315 | { | |
1316 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1317 | vty_out (vty, " write-quanta %d%s", | |
1318 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1319 | ||
1320 | return 0; | |
1321 | } | |
1322 | ||
1323 | ||
1324 | /* Update-delay configuration */ | |
1325 | DEFUN (bgp_wpkt_quanta, | |
1326 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1327 | "write-quanta (1-10000)", |
cb1faec9 DS |
1328 | "How many packets to write to peer socket per run\n" |
1329 | "Number of packets\n") | |
1330 | { | |
c500ae40 DW |
1331 | int idx_number = 1; |
1332 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1333 | } |
1334 | ||
1335 | /* Update-delay deconfiguration */ | |
1336 | DEFUN (no_bgp_wpkt_quanta, | |
1337 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1338 | "no write-quanta (1-10000)", |
d7fa34c1 | 1339 | NO_STR |
cb1faec9 DS |
1340 | "How many packets to write to peer socket per run\n" |
1341 | "Number of packets\n") | |
1342 | { | |
c500ae40 DW |
1343 | int idx_number = 2; |
1344 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1345 | } |
1346 | ||
ffd0c037 | 1347 | static int |
3f9c7369 DS |
1348 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1349 | { | |
cdc2d765 | 1350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1351 | |
1352 | if (set) | |
1353 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1354 | 0, 4294967295); | |
1355 | else | |
1356 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1357 | ||
1358 | return CMD_SUCCESS; | |
1359 | } | |
1360 | ||
1361 | int | |
1362 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1363 | { | |
1364 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1365 | vty_out (vty, " coalesce-time %d%s", | |
1366 | bgp->coalesce_time, VTY_NEWLINE); | |
1367 | ||
1368 | return 0; | |
1369 | } | |
1370 | ||
1371 | ||
1372 | DEFUN (bgp_coalesce_time, | |
1373 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1374 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1375 | "Subgroup coalesce timer\n" |
1376 | "Subgroup coalesce timer value (in ms)\n") | |
1377 | { | |
c500ae40 DW |
1378 | int idx_number = 1; |
1379 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1380 | } |
1381 | ||
1382 | DEFUN (no_bgp_coalesce_time, | |
1383 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1384 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1385 | NO_STR |
3f9c7369 DS |
1386 | "Subgroup coalesce timer\n" |
1387 | "Subgroup coalesce timer value (in ms)\n") | |
1388 | { | |
c500ae40 DW |
1389 | int idx_number = 2; |
1390 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1391 | } |
1392 | ||
5e242b0d DS |
1393 | /* Maximum-paths configuration */ |
1394 | DEFUN (bgp_maxpaths, | |
1395 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1396 | "maximum-paths (1-255)", |
5e242b0d DS |
1397 | "Forward packets over multiple paths\n" |
1398 | "Number of paths\n") | |
1399 | { | |
c500ae40 DW |
1400 | int idx_number = 1; |
1401 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1402 | } |
1403 | ||
165b5fff JB |
1404 | DEFUN (bgp_maxpaths_ibgp, |
1405 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1406 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1407 | "Forward packets over multiple paths\n" |
1408 | "iBGP-multipath\n" | |
1409 | "Number of paths\n") | |
1410 | { | |
c500ae40 DW |
1411 | int idx_number = 2; |
1412 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1413 | } |
165b5fff | 1414 | |
5e242b0d DS |
1415 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1416 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1417 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1418 | "Forward packets over multiple paths\n" |
1419 | "iBGP-multipath\n" | |
1420 | "Number of paths\n" | |
1421 | "Match the cluster length\n") | |
1422 | { | |
c500ae40 DW |
1423 | int idx_number = 2; |
1424 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1425 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1426 | } |
1427 | ||
1428 | DEFUN (no_bgp_maxpaths, | |
1429 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1430 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1431 | NO_STR |
1432 | "Forward packets over multiple paths\n" | |
1433 | "Number of paths\n") | |
1434 | { | |
5e242b0d | 1435 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1436 | } |
1437 | ||
165b5fff JB |
1438 | DEFUN (no_bgp_maxpaths_ibgp, |
1439 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1440 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1441 | NO_STR |
1442 | "Forward packets over multiple paths\n" | |
1443 | "iBGP-multipath\n" | |
838758ac DW |
1444 | "Number of paths\n" |
1445 | "Match the cluster length\n") | |
165b5fff | 1446 | { |
5e242b0d | 1447 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1448 | } |
1449 | ||
165b5fff JB |
1450 | int |
1451 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1452 | safi_t safi, int *write) | |
1453 | { | |
d5b77cc2 | 1454 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1455 | { |
1456 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1457 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1458 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1459 | } | |
1460 | ||
d5b77cc2 | 1461 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1462 | { |
1463 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1464 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1465 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1466 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1467 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1468 | vty_out (vty, " equal-cluster-length"); | |
1469 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1470 | } |
1471 | ||
1472 | return 0; | |
1473 | } | |
6b0655a2 | 1474 | |
718e3744 | 1475 | /* BGP timers. */ |
1476 | ||
1477 | DEFUN (bgp_timers, | |
1478 | bgp_timers_cmd, | |
6147e2c6 | 1479 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1480 | "Adjust routing timers\n" |
1481 | "BGP timers\n" | |
1482 | "Keepalive interval\n" | |
1483 | "Holdtime\n") | |
1484 | { | |
cdc2d765 | 1485 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1486 | int idx_number = 2; |
1487 | int idx_number_2 = 3; | |
718e3744 | 1488 | unsigned long keepalive = 0; |
1489 | unsigned long holdtime = 0; | |
1490 | ||
c500ae40 DW |
1491 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1492 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1493 | |
1494 | /* Holdtime value check. */ | |
1495 | if (holdtime < 3 && holdtime != 0) | |
1496 | { | |
1497 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1498 | VTY_NEWLINE); | |
1499 | return CMD_WARNING; | |
1500 | } | |
1501 | ||
1502 | bgp_timers_set (bgp, keepalive, holdtime); | |
1503 | ||
1504 | return CMD_SUCCESS; | |
1505 | } | |
1506 | ||
1507 | DEFUN (no_bgp_timers, | |
1508 | no_bgp_timers_cmd, | |
838758ac | 1509 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1510 | NO_STR |
1511 | "Adjust routing timers\n" | |
838758ac DW |
1512 | "BGP timers\n" |
1513 | "Keepalive interval\n" | |
1514 | "Holdtime\n") | |
718e3744 | 1515 | { |
cdc2d765 | 1516 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1517 | bgp_timers_unset (bgp); |
1518 | ||
1519 | return CMD_SUCCESS; | |
1520 | } | |
1521 | ||
6b0655a2 | 1522 | |
718e3744 | 1523 | DEFUN (bgp_client_to_client_reflection, |
1524 | bgp_client_to_client_reflection_cmd, | |
1525 | "bgp client-to-client reflection", | |
1526 | "BGP specific commands\n" | |
1527 | "Configure client to client route reflection\n" | |
1528 | "reflection of routes allowed\n") | |
1529 | { | |
cdc2d765 | 1530 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1531 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1532 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1533 | |
718e3744 | 1534 | return CMD_SUCCESS; |
1535 | } | |
1536 | ||
1537 | DEFUN (no_bgp_client_to_client_reflection, | |
1538 | no_bgp_client_to_client_reflection_cmd, | |
1539 | "no bgp client-to-client reflection", | |
1540 | NO_STR | |
1541 | "BGP specific commands\n" | |
1542 | "Configure client to client route reflection\n" | |
1543 | "reflection of routes allowed\n") | |
1544 | { | |
cdc2d765 | 1545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1546 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1547 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1548 | |
718e3744 | 1549 | return CMD_SUCCESS; |
1550 | } | |
1551 | ||
1552 | /* "bgp always-compare-med" configuration. */ | |
1553 | DEFUN (bgp_always_compare_med, | |
1554 | bgp_always_compare_med_cmd, | |
1555 | "bgp always-compare-med", | |
1556 | "BGP specific commands\n" | |
1557 | "Allow comparing MED from different neighbors\n") | |
1558 | { | |
cdc2d765 | 1559 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1560 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1561 | bgp_recalculate_all_bestpaths (bgp); |
1562 | ||
718e3744 | 1563 | return CMD_SUCCESS; |
1564 | } | |
1565 | ||
1566 | DEFUN (no_bgp_always_compare_med, | |
1567 | no_bgp_always_compare_med_cmd, | |
1568 | "no bgp always-compare-med", | |
1569 | NO_STR | |
1570 | "BGP specific commands\n" | |
1571 | "Allow comparing MED from different neighbors\n") | |
1572 | { | |
cdc2d765 | 1573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1574 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1575 | bgp_recalculate_all_bestpaths (bgp); |
1576 | ||
718e3744 | 1577 | return CMD_SUCCESS; |
1578 | } | |
6b0655a2 | 1579 | |
718e3744 | 1580 | /* "bgp deterministic-med" configuration. */ |
1581 | DEFUN (bgp_deterministic_med, | |
1582 | bgp_deterministic_med_cmd, | |
1583 | "bgp deterministic-med", | |
1584 | "BGP specific commands\n" | |
1585 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1586 | { | |
cdc2d765 | 1587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1588 | |
1589 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1590 | { | |
1591 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1592 | bgp_recalculate_all_bestpaths (bgp); | |
1593 | } | |
7aafcaca | 1594 | |
718e3744 | 1595 | return CMD_SUCCESS; |
1596 | } | |
1597 | ||
1598 | DEFUN (no_bgp_deterministic_med, | |
1599 | no_bgp_deterministic_med_cmd, | |
1600 | "no bgp deterministic-med", | |
1601 | NO_STR | |
1602 | "BGP specific commands\n" | |
1603 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1604 | { | |
cdc2d765 | 1605 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1606 | int bestpath_per_as_used; |
1607 | afi_t afi; | |
1608 | safi_t safi; | |
1609 | struct peer *peer; | |
1610 | struct listnode *node, *nnode; | |
718e3744 | 1611 | |
1475ac87 DW |
1612 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1613 | { | |
06370dac DW |
1614 | bestpath_per_as_used = 0; |
1615 | ||
1616 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1617 | { | |
1618 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1619 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1620 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1621 | { | |
1622 | bestpath_per_as_used = 1; | |
1623 | break; | |
1624 | } | |
1625 | ||
1626 | if (bestpath_per_as_used) | |
1627 | break; | |
1628 | } | |
1629 | ||
1630 | if (bestpath_per_as_used) | |
1631 | { | |
1632 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1633 | VTY_NEWLINE); | |
1634 | return CMD_WARNING; | |
1635 | } | |
1636 | else | |
1637 | { | |
1638 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1639 | bgp_recalculate_all_bestpaths (bgp); | |
1640 | } | |
1475ac87 | 1641 | } |
7aafcaca | 1642 | |
718e3744 | 1643 | return CMD_SUCCESS; |
1644 | } | |
538621f2 | 1645 | |
1646 | /* "bgp graceful-restart" configuration. */ | |
1647 | DEFUN (bgp_graceful_restart, | |
1648 | bgp_graceful_restart_cmd, | |
1649 | "bgp graceful-restart", | |
1650 | "BGP specific commands\n" | |
1651 | "Graceful restart capability parameters\n") | |
1652 | { | |
cdc2d765 | 1653 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1654 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1655 | return CMD_SUCCESS; | |
1656 | } | |
1657 | ||
1658 | DEFUN (no_bgp_graceful_restart, | |
1659 | no_bgp_graceful_restart_cmd, | |
1660 | "no bgp graceful-restart", | |
1661 | NO_STR | |
1662 | "BGP specific commands\n" | |
1663 | "Graceful restart capability parameters\n") | |
1664 | { | |
cdc2d765 | 1665 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1666 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1667 | return CMD_SUCCESS; | |
1668 | } | |
1669 | ||
93406d87 | 1670 | DEFUN (bgp_graceful_restart_stalepath_time, |
1671 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1672 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1673 | "BGP specific commands\n" |
1674 | "Graceful restart capability parameters\n" | |
1675 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1676 | "Delay value (seconds)\n") | |
1677 | { | |
cdc2d765 | 1678 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1679 | int idx_number = 3; |
93406d87 | 1680 | u_int32_t stalepath; |
1681 | ||
c500ae40 | 1682 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1683 | bgp->stalepath_time = stalepath; |
1684 | return CMD_SUCCESS; | |
1685 | } | |
1686 | ||
eb6f1b41 PG |
1687 | DEFUN (bgp_graceful_restart_restart_time, |
1688 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1689 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1690 | "BGP specific commands\n" |
1691 | "Graceful restart capability parameters\n" | |
1692 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1693 | "Delay value (seconds)\n") | |
1694 | { | |
cdc2d765 | 1695 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1696 | int idx_number = 3; |
eb6f1b41 PG |
1697 | u_int32_t restart; |
1698 | ||
c500ae40 | 1699 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1700 | bgp->restart_time = restart; |
1701 | return CMD_SUCCESS; | |
1702 | } | |
1703 | ||
93406d87 | 1704 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1705 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1706 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1707 | NO_STR |
1708 | "BGP specific commands\n" | |
1709 | "Graceful restart capability parameters\n" | |
838758ac DW |
1710 | "Set the max time to hold onto restarting peer's stale paths\n" |
1711 | "Delay value (seconds)\n") | |
93406d87 | 1712 | { |
cdc2d765 | 1713 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1714 | |
1715 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1716 | return CMD_SUCCESS; | |
1717 | } | |
1718 | ||
eb6f1b41 PG |
1719 | DEFUN (no_bgp_graceful_restart_restart_time, |
1720 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1721 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1722 | NO_STR |
1723 | "BGP specific commands\n" | |
1724 | "Graceful restart capability parameters\n" | |
838758ac DW |
1725 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1726 | "Delay value (seconds)\n") | |
eb6f1b41 | 1727 | { |
cdc2d765 | 1728 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1729 | |
1730 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1731 | return CMD_SUCCESS; | |
1732 | } | |
1733 | ||
43fc21b3 JC |
1734 | DEFUN (bgp_graceful_restart_preserve_fw, |
1735 | bgp_graceful_restart_preserve_fw_cmd, | |
1736 | "bgp graceful-restart preserve-fw-state", | |
1737 | "BGP specific commands\n" | |
1738 | "Graceful restart capability parameters\n" | |
1739 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1740 | { | |
1741 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1742 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1743 | return CMD_SUCCESS; | |
1744 | } | |
1745 | ||
1746 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1747 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1748 | "no bgp graceful-restart preserve-fw-state", | |
1749 | NO_STR | |
1750 | "BGP specific commands\n" | |
1751 | "Graceful restart capability parameters\n" | |
1752 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1753 | { | |
1754 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1755 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1756 | return CMD_SUCCESS; | |
1757 | } | |
1758 | ||
718e3744 | 1759 | /* "bgp fast-external-failover" configuration. */ |
1760 | DEFUN (bgp_fast_external_failover, | |
1761 | bgp_fast_external_failover_cmd, | |
1762 | "bgp fast-external-failover", | |
1763 | BGP_STR | |
1764 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1765 | { | |
cdc2d765 | 1766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1767 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1768 | return CMD_SUCCESS; | |
1769 | } | |
1770 | ||
1771 | DEFUN (no_bgp_fast_external_failover, | |
1772 | no_bgp_fast_external_failover_cmd, | |
1773 | "no bgp fast-external-failover", | |
1774 | NO_STR | |
1775 | BGP_STR | |
1776 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1777 | { | |
cdc2d765 | 1778 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1779 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1780 | return CMD_SUCCESS; | |
1781 | } | |
6b0655a2 | 1782 | |
718e3744 | 1783 | /* "bgp enforce-first-as" configuration. */ |
1784 | DEFUN (bgp_enforce_first_as, | |
1785 | bgp_enforce_first_as_cmd, | |
1786 | "bgp enforce-first-as", | |
1787 | BGP_STR | |
1788 | "Enforce the first AS for EBGP routes\n") | |
1789 | { | |
cdc2d765 | 1790 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1791 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1792 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1793 | |
718e3744 | 1794 | return CMD_SUCCESS; |
1795 | } | |
1796 | ||
1797 | DEFUN (no_bgp_enforce_first_as, | |
1798 | no_bgp_enforce_first_as_cmd, | |
1799 | "no bgp enforce-first-as", | |
1800 | NO_STR | |
1801 | BGP_STR | |
1802 | "Enforce the first AS for EBGP routes\n") | |
1803 | { | |
cdc2d765 | 1804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1805 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1806 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1807 | |
718e3744 | 1808 | return CMD_SUCCESS; |
1809 | } | |
6b0655a2 | 1810 | |
718e3744 | 1811 | /* "bgp bestpath compare-routerid" configuration. */ |
1812 | DEFUN (bgp_bestpath_compare_router_id, | |
1813 | bgp_bestpath_compare_router_id_cmd, | |
1814 | "bgp bestpath compare-routerid", | |
1815 | "BGP specific commands\n" | |
1816 | "Change the default bestpath selection\n" | |
1817 | "Compare router-id for identical EBGP paths\n") | |
1818 | { | |
cdc2d765 | 1819 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1820 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1821 | bgp_recalculate_all_bestpaths (bgp); |
1822 | ||
718e3744 | 1823 | return CMD_SUCCESS; |
1824 | } | |
1825 | ||
1826 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1827 | no_bgp_bestpath_compare_router_id_cmd, | |
1828 | "no bgp bestpath compare-routerid", | |
1829 | NO_STR | |
1830 | "BGP specific commands\n" | |
1831 | "Change the default bestpath selection\n" | |
1832 | "Compare router-id for identical EBGP paths\n") | |
1833 | { | |
cdc2d765 | 1834 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1835 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1836 | bgp_recalculate_all_bestpaths (bgp); |
1837 | ||
718e3744 | 1838 | return CMD_SUCCESS; |
1839 | } | |
6b0655a2 | 1840 | |
718e3744 | 1841 | /* "bgp bestpath as-path ignore" configuration. */ |
1842 | DEFUN (bgp_bestpath_aspath_ignore, | |
1843 | bgp_bestpath_aspath_ignore_cmd, | |
1844 | "bgp bestpath as-path ignore", | |
1845 | "BGP specific commands\n" | |
1846 | "Change the default bestpath selection\n" | |
1847 | "AS-path attribute\n" | |
1848 | "Ignore as-path length in selecting a route\n") | |
1849 | { | |
cdc2d765 | 1850 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1851 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1852 | bgp_recalculate_all_bestpaths (bgp); |
1853 | ||
718e3744 | 1854 | return CMD_SUCCESS; |
1855 | } | |
1856 | ||
1857 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1858 | no_bgp_bestpath_aspath_ignore_cmd, | |
1859 | "no bgp bestpath as-path ignore", | |
1860 | NO_STR | |
1861 | "BGP specific commands\n" | |
1862 | "Change the default bestpath selection\n" | |
1863 | "AS-path attribute\n" | |
1864 | "Ignore as-path length in selecting a route\n") | |
1865 | { | |
cdc2d765 | 1866 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1867 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1868 | bgp_recalculate_all_bestpaths (bgp); |
1869 | ||
718e3744 | 1870 | return CMD_SUCCESS; |
1871 | } | |
6b0655a2 | 1872 | |
6811845b | 1873 | /* "bgp bestpath as-path confed" configuration. */ |
1874 | DEFUN (bgp_bestpath_aspath_confed, | |
1875 | bgp_bestpath_aspath_confed_cmd, | |
1876 | "bgp bestpath as-path confed", | |
1877 | "BGP specific commands\n" | |
1878 | "Change the default bestpath selection\n" | |
1879 | "AS-path attribute\n" | |
1880 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1881 | { | |
cdc2d765 | 1882 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1883 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1884 | bgp_recalculate_all_bestpaths (bgp); |
1885 | ||
6811845b | 1886 | return CMD_SUCCESS; |
1887 | } | |
1888 | ||
1889 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1890 | no_bgp_bestpath_aspath_confed_cmd, | |
1891 | "no bgp bestpath as-path confed", | |
1892 | NO_STR | |
1893 | "BGP specific commands\n" | |
1894 | "Change the default bestpath selection\n" | |
1895 | "AS-path attribute\n" | |
1896 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1897 | { | |
cdc2d765 | 1898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1899 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1900 | bgp_recalculate_all_bestpaths (bgp); |
1901 | ||
6811845b | 1902 | return CMD_SUCCESS; |
1903 | } | |
6b0655a2 | 1904 | |
2fdd455c PM |
1905 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1906 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1907 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1908 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1909 | "BGP specific commands\n" |
1910 | "Change the default bestpath selection\n" | |
1911 | "AS-path attribute\n" | |
1912 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1913 | "Generate an AS_SET\n" |
16fc1eec DS |
1914 | "Do not generate an AS_SET\n") |
1915 | { | |
cdc2d765 | 1916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 1917 | int idx = 0; |
16fc1eec | 1918 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
1919 | |
1920 | /* no-as-set is now the default behavior so we can silently | |
1921 | * ignore it */ | |
4c4ff4c1 | 1922 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
1923 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
1924 | else | |
1925 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
1926 | ||
7aafcaca DS |
1927 | bgp_recalculate_all_bestpaths (bgp); |
1928 | ||
16fc1eec DS |
1929 | return CMD_SUCCESS; |
1930 | } | |
1931 | ||
219178b6 DW |
1932 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1933 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1934 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1935 | NO_STR |
1936 | "BGP specific commands\n" | |
1937 | "Change the default bestpath selection\n" | |
1938 | "AS-path attribute\n" | |
1939 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1940 | "Generate an AS_SET\n" |
16fc1eec DS |
1941 | "Do not generate an AS_SET\n") |
1942 | { | |
cdc2d765 | 1943 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 1944 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 1945 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
1946 | bgp_recalculate_all_bestpaths (bgp); |
1947 | ||
2fdd455c PM |
1948 | return CMD_SUCCESS; |
1949 | } | |
6b0655a2 | 1950 | |
848973c7 | 1951 | /* "bgp log-neighbor-changes" configuration. */ |
1952 | DEFUN (bgp_log_neighbor_changes, | |
1953 | bgp_log_neighbor_changes_cmd, | |
1954 | "bgp log-neighbor-changes", | |
1955 | "BGP specific commands\n" | |
1956 | "Log neighbor up/down and reset reason\n") | |
1957 | { | |
cdc2d765 | 1958 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1959 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1960 | return CMD_SUCCESS; | |
1961 | } | |
1962 | ||
1963 | DEFUN (no_bgp_log_neighbor_changes, | |
1964 | no_bgp_log_neighbor_changes_cmd, | |
1965 | "no bgp log-neighbor-changes", | |
1966 | NO_STR | |
1967 | "BGP specific commands\n" | |
1968 | "Log neighbor up/down and reset reason\n") | |
1969 | { | |
cdc2d765 | 1970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1971 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1972 | return CMD_SUCCESS; | |
1973 | } | |
6b0655a2 | 1974 | |
718e3744 | 1975 | /* "bgp bestpath med" configuration. */ |
1976 | DEFUN (bgp_bestpath_med, | |
1977 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 1978 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 1979 | "BGP specific commands\n" |
1980 | "Change the default bestpath selection\n" | |
1981 | "MED attribute\n" | |
1982 | "Compare MED among confederation paths\n" | |
838758ac DW |
1983 | "Treat missing MED as the least preferred one\n" |
1984 | "Treat missing MED as the least preferred one\n" | |
1985 | "Compare MED among confederation paths\n") | |
718e3744 | 1986 | { |
cdc2d765 | 1987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
1988 | |
1989 | int idx = 0; | |
1990 | if (argv_find (argv, argc, "confed", &idx)) | |
1991 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
1992 | idx = 0; | |
1993 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
1994 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 1995 | |
7aafcaca DS |
1996 | bgp_recalculate_all_bestpaths (bgp); |
1997 | ||
718e3744 | 1998 | return CMD_SUCCESS; |
1999 | } | |
2000 | ||
718e3744 | 2001 | DEFUN (no_bgp_bestpath_med, |
2002 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2003 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2004 | NO_STR |
2005 | "BGP specific commands\n" | |
2006 | "Change the default bestpath selection\n" | |
2007 | "MED attribute\n" | |
2008 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2009 | "Treat missing MED as the least preferred one\n" |
2010 | "Treat missing MED as the least preferred one\n" | |
2011 | "Compare MED among confederation paths\n") | |
718e3744 | 2012 | { |
cdc2d765 | 2013 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2014 | |
6cbd1915 QY |
2015 | int idx = 0; |
2016 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2017 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2018 | idx = 0; |
2019 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2020 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2021 | ||
7aafcaca DS |
2022 | bgp_recalculate_all_bestpaths (bgp); |
2023 | ||
718e3744 | 2024 | return CMD_SUCCESS; |
2025 | } | |
2026 | ||
718e3744 | 2027 | /* "no bgp default ipv4-unicast". */ |
2028 | DEFUN (no_bgp_default_ipv4_unicast, | |
2029 | no_bgp_default_ipv4_unicast_cmd, | |
2030 | "no bgp default ipv4-unicast", | |
2031 | NO_STR | |
2032 | "BGP specific commands\n" | |
2033 | "Configure BGP defaults\n" | |
2034 | "Activate ipv4-unicast for a peer by default\n") | |
2035 | { | |
cdc2d765 | 2036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2037 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2038 | return CMD_SUCCESS; | |
2039 | } | |
2040 | ||
2041 | DEFUN (bgp_default_ipv4_unicast, | |
2042 | bgp_default_ipv4_unicast_cmd, | |
2043 | "bgp default ipv4-unicast", | |
2044 | "BGP specific commands\n" | |
2045 | "Configure BGP defaults\n" | |
2046 | "Activate ipv4-unicast for a peer by default\n") | |
2047 | { | |
cdc2d765 | 2048 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2049 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2050 | return CMD_SUCCESS; | |
2051 | } | |
6b0655a2 | 2052 | |
04b6bdc0 DW |
2053 | /* Display hostname in certain command outputs */ |
2054 | DEFUN (bgp_default_show_hostname, | |
2055 | bgp_default_show_hostname_cmd, | |
2056 | "bgp default show-hostname", | |
2057 | "BGP specific commands\n" | |
2058 | "Configure BGP defaults\n" | |
2059 | "Show hostname in certain command ouputs\n") | |
2060 | { | |
cdc2d765 | 2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2062 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2063 | return CMD_SUCCESS; | |
2064 | } | |
2065 | ||
2066 | DEFUN (no_bgp_default_show_hostname, | |
2067 | no_bgp_default_show_hostname_cmd, | |
2068 | "no bgp default show-hostname", | |
2069 | NO_STR | |
2070 | "BGP specific commands\n" | |
2071 | "Configure BGP defaults\n" | |
2072 | "Show hostname in certain command ouputs\n") | |
2073 | { | |
cdc2d765 | 2074 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2075 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2076 | return CMD_SUCCESS; | |
2077 | } | |
2078 | ||
8233ef81 | 2079 | /* "bgp network import-check" configuration. */ |
718e3744 | 2080 | DEFUN (bgp_network_import_check, |
2081 | bgp_network_import_check_cmd, | |
5623e905 | 2082 | "bgp network import-check", |
718e3744 | 2083 | "BGP specific commands\n" |
2084 | "BGP network command\n" | |
5623e905 | 2085 | "Check BGP network route exists in IGP\n") |
718e3744 | 2086 | { |
cdc2d765 | 2087 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2088 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2089 | { | |
2090 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2091 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2092 | } |
2093 | ||
718e3744 | 2094 | return CMD_SUCCESS; |
2095 | } | |
2096 | ||
8233ef81 DW |
2097 | ALIAS_HIDDEN (bgp_network_import_check, |
2098 | bgp_network_import_check_exact_cmd, | |
2099 | "bgp network import-check exact", | |
2100 | "BGP specific commands\n" | |
2101 | "BGP network command\n" | |
2102 | "Check BGP network route exists in IGP\n" | |
2103 | "Match route precisely\n") | |
2104 | ||
718e3744 | 2105 | DEFUN (no_bgp_network_import_check, |
2106 | no_bgp_network_import_check_cmd, | |
5623e905 | 2107 | "no bgp network import-check", |
718e3744 | 2108 | NO_STR |
2109 | "BGP specific commands\n" | |
2110 | "BGP network command\n" | |
2111 | "Check BGP network route exists in IGP\n") | |
2112 | { | |
cdc2d765 | 2113 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2114 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2115 | { | |
2116 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2117 | bgp_static_redo_import_check(bgp); |
2118 | } | |
5623e905 | 2119 | |
718e3744 | 2120 | return CMD_SUCCESS; |
2121 | } | |
6b0655a2 | 2122 | |
718e3744 | 2123 | DEFUN (bgp_default_local_preference, |
2124 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2125 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2126 | "BGP specific commands\n" |
2127 | "Configure BGP defaults\n" | |
2128 | "local preference (higher=more preferred)\n" | |
2129 | "Configure default local preference value\n") | |
2130 | { | |
cdc2d765 | 2131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2132 | int idx_number = 3; |
718e3744 | 2133 | u_int32_t local_pref; |
2134 | ||
c500ae40 | 2135 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2136 | |
2137 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2138 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2139 | |
2140 | return CMD_SUCCESS; | |
2141 | } | |
2142 | ||
2143 | DEFUN (no_bgp_default_local_preference, | |
2144 | no_bgp_default_local_preference_cmd, | |
838758ac | 2145 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2146 | NO_STR |
2147 | "BGP specific commands\n" | |
2148 | "Configure BGP defaults\n" | |
838758ac DW |
2149 | "local preference (higher=more preferred)\n" |
2150 | "Configure default local preference value\n") | |
718e3744 | 2151 | { |
cdc2d765 | 2152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2153 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2154 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2155 | |
718e3744 | 2156 | return CMD_SUCCESS; |
2157 | } | |
2158 | ||
6b0655a2 | 2159 | |
3f9c7369 DS |
2160 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2161 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2162 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2163 | "BGP specific commands\n" |
2164 | "Configure BGP defaults\n" | |
2165 | "subgroup-pkt-queue-max\n" | |
2166 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2167 | { |
cdc2d765 | 2168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2169 | int idx_number = 3; |
3f9c7369 | 2170 | u_int32_t max_size; |
8bd9d948 | 2171 | |
c500ae40 | 2172 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2173 | |
2174 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2175 | ||
2176 | return CMD_SUCCESS; | |
2177 | } | |
2178 | ||
2179 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2180 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2181 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2182 | NO_STR |
2183 | "BGP specific commands\n" | |
2184 | "Configure BGP defaults\n" | |
838758ac DW |
2185 | "subgroup-pkt-queue-max\n" |
2186 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2187 | { |
cdc2d765 | 2188 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2189 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2190 | return CMD_SUCCESS; | |
8bd9d948 DS |
2191 | } |
2192 | ||
813d4307 | 2193 | |
8bd9d948 DS |
2194 | DEFUN (bgp_rr_allow_outbound_policy, |
2195 | bgp_rr_allow_outbound_policy_cmd, | |
2196 | "bgp route-reflector allow-outbound-policy", | |
2197 | "BGP specific commands\n" | |
2198 | "Allow modifications made by out route-map\n" | |
2199 | "on ibgp neighbors\n") | |
2200 | { | |
cdc2d765 | 2201 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2202 | |
2203 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2204 | { | |
2205 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2206 | update_group_announce_rrclients(bgp); |
f31fa004 | 2207 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2208 | } |
2209 | ||
2210 | return CMD_SUCCESS; | |
2211 | } | |
2212 | ||
2213 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2214 | no_bgp_rr_allow_outbound_policy_cmd, | |
2215 | "no bgp route-reflector allow-outbound-policy", | |
2216 | NO_STR | |
2217 | "BGP specific commands\n" | |
2218 | "Allow modifications made by out route-map\n" | |
2219 | "on ibgp neighbors\n") | |
2220 | { | |
cdc2d765 | 2221 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2222 | |
2223 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2224 | { | |
2225 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2226 | update_group_announce_rrclients(bgp); |
f31fa004 | 2227 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2228 | } |
2229 | ||
2230 | return CMD_SUCCESS; | |
2231 | } | |
2232 | ||
f14e6fdb DS |
2233 | DEFUN (bgp_listen_limit, |
2234 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2235 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2236 | "BGP specific commands\n" |
2237 | "Configure BGP defaults\n" | |
2238 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2239 | "Configure Dynamic Neighbors listen limit value\n") | |
2240 | { | |
cdc2d765 | 2241 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2242 | int idx_number = 3; |
f14e6fdb DS |
2243 | int listen_limit; |
2244 | ||
c500ae40 | 2245 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2246 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2247 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2248 | ||
2249 | bgp_listen_limit_set (bgp, listen_limit); | |
2250 | ||
2251 | return CMD_SUCCESS; | |
2252 | } | |
2253 | ||
2254 | DEFUN (no_bgp_listen_limit, | |
2255 | no_bgp_listen_limit_cmd, | |
838758ac | 2256 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2257 | "BGP specific commands\n" |
2258 | "Configure BGP defaults\n" | |
2259 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2260 | "Configure Dynamic Neighbors listen limit value to default\n" |
2261 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2262 | { |
cdc2d765 | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2264 | bgp_listen_limit_unset (bgp); |
2265 | return CMD_SUCCESS; | |
2266 | } | |
2267 | ||
2268 | ||
20eb8864 | 2269 | /* |
2270 | * Check if this listen range is already configured. Check for exact | |
2271 | * match or overlap based on input. | |
2272 | */ | |
2273 | static struct peer_group * | |
2274 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2275 | { | |
2276 | struct listnode *node, *nnode; | |
2277 | struct listnode *node1, *nnode1; | |
2278 | struct peer_group *group; | |
2279 | struct prefix *lr; | |
2280 | afi_t afi; | |
2281 | int match; | |
2282 | ||
2283 | afi = family2afi(range->family); | |
2284 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2285 | { | |
2286 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2287 | nnode1, lr)) | |
2288 | { | |
2289 | if (exact) | |
2290 | match = prefix_same (range, lr); | |
2291 | else | |
2292 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2293 | if (match) | |
2294 | return group; | |
2295 | } | |
2296 | } | |
2297 | ||
2298 | return NULL; | |
2299 | } | |
2300 | ||
f14e6fdb DS |
2301 | DEFUN (bgp_listen_range, |
2302 | bgp_listen_range_cmd, | |
9ccf14f7 | 2303 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2304 | "BGP specific commands\n" |
d7fa34c1 QY |
2305 | "Configure BGP dynamic neighbors listen range\n" |
2306 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2307 | NEIGHBOR_ADDR_STR |
2308 | "Member of the peer-group\n" | |
2309 | "Peer-group name\n") | |
f14e6fdb | 2310 | { |
cdc2d765 | 2311 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2312 | struct prefix range; |
20eb8864 | 2313 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2314 | afi_t afi; |
2315 | int ret; | |
d7fa34c1 | 2316 | int idx = 0; |
f14e6fdb | 2317 | |
d7fa34c1 QY |
2318 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2319 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2320 | char *prefix = argv[idx]->arg; | |
2321 | argv_find (argv, argc, "WORD", &idx); | |
2322 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2323 | |
f14e6fdb | 2324 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2325 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2326 | if (! ret) |
2327 | { | |
2328 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2329 | return CMD_WARNING; | |
2330 | } | |
2331 | ||
2332 | afi = family2afi(range.family); | |
2333 | ||
f14e6fdb DS |
2334 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2335 | { | |
2336 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2337 | VTY_NEWLINE); | |
2338 | return CMD_WARNING; | |
2339 | } | |
f14e6fdb DS |
2340 | |
2341 | apply_mask (&range); | |
2342 | ||
20eb8864 | 2343 | /* Check if same listen range is already configured. */ |
2344 | existing_group = listen_range_exists (bgp, &range, 1); | |
2345 | if (existing_group) | |
2346 | { | |
d7fa34c1 | 2347 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2348 | return CMD_SUCCESS; |
2349 | else | |
2350 | { | |
2351 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2352 | existing_group->name, VTY_NEWLINE); | |
2353 | return CMD_WARNING; | |
2354 | } | |
2355 | } | |
2356 | ||
2357 | /* Check if an overlapping listen range exists. */ | |
2358 | if (listen_range_exists (bgp, &range, 0)) | |
2359 | { | |
2360 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2361 | VTY_NEWLINE); | |
2362 | return CMD_WARNING; | |
2363 | } | |
f14e6fdb | 2364 | |
d7fa34c1 | 2365 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2366 | if (! group) |
2367 | { | |
2368 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2369 | return CMD_WARNING; | |
2370 | } | |
2371 | ||
2372 | ret = peer_group_listen_range_add(group, &range); | |
2373 | return bgp_vty_return (vty, ret); | |
2374 | } | |
2375 | ||
2376 | DEFUN (no_bgp_listen_range, | |
2377 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2378 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2379 | NO_STR | |
f14e6fdb | 2380 | "BGP specific commands\n" |
d7fa34c1 QY |
2381 | "Unconfigure BGP dynamic neighbors listen range\n" |
2382 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2383 | NEIGHBOR_ADDR_STR | |
2384 | "Member of the peer-group\n" | |
2385 | "Peer-group name\n") | |
f14e6fdb | 2386 | { |
cdc2d765 | 2387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2388 | struct prefix range; |
2389 | struct peer_group *group; | |
2390 | afi_t afi; | |
2391 | int ret; | |
d7fa34c1 QY |
2392 | int idx = 0; |
2393 | ||
2394 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2395 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2396 | char *prefix = argv[idx]->arg; | |
2397 | argv_find (argv, argc, "WORD", &idx); | |
2398 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2399 | |
c500ae40 | 2400 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2401 | |
2402 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2403 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2404 | if (! ret) |
2405 | { | |
2406 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2407 | return CMD_WARNING; | |
2408 | } | |
2409 | ||
2410 | afi = family2afi(range.family); | |
2411 | ||
f14e6fdb DS |
2412 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2413 | { | |
2414 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2415 | VTY_NEWLINE); | |
2416 | return CMD_WARNING; | |
2417 | } | |
f14e6fdb DS |
2418 | |
2419 | apply_mask (&range); | |
2420 | ||
d7fa34c1 | 2421 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2422 | if (! group) |
2423 | { | |
2424 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2425 | return CMD_WARNING; | |
2426 | } | |
2427 | ||
2428 | ret = peer_group_listen_range_del(group, &range); | |
2429 | return bgp_vty_return (vty, ret); | |
2430 | } | |
2431 | ||
2432 | int | |
2433 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2434 | { | |
2435 | struct peer_group *group; | |
2436 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2437 | struct prefix *range; | |
2438 | afi_t afi; | |
4690c7d7 | 2439 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2440 | |
2441 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2442 | vty_out (vty, " bgp listen limit %d%s", | |
2443 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2444 | ||
2445 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2446 | { | |
2447 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2448 | { | |
2449 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2450 | { | |
2451 | prefix2str(range, buf, sizeof(buf)); | |
2452 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2453 | buf, group->name, VTY_NEWLINE); | |
2454 | } | |
2455 | } | |
2456 | } | |
2457 | ||
2458 | return 0; | |
2459 | } | |
2460 | ||
2461 | ||
907f92c8 DS |
2462 | DEFUN (bgp_disable_connected_route_check, |
2463 | bgp_disable_connected_route_check_cmd, | |
2464 | "bgp disable-ebgp-connected-route-check", | |
2465 | "BGP specific commands\n" | |
2466 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2467 | { | |
cdc2d765 | 2468 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2469 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2470 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2471 | |
907f92c8 DS |
2472 | return CMD_SUCCESS; |
2473 | } | |
2474 | ||
2475 | DEFUN (no_bgp_disable_connected_route_check, | |
2476 | no_bgp_disable_connected_route_check_cmd, | |
2477 | "no bgp disable-ebgp-connected-route-check", | |
2478 | NO_STR | |
2479 | "BGP specific commands\n" | |
2480 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2481 | { | |
cdc2d765 | 2482 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2483 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2484 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2485 | |
907f92c8 DS |
2486 | return CMD_SUCCESS; |
2487 | } | |
2488 | ||
2489 | ||
718e3744 | 2490 | static int |
e52702f2 | 2491 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2492 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2493 | { |
cdc2d765 | 2494 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2495 | int ret; |
718e3744 | 2496 | as_t as; |
0299c004 | 2497 | int as_type = AS_SPECIFIED; |
718e3744 | 2498 | union sockunion su; |
2499 | ||
7ae5fc81 | 2500 | if (as_str[0] == 'i') |
0299c004 DS |
2501 | { |
2502 | as = 0; | |
2503 | as_type = AS_INTERNAL; | |
2504 | } | |
7ae5fc81 | 2505 | else if (as_str[0] == 'e') |
0299c004 DS |
2506 | { |
2507 | as = 0; | |
2508 | as_type = AS_EXTERNAL; | |
2509 | } | |
2510 | else | |
2511 | { | |
2512 | /* Get AS number. */ | |
2513 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2514 | } | |
718e3744 | 2515 | |
2516 | /* If peer is peer group, call proper function. */ | |
2517 | ret = str2sockunion (peer_str, &su); | |
2518 | if (ret < 0) | |
2519 | { | |
a80beece | 2520 | /* Check for peer by interface */ |
0299c004 | 2521 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2522 | if (ret < 0) |
a80beece | 2523 | { |
0299c004 | 2524 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2525 | if (ret < 0) |
2526 | { | |
2527 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2528 | VTY_NEWLINE); | |
2529 | return CMD_WARNING; | |
2530 | } | |
2531 | return CMD_SUCCESS; | |
2532 | } | |
718e3744 | 2533 | } |
a80beece | 2534 | else |
718e3744 | 2535 | { |
6aeb9e78 | 2536 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2537 | { |
2538 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2539 | VTY_NEWLINE); | |
2540 | return CMD_WARNING; | |
2541 | } | |
0299c004 | 2542 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2543 | } |
2544 | ||
718e3744 | 2545 | /* This peer belongs to peer group. */ |
2546 | switch (ret) | |
2547 | { | |
2548 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2549 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2550 | return CMD_WARNING; |
718e3744 | 2551 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2552 | 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 | 2553 | return CMD_WARNING; |
718e3744 | 2554 | } |
2555 | return bgp_vty_return (vty, ret); | |
2556 | } | |
2557 | ||
2558 | DEFUN (neighbor_remote_as, | |
2559 | neighbor_remote_as_cmd, | |
3a2d747c | 2560 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2561 | NEIGHBOR_STR |
2562 | NEIGHBOR_ADDR_STR2 | |
2563 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2564 | AS_STR |
3a2d747c QY |
2565 | "Internal BGP peer\n" |
2566 | "External BGP peer\n") | |
718e3744 | 2567 | { |
c500ae40 DW |
2568 | int idx_peer = 1; |
2569 | int idx_remote_as = 3; | |
2570 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2571 | } |
6b0655a2 | 2572 | |
4c48cf63 DW |
2573 | static int |
2574 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2575 | safi_t safi, int v6only, const char *peer_group_name, |
2576 | const char *as_str) | |
a80beece | 2577 | { |
cdc2d765 | 2578 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2579 | as_t as = 0; |
2580 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2581 | struct peer *peer; |
2582 | struct peer_group *group; | |
4c48cf63 DW |
2583 | int ret = 0; |
2584 | union sockunion su; | |
a80beece | 2585 | |
4c48cf63 DW |
2586 | group = peer_group_lookup (bgp, conf_if); |
2587 | ||
a80beece DS |
2588 | if (group) |
2589 | { | |
2590 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2591 | return CMD_WARNING; | |
2592 | } | |
2593 | ||
b3a39dc5 DD |
2594 | if (as_str) |
2595 | { | |
7ae5fc81 | 2596 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2597 | { |
2598 | as_type = AS_INTERNAL; | |
2599 | } | |
7ae5fc81 | 2600 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2601 | { |
2602 | as_type = AS_EXTERNAL; | |
2603 | } | |
2604 | else | |
2605 | { | |
2606 | /* Get AS number. */ | |
2607 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2608 | as_type = AS_SPECIFIED; | |
2609 | } | |
2610 | } | |
2611 | ||
4c48cf63 DW |
2612 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2613 | if (!peer) | |
2614 | { | |
2615 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2616 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2617 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2618 | NULL); | |
4c48cf63 | 2619 | else |
b3a39dc5 DD |
2620 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2621 | NULL); | |
4c48cf63 DW |
2622 | |
2623 | if (peer && v6only) | |
2624 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2625 | |
2626 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2627 | * any unnumbered peer in order to not worry about run-time transitions | |
2628 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2629 | * gets deleted later etc.) | |
2630 | */ | |
2631 | if (peer->ifp) | |
b3a39dc5 DD |
2632 | { |
2633 | bgp_zebra_initiate_radv (bgp, peer); | |
2634 | } | |
2635 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2636 | } |
2637 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2638 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2639 | { | |
2640 | if (v6only) | |
2641 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2642 | else | |
2643 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2644 | ||
2645 | /* v6only flag changed. Reset bgp seesion */ | |
2646 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2647 | { | |
2648 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2649 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2650 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2651 | } | |
2652 | else | |
2653 | bgp_session_reset(peer); | |
2654 | } | |
2655 | ||
a80beece DS |
2656 | if (!peer) |
2657 | return CMD_WARNING; | |
2658 | ||
4c48cf63 DW |
2659 | if (peer_group_name) |
2660 | { | |
2661 | group = peer_group_lookup (bgp, peer_group_name); | |
2662 | if (! group) | |
2663 | { | |
2664 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2665 | return CMD_WARNING; | |
2666 | } | |
2667 | ||
2668 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2669 | } | |
2670 | ||
2671 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2672 | } |
2673 | ||
4c48cf63 DW |
2674 | DEFUN (neighbor_interface_config, |
2675 | neighbor_interface_config_cmd, | |
31500417 | 2676 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2677 | NEIGHBOR_STR |
2678 | "Interface name or neighbor tag\n" | |
31500417 DW |
2679 | "Enable BGP on interface\n" |
2680 | "Member of the peer-group\n" | |
16cedbb0 | 2681 | "Peer-group name\n") |
4c48cf63 | 2682 | { |
c500ae40 | 2683 | int idx_word = 1; |
31500417 DW |
2684 | int idx_peer_group_word = 4; |
2685 | ||
2686 | if (argc > idx_peer_group_word) | |
c500ae40 | 2687 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2688 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2689 | else |
c500ae40 | 2690 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2691 | NULL, NULL); |
4c48cf63 DW |
2692 | } |
2693 | ||
4c48cf63 DW |
2694 | DEFUN (neighbor_interface_config_v6only, |
2695 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2696 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2697 | NEIGHBOR_STR |
2698 | "Interface name or neighbor tag\n" | |
2699 | "Enable BGP on interface\n" | |
31500417 DW |
2700 | "Enable BGP with v6 link-local only\n" |
2701 | "Member of the peer-group\n" | |
16cedbb0 | 2702 | "Peer-group name\n") |
4c48cf63 | 2703 | { |
c500ae40 | 2704 | int idx_word = 1; |
31500417 DW |
2705 | int idx_peer_group_word = 5; |
2706 | ||
2707 | if (argc > idx_peer_group_word) | |
2708 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2709 | argv[idx_peer_group_word]->arg, NULL); | |
2710 | ||
c500ae40 | 2711 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2712 | NULL, NULL); |
4c48cf63 DW |
2713 | } |
2714 | ||
a80beece | 2715 | |
b3a39dc5 DD |
2716 | DEFUN (neighbor_interface_config_remote_as, |
2717 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2718 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2719 | NEIGHBOR_STR |
2720 | "Interface name or neighbor tag\n" | |
2721 | "Enable BGP on interface\n" | |
3a2d747c | 2722 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2723 | AS_STR |
3a2d747c QY |
2724 | "Internal BGP peer\n" |
2725 | "External BGP peer\n") | |
b3a39dc5 | 2726 | { |
c500ae40 DW |
2727 | int idx_word = 1; |
2728 | int idx_remote_as = 4; | |
2729 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2730 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2731 | } |
2732 | ||
2733 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2734 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2735 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2736 | NEIGHBOR_STR |
2737 | "Interface name or neighbor tag\n" | |
3a2d747c | 2738 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2739 | "Enable BGP on interface\n" |
3a2d747c | 2740 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2741 | AS_STR |
3a2d747c QY |
2742 | "Internal BGP peer\n" |
2743 | "External BGP peer\n") | |
b3a39dc5 | 2744 | { |
c500ae40 DW |
2745 | int idx_word = 1; |
2746 | int idx_remote_as = 5; | |
2747 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2748 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2749 | } |
2750 | ||
718e3744 | 2751 | DEFUN (neighbor_peer_group, |
2752 | neighbor_peer_group_cmd, | |
2753 | "neighbor WORD peer-group", | |
2754 | NEIGHBOR_STR | |
a80beece | 2755 | "Interface name or neighbor tag\n" |
718e3744 | 2756 | "Configure peer-group\n") |
2757 | { | |
cdc2d765 | 2758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2759 | int idx_word = 1; |
a80beece | 2760 | struct peer *peer; |
718e3744 | 2761 | struct peer_group *group; |
2762 | ||
c500ae40 | 2763 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2764 | if (peer) |
2765 | { | |
2766 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2767 | return CMD_WARNING; | |
2768 | } | |
718e3744 | 2769 | |
c500ae40 | 2770 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2771 | if (! group) |
2772 | return CMD_WARNING; | |
2773 | ||
2774 | return CMD_SUCCESS; | |
2775 | } | |
2776 | ||
2777 | DEFUN (no_neighbor, | |
2778 | no_neighbor_cmd, | |
a636c635 | 2779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> [remote-as <(1-4294967295)|internal|external>]", |
718e3744 | 2780 | NO_STR |
2781 | NEIGHBOR_STR | |
3a2d747c QY |
2782 | NEIGHBOR_ADDR_STR2 |
2783 | "Specify a BGP neighbor\n" | |
2784 | AS_STR | |
2785 | "Internal BGP peer\n" | |
2786 | "External BGP peer\n") | |
718e3744 | 2787 | { |
cdc2d765 | 2788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2789 | int idx_peer = 2; |
718e3744 | 2790 | int ret; |
2791 | union sockunion su; | |
2792 | struct peer_group *group; | |
2793 | struct peer *peer; | |
1ff9a340 | 2794 | struct peer *other; |
718e3744 | 2795 | |
c500ae40 | 2796 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2797 | if (ret < 0) |
2798 | { | |
a80beece | 2799 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2800 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2801 | if (peer) |
2802 | { | |
4a04e5f7 | 2803 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2804 | if (peer->ifp) | |
2805 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2806 | peer_delete (peer); |
2807 | return CMD_SUCCESS; | |
2808 | } | |
2809 | ||
cdc2d765 | 2810 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2811 | if (group) |
2812 | peer_group_delete (group); | |
2813 | else | |
2814 | { | |
2815 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2816 | return CMD_WARNING; | |
2817 | } | |
2818 | } | |
2819 | else | |
2820 | { | |
cdc2d765 | 2821 | peer = peer_lookup (bgp, &su); |
718e3744 | 2822 | if (peer) |
1ff9a340 | 2823 | { |
f14e6fdb DS |
2824 | if (peer_dynamic_neighbor (peer)) |
2825 | { | |
2826 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2827 | VTY_NEWLINE); | |
2828 | return CMD_WARNING; | |
2829 | } | |
2830 | ||
1ff9a340 DS |
2831 | other = peer->doppelganger; |
2832 | peer_delete (peer); | |
2833 | if (other && other->status != Deleted) | |
2834 | peer_delete(other); | |
2835 | } | |
718e3744 | 2836 | } |
2837 | ||
2838 | return CMD_SUCCESS; | |
2839 | } | |
2840 | ||
a80beece DS |
2841 | DEFUN (no_neighbor_interface_config, |
2842 | no_neighbor_interface_config_cmd, | |
31500417 | 2843 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2844 | NO_STR |
2845 | NEIGHBOR_STR | |
2846 | "Interface name\n" | |
31500417 DW |
2847 | "Configure BGP on interface\n" |
2848 | "Enable BGP with v6 link-local only\n" | |
2849 | "Member of the peer-group\n" | |
16cedbb0 | 2850 | "Peer-group name\n" |
3a2d747c QY |
2851 | "Specify a BGP neighbor\n" |
2852 | AS_STR | |
2853 | "Internal BGP peer\n" | |
2854 | "External BGP peer\n") | |
a80beece | 2855 | { |
cdc2d765 | 2856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2857 | int idx_word = 2; |
a80beece DS |
2858 | struct peer *peer; |
2859 | ||
2860 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2861 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2862 | if (peer) |
2863 | { | |
4a04e5f7 | 2864 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2865 | if (peer->ifp) | |
2866 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2867 | peer_delete (peer); |
2868 | } | |
2869 | else | |
2870 | { | |
2871 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2872 | return CMD_WARNING; | |
2873 | } | |
2874 | return CMD_SUCCESS; | |
2875 | } | |
2876 | ||
718e3744 | 2877 | DEFUN (no_neighbor_peer_group, |
2878 | no_neighbor_peer_group_cmd, | |
2879 | "no neighbor WORD peer-group", | |
2880 | NO_STR | |
2881 | NEIGHBOR_STR | |
2882 | "Neighbor tag\n" | |
2883 | "Configure peer-group\n") | |
2884 | { | |
cdc2d765 | 2885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2886 | int idx_word = 2; |
718e3744 | 2887 | struct peer_group *group; |
2888 | ||
cdc2d765 | 2889 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2890 | if (group) |
2891 | peer_group_delete (group); | |
2892 | else | |
2893 | { | |
2894 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2895 | return CMD_WARNING; | |
2896 | } | |
2897 | return CMD_SUCCESS; | |
2898 | } | |
2899 | ||
a80beece DS |
2900 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2901 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2902 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2903 | NO_STR |
2904 | NEIGHBOR_STR | |
a80beece | 2905 | "Interface name or neighbor tag\n" |
718e3744 | 2906 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2907 | AS_STR |
2908 | "Internal BGP peer\n" | |
2909 | "External BGP peer\n") | |
718e3744 | 2910 | { |
cdc2d765 | 2911 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2912 | int idx_word = 2; |
718e3744 | 2913 | struct peer_group *group; |
a80beece DS |
2914 | struct peer *peer; |
2915 | ||
2916 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2917 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2918 | if (peer) |
2919 | { | |
0299c004 | 2920 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
2921 | return CMD_SUCCESS; |
2922 | } | |
718e3744 | 2923 | |
cdc2d765 | 2924 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2925 | if (group) |
2926 | peer_group_remote_as_delete (group); | |
2927 | else | |
2928 | { | |
a80beece | 2929 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 2930 | return CMD_WARNING; |
2931 | } | |
2932 | return CMD_SUCCESS; | |
2933 | } | |
6b0655a2 | 2934 | |
718e3744 | 2935 | DEFUN (neighbor_local_as, |
2936 | neighbor_local_as_cmd, | |
9ccf14f7 | 2937 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2938 | NEIGHBOR_STR |
2939 | NEIGHBOR_ADDR_STR2 | |
2940 | "Specify a local-as number\n" | |
2941 | "AS number used as local AS\n") | |
2942 | { | |
c500ae40 DW |
2943 | int idx_peer = 1; |
2944 | int idx_number = 3; | |
718e3744 | 2945 | struct peer *peer; |
2946 | int ret; | |
e14fda0f | 2947 | as_t as; |
718e3744 | 2948 | |
c500ae40 | 2949 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2950 | if (! peer) |
2951 | return CMD_WARNING; | |
2952 | ||
b6f1faf0 | 2953 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 2954 | ret = peer_local_as_set (peer, as, 0, 0); |
718e3744 | 2955 | return bgp_vty_return (vty, ret); |
2956 | } | |
2957 | ||
2958 | DEFUN (neighbor_local_as_no_prepend, | |
2959 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2960 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2961 | NEIGHBOR_STR |
2962 | NEIGHBOR_ADDR_STR2 | |
2963 | "Specify a local-as number\n" | |
2964 | "AS number used as local AS\n" | |
2965 | "Do not prepend local-as to updates from ebgp peers\n") | |
2966 | { | |
c500ae40 DW |
2967 | int idx_peer = 1; |
2968 | int idx_number = 3; | |
718e3744 | 2969 | struct peer *peer; |
2970 | int ret; | |
e14fda0f | 2971 | as_t as; |
718e3744 | 2972 | |
c500ae40 | 2973 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2974 | if (! peer) |
2975 | return CMD_WARNING; | |
2976 | ||
b6f1faf0 | 2977 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 2978 | ret = peer_local_as_set (peer, as, 1, 0); |
718e3744 | 2979 | return bgp_vty_return (vty, ret); |
2980 | } | |
2981 | ||
9d3f9705 AC |
2982 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2983 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2984 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2985 | NEIGHBOR_STR |
2986 | NEIGHBOR_ADDR_STR2 | |
2987 | "Specify a local-as number\n" | |
2988 | "AS number used as local AS\n" | |
2989 | "Do not prepend local-as to updates from ebgp peers\n" | |
2990 | "Do not prepend local-as to updates from ibgp peers\n") | |
2991 | { | |
c500ae40 DW |
2992 | int idx_peer = 1; |
2993 | int idx_number = 3; | |
9d3f9705 AC |
2994 | struct peer *peer; |
2995 | int ret; | |
e14fda0f | 2996 | as_t as; |
9d3f9705 | 2997 | |
c500ae40 | 2998 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
2999 | if (! peer) |
3000 | return CMD_WARNING; | |
3001 | ||
b6f1faf0 | 3002 | VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
e14fda0f | 3003 | ret = peer_local_as_set (peer, as, 1, 1); |
9d3f9705 AC |
3004 | return bgp_vty_return (vty, ret); |
3005 | } | |
3006 | ||
718e3744 | 3007 | DEFUN (no_neighbor_local_as, |
3008 | no_neighbor_local_as_cmd, | |
a636c635 | 3009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3010 | NO_STR |
3011 | NEIGHBOR_STR | |
3012 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3013 | "Specify a local-as number\n" |
3014 | "AS number used as local AS\n" | |
3015 | "Do not prepend local-as to updates from ebgp peers\n" | |
3016 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3017 | { |
c500ae40 | 3018 | int idx_peer = 2; |
718e3744 | 3019 | struct peer *peer; |
3020 | int ret; | |
3021 | ||
c500ae40 | 3022 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3023 | if (! peer) |
3024 | return CMD_WARNING; | |
3025 | ||
3026 | ret = peer_local_as_unset (peer); | |
3027 | return bgp_vty_return (vty, ret); | |
3028 | } | |
3029 | ||
718e3744 | 3030 | |
9d3f9705 | 3031 | |
6b0655a2 | 3032 | |
3f9c7369 DS |
3033 | DEFUN (neighbor_solo, |
3034 | neighbor_solo_cmd, | |
9ccf14f7 | 3035 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3036 | NEIGHBOR_STR |
3037 | NEIGHBOR_ADDR_STR2 | |
3038 | "Solo peer - part of its own update group\n") | |
3039 | { | |
c500ae40 | 3040 | int idx_peer = 1; |
3f9c7369 DS |
3041 | struct peer *peer; |
3042 | int ret; | |
3043 | ||
c500ae40 | 3044 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3045 | if (! peer) |
3046 | return CMD_WARNING; | |
3047 | ||
3048 | ret = update_group_adjust_soloness(peer, 1); | |
3049 | return bgp_vty_return (vty, ret); | |
3050 | } | |
3051 | ||
3052 | DEFUN (no_neighbor_solo, | |
3053 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3054 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3055 | NO_STR |
3056 | NEIGHBOR_STR | |
3057 | NEIGHBOR_ADDR_STR2 | |
3058 | "Solo peer - part of its own update group\n") | |
3059 | { | |
c500ae40 | 3060 | int idx_peer = 2; |
3f9c7369 DS |
3061 | struct peer *peer; |
3062 | int ret; | |
3063 | ||
c500ae40 | 3064 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3065 | if (! peer) |
3066 | return CMD_WARNING; | |
3067 | ||
3068 | ret = update_group_adjust_soloness(peer, 0); | |
3069 | return bgp_vty_return (vty, ret); | |
3070 | } | |
3071 | ||
0df7c91f PJ |
3072 | DEFUN (neighbor_password, |
3073 | neighbor_password_cmd, | |
9ccf14f7 | 3074 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3075 | NEIGHBOR_STR |
3076 | NEIGHBOR_ADDR_STR2 | |
3077 | "Set a password\n" | |
3078 | "The password\n") | |
3079 | { | |
c500ae40 DW |
3080 | int idx_peer = 1; |
3081 | int idx_line = 3; | |
0df7c91f PJ |
3082 | struct peer *peer; |
3083 | int ret; | |
3084 | ||
c500ae40 | 3085 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3086 | if (! peer) |
3087 | return CMD_WARNING; | |
3088 | ||
c500ae40 | 3089 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3090 | return bgp_vty_return (vty, ret); |
3091 | } | |
3092 | ||
3093 | DEFUN (no_neighbor_password, | |
3094 | no_neighbor_password_cmd, | |
a636c635 | 3095 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3096 | NO_STR |
3097 | NEIGHBOR_STR | |
3098 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3099 | "Set a password\n" |
3100 | "The password\n") | |
0df7c91f | 3101 | { |
c500ae40 | 3102 | int idx_peer = 2; |
0df7c91f PJ |
3103 | struct peer *peer; |
3104 | int ret; | |
3105 | ||
c500ae40 | 3106 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3107 | if (! peer) |
3108 | return CMD_WARNING; | |
3109 | ||
3110 | ret = peer_password_unset (peer); | |
3111 | return bgp_vty_return (vty, ret); | |
3112 | } | |
6b0655a2 | 3113 | |
813d4307 | 3114 | |
718e3744 | 3115 | DEFUN (neighbor_activate, |
3116 | neighbor_activate_cmd, | |
9ccf14f7 | 3117 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3118 | NEIGHBOR_STR |
3119 | NEIGHBOR_ADDR_STR2 | |
3120 | "Enable the Address Family for this Neighbor\n") | |
3121 | { | |
c500ae40 | 3122 | int idx_peer = 1; |
c8560b44 | 3123 | int ret; |
718e3744 | 3124 | struct peer *peer; |
3125 | ||
c500ae40 | 3126 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3127 | if (! peer) |
3128 | return CMD_WARNING; | |
3129 | ||
c8560b44 | 3130 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3131 | |
c8560b44 DW |
3132 | if (ret) |
3133 | return CMD_WARNING; | |
718e3744 | 3134 | return CMD_SUCCESS; |
3135 | } | |
3136 | ||
3137 | DEFUN (no_neighbor_activate, | |
3138 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3140 | NO_STR |
3141 | NEIGHBOR_STR | |
3142 | NEIGHBOR_ADDR_STR2 | |
3143 | "Enable the Address Family for this Neighbor\n") | |
3144 | { | |
c500ae40 | 3145 | int idx_peer = 2; |
718e3744 | 3146 | int ret; |
3147 | struct peer *peer; | |
3148 | ||
3149 | /* Lookup peer. */ | |
c500ae40 | 3150 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3151 | if (! peer) |
3152 | return CMD_WARNING; | |
3153 | ||
3154 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3155 | ||
c8560b44 DW |
3156 | if (ret) |
3157 | return CMD_WARNING; | |
3158 | return CMD_SUCCESS; | |
718e3744 | 3159 | } |
6b0655a2 | 3160 | |
718e3744 | 3161 | DEFUN (neighbor_set_peer_group, |
3162 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3163 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3164 | NEIGHBOR_STR |
a80beece | 3165 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3166 | "Member of the peer-group\n" |
16cedbb0 | 3167 | "Peer-group name\n") |
718e3744 | 3168 | { |
cdc2d765 | 3169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3170 | int idx_peer = 1; |
3171 | int idx_word = 3; | |
718e3744 | 3172 | int ret; |
3173 | as_t as; | |
3174 | union sockunion su; | |
a80beece | 3175 | struct peer *peer; |
718e3744 | 3176 | struct peer_group *group; |
3177 | ||
a80beece | 3178 | peer = NULL; |
718e3744 | 3179 | |
c500ae40 | 3180 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3181 | if (ret < 0) |
3182 | { | |
c500ae40 | 3183 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3184 | if (!peer) |
3185 | { | |
c500ae40 | 3186 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3187 | return CMD_WARNING; |
3188 | } | |
3189 | } | |
3190 | else | |
3191 | { | |
6aeb9e78 | 3192 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3193 | { |
3194 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3195 | VTY_NEWLINE); | |
3196 | return CMD_WARNING; | |
3197 | } | |
f14e6fdb DS |
3198 | |
3199 | /* Disallow for dynamic neighbor. */ | |
3200 | peer = peer_lookup (bgp, &su); | |
3201 | if (peer && peer_dynamic_neighbor (peer)) | |
3202 | { | |
3203 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3204 | VTY_NEWLINE); | |
3205 | return CMD_WARNING; | |
3206 | } | |
718e3744 | 3207 | } |
3208 | ||
c500ae40 | 3209 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3210 | if (! group) |
3211 | { | |
3212 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3213 | return CMD_WARNING; | |
3214 | } | |
3215 | ||
c8560b44 | 3216 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3217 | |
3218 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3219 | { | |
aea339f7 | 3220 | 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 | 3221 | return CMD_WARNING; |
3222 | } | |
3223 | ||
3224 | return bgp_vty_return (vty, ret); | |
3225 | } | |
3226 | ||
3227 | DEFUN (no_neighbor_set_peer_group, | |
3228 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3229 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3230 | NO_STR |
3231 | NEIGHBOR_STR | |
a80beece | 3232 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3233 | "Member of the peer-group\n" |
16cedbb0 | 3234 | "Peer-group name\n") |
718e3744 | 3235 | { |
cdc2d765 | 3236 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3237 | int idx_peer = 2; |
3238 | int idx_word = 4; | |
718e3744 | 3239 | int ret; |
718e3744 | 3240 | struct peer *peer; |
3241 | struct peer_group *group; | |
3242 | ||
c500ae40 | 3243 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3244 | if (! peer) |
3245 | return CMD_WARNING; | |
3246 | ||
c500ae40 | 3247 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3248 | if (! group) |
3249 | { | |
3250 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3251 | return CMD_WARNING; | |
3252 | } | |
3253 | ||
c8560b44 | 3254 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3255 | |
3256 | return bgp_vty_return (vty, ret); | |
3257 | } | |
6b0655a2 | 3258 | |
94f2b392 | 3259 | static int |
e52702f2 | 3260 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3261 | u_int16_t flag, int set) |
718e3744 | 3262 | { |
3263 | int ret; | |
3264 | struct peer *peer; | |
3265 | ||
3266 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3267 | if (! peer) | |
3268 | return CMD_WARNING; | |
3269 | ||
8cdabf90 SK |
3270 | /* |
3271 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3272 | * we should not accept disable-connected-check. | |
3273 | */ | |
3274 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3275 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3276 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3277 | return CMD_WARNING; | |
3278 | } | |
3279 | ||
718e3744 | 3280 | if (set) |
3281 | ret = peer_flag_set (peer, flag); | |
3282 | else | |
3283 | ret = peer_flag_unset (peer, flag); | |
3284 | ||
3285 | return bgp_vty_return (vty, ret); | |
3286 | } | |
3287 | ||
94f2b392 | 3288 | static int |
fd79ac91 | 3289 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3290 | { |
3291 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3292 | } | |
3293 | ||
94f2b392 | 3294 | static int |
fd79ac91 | 3295 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3296 | { |
3297 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3298 | } | |
3299 | ||
3300 | /* neighbor passive. */ | |
3301 | DEFUN (neighbor_passive, | |
3302 | neighbor_passive_cmd, | |
9ccf14f7 | 3303 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3304 | NEIGHBOR_STR |
3305 | NEIGHBOR_ADDR_STR2 | |
3306 | "Don't send open messages to this neighbor\n") | |
3307 | { | |
c500ae40 DW |
3308 | int idx_peer = 1; |
3309 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3310 | } |
3311 | ||
3312 | DEFUN (no_neighbor_passive, | |
3313 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3314 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3315 | NO_STR |
3316 | NEIGHBOR_STR | |
3317 | NEIGHBOR_ADDR_STR2 | |
3318 | "Don't send open messages to this neighbor\n") | |
3319 | { | |
c500ae40 DW |
3320 | int idx_peer = 2; |
3321 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3322 | } |
6b0655a2 | 3323 | |
718e3744 | 3324 | /* neighbor shutdown. */ |
3325 | DEFUN (neighbor_shutdown, | |
3326 | neighbor_shutdown_cmd, | |
9ccf14f7 | 3327 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3328 | NEIGHBOR_STR |
3329 | NEIGHBOR_ADDR_STR2 | |
3330 | "Administratively shut down this neighbor\n") | |
3331 | { | |
c500ae40 DW |
3332 | int idx_peer = 1; |
3333 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3334 | } |
3335 | ||
3336 | DEFUN (no_neighbor_shutdown, | |
3337 | no_neighbor_shutdown_cmd, | |
9ccf14f7 | 3338 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3339 | NO_STR |
3340 | NEIGHBOR_STR | |
3341 | NEIGHBOR_ADDR_STR2 | |
3342 | "Administratively shut down this neighbor\n") | |
3343 | { | |
c500ae40 DW |
3344 | int idx_peer = 2; |
3345 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3346 | } |
6b0655a2 | 3347 | |
718e3744 | 3348 | /* neighbor capability dynamic. */ |
3349 | DEFUN (neighbor_capability_dynamic, | |
3350 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3351 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3352 | NEIGHBOR_STR |
3353 | NEIGHBOR_ADDR_STR2 | |
3354 | "Advertise capability to the peer\n" | |
3355 | "Advertise dynamic capability to this neighbor\n") | |
3356 | { | |
c500ae40 DW |
3357 | int idx_peer = 1; |
3358 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3359 | } |
3360 | ||
3361 | DEFUN (no_neighbor_capability_dynamic, | |
3362 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3364 | NO_STR |
3365 | NEIGHBOR_STR | |
3366 | NEIGHBOR_ADDR_STR2 | |
3367 | "Advertise capability to the peer\n" | |
3368 | "Advertise dynamic capability to this neighbor\n") | |
3369 | { | |
c500ae40 DW |
3370 | int idx_peer = 2; |
3371 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3372 | } |
6b0655a2 | 3373 | |
718e3744 | 3374 | /* neighbor dont-capability-negotiate */ |
3375 | DEFUN (neighbor_dont_capability_negotiate, | |
3376 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3377 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3378 | NEIGHBOR_STR |
3379 | NEIGHBOR_ADDR_STR2 | |
3380 | "Do not perform capability negotiation\n") | |
3381 | { | |
c500ae40 DW |
3382 | int idx_peer = 1; |
3383 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3384 | } |
3385 | ||
3386 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3387 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3389 | NO_STR |
3390 | NEIGHBOR_STR | |
3391 | NEIGHBOR_ADDR_STR2 | |
3392 | "Do not perform capability negotiation\n") | |
3393 | { | |
c500ae40 DW |
3394 | int idx_peer = 2; |
3395 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3396 | } |
6b0655a2 | 3397 | |
8a92a8a0 DS |
3398 | /* neighbor capability extended next hop encoding */ |
3399 | DEFUN (neighbor_capability_enhe, | |
3400 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3401 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3402 | NEIGHBOR_STR |
3403 | NEIGHBOR_ADDR_STR2 | |
3404 | "Advertise capability to the peer\n" | |
3405 | "Advertise extended next-hop capability to the peer\n") | |
3406 | { | |
c500ae40 DW |
3407 | int idx_peer = 1; |
3408 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3409 | } |
3410 | ||
3411 | DEFUN (no_neighbor_capability_enhe, | |
3412 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3413 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3414 | NO_STR |
3415 | NEIGHBOR_STR | |
3416 | NEIGHBOR_ADDR_STR2 | |
3417 | "Advertise capability to the peer\n" | |
3418 | "Advertise extended next-hop capability to the peer\n") | |
3419 | { | |
c500ae40 DW |
3420 | int idx_peer = 2; |
3421 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3422 | } |
3423 | ||
94f2b392 | 3424 | static int |
fd79ac91 | 3425 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3426 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3427 | { |
3428 | int ret; | |
3429 | struct peer *peer; | |
3430 | ||
3431 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3432 | if (! peer) | |
3433 | return CMD_WARNING; | |
3434 | ||
3435 | if (set) | |
3436 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3437 | else | |
3438 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3439 | ||
3440 | return bgp_vty_return (vty, ret); | |
3441 | } | |
3442 | ||
94f2b392 | 3443 | static int |
fd79ac91 | 3444 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3445 | safi_t safi, u_int32_t flag) |
718e3744 | 3446 | { |
3447 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3448 | } | |
3449 | ||
94f2b392 | 3450 | static int |
fd79ac91 | 3451 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3452 | safi_t safi, u_int32_t flag) |
718e3744 | 3453 | { |
3454 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3455 | } | |
6b0655a2 | 3456 | |
718e3744 | 3457 | /* neighbor capability orf prefix-list. */ |
3458 | DEFUN (neighbor_capability_orf_prefix, | |
3459 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3460 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3461 | NEIGHBOR_STR |
3462 | NEIGHBOR_ADDR_STR2 | |
3463 | "Advertise capability to the peer\n" | |
3464 | "Advertise ORF capability to the peer\n" | |
3465 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3466 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3467 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3468 | "Capability to SEND the ORF to this neighbor\n") | |
3469 | { | |
c500ae40 DW |
3470 | int idx_peer = 1; |
3471 | int idx_send_recv = 5; | |
718e3744 | 3472 | u_int16_t flag = 0; |
3473 | ||
c500ae40 | 3474 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3475 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3476 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3477 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3478 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3479 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3480 | else | |
3481 | return CMD_WARNING; | |
3482 | ||
c500ae40 | 3483 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3484 | bgp_node_safi (vty), flag); |
3485 | } | |
3486 | ||
3487 | DEFUN (no_neighbor_capability_orf_prefix, | |
3488 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3489 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3490 | NO_STR |
3491 | NEIGHBOR_STR | |
3492 | NEIGHBOR_ADDR_STR2 | |
3493 | "Advertise capability to the peer\n" | |
3494 | "Advertise ORF capability to the peer\n" | |
3495 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3496 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3497 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3498 | "Capability to SEND the ORF to this neighbor\n") | |
3499 | { | |
c500ae40 DW |
3500 | int idx_peer = 2; |
3501 | int idx_send_recv = 6; | |
718e3744 | 3502 | u_int16_t flag = 0; |
3503 | ||
c500ae40 | 3504 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3505 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3506 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3507 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3508 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3509 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3510 | else | |
3511 | return CMD_WARNING; | |
3512 | ||
c500ae40 | 3513 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3514 | bgp_node_safi (vty), flag); |
3515 | } | |
6b0655a2 | 3516 | |
718e3744 | 3517 | /* neighbor next-hop-self. */ |
3518 | DEFUN (neighbor_nexthop_self, | |
3519 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3520 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3521 | NEIGHBOR_STR |
3522 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3523 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3524 | { |
c500ae40 DW |
3525 | int idx_peer = 1; |
3526 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3527 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3528 | } | |
9e7a53c1 | 3529 | |
a538debe DS |
3530 | /* neighbor next-hop-self. */ |
3531 | DEFUN (neighbor_nexthop_self_force, | |
3532 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3533 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3534 | NEIGHBOR_STR |
3535 | NEIGHBOR_ADDR_STR2 | |
3536 | "Disable the next hop calculation for this neighbor\n" | |
3537 | "Set the next hop to self for reflected routes\n") | |
3538 | { | |
c500ae40 DW |
3539 | int idx_peer = 1; |
3540 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3541 | bgp_node_safi (vty), |
88b8ed8d | 3542 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3543 | } |
3544 | ||
3545 | DEFUN (no_neighbor_nexthop_self, | |
3546 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3548 | NO_STR |
3549 | NEIGHBOR_STR | |
3550 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3551 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3552 | { |
c500ae40 DW |
3553 | int idx_peer = 2; |
3554 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3555 | bgp_node_safi (vty), |
88b8ed8d | 3556 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3557 | } |
6b0655a2 | 3558 | |
88b8ed8d | 3559 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3560 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3561 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3562 | NO_STR |
3563 | NEIGHBOR_STR | |
3564 | NEIGHBOR_ADDR_STR2 | |
3565 | "Disable the next hop calculation for this neighbor\n" | |
3566 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3567 | { |
c500ae40 DW |
3568 | int idx_peer = 2; |
3569 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3570 | bgp_node_safi (vty), |
3571 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3572 | } | |
a538debe | 3573 | |
c7122e14 DS |
3574 | /* neighbor as-override */ |
3575 | DEFUN (neighbor_as_override, | |
3576 | neighbor_as_override_cmd, | |
9ccf14f7 | 3577 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3578 | NEIGHBOR_STR |
3579 | NEIGHBOR_ADDR_STR2 | |
3580 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3581 | { | |
c500ae40 DW |
3582 | int idx_peer = 1; |
3583 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3584 | bgp_node_safi (vty), |
3585 | PEER_FLAG_AS_OVERRIDE); | |
3586 | } | |
3587 | ||
3588 | DEFUN (no_neighbor_as_override, | |
3589 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3591 | NO_STR |
3592 | NEIGHBOR_STR | |
3593 | NEIGHBOR_ADDR_STR2 | |
3594 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3595 | { | |
c500ae40 DW |
3596 | int idx_peer = 2; |
3597 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3598 | bgp_node_safi (vty), |
3599 | PEER_FLAG_AS_OVERRIDE); | |
3600 | } | |
3601 | ||
718e3744 | 3602 | /* neighbor remove-private-AS. */ |
3603 | DEFUN (neighbor_remove_private_as, | |
3604 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3605 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3606 | NEIGHBOR_STR |
3607 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3608 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3609 | { |
c500ae40 DW |
3610 | int idx_peer = 1; |
3611 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3612 | bgp_node_safi (vty), |
3613 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3614 | } | |
3615 | ||
5000f21c DS |
3616 | DEFUN (neighbor_remove_private_as_all, |
3617 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3618 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3619 | NEIGHBOR_STR |
3620 | NEIGHBOR_ADDR_STR2 | |
3621 | "Remove private ASNs in outbound updates\n" | |
3622 | "Apply to all AS numbers") | |
3623 | { | |
c500ae40 DW |
3624 | int idx_peer = 1; |
3625 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3626 | bgp_node_safi (vty), |
5000f21c DS |
3627 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3628 | } | |
3629 | ||
3630 | DEFUN (neighbor_remove_private_as_replace_as, | |
3631 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3632 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3633 | NEIGHBOR_STR |
3634 | NEIGHBOR_ADDR_STR2 | |
3635 | "Remove private ASNs in outbound updates\n" | |
3636 | "Replace private ASNs with our ASN in outbound updates\n") | |
3637 | { | |
c500ae40 DW |
3638 | int idx_peer = 1; |
3639 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3640 | bgp_node_safi (vty), |
5000f21c DS |
3641 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3642 | } | |
3643 | ||
3644 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3645 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3646 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3647 | NEIGHBOR_STR |
3648 | NEIGHBOR_ADDR_STR2 | |
3649 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3650 | "Apply to all AS numbers\n" |
5000f21c DS |
3651 | "Replace private ASNs with our ASN in outbound updates\n") |
3652 | { | |
c500ae40 DW |
3653 | int idx_peer = 1; |
3654 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3655 | bgp_node_safi (vty), |
88b8ed8d | 3656 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3657 | } |
3658 | ||
718e3744 | 3659 | DEFUN (no_neighbor_remove_private_as, |
3660 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3662 | NO_STR |
3663 | NEIGHBOR_STR | |
3664 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3665 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3666 | { |
c500ae40 DW |
3667 | int idx_peer = 2; |
3668 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3669 | bgp_node_safi (vty), |
88b8ed8d | 3670 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3671 | } |
6b0655a2 | 3672 | |
88b8ed8d | 3673 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3674 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3675 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3676 | NO_STR |
3677 | NEIGHBOR_STR | |
3678 | NEIGHBOR_ADDR_STR2 | |
3679 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3680 | "Apply to all AS numbers\n") |
88b8ed8d | 3681 | { |
c500ae40 DW |
3682 | int idx_peer = 2; |
3683 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3684 | bgp_node_safi (vty), |
3685 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3686 | } | |
5000f21c | 3687 | |
88b8ed8d | 3688 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3689 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3691 | NO_STR |
3692 | NEIGHBOR_STR | |
3693 | NEIGHBOR_ADDR_STR2 | |
3694 | "Remove private ASNs in outbound updates\n" | |
3695 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3696 | { |
c500ae40 DW |
3697 | int idx_peer = 2; |
3698 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3699 | bgp_node_safi (vty), |
3700 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3701 | } | |
5000f21c | 3702 | |
88b8ed8d | 3703 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3704 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3706 | NO_STR |
3707 | NEIGHBOR_STR | |
3708 | NEIGHBOR_ADDR_STR2 | |
3709 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3710 | "Apply to all AS numbers\n" |
5000f21c | 3711 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3712 | { |
c500ae40 DW |
3713 | int idx_peer = 2; |
3714 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3715 | bgp_node_safi (vty), |
3716 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3717 | } | |
5000f21c DS |
3718 | |
3719 | ||
718e3744 | 3720 | /* neighbor send-community. */ |
3721 | DEFUN (neighbor_send_community, | |
3722 | neighbor_send_community_cmd, | |
9ccf14f7 | 3723 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3724 | NEIGHBOR_STR |
3725 | NEIGHBOR_ADDR_STR2 | |
3726 | "Send Community attribute to this neighbor\n") | |
3727 | { | |
c500ae40 DW |
3728 | int idx_peer = 1; |
3729 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3730 | bgp_node_safi (vty), |
3731 | PEER_FLAG_SEND_COMMUNITY); | |
3732 | } | |
3733 | ||
3734 | DEFUN (no_neighbor_send_community, | |
3735 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3736 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3737 | NO_STR |
3738 | NEIGHBOR_STR | |
3739 | NEIGHBOR_ADDR_STR2 | |
3740 | "Send Community attribute to this neighbor\n") | |
3741 | { | |
c500ae40 DW |
3742 | int idx_peer = 2; |
3743 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3744 | bgp_node_safi (vty), |
3745 | PEER_FLAG_SEND_COMMUNITY); | |
3746 | } | |
6b0655a2 | 3747 | |
718e3744 | 3748 | /* neighbor send-community extended. */ |
3749 | DEFUN (neighbor_send_community_type, | |
3750 | neighbor_send_community_type_cmd, | |
9ccf14f7 | 3751 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3752 | NEIGHBOR_STR |
3753 | NEIGHBOR_ADDR_STR2 | |
3754 | "Send Community attribute to this neighbor\n" | |
3755 | "Send Standard and Extended Community attributes\n" | |
3756 | "Send Extended Community attributes\n" | |
3757 | "Send Standard Community attributes\n") | |
3758 | { | |
4c4ff4c1 QY |
3759 | int idx = 0; |
3760 | u_int32_t flag = 0; | |
718e3744 | 3761 | |
4c4ff4c1 QY |
3762 | char *peer = argv[1]->arg; |
3763 | ||
3764 | if (argv_find (argv, argc, "standard", &idx)) | |
3765 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3766 | else if (argv_find (argv, argc, "extended", &idx)) | |
3767 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3768 | else | |
3769 | { | |
3770 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3771 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3772 | } | |
3773 | ||
3774 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3775 | } |
3776 | ||
3777 | DEFUN (no_neighbor_send_community_type, | |
3778 | no_neighbor_send_community_type_cmd, | |
9ccf14f7 | 3779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3780 | NO_STR |
3781 | NEIGHBOR_STR | |
3782 | NEIGHBOR_ADDR_STR2 | |
3783 | "Send Community attribute to this neighbor\n" | |
3784 | "Send Standard and Extended Community attributes\n" | |
3785 | "Send Extended Community attributes\n" | |
3786 | "Send Standard Community attributes\n") | |
3787 | { | |
c500ae40 DW |
3788 | int idx_peer = 2; |
3789 | int idx_type = 4; | |
3790 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3791 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3792 | bgp_node_safi (vty), |
3793 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3794 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3795 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3796 | bgp_node_safi (vty), |
3797 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
3798 | ||
c500ae40 | 3799 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3800 | bgp_node_safi (vty), |
3801 | (PEER_FLAG_SEND_COMMUNITY | | |
3802 | PEER_FLAG_SEND_EXT_COMMUNITY)); | |
3803 | } | |
6b0655a2 | 3804 | |
718e3744 | 3805 | /* neighbor soft-reconfig. */ |
3806 | DEFUN (neighbor_soft_reconfiguration, | |
3807 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3808 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3809 | NEIGHBOR_STR |
3810 | NEIGHBOR_ADDR_STR2 | |
3811 | "Per neighbor soft reconfiguration\n" | |
3812 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3813 | { | |
c500ae40 DW |
3814 | int idx_peer = 1; |
3815 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3816 | bgp_node_afi (vty), bgp_node_safi (vty), |
3817 | PEER_FLAG_SOFT_RECONFIG); | |
3818 | } | |
3819 | ||
3820 | DEFUN (no_neighbor_soft_reconfiguration, | |
3821 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3823 | NO_STR |
3824 | NEIGHBOR_STR | |
3825 | NEIGHBOR_ADDR_STR2 | |
3826 | "Per neighbor soft reconfiguration\n" | |
3827 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3828 | { | |
c500ae40 DW |
3829 | int idx_peer = 2; |
3830 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3831 | bgp_node_afi (vty), bgp_node_safi (vty), |
3832 | PEER_FLAG_SOFT_RECONFIG); | |
3833 | } | |
6b0655a2 | 3834 | |
718e3744 | 3835 | DEFUN (neighbor_route_reflector_client, |
3836 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3837 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3838 | NEIGHBOR_STR |
3839 | NEIGHBOR_ADDR_STR2 | |
3840 | "Configure a neighbor as Route Reflector client\n") | |
3841 | { | |
c500ae40 | 3842 | int idx_peer = 1; |
718e3744 | 3843 | struct peer *peer; |
3844 | ||
3845 | ||
c500ae40 | 3846 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3847 | if (! peer) |
3848 | return CMD_WARNING; | |
3849 | ||
c500ae40 | 3850 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3851 | bgp_node_safi (vty), |
3852 | PEER_FLAG_REFLECTOR_CLIENT); | |
3853 | } | |
3854 | ||
3855 | DEFUN (no_neighbor_route_reflector_client, | |
3856 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3857 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3858 | NO_STR |
3859 | NEIGHBOR_STR | |
3860 | NEIGHBOR_ADDR_STR2 | |
3861 | "Configure a neighbor as Route Reflector client\n") | |
3862 | { | |
c500ae40 DW |
3863 | int idx_peer = 2; |
3864 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3865 | bgp_node_safi (vty), |
3866 | PEER_FLAG_REFLECTOR_CLIENT); | |
3867 | } | |
6b0655a2 | 3868 | |
718e3744 | 3869 | /* neighbor route-server-client. */ |
3870 | DEFUN (neighbor_route_server_client, | |
3871 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 3872 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3873 | NEIGHBOR_STR |
3874 | NEIGHBOR_ADDR_STR2 | |
3875 | "Configure a neighbor as Route Server client\n") | |
3876 | { | |
c500ae40 | 3877 | int idx_peer = 1; |
2a3d5731 DW |
3878 | struct peer *peer; |
3879 | ||
c500ae40 | 3880 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
3881 | if (! peer) |
3882 | return CMD_WARNING; | |
c500ae40 | 3883 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
3884 | bgp_node_safi (vty), |
3885 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 3886 | } |
3887 | ||
3888 | DEFUN (no_neighbor_route_server_client, | |
3889 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 3890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3891 | NO_STR |
3892 | NEIGHBOR_STR | |
3893 | NEIGHBOR_ADDR_STR2 | |
3894 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 3895 | { |
c500ae40 DW |
3896 | int idx_peer = 2; |
3897 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
3898 | bgp_node_safi (vty), |
3899 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 3900 | } |
6b0655a2 | 3901 | |
fee0f4c6 | 3902 | DEFUN (neighbor_nexthop_local_unchanged, |
3903 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3904 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3905 | NEIGHBOR_STR |
3906 | NEIGHBOR_ADDR_STR2 | |
3907 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
3908 | "Leave link-local nexthop unchanged for this peer\n") | |
3909 | { | |
c500ae40 DW |
3910 | int idx_peer = 1; |
3911 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 3912 | bgp_node_safi (vty), |
3913 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
3914 | } | |
6b0655a2 | 3915 | |
fee0f4c6 | 3916 | DEFUN (no_neighbor_nexthop_local_unchanged, |
3917 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3918 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3919 | NO_STR |
3920 | NEIGHBOR_STR | |
3921 | NEIGHBOR_ADDR_STR2 | |
3922 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
3923 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 3924 | { |
c500ae40 DW |
3925 | int idx_peer = 2; |
3926 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3927 | bgp_node_safi (vty), |
fee0f4c6 | 3928 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 3929 | } |
6b0655a2 | 3930 | |
718e3744 | 3931 | DEFUN (neighbor_attr_unchanged, |
3932 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
3933 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3934 | [<\ | |
ddbaf941 QY |
3935 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3936 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3937 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3938 | >]", |
718e3744 | 3939 | NEIGHBOR_STR |
3940 | NEIGHBOR_ADDR_STR2 | |
3941 | "BGP attribute is propagated unchanged to this neighbor\n" | |
3942 | "As-path attribute\n" | |
3943 | "Nexthop attribute\n" | |
40e718b5 | 3944 | "Med attribute\n" |
1084263f QY |
3945 | "Med attribute\n" |
3946 | "Nexthop attribute\n" | |
3947 | "Nexthop attribute\n" | |
3948 | "As-path attribute\n" | |
3949 | "Med attribute\n" | |
40e718b5 | 3950 | "Med attribute\n" |
718e3744 | 3951 | "As-path attribute\n" |
1084263f QY |
3952 | "Med attribute\n" |
3953 | "As-path attribute\n" | |
3954 | "Nexthop attribute\n" | |
40e718b5 | 3955 | "Nexthop attribute\n" |
1084263f | 3956 | "As-path attribute\n") |
718e3744 | 3957 | { |
40e718b5 QY |
3958 | int idx = 0; |
3959 | char *peer = argv[1]->arg; | |
3960 | u_int16_t flags = 0; | |
718e3744 | 3961 | |
40e718b5 | 3962 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 3963 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
3964 | idx = 0; |
3965 | if (argv_find (argv, argc, "next-hop", &idx)) | |
3966 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
3967 | idx = 0; | |
3968 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 3969 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3970 | ||
40e718b5 QY |
3971 | if (!flags) // no flags means all of them! |
3972 | { | |
718e3744 | 3973 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 3974 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
3975 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3976 | } | |
718e3744 | 3977 | |
40e718b5 | 3978 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 3979 | } |
3980 | ||
718e3744 | 3981 | DEFUN (no_neighbor_attr_unchanged, |
3982 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
3983 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3984 | [<\ | |
ddbaf941 QY |
3985 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3986 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3987 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3988 | >]", |
e52702f2 | 3989 | NO_STR |
718e3744 | 3990 | NEIGHBOR_STR |
3991 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
3992 | "BGP attribute is propagated unchanged to this neighbor\n" |
3993 | "As-path attribute\n" | |
40e718b5 | 3994 | "Nexthop attribute\n" |
31500417 | 3995 | "Med attribute\n" |
1084263f QY |
3996 | "Med attribute\n" |
3997 | "Nexthop attribute\n" | |
3998 | "Nexthop attribute\n" | |
3999 | "As-path attribute\n" | |
4000 | "Med attribute\n" | |
40e718b5 | 4001 | "Med attribute\n" |
718e3744 | 4002 | "As-path attribute\n" |
1084263f QY |
4003 | "Med attribute\n" |
4004 | "As-path attribute\n" | |
4005 | "Nexthop attribute\n" | |
718e3744 | 4006 | "Nexthop attribute\n" |
1084263f | 4007 | "As-path attribute\n") |
718e3744 | 4008 | { |
40e718b5 QY |
4009 | int idx = 0; |
4010 | char *peer = argv[2]->arg; | |
4011 | u_int16_t flags = 0; | |
718e3744 | 4012 | |
40e718b5 | 4013 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4014 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4015 | idx = 0; |
4016 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4017 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4018 | idx = 0; | |
4019 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4020 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4021 | ||
40e718b5 QY |
4022 | if (!flags) // no flags means all of them! |
4023 | { | |
718e3744 | 4024 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4025 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4026 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4027 | } | |
718e3744 | 4028 | |
40e718b5 | 4029 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4030 | } |
4031 | ||
718e3744 | 4032 | |
718e3744 | 4033 | /* EBGP multihop configuration. */ |
94f2b392 | 4034 | static int |
e52702f2 | 4035 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4036 | const char *ttl_str) |
718e3744 | 4037 | { |
4038 | struct peer *peer; | |
fd79ac91 | 4039 | unsigned int ttl; |
718e3744 | 4040 | |
4041 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4042 | if (! peer) | |
4043 | return CMD_WARNING; | |
4044 | ||
63fa10b5 QY |
4045 | if (peer->conf_if) |
4046 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4047 | ||
718e3744 | 4048 | if (! ttl_str) |
9b1be336 | 4049 | ttl = MAXTTL; |
718e3744 | 4050 | else |
9b1be336 | 4051 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4052 | |
89b6d1f8 | 4053 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4054 | } |
4055 | ||
94f2b392 | 4056 | static int |
e52702f2 | 4057 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4058 | { |
4059 | struct peer *peer; | |
4060 | ||
4061 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4062 | if (! peer) | |
4063 | return CMD_WARNING; | |
4064 | ||
89b6d1f8 | 4065 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4066 | } |
4067 | ||
4068 | /* neighbor ebgp-multihop. */ | |
4069 | DEFUN (neighbor_ebgp_multihop, | |
4070 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4071 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4072 | NEIGHBOR_STR |
4073 | NEIGHBOR_ADDR_STR2 | |
4074 | "Allow EBGP neighbors not on directly connected networks\n") | |
4075 | { | |
c500ae40 DW |
4076 | int idx_peer = 1; |
4077 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4078 | } |
4079 | ||
4080 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4081 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4082 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4083 | NEIGHBOR_STR |
4084 | NEIGHBOR_ADDR_STR2 | |
4085 | "Allow EBGP neighbors not on directly connected networks\n" | |
4086 | "maximum hop count\n") | |
4087 | { | |
c500ae40 DW |
4088 | int idx_peer = 1; |
4089 | int idx_number = 3; | |
4090 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4091 | } |
4092 | ||
4093 | DEFUN (no_neighbor_ebgp_multihop, | |
4094 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4095 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4096 | NO_STR |
4097 | NEIGHBOR_STR | |
4098 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4099 | "Allow EBGP neighbors not on directly connected networks\n" |
4100 | "maximum hop count\n") | |
718e3744 | 4101 | { |
c500ae40 DW |
4102 | int idx_peer = 2; |
4103 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4104 | } |
4105 | ||
6b0655a2 | 4106 | |
6ffd2079 | 4107 | /* disable-connected-check */ |
4108 | DEFUN (neighbor_disable_connected_check, | |
4109 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4110 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4111 | NEIGHBOR_STR |
4112 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4113 | "one-hop away EBGP peer using loopback address\n" |
4114 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4115 | { |
c500ae40 DW |
4116 | int idx_peer = 1; |
4117 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4118 | } |
4119 | ||
4120 | DEFUN (no_neighbor_disable_connected_check, | |
4121 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4122 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4123 | NO_STR |
4124 | NEIGHBOR_STR | |
4125 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4126 | "one-hop away EBGP peer using loopback address\n" |
4127 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4128 | { |
c500ae40 DW |
4129 | int idx_peer = 2; |
4130 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4131 | } |
4132 | ||
718e3744 | 4133 | DEFUN (neighbor_description, |
4134 | neighbor_description_cmd, | |
e961923c | 4135 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4136 | NEIGHBOR_STR |
4137 | NEIGHBOR_ADDR_STR2 | |
4138 | "Neighbor specific description\n" | |
4139 | "Up to 80 characters describing this neighbor\n") | |
4140 | { | |
c500ae40 | 4141 | int idx_peer = 1; |
58749582 | 4142 | int idx_line = 3; |
718e3744 | 4143 | struct peer *peer; |
718e3744 | 4144 | char *str; |
718e3744 | 4145 | |
c500ae40 | 4146 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4147 | if (! peer) |
4148 | return CMD_WARNING; | |
4149 | ||
58749582 | 4150 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4151 | |
4152 | peer_description_set (peer, str); | |
4153 | ||
3b8b1855 | 4154 | XFREE (MTYPE_TMP, str); |
718e3744 | 4155 | |
4156 | return CMD_SUCCESS; | |
4157 | } | |
4158 | ||
4159 | DEFUN (no_neighbor_description, | |
4160 | no_neighbor_description_cmd, | |
a636c635 | 4161 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4162 | NO_STR |
4163 | NEIGHBOR_STR | |
4164 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4165 | "Neighbor specific description\n" |
4166 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4167 | { |
c500ae40 | 4168 | int idx_peer = 2; |
718e3744 | 4169 | struct peer *peer; |
4170 | ||
c500ae40 | 4171 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4172 | if (! peer) |
4173 | return CMD_WARNING; | |
4174 | ||
4175 | peer_description_unset (peer); | |
4176 | ||
4177 | return CMD_SUCCESS; | |
4178 | } | |
4179 | ||
6b0655a2 | 4180 | |
718e3744 | 4181 | /* Neighbor update-source. */ |
94f2b392 | 4182 | static int |
e52702f2 | 4183 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4184 | const char *source_str) |
718e3744 | 4185 | { |
4186 | struct peer *peer; | |
718e3744 | 4187 | |
4188 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4189 | if (! peer) | |
4190 | return CMD_WARNING; | |
4191 | ||
a80beece DS |
4192 | if (peer->conf_if) |
4193 | return CMD_WARNING; | |
4194 | ||
718e3744 | 4195 | if (source_str) |
4196 | { | |
c63b83fe JBD |
4197 | union sockunion su; |
4198 | int ret = str2sockunion (source_str, &su); | |
4199 | ||
4200 | if (ret == 0) | |
4201 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4202 | else |
4203 | peer_update_source_if_set (peer, source_str); | |
4204 | } | |
4205 | else | |
4206 | peer_update_source_unset (peer); | |
4207 | ||
4208 | return CMD_SUCCESS; | |
4209 | } | |
4210 | ||
369688c0 PJ |
4211 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4212 | "IPv4 address\n" \ | |
9a1a331d PJ |
4213 | "IPv6 address\n" \ |
4214 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4215 | |
718e3744 | 4216 | DEFUN (neighbor_update_source, |
4217 | neighbor_update_source_cmd, | |
9ccf14f7 | 4218 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4219 | NEIGHBOR_STR |
4220 | NEIGHBOR_ADDR_STR2 | |
4221 | "Source of routing updates\n" | |
369688c0 | 4222 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4223 | { |
c500ae40 DW |
4224 | int idx_peer = 1; |
4225 | int idx_peer_2 = 3; | |
4226 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4227 | } |
4228 | ||
4229 | DEFUN (no_neighbor_update_source, | |
4230 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4231 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4232 | NO_STR |
4233 | NEIGHBOR_STR | |
4234 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4235 | "Source of routing updates\n" |
4236 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4237 | { |
c500ae40 DW |
4238 | int idx_peer = 2; |
4239 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4240 | } |
6b0655a2 | 4241 | |
94f2b392 | 4242 | static int |
e52702f2 QY |
4243 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4244 | afi_t afi, safi_t safi, | |
fd79ac91 | 4245 | const char *rmap, int set) |
718e3744 | 4246 | { |
4247 | int ret; | |
4248 | struct peer *peer; | |
4249 | ||
4250 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4251 | if (! peer) | |
4252 | return CMD_WARNING; | |
4253 | ||
4254 | if (set) | |
4255 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4256 | else | |
4257 | ret = peer_default_originate_unset (peer, afi, safi); | |
4258 | ||
4259 | return bgp_vty_return (vty, ret); | |
4260 | } | |
4261 | ||
4262 | /* neighbor default-originate. */ | |
4263 | DEFUN (neighbor_default_originate, | |
4264 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4265 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4266 | NEIGHBOR_STR |
4267 | NEIGHBOR_ADDR_STR2 | |
4268 | "Originate default route to this neighbor\n") | |
4269 | { | |
c500ae40 DW |
4270 | int idx_peer = 1; |
4271 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4272 | bgp_node_safi (vty), NULL, 1); |
4273 | } | |
4274 | ||
4275 | DEFUN (neighbor_default_originate_rmap, | |
4276 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4277 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4278 | NEIGHBOR_STR |
4279 | NEIGHBOR_ADDR_STR2 | |
4280 | "Originate default route to this neighbor\n" | |
4281 | "Route-map to specify criteria to originate default\n" | |
4282 | "route-map name\n") | |
4283 | { | |
c500ae40 DW |
4284 | int idx_peer = 1; |
4285 | int idx_word = 4; | |
4286 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4287 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4288 | } |
4289 | ||
4290 | DEFUN (no_neighbor_default_originate, | |
4291 | no_neighbor_default_originate_cmd, | |
a636c635 | 4292 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4293 | NO_STR |
4294 | NEIGHBOR_STR | |
4295 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4296 | "Originate default route to this neighbor\n" |
4297 | "Route-map to specify criteria to originate default\n" | |
4298 | "route-map name\n") | |
718e3744 | 4299 | { |
c500ae40 DW |
4300 | int idx_peer = 2; |
4301 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4302 | bgp_node_safi (vty), NULL, 0); |
4303 | } | |
4304 | ||
6b0655a2 | 4305 | |
718e3744 | 4306 | /* Set neighbor's BGP port. */ |
94f2b392 | 4307 | static int |
e52702f2 | 4308 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4309 | const char *port_str) |
718e3744 | 4310 | { |
4311 | struct peer *peer; | |
4312 | u_int16_t port; | |
4313 | struct servent *sp; | |
4314 | ||
4315 | peer = peer_lookup_vty (vty, ip_str); | |
4316 | if (! peer) | |
4317 | return CMD_WARNING; | |
4318 | ||
4319 | if (! port_str) | |
e52702f2 | 4320 | { |
718e3744 | 4321 | sp = getservbyname ("bgp", "tcp"); |
4322 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4323 | } | |
4324 | else | |
4325 | { | |
4326 | VTY_GET_INTEGER("port", port, port_str); | |
4327 | } | |
4328 | ||
4329 | peer_port_set (peer, port); | |
4330 | ||
4331 | return CMD_SUCCESS; | |
4332 | } | |
4333 | ||
f418446b | 4334 | /* Set specified peer's BGP port. */ |
718e3744 | 4335 | DEFUN (neighbor_port, |
4336 | neighbor_port_cmd, | |
9ccf14f7 | 4337 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4338 | NEIGHBOR_STR |
4339 | NEIGHBOR_ADDR_STR | |
4340 | "Neighbor's BGP port\n" | |
4341 | "TCP port number\n") | |
4342 | { | |
c500ae40 DW |
4343 | int idx_ip = 1; |
4344 | int idx_number = 3; | |
4345 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4346 | } |
4347 | ||
4348 | DEFUN (no_neighbor_port, | |
4349 | no_neighbor_port_cmd, | |
9ccf14f7 | 4350 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4351 | NO_STR |
4352 | NEIGHBOR_STR | |
4353 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4354 | "Neighbor's BGP port\n" |
4355 | "TCP port number\n") | |
718e3744 | 4356 | { |
c500ae40 DW |
4357 | int idx_ip = 2; |
4358 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4359 | } |
4360 | ||
6b0655a2 | 4361 | |
718e3744 | 4362 | /* neighbor weight. */ |
94f2b392 | 4363 | static int |
e52702f2 | 4364 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4365 | afi_t afi, safi_t safi, |
fd79ac91 | 4366 | const char *weight_str) |
718e3744 | 4367 | { |
1f9a9fff | 4368 | int ret; |
718e3744 | 4369 | struct peer *peer; |
4370 | unsigned long weight; | |
4371 | ||
4372 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4373 | if (! peer) | |
4374 | return CMD_WARNING; | |
4375 | ||
4376 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4377 | ||
d93f7ffc | 4378 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4379 | return bgp_vty_return (vty, ret); |
718e3744 | 4380 | } |
4381 | ||
94f2b392 | 4382 | static int |
d93f7ffc DW |
4383 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4384 | afi_t afi, safi_t safi) | |
718e3744 | 4385 | { |
1f9a9fff | 4386 | int ret; |
718e3744 | 4387 | struct peer *peer; |
4388 | ||
4389 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4390 | if (! peer) | |
4391 | return CMD_WARNING; | |
4392 | ||
d93f7ffc | 4393 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4394 | return bgp_vty_return (vty, ret); |
718e3744 | 4395 | } |
4396 | ||
4397 | DEFUN (neighbor_weight, | |
4398 | neighbor_weight_cmd, | |
9ccf14f7 | 4399 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4400 | NEIGHBOR_STR |
4401 | NEIGHBOR_ADDR_STR2 | |
4402 | "Set default weight for routes from this neighbor\n" | |
4403 | "default weight\n") | |
4404 | { | |
c500ae40 DW |
4405 | int idx_peer = 1; |
4406 | int idx_number = 3; | |
e52702f2 QY |
4407 | return peer_weight_set_vty (vty, |
4408 | argv[idx_peer]->arg, | |
4409 | bgp_node_afi (vty), | |
4410 | bgp_node_safi (vty), | |
4411 | argv[idx_number]->arg); | |
718e3744 | 4412 | } |
4413 | ||
4414 | DEFUN (no_neighbor_weight, | |
4415 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4417 | NO_STR |
4418 | NEIGHBOR_STR | |
4419 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4420 | "Set default weight for routes from this neighbor\n" |
4421 | "default weight\n") | |
718e3744 | 4422 | { |
c500ae40 | 4423 | int idx_peer = 2; |
e52702f2 | 4424 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4425 | } |
4426 | ||
6b0655a2 | 4427 | |
718e3744 | 4428 | /* Override capability negotiation. */ |
4429 | DEFUN (neighbor_override_capability, | |
4430 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4431 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4432 | NEIGHBOR_STR |
4433 | NEIGHBOR_ADDR_STR2 | |
4434 | "Override capability negotiation result\n") | |
4435 | { | |
c500ae40 DW |
4436 | int idx_peer = 1; |
4437 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4438 | } |
4439 | ||
4440 | DEFUN (no_neighbor_override_capability, | |
4441 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4442 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4443 | NO_STR |
4444 | NEIGHBOR_STR | |
4445 | NEIGHBOR_ADDR_STR2 | |
4446 | "Override capability negotiation result\n") | |
4447 | { | |
c500ae40 DW |
4448 | int idx_peer = 2; |
4449 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4450 | } |
6b0655a2 | 4451 | |
718e3744 | 4452 | DEFUN (neighbor_strict_capability, |
4453 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4454 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4455 | NEIGHBOR_STR |
4456 | NEIGHBOR_ADDR_STR | |
4457 | "Strict capability negotiation match\n") | |
4458 | { | |
c500ae40 DW |
4459 | int idx_ip = 1; |
4460 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4461 | } |
4462 | ||
4463 | DEFUN (no_neighbor_strict_capability, | |
4464 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4465 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4466 | NO_STR |
4467 | NEIGHBOR_STR | |
4468 | NEIGHBOR_ADDR_STR | |
4469 | "Strict capability negotiation match\n") | |
4470 | { | |
c500ae40 DW |
4471 | int idx_ip = 2; |
4472 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4473 | } |
6b0655a2 | 4474 | |
94f2b392 | 4475 | static int |
e52702f2 | 4476 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4477 | const char *keep_str, const char *hold_str) |
718e3744 | 4478 | { |
4479 | int ret; | |
4480 | struct peer *peer; | |
4481 | u_int32_t keepalive; | |
4482 | u_int32_t holdtime; | |
4483 | ||
4484 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4485 | if (! peer) | |
4486 | return CMD_WARNING; | |
4487 | ||
4488 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4489 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4490 | ||
4491 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4492 | ||
4493 | return bgp_vty_return (vty, ret); | |
4494 | } | |
6b0655a2 | 4495 | |
94f2b392 | 4496 | static int |
fd79ac91 | 4497 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4498 | { |
4499 | int ret; | |
4500 | struct peer *peer; | |
4501 | ||
0c412461 | 4502 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4503 | if (! peer) |
4504 | return CMD_WARNING; | |
4505 | ||
4506 | ret = peer_timers_unset (peer); | |
4507 | ||
4508 | return bgp_vty_return (vty, ret); | |
4509 | } | |
4510 | ||
4511 | DEFUN (neighbor_timers, | |
4512 | neighbor_timers_cmd, | |
9ccf14f7 | 4513 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4514 | NEIGHBOR_STR |
4515 | NEIGHBOR_ADDR_STR2 | |
4516 | "BGP per neighbor timers\n" | |
4517 | "Keepalive interval\n" | |
4518 | "Holdtime\n") | |
4519 | { | |
c500ae40 DW |
4520 | int idx_peer = 1; |
4521 | int idx_number = 3; | |
4522 | int idx_number_2 = 4; | |
4523 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4524 | } |
4525 | ||
4526 | DEFUN (no_neighbor_timers, | |
4527 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4528 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4529 | NO_STR |
4530 | NEIGHBOR_STR | |
4531 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4532 | "BGP per neighbor timers\n" |
4533 | "Keepalive interval\n" | |
4534 | "Holdtime\n") | |
718e3744 | 4535 | { |
c500ae40 DW |
4536 | int idx_peer = 2; |
4537 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4538 | } |
6b0655a2 | 4539 | |
813d4307 | 4540 | |
94f2b392 | 4541 | static int |
e52702f2 | 4542 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4543 | const char *time_str) |
718e3744 | 4544 | { |
4545 | int ret; | |
4546 | struct peer *peer; | |
4547 | u_int32_t connect; | |
4548 | ||
966f821c | 4549 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4550 | if (! peer) |
4551 | return CMD_WARNING; | |
4552 | ||
4553 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4554 | ||
4555 | ret = peer_timers_connect_set (peer, connect); | |
4556 | ||
966f821c | 4557 | return bgp_vty_return (vty, ret); |
718e3744 | 4558 | } |
4559 | ||
94f2b392 | 4560 | static int |
fd79ac91 | 4561 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4562 | { |
4563 | int ret; | |
4564 | struct peer *peer; | |
4565 | ||
4566 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4567 | if (! peer) | |
4568 | return CMD_WARNING; | |
4569 | ||
4570 | ret = peer_timers_connect_unset (peer); | |
4571 | ||
966f821c | 4572 | return bgp_vty_return (vty, ret); |
718e3744 | 4573 | } |
4574 | ||
4575 | DEFUN (neighbor_timers_connect, | |
4576 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4577 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4578 | NEIGHBOR_STR |
966f821c | 4579 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4580 | "BGP per neighbor timers\n" |
4581 | "BGP connect timer\n" | |
4582 | "Connect timer\n") | |
4583 | { | |
c500ae40 DW |
4584 | int idx_peer = 1; |
4585 | int idx_number = 4; | |
4586 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4587 | } |
4588 | ||
4589 | DEFUN (no_neighbor_timers_connect, | |
4590 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4592 | NO_STR |
4593 | NEIGHBOR_STR | |
966f821c | 4594 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4595 | "BGP per neighbor timers\n" |
8334fd5a DW |
4596 | "BGP connect timer\n" |
4597 | "Connect timer\n") | |
718e3744 | 4598 | { |
c500ae40 DW |
4599 | int idx_peer = 2; |
4600 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4601 | } |
4602 | ||
6b0655a2 | 4603 | |
94f2b392 | 4604 | static int |
e52702f2 QY |
4605 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4606 | const char *time_str, int set) | |
718e3744 | 4607 | { |
4608 | int ret; | |
4609 | struct peer *peer; | |
4610 | u_int32_t routeadv = 0; | |
4611 | ||
966f821c | 4612 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4613 | if (! peer) |
4614 | return CMD_WARNING; | |
4615 | ||
4616 | if (time_str) | |
4617 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4618 | ||
4619 | if (set) | |
4620 | ret = peer_advertise_interval_set (peer, routeadv); | |
4621 | else | |
4622 | ret = peer_advertise_interval_unset (peer); | |
4623 | ||
966f821c | 4624 | return bgp_vty_return (vty, ret); |
718e3744 | 4625 | } |
4626 | ||
4627 | DEFUN (neighbor_advertise_interval, | |
4628 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4629 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4630 | NEIGHBOR_STR |
966f821c | 4631 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4632 | "Minimum interval between sending BGP routing updates\n" |
4633 | "time in seconds\n") | |
4634 | { | |
c500ae40 DW |
4635 | int idx_peer = 1; |
4636 | int idx_number = 3; | |
4637 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4638 | } |
4639 | ||
4640 | DEFUN (no_neighbor_advertise_interval, | |
4641 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4643 | NO_STR |
4644 | NEIGHBOR_STR | |
966f821c | 4645 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4646 | "Minimum interval between sending BGP routing updates\n" |
4647 | "time in seconds\n") | |
718e3744 | 4648 | { |
c500ae40 DW |
4649 | int idx_peer = 2; |
4650 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4651 | } |
4652 | ||
6b0655a2 | 4653 | |
518f0eb1 DS |
4654 | /* Time to wait before processing route-map updates */ |
4655 | DEFUN (bgp_set_route_map_delay_timer, | |
4656 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4657 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4658 | SET_STR |
4659 | "BGP route-map delay timer\n" | |
4660 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4661 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4662 | { |
c500ae40 | 4663 | int idx_number = 3; |
518f0eb1 | 4664 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4665 | |
c500ae40 | 4666 | if (argv[idx_number]->arg) |
518f0eb1 | 4667 | { |
c500ae40 | 4668 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4669 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4670 | |
4671 | /* if the dynamic update handling is being disabled, and a timer is | |
4672 | * running, stop the timer and act as if the timer has already fired. | |
4673 | */ | |
5fe9f963 | 4674 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4675 | { |
5fe9f963 | 4676 | BGP_TIMER_OFF(bm->t_rmap_update); |
4677 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4678 | } |
4679 | return CMD_SUCCESS; | |
4680 | } | |
4681 | else | |
ffd0c037 | 4682 | return CMD_WARNING; |
518f0eb1 DS |
4683 | } |
4684 | ||
4685 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4686 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4687 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4688 | NO_STR |
3a2d747c | 4689 | BGP_STR |
518f0eb1 | 4690 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4691 | "Reset to default time to wait for processing route-map changes\n" |
4692 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4693 | { |
518f0eb1 | 4694 | |
5fe9f963 | 4695 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4696 | |
4697 | return CMD_SUCCESS; | |
4698 | } | |
4699 | ||
f414725f | 4700 | |
718e3744 | 4701 | /* neighbor interface */ |
94f2b392 | 4702 | static int |
fd79ac91 | 4703 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4704 | { |
718e3744 | 4705 | struct peer *peer; |
4706 | ||
4707 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4708 | if (! peer || peer->conf_if) |
718e3744 | 4709 | return CMD_WARNING; |
4710 | ||
4711 | if (str) | |
ffd0c037 | 4712 | peer_interface_set (peer, str); |
718e3744 | 4713 | else |
ffd0c037 | 4714 | peer_interface_unset (peer); |
718e3744 | 4715 | |
4716 | return CMD_SUCCESS; | |
4717 | } | |
4718 | ||
4719 | DEFUN (neighbor_interface, | |
4720 | neighbor_interface_cmd, | |
9ccf14f7 | 4721 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4722 | NEIGHBOR_STR |
4723 | NEIGHBOR_ADDR_STR | |
4724 | "Interface\n" | |
4725 | "Interface name\n") | |
4726 | { | |
c500ae40 DW |
4727 | int idx_ip = 1; |
4728 | int idx_word = 3; | |
00d7d2d3 | 4729 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4730 | } |
4731 | ||
4732 | DEFUN (no_neighbor_interface, | |
4733 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4735 | NO_STR |
4736 | NEIGHBOR_STR | |
16cedbb0 | 4737 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4738 | "Interface\n" |
4739 | "Interface name\n") | |
4740 | { | |
c500ae40 DW |
4741 | int idx_peer = 2; |
4742 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4743 | } |
6b0655a2 | 4744 | |
718e3744 | 4745 | /* Set distribute list to the peer. */ |
94f2b392 | 4746 | static int |
e52702f2 | 4747 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4748 | afi_t afi, safi_t safi, |
4749 | const char *name_str, const char *direct_str) | |
718e3744 | 4750 | { |
4751 | int ret; | |
4752 | struct peer *peer; | |
4753 | int direct = FILTER_IN; | |
4754 | ||
4755 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4756 | if (! peer) | |
4757 | return CMD_WARNING; | |
4758 | ||
4759 | /* Check filter direction. */ | |
4760 | if (strncmp (direct_str, "i", 1) == 0) | |
4761 | direct = FILTER_IN; | |
4762 | else if (strncmp (direct_str, "o", 1) == 0) | |
4763 | direct = FILTER_OUT; | |
4764 | ||
4765 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4766 | ||
4767 | return bgp_vty_return (vty, ret); | |
4768 | } | |
4769 | ||
94f2b392 | 4770 | static int |
fd79ac91 | 4771 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4772 | safi_t safi, 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_unset (peer, afi, safi, direct); | |
4789 | ||
4790 | return bgp_vty_return (vty, ret); | |
4791 | } | |
4792 | ||
4793 | DEFUN (neighbor_distribute_list, | |
4794 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4795 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4796 | NEIGHBOR_STR |
4797 | NEIGHBOR_ADDR_STR2 | |
4798 | "Filter updates to/from this neighbor\n" | |
4799 | "IP access-list number\n" | |
4800 | "IP access-list number (expanded range)\n" | |
4801 | "IP Access-list name\n" | |
4802 | "Filter incoming updates\n" | |
4803 | "Filter outgoing updates\n") | |
4804 | { | |
c500ae40 DW |
4805 | int idx_peer = 1; |
4806 | int idx_acl = 3; | |
4807 | int idx_in_out = 4; | |
4808 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4809 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4810 | } |
4811 | ||
4812 | DEFUN (no_neighbor_distribute_list, | |
4813 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4815 | NO_STR |
4816 | NEIGHBOR_STR | |
4817 | NEIGHBOR_ADDR_STR2 | |
4818 | "Filter updates to/from this neighbor\n" | |
4819 | "IP access-list number\n" | |
4820 | "IP access-list number (expanded range)\n" | |
4821 | "IP Access-list name\n" | |
4822 | "Filter incoming updates\n" | |
4823 | "Filter outgoing updates\n") | |
4824 | { | |
c500ae40 DW |
4825 | int idx_peer = 2; |
4826 | int idx_in_out = 5; | |
4827 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4828 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4829 | } |
6b0655a2 | 4830 | |
718e3744 | 4831 | /* Set prefix list to the peer. */ |
94f2b392 | 4832 | static int |
fd79ac91 | 4833 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4834 | safi_t safi, const char *name_str, |
fd79ac91 | 4835 | const char *direct_str) |
718e3744 | 4836 | { |
4837 | int ret; | |
4838 | struct peer *peer; | |
4839 | int direct = FILTER_IN; | |
4840 | ||
4841 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4842 | if (! peer) | |
4843 | return CMD_WARNING; | |
4844 | ||
4845 | /* Check filter direction. */ | |
4846 | if (strncmp (direct_str, "i", 1) == 0) | |
4847 | direct = FILTER_IN; | |
4848 | else if (strncmp (direct_str, "o", 1) == 0) | |
4849 | direct = FILTER_OUT; | |
4850 | ||
4851 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
4852 | ||
4853 | return bgp_vty_return (vty, ret); | |
4854 | } | |
4855 | ||
94f2b392 | 4856 | static int |
fd79ac91 | 4857 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4858 | safi_t safi, 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; | |
e52702f2 | 4867 | |
718e3744 | 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_unset (peer, afi, safi, direct); | |
4875 | ||
4876 | return bgp_vty_return (vty, ret); | |
4877 | } | |
4878 | ||
4879 | DEFUN (neighbor_prefix_list, | |
4880 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 4881 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4882 | NEIGHBOR_STR |
4883 | NEIGHBOR_ADDR_STR2 | |
4884 | "Filter updates to/from this neighbor\n" | |
4885 | "Name of a prefix list\n" | |
4886 | "Filter incoming updates\n" | |
4887 | "Filter outgoing updates\n") | |
4888 | { | |
c500ae40 DW |
4889 | int idx_peer = 1; |
4890 | int idx_word = 3; | |
4891 | int idx_in_out = 4; | |
4892 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4893 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4894 | } |
4895 | ||
4896 | DEFUN (no_neighbor_prefix_list, | |
4897 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 4898 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4899 | NO_STR |
4900 | NEIGHBOR_STR | |
4901 | NEIGHBOR_ADDR_STR2 | |
4902 | "Filter updates to/from this neighbor\n" | |
4903 | "Name of a prefix list\n" | |
4904 | "Filter incoming updates\n" | |
4905 | "Filter outgoing updates\n") | |
4906 | { | |
c500ae40 DW |
4907 | int idx_peer = 2; |
4908 | int idx_in_out = 5; | |
4909 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4910 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4911 | } |
6b0655a2 | 4912 | |
94f2b392 | 4913 | static int |
e52702f2 | 4914 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4915 | afi_t afi, safi_t safi, |
4916 | const char *name_str, const char *direct_str) | |
718e3744 | 4917 | { |
4918 | int ret; | |
4919 | struct peer *peer; | |
4920 | int direct = FILTER_IN; | |
4921 | ||
4922 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4923 | if (! peer) | |
4924 | return CMD_WARNING; | |
4925 | ||
4926 | /* Check filter direction. */ | |
4927 | if (strncmp (direct_str, "i", 1) == 0) | |
4928 | direct = FILTER_IN; | |
4929 | else if (strncmp (direct_str, "o", 1) == 0) | |
4930 | direct = FILTER_OUT; | |
4931 | ||
4932 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
4933 | ||
4934 | return bgp_vty_return (vty, ret); | |
4935 | } | |
4936 | ||
94f2b392 | 4937 | static int |
e52702f2 | 4938 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4939 | afi_t afi, safi_t safi, |
4940 | const char *direct_str) | |
718e3744 | 4941 | { |
4942 | int ret; | |
4943 | struct peer *peer; | |
4944 | int direct = FILTER_IN; | |
4945 | ||
4946 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4947 | if (! peer) | |
4948 | return CMD_WARNING; | |
4949 | ||
4950 | /* Check filter direction. */ | |
4951 | if (strncmp (direct_str, "i", 1) == 0) | |
4952 | direct = FILTER_IN; | |
4953 | else if (strncmp (direct_str, "o", 1) == 0) | |
4954 | direct = FILTER_OUT; | |
4955 | ||
4956 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
4957 | ||
4958 | return bgp_vty_return (vty, ret); | |
4959 | } | |
4960 | ||
4961 | DEFUN (neighbor_filter_list, | |
4962 | neighbor_filter_list_cmd, | |
9ccf14f7 | 4963 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 4964 | NEIGHBOR_STR |
4965 | NEIGHBOR_ADDR_STR2 | |
4966 | "Establish BGP filters\n" | |
4967 | "AS path access-list name\n" | |
4968 | "Filter incoming routes\n" | |
4969 | "Filter outgoing routes\n") | |
4970 | { | |
c500ae40 DW |
4971 | int idx_peer = 1; |
4972 | int idx_word = 3; | |
4973 | int idx_in_out = 4; | |
4974 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4975 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4976 | } |
4977 | ||
4978 | DEFUN (no_neighbor_filter_list, | |
4979 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 4980 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 4981 | NO_STR |
4982 | NEIGHBOR_STR | |
4983 | NEIGHBOR_ADDR_STR2 | |
4984 | "Establish BGP filters\n" | |
4985 | "AS path access-list name\n" | |
4986 | "Filter incoming routes\n" | |
4987 | "Filter outgoing routes\n") | |
4988 | { | |
c500ae40 DW |
4989 | int idx_peer = 2; |
4990 | int idx_in_out = 5; | |
4991 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4992 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4993 | } |
6b0655a2 | 4994 | |
718e3744 | 4995 | /* Set route-map to the peer. */ |
94f2b392 | 4996 | static int |
e52702f2 | 4997 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4998 | afi_t afi, safi_t safi, |
4999 | const char *name_str, const char *direct_str) | |
718e3744 | 5000 | { |
5001 | int ret; | |
5002 | struct peer *peer; | |
fee0f4c6 | 5003 | int direct = RMAP_IN; |
718e3744 | 5004 | |
5005 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5006 | if (! peer) | |
5007 | return CMD_WARNING; | |
5008 | ||
5009 | /* Check filter direction. */ | |
fee0f4c6 | 5010 | if (strncmp (direct_str, "in", 2) == 0) |
5011 | direct = RMAP_IN; | |
718e3744 | 5012 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5013 | direct = RMAP_OUT; |
718e3744 | 5014 | |
5015 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5016 | ||
5017 | return bgp_vty_return (vty, ret); | |
5018 | } | |
5019 | ||
94f2b392 | 5020 | static int |
fd79ac91 | 5021 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5022 | safi_t safi, 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_unset (peer, afi, safi, direct); | |
5039 | ||
5040 | return bgp_vty_return (vty, ret); | |
5041 | } | |
5042 | ||
5043 | DEFUN (neighbor_route_map, | |
5044 | neighbor_route_map_cmd, | |
9ccf14f7 | 5045 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5046 | NEIGHBOR_STR |
5047 | NEIGHBOR_ADDR_STR2 | |
5048 | "Apply route map to neighbor\n" | |
5049 | "Name of route map\n" | |
5050 | "Apply map to incoming routes\n" | |
2a3d5731 | 5051 | "Apply map to outbound routes\n") |
718e3744 | 5052 | { |
c500ae40 DW |
5053 | int idx_peer = 1; |
5054 | int idx_word = 3; | |
5055 | int idx_in_out = 4; | |
5056 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5057 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5058 | } |
5059 | ||
5060 | DEFUN (no_neighbor_route_map, | |
5061 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5062 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5063 | NO_STR |
5064 | NEIGHBOR_STR | |
5065 | NEIGHBOR_ADDR_STR2 | |
5066 | "Apply route map to neighbor\n" | |
5067 | "Name of route map\n" | |
5068 | "Apply map to incoming routes\n" | |
2a3d5731 | 5069 | "Apply map to outbound routes\n") |
718e3744 | 5070 | { |
c500ae40 DW |
5071 | int idx_peer = 2; |
5072 | int idx_in_out = 5; | |
5073 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5074 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5075 | } |
6b0655a2 | 5076 | |
718e3744 | 5077 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5078 | static int |
fd79ac91 | 5079 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5080 | safi_t safi, const char *name_str) | |
718e3744 | 5081 | { |
5082 | int ret; | |
5083 | struct peer *peer; | |
5084 | ||
5085 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5086 | if (! peer) | |
5087 | return CMD_WARNING; | |
5088 | ||
5089 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5090 | ||
5091 | return bgp_vty_return (vty, ret); | |
5092 | } | |
5093 | ||
5094 | /* Unset route-map from the peer. */ | |
94f2b392 | 5095 | static int |
fd79ac91 | 5096 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5097 | safi_t safi) |
5098 | { | |
5099 | int ret; | |
5100 | struct peer *peer; | |
5101 | ||
5102 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5103 | if (! peer) | |
5104 | return CMD_WARNING; | |
5105 | ||
5106 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5107 | ||
5108 | return bgp_vty_return (vty, ret); | |
5109 | } | |
5110 | ||
5111 | DEFUN (neighbor_unsuppress_map, | |
5112 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5113 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5114 | NEIGHBOR_STR |
5115 | NEIGHBOR_ADDR_STR2 | |
5116 | "Route-map to selectively unsuppress suppressed routes\n" | |
5117 | "Name of route map\n") | |
5118 | { | |
c500ae40 DW |
5119 | int idx_peer = 1; |
5120 | int idx_word = 3; | |
5121 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5122 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5123 | } |
5124 | ||
5125 | DEFUN (no_neighbor_unsuppress_map, | |
5126 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5127 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5128 | NO_STR |
5129 | NEIGHBOR_STR | |
5130 | NEIGHBOR_ADDR_STR2 | |
5131 | "Route-map to selectively unsuppress suppressed routes\n" | |
5132 | "Name of route map\n") | |
5133 | { | |
c500ae40 DW |
5134 | int idx_peer = 2; |
5135 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5136 | bgp_node_safi (vty)); |
5137 | } | |
6b0655a2 | 5138 | |
94f2b392 | 5139 | static int |
fd79ac91 | 5140 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5141 | safi_t safi, const char *num_str, |
0a486e5f | 5142 | const char *threshold_str, int warning, |
5143 | const char *restart_str) | |
718e3744 | 5144 | { |
5145 | int ret; | |
5146 | struct peer *peer; | |
5147 | u_int32_t max; | |
e0701b79 | 5148 | u_char threshold; |
0a486e5f | 5149 | u_int16_t restart; |
718e3744 | 5150 | |
5151 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5152 | if (! peer) | |
5153 | return CMD_WARNING; | |
5154 | ||
e6ec1c36 | 5155 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5156 | if (threshold_str) |
5157 | threshold = atoi (threshold_str); | |
5158 | else | |
5159 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5160 | |
0a486e5f | 5161 | if (restart_str) |
5162 | restart = atoi (restart_str); | |
5163 | else | |
5164 | restart = 0; | |
5165 | ||
5166 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5167 | |
5168 | return bgp_vty_return (vty, ret); | |
5169 | } | |
5170 | ||
94f2b392 | 5171 | static int |
fd79ac91 | 5172 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5173 | safi_t safi) |
5174 | { | |
5175 | int ret; | |
5176 | struct peer *peer; | |
5177 | ||
5178 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5179 | if (! peer) | |
5180 | return CMD_WARNING; | |
5181 | ||
5182 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5183 | ||
5184 | return bgp_vty_return (vty, ret); | |
5185 | } | |
5186 | ||
5187 | /* Maximum number of prefix configuration. prefix count is different | |
5188 | for each peer configuration. So this configuration can be set for | |
5189 | each peer configuration. */ | |
5190 | DEFUN (neighbor_maximum_prefix, | |
5191 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5192 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5193 | NEIGHBOR_STR |
5194 | NEIGHBOR_ADDR_STR2 | |
5195 | "Maximum number of prefix accept from this peer\n" | |
5196 | "maximum no. of prefix limit\n") | |
5197 | { | |
c500ae40 DW |
5198 | int idx_peer = 1; |
5199 | int idx_number = 3; | |
5200 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5201 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5202 | NULL); |
718e3744 | 5203 | } |
5204 | ||
e0701b79 | 5205 | DEFUN (neighbor_maximum_prefix_threshold, |
5206 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5207 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5208 | NEIGHBOR_STR |
5209 | NEIGHBOR_ADDR_STR2 | |
5210 | "Maximum number of prefix accept from this peer\n" | |
5211 | "maximum no. of prefix limit\n" | |
5212 | "Threshold value (%) at which to generate a warning msg\n") | |
5213 | { | |
c500ae40 DW |
5214 | int idx_peer = 1; |
5215 | int idx_number = 3; | |
5216 | int idx_number_2 = 4; | |
5217 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5218 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5219 | NULL); |
5220 | } | |
e0701b79 | 5221 | |
718e3744 | 5222 | DEFUN (neighbor_maximum_prefix_warning, |
5223 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5224 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5225 | NEIGHBOR_STR |
5226 | NEIGHBOR_ADDR_STR2 | |
5227 | "Maximum number of prefix accept from this peer\n" | |
5228 | "maximum no. of prefix limit\n" | |
5229 | "Only give warning message when limit is exceeded\n") | |
5230 | { | |
c500ae40 DW |
5231 | int idx_peer = 1; |
5232 | int idx_number = 3; | |
5233 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5234 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5235 | NULL); |
718e3744 | 5236 | } |
5237 | ||
e0701b79 | 5238 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5239 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5240 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5241 | NEIGHBOR_STR |
5242 | NEIGHBOR_ADDR_STR2 | |
5243 | "Maximum number of prefix accept from this peer\n" | |
5244 | "maximum no. of prefix limit\n" | |
5245 | "Threshold value (%) at which to generate a warning msg\n" | |
5246 | "Only give warning message when limit is exceeded\n") | |
5247 | { | |
c500ae40 DW |
5248 | int idx_peer = 1; |
5249 | int idx_number = 3; | |
5250 | int idx_number_2 = 4; | |
5251 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5252 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5253 | } |
5254 | ||
5255 | DEFUN (neighbor_maximum_prefix_restart, | |
5256 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5257 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5258 | NEIGHBOR_STR |
5259 | NEIGHBOR_ADDR_STR2 | |
5260 | "Maximum number of prefix accept from this peer\n" | |
5261 | "maximum no. of prefix limit\n" | |
5262 | "Restart bgp connection after limit is exceeded\n" | |
5263 | "Restart interval in minutes") | |
5264 | { | |
c500ae40 DW |
5265 | int idx_peer = 1; |
5266 | int idx_number = 3; | |
5267 | int idx_number_2 = 5; | |
5268 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5269 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5270 | } |
5271 | ||
5272 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5273 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5274 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5275 | NEIGHBOR_STR |
5276 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5277 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5278 | "maximum no. of prefix limit\n" |
5279 | "Threshold value (%) at which to generate a warning msg\n" | |
5280 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5281 | "Restart interval in minutes\n") |
0a486e5f | 5282 | { |
c500ae40 DW |
5283 | int idx_peer = 1; |
5284 | int idx_number = 3; | |
5285 | int idx_number_2 = 4; | |
5286 | int idx_number_3 = 6; | |
5287 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5288 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5289 | } |
e0701b79 | 5290 | |
718e3744 | 5291 | DEFUN (no_neighbor_maximum_prefix, |
5292 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5294 | NO_STR |
5295 | NEIGHBOR_STR | |
5296 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5297 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5298 | "maximum no. of prefix limit\n" |
5299 | "Threshold value (%) at which to generate a warning msg\n" | |
5300 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5301 | "Restart interval in minutes\n" |
31500417 | 5302 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5303 | { |
c500ae40 DW |
5304 | int idx_peer = 2; |
5305 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5306 | bgp_node_safi (vty)); |
5307 | } | |
e52702f2 | 5308 | |
718e3744 | 5309 | |
718e3744 | 5310 | /* "neighbor allowas-in" */ |
5311 | DEFUN (neighbor_allowas_in, | |
5312 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5313 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5314 | NEIGHBOR_STR |
5315 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5316 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5317 | "Number of occurances of AS number\n" |
5318 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5319 | { |
c500ae40 | 5320 | int idx_peer = 1; |
fd8503f5 | 5321 | int idx_number_origin = 3; |
718e3744 | 5322 | int ret; |
aac9ef6c | 5323 | int origin = 0; |
718e3744 | 5324 | struct peer *peer; |
aac9ef6c | 5325 | int allow_num = 0; |
718e3744 | 5326 | |
c500ae40 | 5327 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5328 | if (! peer) |
5329 | return CMD_WARNING; | |
5330 | ||
fd8503f5 | 5331 | if (argc <= idx_number_origin) |
718e3744 | 5332 | allow_num = 3; |
5333 | else | |
aac9ef6c | 5334 | { |
fd8503f5 | 5335 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5336 | origin = 1; |
5337 | else | |
fd8503f5 | 5338 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5339 | } |
718e3744 | 5340 | |
5341 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5342 | allow_num, origin); |
718e3744 | 5343 | |
5344 | return bgp_vty_return (vty, ret); | |
5345 | } | |
5346 | ||
718e3744 | 5347 | DEFUN (no_neighbor_allowas_in, |
5348 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5349 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5350 | NO_STR |
5351 | NEIGHBOR_STR | |
5352 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5353 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5354 | "Number of occurances of AS number\n" |
5355 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5356 | { |
c500ae40 | 5357 | int idx_peer = 2; |
718e3744 | 5358 | int ret; |
5359 | struct peer *peer; | |
5360 | ||
c500ae40 | 5361 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5362 | if (! peer) |
5363 | return CMD_WARNING; | |
5364 | ||
5365 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5366 | ||
5367 | return bgp_vty_return (vty, ret); | |
5368 | } | |
6b0655a2 | 5369 | |
fa411a21 NH |
5370 | DEFUN (neighbor_ttl_security, |
5371 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5372 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5373 | NEIGHBOR_STR |
5374 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5375 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5376 | "Specify the maximum number of hops to the BGP peer\n" |
5377 | "Number of hops to BGP peer\n") | |
fa411a21 | 5378 | { |
c500ae40 DW |
5379 | int idx_peer = 1; |
5380 | int idx_number = 4; | |
fa411a21 | 5381 | struct peer *peer; |
89b6d1f8 | 5382 | int gtsm_hops; |
fa411a21 | 5383 | |
c500ae40 | 5384 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5385 | if (! peer) |
5386 | return CMD_WARNING; | |
e52702f2 | 5387 | |
c500ae40 | 5388 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5389 | |
8cdabf90 SK |
5390 | /* |
5391 | * If 'neighbor swpX', then this is for directly connected peers, | |
5392 | * we should not accept a ttl-security hops value greater than 1. | |
5393 | */ | |
5394 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5395 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5396 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5397 | return CMD_WARNING; |
5398 | } | |
5399 | ||
89b6d1f8 | 5400 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5401 | } |
5402 | ||
5403 | DEFUN (no_neighbor_ttl_security, | |
5404 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5405 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5406 | NO_STR |
5407 | NEIGHBOR_STR | |
5408 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5409 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5410 | "Specify the maximum number of hops to the BGP peer\n" |
5411 | "Number of hops to BGP peer\n") | |
fa411a21 | 5412 | { |
c500ae40 | 5413 | int idx_peer = 2; |
fa411a21 | 5414 | struct peer *peer; |
fa411a21 | 5415 | |
c500ae40 | 5416 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5417 | if (! peer) |
5418 | return CMD_WARNING; | |
5419 | ||
89b6d1f8 | 5420 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5421 | } |
6b0655a2 | 5422 | |
adbac85e DW |
5423 | DEFUN (neighbor_addpath_tx_all_paths, |
5424 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5425 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5426 | NEIGHBOR_STR |
5427 | NEIGHBOR_ADDR_STR2 | |
5428 | "Use addpath to advertise all paths to a neighbor\n") | |
5429 | { | |
c500ae40 | 5430 | int idx_peer = 1; |
adbac85e DW |
5431 | struct peer *peer; |
5432 | ||
c500ae40 | 5433 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5434 | if (! peer) |
5435 | return CMD_WARNING; | |
5436 | ||
c500ae40 | 5437 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5438 | bgp_node_safi (vty), |
5439 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5440 | } | |
5441 | ||
5442 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5443 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5445 | NO_STR |
5446 | NEIGHBOR_STR | |
5447 | NEIGHBOR_ADDR_STR2 | |
5448 | "Use addpath to advertise all paths to a neighbor\n") | |
5449 | { | |
c500ae40 DW |
5450 | int idx_peer = 2; |
5451 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5452 | bgp_node_safi (vty), |
5453 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5454 | } | |
5455 | ||
06370dac DW |
5456 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5457 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5458 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5459 | NEIGHBOR_STR |
5460 | NEIGHBOR_ADDR_STR2 | |
5461 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5462 | { | |
c500ae40 | 5463 | int idx_peer = 1; |
06370dac DW |
5464 | struct peer *peer; |
5465 | ||
c500ae40 | 5466 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5467 | if (! peer) |
5468 | return CMD_WARNING; | |
5469 | ||
c500ae40 | 5470 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5471 | bgp_node_safi (vty), |
5472 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5473 | } | |
5474 | ||
5475 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5476 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5477 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5478 | NO_STR |
5479 | NEIGHBOR_STR | |
5480 | NEIGHBOR_ADDR_STR2 | |
5481 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5482 | { | |
c500ae40 DW |
5483 | int idx_peer = 2; |
5484 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5485 | bgp_node_safi (vty), |
5486 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5487 | } | |
5488 | ||
5489 | ||
8c3deaae | 5490 | /* Address Family configuration. */ |
718e3744 | 5491 | DEFUN (address_family_ipv4, |
5492 | address_family_ipv4_cmd, | |
5493 | "address-family ipv4", | |
5494 | "Enter Address Family command mode\n" | |
8c3deaae | 5495 | "Address Family\n") |
718e3744 | 5496 | { |
5497 | vty->node = BGP_IPV4_NODE; | |
5498 | return CMD_SUCCESS; | |
5499 | } | |
5500 | ||
5501 | DEFUN (address_family_ipv4_safi, | |
5502 | address_family_ipv4_safi_cmd, | |
46f296b4 | 5503 | "address-family ipv4 "BGP_SAFI_CMD_STR, |
718e3744 | 5504 | "Enter Address Family command mode\n" |
8c3deaae | 5505 | "Address Family\n" |
46f296b4 | 5506 | BGP_SAFI_HELP_STR) |
718e3744 | 5507 | { |
c500ae40 | 5508 | int idx_safi = 2; |
3b14d86e | 5509 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
ccbb332a LB |
5510 | { |
5511 | case SAFI_MULTICAST: | |
5512 | vty->node = BGP_IPV4M_NODE; | |
5513 | break; | |
5514 | case SAFI_ENCAP: | |
5515 | vty->node = BGP_ENCAP_NODE; | |
5516 | break; | |
5517 | case SAFI_MPLS_VPN: | |
5518 | vty->node = BGP_VPNV4_NODE; | |
5519 | break; | |
5520 | case SAFI_UNICAST: | |
5521 | default: | |
5522 | vty->node = BGP_IPV4_NODE; | |
5523 | break; | |
5524 | } | |
718e3744 | 5525 | |
5526 | return CMD_SUCCESS; | |
5527 | } | |
5528 | ||
25ffbdc1 | 5529 | DEFUN (address_family_ipv6, |
5530 | address_family_ipv6_cmd, | |
5531 | "address-family ipv6", | |
718e3744 | 5532 | "Enter Address Family command mode\n" |
8c3deaae | 5533 | "Address Family\n") |
718e3744 | 5534 | { |
5535 | vty->node = BGP_IPV6_NODE; | |
5536 | return CMD_SUCCESS; | |
5537 | } | |
5538 | ||
25ffbdc1 | 5539 | DEFUN (address_family_ipv6_safi, |
5540 | address_family_ipv6_safi_cmd, | |
46f296b4 | 5541 | "address-family ipv6 "BGP_SAFI_CMD_STR, |
718e3744 | 5542 | "Enter Address Family command mode\n" |
8c3deaae | 5543 | "Address Family\n" |
46f296b4 | 5544 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5545 | { |
c500ae40 | 5546 | int idx_safi = 2; |
46f296b4 LB |
5547 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5548 | { | |
5549 | case SAFI_MULTICAST: | |
5550 | vty->node = BGP_IPV6M_NODE; | |
5551 | break; | |
5552 | case SAFI_ENCAP: | |
5553 | vty->node = BGP_ENCAPV6_NODE; | |
5554 | break; | |
5555 | case SAFI_MPLS_VPN: | |
5556 | vty->node = BGP_VPNV6_NODE; | |
5557 | break; | |
5558 | case SAFI_UNICAST: | |
5559 | default: | |
5560 | vty->node = BGP_IPV6_NODE; | |
5561 | break; | |
5562 | } | |
25ffbdc1 | 5563 | |
5564 | return CMD_SUCCESS; | |
5565 | } | |
718e3744 | 5566 | |
d6902373 | 5567 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 5568 | DEFUN (address_family_vpnv4, |
5569 | address_family_vpnv4_cmd, | |
8334fd5a | 5570 | "address-family vpnv4 [unicast]", |
718e3744 | 5571 | "Enter Address Family command mode\n" |
8c3deaae | 5572 | "Address Family\n" |
3a2d747c | 5573 | "Address Family modifier\n") |
718e3744 | 5574 | { |
5575 | vty->node = BGP_VPNV4_NODE; | |
5576 | return CMD_SUCCESS; | |
5577 | } | |
5578 | ||
8ecd3266 | 5579 | DEFUN (address_family_vpnv6, |
5580 | address_family_vpnv6_cmd, | |
8334fd5a | 5581 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5582 | "Enter Address Family command mode\n" |
8c3deaae | 5583 | "Address Family\n" |
3a2d747c | 5584 | "Address Family modifier\n") |
8ecd3266 | 5585 | { |
5586 | vty->node = BGP_VPNV6_NODE; | |
5587 | return CMD_SUCCESS; | |
5588 | } | |
d6902373 PG |
5589 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
5590 | ||
5591 | DEFUN (address_family_ipv4_vpn, | |
5592 | address_family_ipv4_vpn_cmd, | |
5593 | "address-family ipv4 vpn", | |
5594 | "Enter Address Family command mode\n" | |
5595 | "Address Family\n" | |
5596 | "Subsequent Address Family modifier\n") | |
5597 | { | |
5598 | vty->node = BGP_VPNV4_NODE; | |
5599 | return CMD_SUCCESS; | |
5600 | } | |
5601 | ||
5602 | DEFUN (address_family_ipv6_vpn, | |
5603 | address_family_ipv6_vpn_cmd, | |
5604 | "address-family ipv6 vpn", | |
5605 | "Enter Address Family command mode\n" | |
5606 | "Address Family\n" | |
5607 | "Subsequent Address Family modifier\n") | |
5608 | { | |
5609 | vty->node = BGP_VPNV6_NODE; | |
5610 | return CMD_SUCCESS; | |
5611 | } | |
8ecd3266 | 5612 | |
8b1fb8be LB |
5613 | DEFUN (address_family_encap, |
5614 | address_family_encap_cmd, | |
8334fd5a | 5615 | "address-family <encap|encapv4>", |
8b1fb8be | 5616 | "Enter Address Family command mode\n" |
8c3deaae QY |
5617 | "Address Family\n" |
5618 | "Address Family\n") | |
8b1fb8be LB |
5619 | { |
5620 | vty->node = BGP_ENCAP_NODE; | |
5621 | return CMD_SUCCESS; | |
5622 | } | |
5623 | ||
8b1fb8be LB |
5624 | |
5625 | DEFUN (address_family_encapv6, | |
5626 | address_family_encapv6_cmd, | |
5627 | "address-family encapv6", | |
5628 | "Enter Address Family command mode\n" | |
8c3deaae | 5629 | "Address Family\n") |
8b1fb8be LB |
5630 | { |
5631 | vty->node = BGP_ENCAPV6_NODE; | |
5632 | return CMD_SUCCESS; | |
5633 | } | |
5634 | ||
718e3744 | 5635 | DEFUN (exit_address_family, |
5636 | exit_address_family_cmd, | |
5637 | "exit-address-family", | |
5638 | "Exit from Address Family configuration mode\n") | |
5639 | { | |
a8a80d53 | 5640 | if (vty->node == BGP_IPV4_NODE |
5641 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5642 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5643 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5644 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5645 | || vty->node == BGP_VPNV6_NODE |
5646 | || vty->node == BGP_ENCAP_NODE | |
5647 | || vty->node == BGP_ENCAPV6_NODE) | |
718e3744 | 5648 | vty->node = BGP_NODE; |
5649 | return CMD_SUCCESS; | |
5650 | } | |
6b0655a2 | 5651 | |
8ad7271d DS |
5652 | /* Recalculate bestpath and re-advertise a prefix */ |
5653 | static int | |
01080f7c | 5654 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5655 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5656 | { | |
5657 | int ret; | |
5658 | struct prefix match; | |
5659 | struct bgp_node *rn; | |
5660 | struct bgp_node *rm; | |
8ad7271d DS |
5661 | struct bgp *bgp; |
5662 | struct bgp_table *table; | |
5663 | struct bgp_table *rib; | |
5664 | ||
5665 | /* BGP structure lookup. */ | |
5666 | if (view_name) | |
5667 | { | |
5668 | bgp = bgp_lookup_by_name (view_name); | |
5669 | if (bgp == NULL) | |
5670 | { | |
6aeb9e78 | 5671 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5672 | return CMD_WARNING; |
5673 | } | |
5674 | } | |
5675 | else | |
5676 | { | |
5677 | bgp = bgp_get_default (); | |
5678 | if (bgp == NULL) | |
5679 | { | |
5680 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5681 | return CMD_WARNING; | |
5682 | } | |
5683 | } | |
5684 | ||
5685 | /* Check IP address argument. */ | |
5686 | ret = str2prefix (ip_str, &match); | |
5687 | if (! ret) | |
5688 | { | |
5689 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5690 | return CMD_WARNING; | |
5691 | } | |
5692 | ||
5693 | match.family = afi2family (afi); | |
5694 | rib = bgp->rib[afi][safi]; | |
5695 | ||
5696 | if (safi == SAFI_MPLS_VPN) | |
5697 | { | |
5698 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5699 | { | |
5700 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5701 | continue; | |
5702 | ||
5703 | if ((table = rn->info) != NULL) | |
5704 | { | |
5705 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5706 | { | |
5707 | if (rm->p.prefixlen == match.prefixlen) | |
5708 | { | |
5709 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5710 | bgp_process (bgp, rm, afi, safi); | |
5711 | } | |
5712 | bgp_unlock_node (rm); | |
5713 | } | |
5714 | } | |
5715 | } | |
5716 | } | |
5717 | else | |
5718 | { | |
5719 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5720 | { | |
5721 | if (rn->p.prefixlen == match.prefixlen) | |
5722 | { | |
5723 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5724 | bgp_process (bgp, rn, afi, safi); | |
5725 | } | |
5726 | bgp_unlock_node (rn); | |
5727 | } | |
5728 | } | |
5729 | ||
5730 | return CMD_SUCCESS; | |
5731 | } | |
5732 | ||
b09b5ae0 | 5733 | /* one clear bgp command to rule them all */ |
718e3744 | 5734 | DEFUN (clear_ip_bgp_all, |
5735 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5736 | "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 | 5737 | CLEAR_STR |
5738 | IP_STR | |
5739 | BGP_STR | |
838758ac | 5740 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5741 | "Clear all peers\n" |
5742 | "BGP neighbor address to clear\n" | |
a80beece | 5743 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5744 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5745 | "Clear peers with the AS number\n" |
5746 | "Clear all external peers\n" | |
718e3744 | 5747 | "Clear all members of peer-group\n" |
b09b5ae0 | 5748 | "BGP peer-group name\n" |
46f296b4 LB |
5749 | BGP_AFI_HELP_STR |
5750 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5751 | BGP_SOFT_STR |
5752 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5753 | BGP_SOFT_OUT_STR |
5754 | BGP_SOFT_IN_STR | |
5755 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5756 | BGP_SOFT_OUT_STR) |
718e3744 | 5757 | { |
cdc2d765 | 5758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8334fd5a | 5759 | char *vrf = NULL; |
630a298c | 5760 | |
ae19d7dd QY |
5761 | afi_t afi = AFI_IP6; |
5762 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5763 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5764 | enum bgp_clear_type clr_type; |
5765 | char *clr_arg = NULL; | |
718e3744 | 5766 | |
ae19d7dd | 5767 | int idx = 0; |
01080f7c | 5768 | |
ae19d7dd QY |
5769 | /* clear [ip] bgp */ |
5770 | if (argv_find (argv, argc, "ip", &idx)) | |
5771 | afi = AFI_IP; | |
5772 | /* [<view|vrf> WORD] */ | |
5773 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5774 | { |
ae19d7dd QY |
5775 | vrf = argv[idx + 1]->arg; |
5776 | idx += 2; | |
838758ac | 5777 | } |
ae19d7dd QY |
5778 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5779 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5780 | { |
ae19d7dd | 5781 | clr_sort = clear_all; |
b09b5ae0 | 5782 | } |
ae19d7dd | 5783 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5784 | { |
5785 | clr_sort = clear_peer; | |
ae19d7dd | 5786 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5787 | } |
ae19d7dd | 5788 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5789 | { |
ae19d7dd QY |
5790 | clr_sort = clear_peer; |
5791 | clr_arg = argv[idx]->arg; | |
838758ac | 5792 | } |
ae19d7dd | 5793 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5794 | { |
5795 | clr_sort = clear_group; | |
ae19d7dd QY |
5796 | idx++; |
5797 | clr_arg = argv[idx]->arg; | |
718e3744 | 5798 | |
cdc2d765 | 5799 | if (! peer_group_lookup (bgp, clr_arg)) |
b09b5ae0 DW |
5800 | { |
5801 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5802 | return CMD_WARNING; |
b09b5ae0 DW |
5803 | } |
5804 | } | |
ae19d7dd | 5805 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5806 | { |
cdc2d765 | 5807 | if (peer_lookup_by_conf_if (bgp, argv[idx]->arg)) |
b09b5ae0 DW |
5808 | { |
5809 | clr_sort = clear_peer; | |
ae19d7dd | 5810 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5811 | } |
5812 | else | |
5813 | { | |
5814 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5815 | return CMD_WARNING; | |
5816 | } | |
5817 | } | |
ae19d7dd QY |
5818 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5819 | { | |
5820 | clr_sort = clear_as; | |
5821 | clr_arg = argv[idx]->arg; | |
5822 | } | |
5823 | else if (argv_find (argv, argc, "external", &idx)) | |
5824 | { | |
5825 | clr_sort = clear_external; | |
5826 | } | |
46f296b4 LB |
5827 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
5828 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 5829 | { |
46f296b4 | 5830 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
5831 | } |
5832 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5833 | if (argv_find (argv, argc, "soft", &idx)) | |
5834 | { | |
5835 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5836 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5837 | else | |
5838 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5839 | } | |
5840 | else if (argv_find (argv, argc, "in", &idx)) | |
5841 | { | |
5842 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5843 | } | |
5844 | else if (argv_find (argv, argc, "out", &idx)) | |
5845 | { | |
5daa3e5e | 5846 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5847 | } |
5848 | else | |
5849 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5850 | |
b09b5ae0 | 5851 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5852 | } |
01080f7c | 5853 | |
8ad7271d DS |
5854 | DEFUN (clear_ip_bgp_prefix, |
5855 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5856 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5857 | CLEAR_STR |
5858 | IP_STR | |
5859 | BGP_STR | |
838758ac | 5860 | BGP_INSTANCE_HELP_STR |
8ad7271d | 5861 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5862 | "IPv4 prefix\n") |
8ad7271d | 5863 | { |
8334fd5a | 5864 | char *vrf = NULL; |
630a298c | 5865 | char *prefix = NULL; |
8ad7271d | 5866 | |
630a298c | 5867 | int idx = 0; |
01080f7c | 5868 | |
630a298c QY |
5869 | /* [<view|vrf> WORD] */ |
5870 | if (argv_find (argv, argc, "WORD", &idx)) | |
5871 | vrf = argv[idx]->arg; | |
0c7b1b01 | 5872 | |
630a298c | 5873 | prefix = argv[argc-1]->arg; |
8ad7271d | 5874 | |
630a298c | 5875 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 5876 | } |
8ad7271d | 5877 | |
b09b5ae0 DW |
5878 | DEFUN (clear_bgp_ipv6_safi_prefix, |
5879 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 5880 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5881 | CLEAR_STR |
3a2d747c | 5882 | IP_STR |
718e3744 | 5883 | BGP_STR |
8c3deaae | 5884 | "Address Family\n" |
46f296b4 | 5885 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5886 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5887 | "IPv6 prefix\n") |
718e3744 | 5888 | { |
b09b5ae0 DW |
5889 | int idx_safi = 3; |
5890 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
5891 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5892 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 5893 | } |
01080f7c | 5894 | |
b09b5ae0 DW |
5895 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
5896 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 5897 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5898 | CLEAR_STR |
3a2d747c | 5899 | IP_STR |
718e3744 | 5900 | BGP_STR |
838758ac | 5901 | BGP_INSTANCE_HELP_STR |
8c3deaae | 5902 | "Address Family\n" |
46f296b4 | 5903 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5904 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5905 | "IPv6 prefix\n") |
718e3744 | 5906 | { |
b09b5ae0 | 5907 | int idx_word = 3; |
c500ae40 | 5908 | int idx_safi = 5; |
b09b5ae0 | 5909 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
5910 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5911 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 5912 | } |
5913 | ||
b09b5ae0 DW |
5914 | DEFUN (show_bgp_views, |
5915 | show_bgp_views_cmd, | |
d6e3c605 | 5916 | "show [ip] bgp views", |
b09b5ae0 | 5917 | SHOW_STR |
d6e3c605 | 5918 | IP_STR |
01080f7c | 5919 | BGP_STR |
b09b5ae0 | 5920 | "Show the defined BGP views\n") |
01080f7c | 5921 | { |
b09b5ae0 DW |
5922 | struct list *inst = bm->bgp; |
5923 | struct listnode *node; | |
5924 | struct bgp *bgp; | |
01080f7c | 5925 | |
b09b5ae0 DW |
5926 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
5927 | { | |
5928 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5929 | return CMD_WARNING; | |
5930 | } | |
e52702f2 | 5931 | |
b09b5ae0 DW |
5932 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
5933 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5934 | { | |
5935 | /* Skip VRFs. */ | |
5936 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
5937 | continue; | |
5938 | vty_out (vty, "\t%s (AS%u)%s", | |
5939 | bgp->name ? bgp->name : "(null)", | |
5940 | bgp->as, VTY_NEWLINE); | |
5941 | } | |
e52702f2 | 5942 | |
b09b5ae0 | 5943 | return CMD_SUCCESS; |
e0081f70 ML |
5944 | } |
5945 | ||
8386ac43 | 5946 | DEFUN (show_bgp_vrfs, |
5947 | show_bgp_vrfs_cmd, | |
d6e3c605 | 5948 | "show [ip] bgp vrfs [json]", |
8386ac43 | 5949 | SHOW_STR |
d6e3c605 | 5950 | IP_STR |
8386ac43 | 5951 | BGP_STR |
5952 | "Show BGP VRFs\n" | |
9973d184 | 5953 | JSON_STR) |
8386ac43 | 5954 | { |
5955 | struct list *inst = bm->bgp; | |
5956 | struct listnode *node; | |
5957 | struct bgp *bgp; | |
5958 | u_char uj = use_json(argc, argv); | |
5959 | json_object *json = NULL; | |
5960 | json_object *json_vrfs = NULL; | |
5961 | int count = 0; | |
5962 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
5963 | ||
5964 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
5965 | { | |
5966 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5967 | return CMD_WARNING; | |
5968 | } | |
5969 | ||
5970 | if (uj) | |
5971 | { | |
5972 | json = json_object_new_object(); | |
5973 | json_vrfs = json_object_new_object(); | |
5974 | } | |
5975 | ||
5976 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5977 | { | |
5978 | const char *name, *type; | |
5979 | struct peer *peer; | |
5980 | struct listnode *node, *nnode; | |
5981 | int peers_cfg, peers_estb; | |
5982 | json_object *json_vrf = NULL; | |
5c81a5f3 | 5983 | int vrf_id_ui; |
8386ac43 | 5984 | |
5985 | /* Skip Views. */ | |
5986 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
5987 | continue; | |
5988 | ||
5989 | count++; | |
5990 | if (!uj && count == 1) | |
5991 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
5992 | ||
5993 | peers_cfg = peers_estb = 0; | |
5994 | if (uj) | |
5995 | json_vrf = json_object_new_object(); | |
5996 | ||
5997 | ||
5998 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
5999 | { | |
6000 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6001 | continue; | |
6002 | peers_cfg++; | |
6003 | if (peer->status == Established) | |
6004 | peers_estb++; | |
6005 | } | |
6006 | ||
6007 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6008 | { | |
6009 | name = "Default"; | |
6010 | type = "DFLT"; | |
6011 | } | |
6012 | else | |
6013 | { | |
6014 | name = bgp->name; | |
6015 | type = "VRF"; | |
6016 | } | |
6017 | ||
5c81a5f3 | 6018 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6019 | if (uj) |
6020 | { | |
6021 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6022 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6023 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6024 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6025 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6026 | ||
6027 | json_object_object_add(json_vrfs, name, json_vrf); | |
6028 | } | |
6029 | else | |
5c81a5f3 | 6030 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6031 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6032 | peers_cfg, peers_estb, name, |
6033 | VTY_NEWLINE); | |
6034 | } | |
6035 | ||
6036 | if (uj) | |
6037 | { | |
6038 | json_object_object_add(json, "vrfs", json_vrfs); | |
6039 | ||
6040 | json_object_int_add(json, "totalVrfs", count); | |
6041 | ||
2aac5767 | 6042 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6043 | json_object_free(json); |
6044 | } | |
6045 | else | |
6046 | { | |
6047 | if (count) | |
6048 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6049 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6050 | } | |
6051 | ||
6052 | return CMD_SUCCESS; | |
6053 | } | |
6054 | ||
f412b39a | 6055 | DEFUN (show_bgp_memory, |
4bf6a362 | 6056 | show_bgp_memory_cmd, |
7fa12b13 | 6057 | "show [ip] bgp memory", |
4bf6a362 | 6058 | SHOW_STR |
3a2d747c | 6059 | IP_STR |
4bf6a362 PJ |
6060 | BGP_STR |
6061 | "Global BGP memory statistics\n") | |
6062 | { | |
6063 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6064 | unsigned long count; | |
e52702f2 | 6065 | |
4bf6a362 PJ |
6066 | /* RIB related usage stats */ |
6067 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6068 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6069 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6070 | count * sizeof (struct bgp_node)), | |
6071 | VTY_NEWLINE); | |
e52702f2 | 6072 | |
4bf6a362 PJ |
6073 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6074 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6075 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6076 | count * sizeof (struct bgp_info)), | |
6077 | VTY_NEWLINE); | |
fb982c25 PJ |
6078 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6079 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6080 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6081 | count * sizeof (struct bgp_info_extra)), | |
6082 | VTY_NEWLINE); | |
e52702f2 | 6083 | |
4bf6a362 PJ |
6084 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6085 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6086 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6087 | count * sizeof (struct bgp_static)), | |
6088 | VTY_NEWLINE); | |
3f9c7369 DS |
6089 | |
6090 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6091 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6092 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6093 | count * sizeof (struct bpacket)), | |
6094 | VTY_NEWLINE); | |
e52702f2 | 6095 | |
4bf6a362 PJ |
6096 | /* Adj-In/Out */ |
6097 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6098 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6099 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6100 | count * sizeof (struct bgp_adj_in)), | |
6101 | VTY_NEWLINE); | |
6102 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6103 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6104 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6105 | count * sizeof (struct bgp_adj_out)), | |
6106 | VTY_NEWLINE); | |
e52702f2 | 6107 | |
4bf6a362 PJ |
6108 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6109 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6110 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6111 | count * sizeof (struct bgp_nexthop_cache)), | |
6112 | VTY_NEWLINE); | |
6113 | ||
6114 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6115 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6116 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6117 | count * sizeof (struct bgp_damp_info)), | |
6118 | VTY_NEWLINE); | |
6119 | ||
6120 | /* Attributes */ | |
6121 | count = attr_count(); | |
e52702f2 QY |
6122 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6123 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6124 | count * sizeof(struct attr)), | |
4bf6a362 | 6125 | VTY_NEWLINE); |
fb982c25 | 6126 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6127 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6128 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6129 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6130 | VTY_NEWLINE); |
e52702f2 | 6131 | |
4bf6a362 PJ |
6132 | if ((count = attr_unknown_count())) |
6133 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6134 | |
4bf6a362 PJ |
6135 | /* AS_PATH attributes */ |
6136 | count = aspath_count (); | |
6137 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6138 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6139 | count * sizeof (struct aspath)), | |
6140 | VTY_NEWLINE); | |
e52702f2 | 6141 | |
4bf6a362 PJ |
6142 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6143 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6144 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6145 | count * sizeof (struct assegment)), | |
6146 | VTY_NEWLINE); | |
e52702f2 | 6147 | |
4bf6a362 PJ |
6148 | /* Other attributes */ |
6149 | if ((count = community_count ())) | |
6150 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6151 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6152 | count * sizeof (struct community)), | |
6153 | VTY_NEWLINE); | |
6154 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6155 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6156 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6157 | count * sizeof (struct ecommunity)), | |
6158 | VTY_NEWLINE); | |
e52702f2 | 6159 | |
4bf6a362 PJ |
6160 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6161 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6162 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6163 | count * sizeof (struct cluster_list)), | |
6164 | VTY_NEWLINE); | |
e52702f2 | 6165 | |
4bf6a362 PJ |
6166 | /* Peer related usage */ |
6167 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6168 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6169 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6170 | count * sizeof (struct peer)), | |
6171 | VTY_NEWLINE); | |
e52702f2 | 6172 | |
4a1ab8e4 | 6173 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6174 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6175 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6176 | count * sizeof (struct peer_group)), | |
6177 | VTY_NEWLINE); | |
e52702f2 | 6178 | |
4bf6a362 PJ |
6179 | /* Other */ |
6180 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6181 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6182 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6183 | count * sizeof (struct hash)), | |
6184 | VTY_NEWLINE); | |
6185 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6186 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6187 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6188 | count * sizeof (struct hash_backet)), | |
6189 | VTY_NEWLINE); | |
6190 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6191 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6192 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6193 | count * sizeof (regex_t)), | |
6194 | VTY_NEWLINE); | |
6195 | return CMD_SUCCESS; | |
6196 | } | |
fee0f4c6 | 6197 | |
718e3744 | 6198 | /* Show BGP peer's summary information. */ |
94f2b392 | 6199 | static int |
b05a1c8b | 6200 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6201 | u_char use_json, json_object *json) |
718e3744 | 6202 | { |
6203 | struct peer *peer; | |
1eb8ef25 | 6204 | struct listnode *node, *nnode; |
f14e6fdb DS |
6205 | unsigned int count = 0, dn_count = 0; |
6206 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6207 | char neighbor_buf[VTY_BUFSIZ]; |
6208 | int neighbor_col_default_width = 16; | |
718e3744 | 6209 | int len; |
f933309e | 6210 | int max_neighbor_width = 0; |
ffd0c037 DS |
6211 | json_object *json_peer = NULL; |
6212 | json_object *json_peers = NULL; | |
718e3744 | 6213 | |
b05a1c8b DS |
6214 | if (use_json) |
6215 | { | |
9f689658 DD |
6216 | if (json == NULL) |
6217 | json = json_object_new_object(); | |
6218 | ||
f1aa5d8a | 6219 | json_peers = json_object_new_object(); |
b05a1c8b | 6220 | } |
f933309e DW |
6221 | else |
6222 | { | |
6223 | /* Loop over all neighbors that will be displayed to determine how many | |
6224 | * characters are needed for the Neighbor column | |
6225 | */ | |
6226 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6227 | { | |
6228 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6229 | continue; | |
6230 | ||
6231 | if (peer->afc[afi][safi]) | |
6232 | { | |
c9d5bd27 DS |
6233 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6234 | if (peer_dynamic_neighbor(peer)) | |
6235 | dn_flag[0] = '*'; | |
6236 | ||
f933309e DW |
6237 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6238 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6239 | else | |
6240 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6241 | ||
6242 | len = strlen(neighbor_buf); | |
6243 | ||
6244 | if (len > max_neighbor_width) | |
6245 | max_neighbor_width = len; | |
6246 | } | |
6247 | } | |
6248 | ||
6249 | /* Originally we displayed the Neighbor column as 16 | |
6250 | * characters wide so make that the default | |
6251 | */ | |
6252 | if (max_neighbor_width < neighbor_col_default_width) | |
6253 | max_neighbor_width = neighbor_col_default_width; | |
6254 | } | |
b05a1c8b | 6255 | |
1eb8ef25 | 6256 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6257 | { |
1ff9a340 DS |
6258 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6259 | continue; | |
6260 | ||
718e3744 | 6261 | if (peer->afc[afi][safi]) |
6262 | { | |
b05a1c8b | 6263 | if (!count) |
4bf6a362 PJ |
6264 | { |
6265 | unsigned long ents; | |
6266 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6267 | int vrf_id_ui; |
6268 | ||
6269 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6270 | |
4bf6a362 | 6271 | /* Usage summary and header */ |
b05a1c8b DS |
6272 | if (use_json) |
6273 | { | |
62d6dca0 | 6274 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6275 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6276 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6277 | json_object_string_add(json, "vrfName", | |
6278 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6279 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6280 | } |
6281 | else | |
6282 | { | |
6283 | vty_out (vty, | |
5c81a5f3 | 6284 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6285 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6286 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6287 | } |
6288 | ||
f188f2c4 DS |
6289 | if (bgp_update_delay_configured(bgp)) |
6290 | { | |
b05a1c8b | 6291 | if (use_json) |
f188f2c4 | 6292 | { |
62d6dca0 | 6293 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6294 | |
6295 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6296 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6297 | |
6298 | if (bgp_update_delay_active(bgp)) | |
6299 | { | |
62d6dca0 DS |
6300 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6301 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6302 | } |
6303 | else | |
6304 | { | |
6305 | if (bgp->update_delay_over) | |
6306 | { | |
62d6dca0 | 6307 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6308 | bgp->update_delay_begin_time); |
62d6dca0 | 6309 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6310 | bgp->update_delay_end_time); |
62d6dca0 | 6311 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6312 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6313 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6314 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6315 | } |
6316 | } | |
f188f2c4 DS |
6317 | } |
6318 | else | |
6319 | { | |
b05a1c8b DS |
6320 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6321 | bgp->v_update_delay, VTY_NEWLINE); | |
6322 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6323 | vty_out (vty, " Establish wait: %d seconds%s", | |
6324 | bgp->v_establish_wait, VTY_NEWLINE); | |
6325 | ||
6326 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6327 | { |
6328 | vty_out (vty, " First neighbor established: %s%s", | |
6329 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6330 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6331 | } | |
6332 | else | |
6333 | { | |
6334 | if (bgp->update_delay_over) | |
6335 | { | |
6336 | vty_out (vty, " First neighbor established: %s%s", | |
6337 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6338 | vty_out (vty, " Best-paths resumed: %s%s", | |
6339 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6340 | vty_out (vty, " zebra update resumed: %s%s", | |
6341 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6342 | vty_out (vty, " peers update resumed: %s%s", | |
6343 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6344 | } | |
f188f2c4 DS |
6345 | } |
6346 | } | |
6347 | } | |
4bf6a362 | 6348 | |
b05a1c8b DS |
6349 | if (use_json) |
6350 | { | |
6351 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6352 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6353 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6354 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6355 | |
62d6dca0 | 6356 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6357 | |
6358 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6359 | json_object_int_add(json, "ribCount", ents); |
6360 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6361 | |
6362 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6363 | json_object_int_add(json, "peerCount", ents); |
6364 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6365 | |
b05a1c8b DS |
6366 | if ((ents = listcount (bgp->group))) |
6367 | { | |
62d6dca0 DS |
6368 | json_object_int_add(json, "peerGroupCount", ents); |
6369 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6370 | } |
3f9c7369 | 6371 | |
b05a1c8b | 6372 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6373 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6374 | } |
6375 | else | |
6376 | { | |
6377 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6378 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6379 | if (bgp->v_maxmed_admin) | |
6380 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6381 | ||
ffd0c037 | 6382 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6383 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6384 | ||
6385 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6386 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6387 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6388 | ents * sizeof (struct bgp_node)), | |
6389 | VTY_NEWLINE); | |
6390 | ||
6391 | /* Peer related usage */ | |
6392 | ents = listcount (bgp->peer); | |
6393 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6394 | ents, | |
6395 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6396 | ents * sizeof (struct peer)), | |
6397 | VTY_NEWLINE); | |
6398 | ||
b05a1c8b DS |
6399 | if ((ents = listcount (bgp->group))) |
6400 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6401 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6402 | ents * sizeof (struct peer_group)), | |
6403 | VTY_NEWLINE); | |
6404 | ||
6405 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6406 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6407 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6408 | |
6409 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6410 | vty_out (vty, "Neighbor"); | |
6411 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6412 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6413 | } |
4bf6a362 | 6414 | } |
e52702f2 | 6415 | |
b05a1c8b | 6416 | count++; |
718e3744 | 6417 | |
b05a1c8b DS |
6418 | if (use_json) |
6419 | { | |
6420 | json_peer = json_object_new_object(); | |
f14e6fdb | 6421 | |
b05a1c8b | 6422 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6423 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6424 | |
04b6bdc0 DW |
6425 | if (peer->hostname) |
6426 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6427 | ||
6428 | if (peer->domainname) | |
6429 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6430 | ||
62d6dca0 | 6431 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6432 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6433 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6434 | peer->open_in + peer->update_in + peer->keepalive_in |
6435 | + peer->notify_in + peer->refresh_in | |
6436 | + peer->dynamic_cap_in); | |
62d6dca0 | 6437 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6438 | peer->open_out + peer->update_out + peer->keepalive_out |
6439 | + peer->notify_out + peer->refresh_out | |
6440 | + peer->dynamic_cap_out); | |
6441 | ||
62d6dca0 | 6442 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6443 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6444 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6445 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6446 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6447 | |
6448 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6449 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6450 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6451 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6452 | else |
f1aa5d8a | 6453 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6454 | |
f1aa5d8a | 6455 | if (peer->conf_if) |
62d6dca0 | 6456 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6457 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6458 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6459 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6460 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6461 | |
f1aa5d8a | 6462 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6463 | } |
6464 | else | |
6465 | { | |
6466 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6467 | if (peer_dynamic_neighbor(peer)) | |
6468 | { | |
6469 | dn_count++; | |
6470 | dn_flag[0] = '*'; | |
6471 | } | |
6472 | ||
04b6bdc0 DW |
6473 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6474 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6475 | peer->host); | |
6476 | else | |
6477 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6478 | |
f933309e DW |
6479 | /* pad the neighbor column with spaces */ |
6480 | if (len < max_neighbor_width) | |
6481 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6482 | |
f933309e | 6483 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6484 | peer->as, |
6485 | peer->open_in + peer->update_in + peer->keepalive_in | |
6486 | + peer->notify_in + peer->refresh_in | |
6487 | + peer->dynamic_cap_in, | |
6488 | peer->open_out + peer->update_out + peer->keepalive_out | |
6489 | + peer->notify_out + peer->refresh_out | |
6490 | + peer->dynamic_cap_out, | |
6491 | peer->version[afi][safi], | |
6492 | 0, | |
f933309e | 6493 | peer->obuf->count, |
856ca177 | 6494 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6495 | |
6496 | if (peer->status == Established) | |
46f8c104 | 6497 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6498 | else |
6499 | { | |
6500 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6501 | vty_out (vty, " Idle (Admin)"); | |
6502 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6503 | vty_out (vty, " Idle (PfxCt)"); | |
6504 | else | |
f933309e | 6505 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6506 | } |
6507 | vty_out (vty, "%s", VTY_NEWLINE); | |
6508 | } | |
718e3744 | 6509 | } |
6510 | } | |
6511 | ||
b05a1c8b DS |
6512 | if (use_json) |
6513 | { | |
6514 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6515 | |
62d6dca0 DS |
6516 | json_object_int_add(json, "totalPeers", count); |
6517 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6518 | |
2aac5767 | 6519 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6520 | json_object_free(json); |
b05a1c8b DS |
6521 | } |
6522 | else | |
f14e6fdb | 6523 | { |
b05a1c8b DS |
6524 | if (count) |
6525 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6526 | count, VTY_NEWLINE); | |
6527 | else | |
9f689658 DD |
6528 | { |
6529 | if (use_json) | |
6530 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6531 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6532 | else |
6533 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6534 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6535 | } |
b05a1c8b | 6536 | |
9f689658 | 6537 | if (dn_count && ! use_json) |
b05a1c8b DS |
6538 | { |
6539 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6540 | vty_out(vty, | |
6541 | "%d dynamic neighbor(s), limit %d%s", | |
6542 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6543 | } | |
f14e6fdb DS |
6544 | } |
6545 | ||
718e3744 | 6546 | return CMD_SUCCESS; |
6547 | } | |
6548 | ||
27162734 LB |
6549 | static void |
6550 | bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, | |
6551 | u_char use_json, json_object *json) | |
6552 | { | |
6553 | int is_first = 1; | |
6554 | int afi_wildcard = (afi == AFI_MAX); | |
6555 | int safi_wildcard = (safi == SAFI_MAX); | |
6556 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
6557 | if (use_json && is_wildcard) | |
6558 | vty_out (vty, "{%s", VTY_NEWLINE); | |
6559 | if (afi_wildcard) | |
6560 | afi = 1; /* AFI_IP */ | |
6561 | while (afi < AFI_MAX) | |
6562 | { | |
6563 | if (safi_wildcard) | |
6564 | safi = 1; /* SAFI_UNICAST */ | |
6565 | while (safi < SAFI_MAX) | |
6566 | { | |
6567 | if (is_wildcard) | |
6568 | { | |
6569 | if (use_json) | |
6570 | { | |
6571 | json = json_object_new_object(); | |
6572 | ||
6573 | if (! is_first) | |
6574 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6575 | else | |
6576 | is_first = 0; | |
6577 | ||
6578 | vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); | |
6579 | } | |
6580 | else | |
6581 | { | |
6582 | vty_out (vty, "%s%s Summary:%s", | |
6583 | VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); | |
6584 | } | |
6585 | } | |
6586 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); | |
6587 | if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */ | |
6588 | safi = SAFI_ENCAP; | |
6589 | else | |
6590 | safi++; | |
6591 | if (! safi_wildcard) | |
6592 | safi = SAFI_MAX; | |
6593 | } | |
6594 | afi++; | |
6595 | if (! afi_wildcard || | |
6596 | afi == AFI_ETHER) /* special case, not handled yet */ | |
6597 | afi = AFI_MAX; | |
6598 | } | |
6599 | ||
6600 | if (use_json && is_wildcard) | |
6601 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6602 | ||
6603 | } | |
6604 | ||
f186de26 | 6605 | static void |
6606 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6607 | u_char use_json) | |
6608 | { | |
6609 | struct listnode *node, *nnode; | |
6610 | struct bgp *bgp; | |
9f689658 DD |
6611 | json_object *json = NULL; |
6612 | int is_first = 1; | |
6613 | ||
6614 | if (use_json) | |
6615 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6616 | |
6617 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6618 | { | |
9f689658 DD |
6619 | if (use_json) |
6620 | { | |
4fb25c53 | 6621 | json = json_object_new_object(); |
9f689658 DD |
6622 | |
6623 | if (! is_first) | |
6624 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6625 | else | |
6626 | is_first = 0; | |
6627 | ||
6628 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6629 | ? "Default" : bgp->name); | |
6630 | } | |
6631 | else | |
6632 | { | |
6633 | vty_out (vty, "%sInstance %s:%s", | |
6634 | VTY_NEWLINE, | |
6635 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6636 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6637 | } | |
27162734 | 6638 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); |
f186de26 | 6639 | } |
9f689658 DD |
6640 | |
6641 | if (use_json) | |
6642 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6643 | ||
f186de26 | 6644 | } |
6645 | ||
4fb25c53 DW |
6646 | static int |
6647 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6648 | afi_t afi, safi_t safi, u_char use_json) | |
6649 | { | |
6650 | struct bgp *bgp; | |
6651 | ||
6652 | if (name) | |
6653 | { | |
6654 | if (strmatch(name, "all")) | |
6655 | { | |
6656 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6657 | return CMD_SUCCESS; | |
6658 | } | |
6659 | else | |
6660 | { | |
6661 | bgp = bgp_lookup_by_name (name); | |
6662 | ||
6663 | if (! bgp) | |
6664 | { | |
6665 | if (use_json) | |
6666 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6667 | else | |
6668 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6669 | return CMD_WARNING; | |
6670 | } | |
6671 | ||
27162734 | 6672 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6673 | return CMD_SUCCESS; |
6674 | } | |
6675 | } | |
6676 | ||
6677 | bgp = bgp_get_default (); | |
6678 | ||
6679 | if (bgp) | |
27162734 | 6680 | bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); |
4fb25c53 DW |
6681 | |
6682 | return CMD_SUCCESS; | |
6683 | } | |
6684 | ||
716b2d8a | 6685 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6686 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6687 | show_ip_bgp_summary_cmd, |
46f296b4 | 6688 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6689 | SHOW_STR |
6690 | IP_STR | |
6691 | BGP_STR | |
8386ac43 | 6692 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6693 | BGP_AFI_HELP_STR |
6694 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6695 | "Summary of BGP neighbor status\n" |
9973d184 | 6696 | JSON_STR) |
718e3744 | 6697 | { |
74ca3d33 | 6698 | char *vrf = NULL; |
27162734 LB |
6699 | afi_t afi = AFI_MAX; |
6700 | safi_t safi = SAFI_MAX; | |
ae19d7dd QY |
6701 | |
6702 | int idx = 0; | |
6703 | ||
6704 | /* show [ip] bgp */ | |
6705 | if (argv_find (argv, argc, "ip", &idx)) | |
6706 | afi = AFI_IP; | |
6707 | /* [<view|vrf> WORD] */ | |
6708 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6709 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6710 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6711 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6712 | { |
46f296b4 | 6713 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6714 | } |
6715 | ||
ae19d7dd | 6716 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6717 | |
6718 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6719 | } |
6720 | ||
fd79ac91 | 6721 | const char * |
538621f2 | 6722 | afi_safi_print (afi_t afi, safi_t safi) |
6723 | { | |
6724 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6725 | return "IPv4 Unicast"; | |
6726 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6727 | return "IPv4 Multicast"; | |
6728 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
46f296b4 | 6729 | return "IPv4 VPN"; |
8b1fb8be | 6730 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6731 | return "IPv4 Encap"; |
538621f2 | 6732 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6733 | return "IPv6 Unicast"; | |
6734 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6735 | return "IPv6 Multicast"; | |
945c8fe9 | 6736 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6737 | return "IPv6 VPN"; |
8b1fb8be | 6738 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6739 | return "IPv6 Encap"; |
538621f2 | 6740 | else |
6741 | return "Unknown"; | |
6742 | } | |
6743 | ||
27162734 LB |
6744 | const char * |
6745 | afi_safi_json (afi_t afi, safi_t safi) | |
6746 | { | |
6747 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6748 | return "IPv4Unicast"; | |
6749 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6750 | return "IPv4Multicast"; | |
6751 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
6752 | return "IPv4VPN"; | |
6753 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
6754 | return "IPv4Encap"; | |
6755 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
6756 | return "IPv6Unicast"; | |
6757 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6758 | return "IPv6Multicast"; | |
6759 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
6760 | return "IPv6VPN"; | |
6761 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
6762 | return "IPv6Encap"; | |
6763 | else | |
6764 | return "Unknown"; | |
6765 | } | |
6766 | ||
718e3744 | 6767 | /* Show BGP peer's information. */ |
6768 | enum show_type | |
6769 | { | |
6770 | show_all, | |
6771 | show_peer | |
6772 | }; | |
6773 | ||
94f2b392 | 6774 | static void |
856ca177 MS |
6775 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6776 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6777 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6778 | { |
6779 | /* Send-Mode */ | |
6780 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6781 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6782 | { | |
856ca177 MS |
6783 | if (use_json) |
6784 | { | |
6785 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6786 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6787 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6788 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6789 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6790 | json_object_string_add(json_pref, "sendMode", "received"); | |
6791 | } | |
6792 | else | |
6793 | { | |
6794 | vty_out (vty, " Send-mode: "); | |
6795 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6796 | vty_out (vty, "advertised"); | |
6797 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6798 | vty_out (vty, "%sreceived", | |
6799 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6800 | ", " : ""); | |
6801 | vty_out (vty, "%s", VTY_NEWLINE); | |
6802 | } | |
718e3744 | 6803 | } |
6804 | ||
6805 | /* Receive-Mode */ | |
6806 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6807 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6808 | { | |
856ca177 MS |
6809 | if (use_json) |
6810 | { | |
6811 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6812 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6813 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6814 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6815 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6816 | json_object_string_add(json_pref, "recvMode", "received"); | |
6817 | } | |
6818 | else | |
6819 | { | |
6820 | vty_out (vty, " Receive-mode: "); | |
6821 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6822 | vty_out (vty, "advertised"); | |
6823 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6824 | vty_out (vty, "%sreceived", | |
6825 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
6826 | ", " : ""); | |
6827 | vty_out (vty, "%s", VTY_NEWLINE); | |
6828 | } | |
718e3744 | 6829 | } |
6830 | } | |
6831 | ||
94f2b392 | 6832 | static void |
856ca177 MS |
6833 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6834 | u_char use_json, json_object *json_neigh) | |
718e3744 | 6835 | { |
6836 | struct bgp_filter *filter; | |
3f9c7369 | 6837 | struct peer_af *paf; |
718e3744 | 6838 | char orf_pfx_name[BUFSIZ]; |
6839 | int orf_pfx_count; | |
856ca177 MS |
6840 | json_object *json_af = NULL; |
6841 | json_object *json_prefA = NULL; | |
6842 | json_object *json_prefB = NULL; | |
6843 | json_object *json_addr = NULL; | |
718e3744 | 6844 | |
856ca177 MS |
6845 | if (use_json) |
6846 | { | |
6847 | json_addr = json_object_new_object(); | |
6848 | json_af = json_object_new_object(); | |
856ca177 | 6849 | filter = &p->filter[afi][safi]; |
718e3744 | 6850 | |
c8560b44 | 6851 | if (peer_group_active(p)) |
856ca177 | 6852 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 6853 | |
856ca177 MS |
6854 | paf = peer_af_find(p, afi, safi); |
6855 | if (paf && PAF_SUBGRP(paf)) | |
6856 | { | |
6857 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
6858 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
6859 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
6860 | } | |
6861 | ||
6862 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6863 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6864 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6865 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6866 | { | |
6867 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 6868 | json_prefA = json_object_new_object(); |
856ca177 MS |
6869 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6870 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6871 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6872 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6873 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
6874 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
6875 | } | |
6876 | ||
6877 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6878 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6879 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6880 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6881 | { | |
6882 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 6883 | json_prefB = json_object_new_object(); |
856ca177 MS |
6884 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6885 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6886 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6887 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6888 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
6889 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
6890 | } | |
6891 | ||
6892 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6893 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6894 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6895 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6896 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6897 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6898 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
6899 | else |
6900 | json_object_free(json_af); | |
856ca177 MS |
6901 | |
6902 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
6903 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
6904 | ||
6905 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
6906 | || orf_pfx_count) | |
6907 | { | |
6908 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
6909 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
6910 | if (orf_pfx_count) | |
6911 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
6912 | } | |
6913 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
6914 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
6915 | ||
6916 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
6917 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
6918 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6919 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
6920 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
6921 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
6922 | ||
88b8ed8d DW |
6923 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
6924 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
6925 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 6926 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
6927 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
6928 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
6929 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
6930 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
6931 | ||
adbac85e DW |
6932 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
6933 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
6934 | ||
06370dac DW |
6935 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
6936 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
6937 | ||
856ca177 MS |
6938 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
6939 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
6940 | ||
6941 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
6942 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
6943 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
6944 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
6945 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
6946 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
6947 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
6948 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
6949 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 6950 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
6951 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
6952 | { | |
6953 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
6954 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6955 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
6956 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6957 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
6958 | else | |
6959 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
6960 | } | |
6961 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
6962 | { | |
6963 | if (p->default_rmap[afi][safi].name) | |
6964 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
6965 | ||
6966 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
6967 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
6968 | else | |
6969 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
6970 | } | |
6971 | ||
6972 | if (filter->plist[FILTER_IN].name | |
6973 | || filter->dlist[FILTER_IN].name | |
6974 | || filter->aslist[FILTER_IN].name | |
6975 | || filter->map[RMAP_IN].name) | |
6976 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
6977 | if (filter->plist[FILTER_OUT].name | |
6978 | || filter->dlist[FILTER_OUT].name | |
6979 | || filter->aslist[FILTER_OUT].name | |
6980 | || filter->map[RMAP_OUT].name | |
6981 | || filter->usmap.name) | |
6982 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
6983 | |
6984 | /* prefix-list */ | |
6985 | if (filter->plist[FILTER_IN].name) | |
6986 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
6987 | if (filter->plist[FILTER_OUT].name) | |
6988 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
6989 | ||
6990 | /* distribute-list */ | |
6991 | if (filter->dlist[FILTER_IN].name) | |
6992 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
6993 | if (filter->dlist[FILTER_OUT].name) | |
6994 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
6995 | ||
6996 | /* filter-list. */ | |
6997 | if (filter->aslist[FILTER_IN].name) | |
6998 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
6999 | if (filter->aslist[FILTER_OUT].name) | |
7000 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
7001 | ||
7002 | /* route-map. */ | |
7003 | if (filter->map[RMAP_IN].name) | |
7004 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
7005 | if (filter->map[RMAP_OUT].name) | |
7006 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
7007 | |
7008 | /* unsuppress-map */ | |
7009 | if (filter->usmap.name) | |
7010 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
7011 | ||
7012 | /* Receive prefix count */ | |
7013 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
7014 | ||
7015 | /* Maximum prefix */ | |
7016 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7017 | { | |
7018 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
7019 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
7020 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
7021 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
7022 | if (p->pmax_restart[afi][safi]) | |
7023 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
7024 | } | |
7025 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
7026 | ||
7027 | } | |
7028 | else | |
7029 | { | |
7030 | filter = &p->filter[afi][safi]; | |
7031 | ||
7032 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
7033 | VTY_NEWLINE); | |
7034 | ||
c8560b44 | 7035 | if (peer_group_active(p)) |
856ca177 MS |
7036 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7037 | ||
7038 | paf = peer_af_find(p, afi, safi); | |
7039 | if (paf && PAF_SUBGRP(paf)) | |
7040 | { | |
7041 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7042 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7043 | vty_out (vty, " Packet Queue length %d%s", | |
7044 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7045 | } | |
718e3744 | 7046 | else |
856ca177 MS |
7047 | { |
7048 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7049 | } | |
7050 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7051 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7052 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7053 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7054 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7055 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7056 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7057 | ||
7058 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7059 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7060 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7061 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7062 | { | |
7063 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7064 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7065 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7066 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7067 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7068 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7069 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7070 | } | |
7071 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7072 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7073 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7074 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7075 | { | |
7076 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7077 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7078 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7079 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7080 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7081 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7082 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7083 | } | |
718e3744 | 7084 | |
856ca177 MS |
7085 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7086 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7087 | |
856ca177 MS |
7088 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7089 | || orf_pfx_count) | |
7090 | { | |
7091 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7092 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7093 | vty_out (vty, " sent;"); | |
7094 | if (orf_pfx_count) | |
7095 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7096 | vty_out (vty, "%s", VTY_NEWLINE); | |
7097 | } | |
7098 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7099 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7100 | ||
7101 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7102 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7103 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7104 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7105 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7106 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7107 | ||
88b8ed8d DW |
7108 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7109 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7110 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7111 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7112 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7113 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7114 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7115 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7116 | ||
adbac85e DW |
7117 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7118 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7119 | ||
06370dac DW |
7120 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7121 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7122 | ||
856ca177 MS |
7123 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7124 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7125 | ||
7126 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7127 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7128 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7129 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7130 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7131 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7132 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7133 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7134 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7135 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7136 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7137 | { | |
7138 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7139 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7140 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7141 | vty_out (vty, "(both)%s", VTY_NEWLINE); | |
7142 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7143 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7144 | else | |
7145 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7146 | } | |
7147 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7148 | { | |
7149 | vty_out (vty, " Default information originate,"); | |
7150 | ||
7151 | if (p->default_rmap[afi][safi].name) | |
7152 | vty_out (vty, " default route-map %s%s,", | |
7153 | p->default_rmap[afi][safi].map ? "*" : "", | |
7154 | p->default_rmap[afi][safi].name); | |
7155 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7156 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7157 | else | |
7158 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7159 | } | |
718e3744 | 7160 | |
856ca177 MS |
7161 | if (filter->plist[FILTER_IN].name |
7162 | || filter->dlist[FILTER_IN].name | |
7163 | || filter->aslist[FILTER_IN].name | |
7164 | || filter->map[RMAP_IN].name) | |
7165 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7166 | if (filter->plist[FILTER_OUT].name | |
7167 | || filter->dlist[FILTER_OUT].name | |
7168 | || filter->aslist[FILTER_OUT].name | |
7169 | || filter->map[RMAP_OUT].name | |
7170 | || filter->usmap.name) | |
7171 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7172 | |
7173 | /* prefix-list */ | |
7174 | if (filter->plist[FILTER_IN].name) | |
7175 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7176 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7177 | filter->plist[FILTER_IN].name, | |
7178 | VTY_NEWLINE); | |
7179 | if (filter->plist[FILTER_OUT].name) | |
7180 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7181 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7182 | filter->plist[FILTER_OUT].name, | |
7183 | VTY_NEWLINE); | |
7184 | ||
7185 | /* distribute-list */ | |
7186 | if (filter->dlist[FILTER_IN].name) | |
7187 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7188 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7189 | filter->dlist[FILTER_IN].name, | |
7190 | VTY_NEWLINE); | |
7191 | if (filter->dlist[FILTER_OUT].name) | |
7192 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7193 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7194 | filter->dlist[FILTER_OUT].name, | |
7195 | VTY_NEWLINE); | |
7196 | ||
7197 | /* filter-list. */ | |
7198 | if (filter->aslist[FILTER_IN].name) | |
7199 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7200 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7201 | filter->aslist[FILTER_IN].name, | |
7202 | VTY_NEWLINE); | |
7203 | if (filter->aslist[FILTER_OUT].name) | |
7204 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7205 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7206 | filter->aslist[FILTER_OUT].name, | |
7207 | VTY_NEWLINE); | |
7208 | ||
7209 | /* route-map. */ | |
7210 | if (filter->map[RMAP_IN].name) | |
7211 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7212 | filter->map[RMAP_IN].map ? "*" : "", | |
7213 | filter->map[RMAP_IN].name, | |
7214 | VTY_NEWLINE); | |
7215 | if (filter->map[RMAP_OUT].name) | |
7216 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7217 | filter->map[RMAP_OUT].map ? "*" : "", | |
7218 | filter->map[RMAP_OUT].name, | |
7219 | VTY_NEWLINE); | |
856ca177 MS |
7220 | |
7221 | /* unsuppress-map */ | |
7222 | if (filter->usmap.name) | |
7223 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7224 | filter->usmap.map ? "*" : "", | |
7225 | filter->usmap.name, VTY_NEWLINE); | |
7226 | ||
7227 | /* Receive prefix count */ | |
7228 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7229 | ||
7230 | /* Maximum prefix */ | |
7231 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7232 | { | |
7233 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7234 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7235 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7236 | vty_out (vty, " Threshold for warning message %d%%", | |
7237 | p->pmax_threshold[afi][safi]); | |
7238 | if (p->pmax_restart[afi][safi]) | |
7239 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7240 | vty_out (vty, "%s", VTY_NEWLINE); | |
7241 | } | |
718e3744 | 7242 | |
0a486e5f | 7243 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7244 | } |
718e3744 | 7245 | } |
7246 | ||
94f2b392 | 7247 | static void |
e8f7da3a | 7248 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7249 | { |
7250 | struct bgp *bgp; | |
4690c7d7 | 7251 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7252 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7253 | char dn_flag[2]; |
3a8c7ba1 DW |
7254 | const char *subcode_str; |
7255 | const char *code_str; | |
538621f2 | 7256 | afi_t afi; |
7257 | safi_t safi; | |
d6661008 DS |
7258 | u_int16_t i; |
7259 | u_char *msg; | |
e8f7da3a | 7260 | json_object *json_neigh = NULL; |
718e3744 | 7261 | |
7262 | bgp = p->bgp; | |
7263 | ||
e8f7da3a DW |
7264 | if (use_json) |
7265 | json_neigh = json_object_new_object(); | |
7266 | ||
856ca177 | 7267 | if (!use_json) |
f14e6fdb | 7268 | { |
856ca177 MS |
7269 | if (p->conf_if) /* Configured interface name. */ |
7270 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7271 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7272 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7273 | else /* Configured IP address. */ | |
7274 | { | |
7275 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7276 | if (peer_dynamic_neighbor(p)) | |
7277 | dn_flag[0] = '*'; | |
f14e6fdb | 7278 | |
856ca177 MS |
7279 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
7280 | } | |
f14e6fdb DS |
7281 | } |
7282 | ||
856ca177 MS |
7283 | if (use_json) |
7284 | { | |
7285 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7286 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7287 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7288 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7289 | ||
7290 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7291 | ||
7292 | if (p->change_local_as) | |
7293 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7294 | else | |
7295 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7296 | ||
7297 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7298 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7299 | |
856ca177 MS |
7300 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7301 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7302 | } | |
7303 | else | |
7304 | { | |
f8cfafda DS |
7305 | if ((p->as_type == AS_SPECIFIED) || |
7306 | (p->as_type == AS_EXTERNAL) || | |
7307 | (p->as_type == AS_INTERNAL)) | |
7308 | vty_out (vty, "remote AS %u, ", p->as); | |
7309 | else | |
7310 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7311 | vty_out (vty, "local AS %u%s%s, ", |
7312 | p->change_local_as ? p->change_local_as : p->local_as, | |
7313 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7314 | " no-prepend" : "", | |
7315 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7316 | " replace-as" : ""); | |
7317 | } | |
66b199b2 DS |
7318 | /* peer type internal, external, confed-internal or confed-external */ |
7319 | if (p->as == p->local_as) | |
7320 | { | |
856ca177 MS |
7321 | if (use_json) |
7322 | { | |
7323 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7324 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7325 | else | |
7326 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7327 | } | |
66b199b2 | 7328 | else |
856ca177 MS |
7329 | { |
7330 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7331 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7332 | else | |
7333 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7334 | } | |
66b199b2 DS |
7335 | } |
7336 | else | |
7337 | { | |
856ca177 MS |
7338 | if (use_json) |
7339 | { | |
7340 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7341 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7342 | else | |
7343 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7344 | } | |
66b199b2 | 7345 | else |
856ca177 MS |
7346 | { |
7347 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7348 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7349 | else | |
7350 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7351 | } | |
66b199b2 | 7352 | } |
718e3744 | 7353 | |
7354 | /* Description. */ | |
7355 | if (p->desc) | |
856ca177 MS |
7356 | { |
7357 | if (use_json) | |
7358 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7359 | else | |
7360 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7361 | } | |
6410e93a | 7362 | |
04b6bdc0 DW |
7363 | if (p->hostname) |
7364 | { | |
d1570739 DW |
7365 | if (use_json) |
7366 | { | |
7367 | if (p->hostname) | |
7368 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7369 | ||
7370 | if (p->domainname) | |
7371 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7372 | } | |
04b6bdc0 | 7373 | else |
d1570739 DW |
7374 | { |
7375 | if (p->domainname && (p->domainname[0] != '\0')) | |
7376 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7377 | VTY_NEWLINE); | |
7378 | else | |
7379 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7380 | } | |
7381 | ||
04b6bdc0 DW |
7382 | } |
7383 | ||
c744aa9f | 7384 | /* Peer-group */ |
718e3744 | 7385 | if (p->group) |
f14e6fdb | 7386 | { |
856ca177 MS |
7387 | if (use_json) |
7388 | { | |
7389 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7390 | ||
7391 | if (dn_flag[0]) | |
7392 | { | |
40ee54a7 | 7393 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7394 | |
40ee54a7 TT |
7395 | sockunion2hostprefix(&(p->su), &prefix); |
7396 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7397 | |
7398 | if (range) | |
7399 | { | |
7400 | prefix2str(range, buf1, sizeof(buf1)); | |
7401 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7402 | } | |
7403 | } | |
7404 | } | |
7405 | else | |
f14e6fdb | 7406 | { |
856ca177 MS |
7407 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7408 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7409 | |
856ca177 | 7410 | if (dn_flag[0]) |
f14e6fdb | 7411 | { |
40ee54a7 | 7412 | struct prefix prefix, *range = NULL; |
856ca177 | 7413 | |
40ee54a7 TT |
7414 | sockunion2hostprefix(&(p->su), &prefix); |
7415 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7416 | |
7417 | if (range) | |
7418 | { | |
7419 | prefix2str(range, buf1, sizeof(buf1)); | |
7420 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7421 | } | |
f14e6fdb DS |
7422 | } |
7423 | } | |
7424 | } | |
718e3744 | 7425 | |
856ca177 MS |
7426 | if (use_json) |
7427 | { | |
7428 | /* Administrative shutdown. */ | |
7429 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7430 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7431 | |
856ca177 MS |
7432 | /* BGP Version. */ |
7433 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
7434 | json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ)); | |
718e3744 | 7435 | |
856ca177 MS |
7436 | /* Confederation */ |
7437 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7438 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7439 | ||
7440 | /* Status. */ | |
7441 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7442 | ||
7443 | if (p->status == Established) | |
7444 | { | |
7445 | time_t uptime; | |
7446 | struct tm *tm; | |
7447 | ||
7448 | uptime = bgp_clock(); | |
7449 | uptime -= p->uptime; | |
7450 | tm = gmtime(&uptime); | |
7451 | ||
7452 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7453 | } | |
7454 | ||
7455 | else if (p->status == Active) | |
7456 | { | |
7457 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7458 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7459 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7460 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7461 | } | |
7462 | ||
7463 | /* read timer */ | |
7464 | time_t uptime; | |
7465 | struct tm *tm; | |
7466 | ||
7467 | uptime = bgp_clock(); | |
7468 | uptime -= p->readtime; | |
7469 | tm = gmtime(&uptime); | |
7470 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7471 | ||
7472 | uptime = bgp_clock(); | |
7473 | uptime -= p->last_write; | |
7474 | tm = gmtime(&uptime); | |
39e871e6 ST |
7475 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7476 | ||
7477 | uptime = bgp_clock(); | |
7478 | uptime -= p->update_time; | |
7479 | tm = gmtime(&uptime); | |
7480 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7481 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7482 | |
7483 | /* Configured timer values. */ | |
7484 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7485 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7486 | ||
7487 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7488 | { | |
7489 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7490 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7491 | } | |
93406d87 | 7492 | } |
856ca177 MS |
7493 | else |
7494 | { | |
7495 | /* Administrative shutdown. */ | |
7496 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7497 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7498 | ||
7499 | /* BGP Version. */ | |
7500 | vty_out (vty, " BGP version 4"); | |
7501 | vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ), | |
7502 | VTY_NEWLINE); | |
7503 | ||
7504 | /* Confederation */ | |
7505 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7506 | && bgp_confederation_peers_check (bgp, p->as)) | |
7507 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7508 | |
856ca177 MS |
7509 | /* Status. */ |
7510 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7511 | |
856ca177 MS |
7512 | if (p->status == Established) |
7513 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7514 | ||
7515 | else if (p->status == Active) | |
7516 | { | |
7517 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7518 | vty_out (vty, " (passive)"); | |
7519 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7520 | vty_out (vty, " (NSF passive)"); | |
7521 | } | |
7522 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7523 | |
856ca177 MS |
7524 | /* read timer */ |
7525 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7526 | vty_out (vty, ", Last write %s%s", | |
7527 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7528 | ||
7529 | /* Configured timer values. */ | |
7530 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7531 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7532 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7533 | { | |
7534 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7535 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7536 | p->keepalive, VTY_NEWLINE); | |
7537 | } | |
7538 | } | |
718e3744 | 7539 | /* Capability. */ |
e52702f2 | 7540 | if (p->status == Established) |
718e3744 | 7541 | { |
538621f2 | 7542 | if (p->cap |
718e3744 | 7543 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7544 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7545 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7546 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
718e3744 | 7547 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] |
7548 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7549 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7550 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7551 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7552 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7553 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7554 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8b1fb8be LB |
7555 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7556 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7557 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7558 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7559 | { | |
856ca177 MS |
7560 | if (use_json) |
7561 | { | |
7562 | json_object *json_cap = NULL; | |
7563 | ||
7564 | json_cap = json_object_new_object(); | |
7565 | ||
7566 | /* AS4 */ | |
7567 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7568 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7569 | { | |
7570 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7571 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7572 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7573 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7574 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7575 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7576 | } | |
7577 | ||
7578 | /* AddPath */ | |
7579 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7580 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7581 | { | |
7582 | json_object *json_add = NULL; | |
7583 | const char *print_store; | |
718e3744 | 7584 | |
856ca177 | 7585 | json_add = json_object_new_object(); |
a82478b9 | 7586 | |
856ca177 MS |
7587 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7588 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7589 | { | |
7590 | json_object *json_sub = NULL; | |
7591 | json_sub = json_object_new_object(); | |
7592 | print_store = afi_safi_print (afi, safi); | |
7593 | ||
7594 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7595 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7596 | { | |
7597 | 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)) | |
7598 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7599 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7600 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7601 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7602 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7603 | } | |
7604 | ||
7605 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7606 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7607 | { | |
7608 | 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)) | |
7609 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7610 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7611 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7612 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7613 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7614 | } | |
7615 | ||
7616 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7617 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7618 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7619 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7620 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7621 | else |
7622 | json_object_free(json_sub); | |
856ca177 | 7623 | } |
a82478b9 | 7624 | |
856ca177 MS |
7625 | json_object_object_add(json_cap, "addPath", json_add); |
7626 | } | |
7627 | ||
7628 | /* Dynamic */ | |
7629 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7630 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7631 | { | |
7632 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7633 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7634 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7635 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7636 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7637 | json_object_string_add(json_cap, "dynamic", "received"); | |
7638 | } | |
7639 | ||
7640 | /* Extended nexthop */ | |
7641 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7642 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7643 | { | |
7644 | json_object *json_nxt = NULL; | |
7645 | const char *print_store; | |
7646 | ||
856ca177 MS |
7647 | |
7648 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7649 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7650 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7651 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7652 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7653 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7654 | ||
7655 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7656 | { | |
b6df4090 DS |
7657 | json_nxt = json_object_new_object(); |
7658 | ||
856ca177 MS |
7659 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7660 | { | |
7661 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7662 | { | |
7663 | print_store = afi_safi_print (AFI_IP, safi); | |
7664 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7665 | } | |
7666 | } | |
7667 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7668 | } | |
7669 | } | |
7670 | ||
7671 | /* Route Refresh */ | |
7672 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7673 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7674 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7675 | { | |
7676 | 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))) | |
7677 | { | |
7678 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7679 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7680 | else | |
7681 | { | |
7682 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7683 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7684 | else | |
7685 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7686 | } | |
7687 | } | |
7688 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7689 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7690 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7691 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7692 | } | |
7693 | ||
7694 | /* Multiprotocol Extensions */ | |
7695 | json_object *json_multi = NULL; | |
7696 | json_multi = json_object_new_object(); | |
7697 | ||
7698 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7699 | { | |
7700 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7701 | { | |
7702 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7703 | { | |
7704 | json_object *json_exten = NULL; | |
7705 | json_exten = json_object_new_object(); | |
7706 | ||
7707 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7708 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7709 | else if (p->afc_adv[afi][safi]) | |
7710 | json_object_boolean_true_add(json_exten, "advertised"); | |
7711 | else if (p->afc_recv[afi][safi]) | |
7712 | json_object_boolean_true_add(json_exten, "received"); | |
7713 | ||
7714 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7715 | } | |
7716 | } | |
7717 | } | |
7718 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7719 | ||
7720 | /* Gracefull Restart */ | |
7721 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7722 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7723 | { | |
7724 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7725 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7726 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7727 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7728 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7729 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7730 | ||
7731 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7732 | { | |
7733 | int restart_af_count = 0; | |
7734 | json_object *json_restart = NULL; | |
7735 | json_restart = json_object_new_object(); | |
7736 | ||
7737 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7738 | ||
7739 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7740 | { | |
7741 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7742 | { | |
7743 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7744 | { | |
7745 | json_object *json_sub = NULL; | |
7746 | json_sub = json_object_new_object(); | |
7747 | ||
7748 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7749 | json_object_boolean_true_add(json_sub, "preserved"); | |
7750 | restart_af_count++; | |
7751 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7752 | } | |
7753 | } | |
7754 | } | |
7755 | if (! restart_af_count) | |
b6df4090 | 7756 | { |
856ca177 | 7757 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7758 | json_object_free(json_restart); |
7759 | } | |
856ca177 MS |
7760 | else |
7761 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7762 | } | |
7763 | } | |
7764 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7765 | } | |
7766 | else | |
7767 | { | |
7768 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7769 | ||
7770 | /* AS4 */ | |
7771 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7772 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7773 | { | |
7774 | vty_out (vty, " 4 Byte AS:"); | |
7775 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7776 | vty_out (vty, " advertised"); | |
7777 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7778 | vty_out (vty, " %sreceived", | |
7779 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7780 | vty_out (vty, "%s", VTY_NEWLINE); | |
7781 | } | |
7782 | ||
7783 | /* AddPath */ | |
7784 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7785 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7786 | { | |
7787 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7788 | |
856ca177 MS |
7789 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7790 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7791 | { |
856ca177 MS |
7792 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7793 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7794 | { | |
7795 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7796 | |
856ca177 MS |
7797 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7798 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7799 | |
856ca177 MS |
7800 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7801 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7802 | |
856ca177 MS |
7803 | vty_out (vty, "%s", VTY_NEWLINE); |
7804 | } | |
a82478b9 | 7805 | |
856ca177 | 7806 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7807 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7808 | { |
7809 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7810 | |
856ca177 MS |
7811 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7812 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7813 | |
856ca177 MS |
7814 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7815 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7816 | |
856ca177 MS |
7817 | vty_out (vty, "%s", VTY_NEWLINE); |
7818 | } | |
a82478b9 | 7819 | } |
856ca177 | 7820 | } |
a82478b9 | 7821 | |
856ca177 MS |
7822 | /* Dynamic */ |
7823 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7824 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7825 | { | |
7826 | vty_out (vty, " Dynamic:"); | |
7827 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7828 | vty_out (vty, " advertised"); | |
7829 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7830 | vty_out (vty, " %sreceived", | |
7831 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
7832 | vty_out (vty, "%s", VTY_NEWLINE); | |
7833 | } | |
7834 | ||
7835 | /* Extended nexthop */ | |
7836 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7837 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7838 | { | |
7839 | vty_out (vty, " Extended nexthop:"); | |
7840 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7841 | vty_out (vty, " advertised"); | |
7842 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7843 | vty_out (vty, " %sreceived", | |
7844 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
7845 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7846 | |
856ca177 MS |
7847 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
7848 | { | |
7849 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7850 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7851 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7852 | vty_out (vty, " %s%s", | |
7853 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
7854 | } | |
7855 | } | |
8a92a8a0 | 7856 | |
856ca177 MS |
7857 | /* Route Refresh */ |
7858 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7859 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7860 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7861 | { | |
7862 | vty_out (vty, " Route refresh:"); | |
7863 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7864 | vty_out (vty, " advertised"); | |
7865 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7866 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7867 | vty_out (vty, " %sreceived(%s)", | |
7868 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
7869 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
7870 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
7871 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 7872 | |
856ca177 MS |
7873 | vty_out (vty, "%s", VTY_NEWLINE); |
7874 | } | |
718e3744 | 7875 | |
856ca177 MS |
7876 | /* Multiprotocol Extensions */ |
7877 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7878 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7879 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7880 | { | |
8c3deaae | 7881 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
7882 | if (p->afc_adv[afi][safi]) |
7883 | vty_out (vty, " advertised"); | |
7884 | if (p->afc_recv[afi][safi]) | |
7885 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
7886 | vty_out (vty, "%s", VTY_NEWLINE); | |
7887 | } | |
538621f2 | 7888 | |
04b6bdc0 DW |
7889 | /* Hostname capability */ |
7890 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
7891 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7892 | { | |
7893 | vty_out (vty, " Hostname Capability:"); | |
7894 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
7895 | vty_out (vty, " advertised"); | |
7896 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7897 | vty_out (vty, " %sreceived", | |
7898 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
7899 | vty_out (vty, "%s", VTY_NEWLINE); | |
7900 | } | |
7901 | ||
856ca177 MS |
7902 | /* Gracefull Restart */ |
7903 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7904 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7905 | { | |
7906 | vty_out (vty, " Graceful Restart Capabilty:"); | |
7907 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 7908 | vty_out (vty, " advertised"); |
856ca177 MS |
7909 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7910 | vty_out (vty, " %sreceived", | |
7911 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
7912 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 7913 | |
856ca177 MS |
7914 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7915 | { | |
7916 | int restart_af_count = 0; | |
7917 | ||
7918 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
7919 | p->v_gr_restart, VTY_NEWLINE); | |
7920 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7921 | ||
7922 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7923 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7924 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7925 | { | |
7926 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
7927 | afi_safi_print (afi, safi), | |
7928 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
7929 | "preserved" : "not preserved"); | |
7930 | restart_af_count++; | |
7931 | } | |
7932 | if (! restart_af_count) | |
7933 | vty_out (vty, "none"); | |
7934 | vty_out (vty, "%s", VTY_NEWLINE); | |
7935 | } | |
7936 | } | |
7937 | } | |
718e3744 | 7938 | } |
7939 | } | |
7940 | ||
93406d87 | 7941 | /* graceful restart information */ |
7942 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7943 | || p->t_gr_restart | |
7944 | || p->t_gr_stale) | |
7945 | { | |
856ca177 MS |
7946 | json_object *json_grace = NULL; |
7947 | json_object *json_grace_send = NULL; | |
7948 | json_object *json_grace_recv = NULL; | |
93406d87 | 7949 | int eor_send_af_count = 0; |
7950 | int eor_receive_af_count = 0; | |
7951 | ||
856ca177 MS |
7952 | if (use_json) |
7953 | { | |
7954 | json_grace = json_object_new_object(); | |
7955 | json_grace_send = json_object_new_object(); | |
7956 | json_grace_recv = json_object_new_object(); | |
7957 | ||
7958 | if (p->status == Established) | |
7959 | { | |
7960 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7961 | { | |
7962 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7963 | { | |
7964 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7965 | { | |
7966 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
7967 | eor_send_af_count++; | |
7968 | } | |
7969 | } | |
7970 | } | |
7971 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7972 | { | |
7973 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7974 | { | |
7975 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7976 | { | |
7977 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
7978 | eor_receive_af_count++; | |
7979 | } | |
7980 | } | |
7981 | } | |
7982 | } | |
7983 | ||
7984 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
7985 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
7986 | ||
7987 | if (p->t_gr_restart) | |
7988 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
7989 | ||
7990 | if (p->t_gr_stale) | |
7991 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
7992 | ||
7993 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
7994 | } | |
7995 | else | |
7996 | { | |
7997 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
7998 | if (p->status == Established) | |
7999 | { | |
8000 | vty_out (vty, " End-of-RIB send: "); | |
8001 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8002 | { | |
8003 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8004 | { | |
8005 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
8006 | { | |
8007 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
8008 | afi_safi_print (afi, safi)); | |
8009 | eor_send_af_count++; | |
8010 | } | |
8011 | } | |
8012 | } | |
8013 | vty_out (vty, "%s", VTY_NEWLINE); | |
8014 | vty_out (vty, " End-of-RIB received: "); | |
8015 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
8016 | { | |
8017 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8018 | { | |
8019 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
8020 | { | |
8021 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
8022 | afi_safi_print (afi, safi)); | |
8023 | eor_receive_af_count++; | |
8024 | } | |
8025 | } | |
8026 | } | |
8027 | vty_out (vty, "%s", VTY_NEWLINE); | |
8028 | } | |
93406d87 | 8029 | |
856ca177 MS |
8030 | if (p->t_gr_restart) |
8031 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
8032 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8033 | |
856ca177 MS |
8034 | if (p->t_gr_stale) |
8035 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8036 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8037 | } | |
8038 | } | |
8039 | if (use_json) | |
8040 | { | |
8041 | json_object *json_stat = NULL; | |
8042 | json_stat = json_object_new_object(); | |
8043 | /* Packet counts. */ | |
8044 | json_object_int_add(json_stat, "depthInq", 0); | |
8045 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8046 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8047 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8048 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8049 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8050 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8051 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8052 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8053 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8054 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8055 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8056 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8057 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8058 | 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); | |
8059 | 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); | |
8060 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8061 | } | |
8062 | else | |
8063 | { | |
8064 | /* Packet counts. */ | |
8065 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8066 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8067 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8068 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8069 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8070 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8071 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8072 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8073 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8074 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8075 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8076 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8077 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8078 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8079 | } |
8080 | ||
856ca177 MS |
8081 | if (use_json) |
8082 | { | |
8083 | /* advertisement-interval */ | |
8084 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8085 | |
856ca177 MS |
8086 | /* Update-source. */ |
8087 | if (p->update_if || p->update_source) | |
8088 | { | |
8089 | if (p->update_if) | |
8090 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8091 | else if (p->update_source) | |
8092 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8093 | } | |
856ca177 MS |
8094 | } |
8095 | else | |
8096 | { | |
8097 | /* advertisement-interval */ | |
8098 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8099 | p->v_routeadv, VTY_NEWLINE); | |
8100 | ||
8101 | /* Update-source. */ | |
8102 | if (p->update_if || p->update_source) | |
8103 | { | |
8104 | vty_out (vty, " Update source is "); | |
8105 | if (p->update_if) | |
8106 | vty_out (vty, "%s", p->update_if); | |
8107 | else if (p->update_source) | |
8108 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8109 | vty_out (vty, "%s", VTY_NEWLINE); | |
8110 | } | |
8111 | ||
856ca177 MS |
8112 | vty_out (vty, "%s", VTY_NEWLINE); |
8113 | } | |
718e3744 | 8114 | |
8115 | /* Address Family Information */ | |
856ca177 MS |
8116 | json_object *json_hold = NULL; |
8117 | ||
8118 | if (use_json) | |
8119 | json_hold = json_object_new_object(); | |
8120 | ||
538621f2 | 8121 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8122 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8123 | if (p->afc[afi][safi]) | |
856ca177 | 8124 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8125 | |
856ca177 MS |
8126 | if (use_json) |
8127 | { | |
58433ae6 | 8128 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8129 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8130 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8131 | } |
8132 | else | |
8133 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8134 | VTY_NEWLINE); | |
718e3744 | 8135 | |
d6661008 | 8136 | if (! p->last_reset) |
856ca177 MS |
8137 | { |
8138 | if (use_json) | |
e08ac8b7 | 8139 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8140 | else |
8141 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8142 | } | |
e0701b79 | 8143 | else |
d6661008 | 8144 | { |
856ca177 MS |
8145 | if (use_json) |
8146 | { | |
8147 | time_t uptime; | |
8148 | struct tm *tm; | |
8149 | ||
8150 | uptime = bgp_clock(); | |
8151 | uptime -= p->resettime; | |
8152 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8153 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8154 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
856ca177 MS |
8155 | if (p->last_reset_cause_size) |
8156 | { | |
39e871e6 ST |
8157 | char errorcodesubcode_hexstr[5]; |
8158 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); | |
e08ac8b7 | 8159 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
856ca177 MS |
8160 | } |
8161 | } | |
8162 | else | |
d6661008 | 8163 | { |
3a8c7ba1 DW |
8164 | vty_out (vty, " Last reset %s, ", |
8165 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8166 | ||
8167 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8168 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8169 | { | |
8170 | code_str = bgp_notify_code_str(p->notify.code); | |
8171 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8172 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8173 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8174 | code_str, subcode_str, VTY_NEWLINE); | |
8175 | } | |
8176 | else | |
8177 | { | |
8178 | vty_out (vty, "due to %s%s", | |
8179 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8180 | } | |
856ca177 MS |
8181 | |
8182 | if (p->last_reset_cause_size) | |
d6661008 | 8183 | { |
856ca177 MS |
8184 | msg = p->last_reset_cause; |
8185 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8186 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8187 | { | |
8188 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8189 | |
856ca177 MS |
8190 | if (i != p->last_reset_cause_size) |
8191 | { | |
8192 | if (i % 16 == 0) | |
8193 | { | |
8194 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8195 | } | |
8196 | else if (i % 4 == 0) | |
8197 | { | |
8198 | vty_out(vty, " "); | |
8199 | } | |
8200 | } | |
8201 | } | |
8202 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8203 | } |
d6661008 DS |
8204 | } |
8205 | } | |
848973c7 | 8206 | |
718e3744 | 8207 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8208 | { | |
856ca177 | 8209 | if (use_json) |
e08ac8b7 | 8210 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8211 | else |
8212 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8213 | |
8214 | if (p->t_pmax_restart) | |
856ca177 MS |
8215 | { |
8216 | if (use_json) | |
8217 | { | |
e08ac8b7 DW |
8218 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8219 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8220 | } |
8221 | else | |
8222 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8223 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8224 | VTY_NEWLINE); | |
8225 | } | |
0a486e5f | 8226 | else |
856ca177 MS |
8227 | { |
8228 | if (use_json) | |
e08ac8b7 | 8229 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8230 | else |
8231 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8232 | p->host, VTY_NEWLINE); | |
8233 | } | |
718e3744 | 8234 | } |
8235 | ||
f5a4827d | 8236 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8237 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8238 | { |
856ca177 MS |
8239 | if (use_json) |
8240 | { | |
8241 | if (p->gtsm_hops > 0) | |
8242 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8243 | else if (p->ttl > 1) | |
8244 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8245 | } | |
8246 | else | |
8247 | { | |
8248 | if (p->gtsm_hops > 0) | |
8249 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8250 | p->gtsm_hops, VTY_NEWLINE); | |
8251 | else if (p->ttl > 1) | |
8252 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8253 | p->ttl, VTY_NEWLINE); | |
8254 | } | |
f5a4827d | 8255 | } |
5d804b43 PM |
8256 | else |
8257 | { | |
8258 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8259 | { |
8260 | if (use_json) | |
8261 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8262 | else | |
8263 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8264 | p->gtsm_hops, VTY_NEWLINE); | |
8265 | } | |
5d804b43 | 8266 | } |
718e3744 | 8267 | |
8268 | /* Local address. */ | |
8269 | if (p->su_local) | |
8270 | { | |
856ca177 MS |
8271 | if (use_json) |
8272 | { | |
8273 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8274 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8275 | } | |
8276 | else | |
8277 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8278 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8279 | ntohs (p->su_local->sin.sin_port), | |
8280 | VTY_NEWLINE); | |
718e3744 | 8281 | } |
e52702f2 | 8282 | |
718e3744 | 8283 | /* Remote address. */ |
8284 | if (p->su_remote) | |
8285 | { | |
856ca177 MS |
8286 | if (use_json) |
8287 | { | |
8288 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8289 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8290 | } | |
8291 | else | |
8292 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8293 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8294 | ntohs (p->su_remote->sin.sin_port), | |
8295 | VTY_NEWLINE); | |
8296 | } | |
8297 | ||
8298 | /* Nexthop display. */ | |
8299 | if (p->su_local) | |
8300 | { | |
856ca177 MS |
8301 | if (use_json) |
8302 | { | |
8303 | json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); | |
856ca177 MS |
8304 | json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); |
8305 | json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); | |
8306 | if (p->shared_network) | |
8307 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8308 | else | |
8309 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
856ca177 MS |
8310 | } |
8311 | else | |
8312 | { | |
8313 | vty_out (vty, "Nexthop: %s%s", | |
8314 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), | |
8315 | VTY_NEWLINE); | |
856ca177 MS |
8316 | vty_out (vty, "Nexthop global: %s%s", |
8317 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), | |
8318 | VTY_NEWLINE); | |
8319 | vty_out (vty, "Nexthop local: %s%s", | |
8320 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ), | |
8321 | VTY_NEWLINE); | |
8322 | vty_out (vty, "BGP connection: %s%s", | |
8323 | p->shared_network ? "shared network" : "non shared network", | |
8324 | VTY_NEWLINE); | |
856ca177 | 8325 | } |
718e3744 | 8326 | } |
8327 | ||
8328 | /* Timer information. */ | |
856ca177 MS |
8329 | if (use_json) |
8330 | { | |
39e871e6 | 8331 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8332 | if (p->status == Established && p->rtt) |
8333 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8334 | if (p->t_start) |
8335 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8336 | if (p->t_connect) | |
8337 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8338 | if (p->t_routeadv) | |
8339 | { | |
8340 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8341 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8342 | } | |
cb1faec9 | 8343 | |
856ca177 MS |
8344 | if (p->t_read) |
8345 | json_object_string_add(json_neigh, "readThread", "on"); | |
8346 | else | |
8347 | json_object_string_add(json_neigh, "readThread", "off"); | |
8348 | if (p->t_write) | |
8349 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8350 | else | |
8351 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8352 | } | |
8353 | else | |
8354 | { | |
39e871e6 ST |
8355 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8356 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8357 | if (p->status == Established && p->rtt) |
8358 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8359 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8360 | if (p->t_start) |
8361 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8362 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8363 | if (p->t_connect) | |
8364 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8365 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8366 | if (p->t_routeadv) | |
8367 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8368 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8369 | VTY_NEWLINE); | |
8370 | ||
8371 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8372 | p->t_read ? "on" : "off", | |
8373 | p->t_write ? "on" : "off", | |
8374 | VTY_NEWLINE); | |
8375 | } | |
718e3744 | 8376 | |
8377 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8378 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8379 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8380 | ||
8381 | if (!use_json) | |
8382 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8383 | |
8384 | /* BFD information. */ | |
856ca177 MS |
8385 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8386 | ||
8387 | if (use_json) | |
8388 | { | |
8389 | if (p->conf_if) /* Configured interface name. */ | |
8390 | json_object_object_add(json, p->conf_if, json_neigh); | |
8391 | else /* Configured IP address. */ | |
8392 | json_object_object_add(json, p->host, json_neigh); | |
8393 | } | |
718e3744 | 8394 | } |
8395 | ||
94f2b392 | 8396 | static int |
856ca177 MS |
8397 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8398 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8399 | { |
1eb8ef25 | 8400 | struct listnode *node, *nnode; |
718e3744 | 8401 | struct peer *peer; |
8402 | int find = 0; | |
8403 | ||
1eb8ef25 | 8404 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8405 | { |
1ff9a340 DS |
8406 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8407 | continue; | |
8408 | ||
718e3744 | 8409 | switch (type) |
856ca177 MS |
8410 | { |
8411 | case show_all: | |
e8f7da3a | 8412 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8413 | break; |
8414 | case show_peer: | |
8415 | if (conf_if) | |
8416 | { | |
4873b3b9 DW |
8417 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8418 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8419 | { |
8420 | find = 1; | |
e8f7da3a | 8421 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8422 | } |
8423 | } | |
8424 | else | |
8425 | { | |
8426 | if (sockunion_same (&peer->su, su)) | |
8427 | { | |
8428 | find = 1; | |
e8f7da3a | 8429 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8430 | } |
8431 | } | |
8432 | break; | |
718e3744 | 8433 | } |
8434 | } | |
8435 | ||
8436 | if (type == show_peer && ! find) | |
856ca177 MS |
8437 | { |
8438 | if (use_json) | |
8439 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8440 | else | |
8441 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8442 | } | |
8443 | ||
8444 | if (use_json) | |
8445 | { | |
2aac5767 | 8446 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8447 | json_object_free(json); |
8448 | } | |
8449 | else | |
8450 | { | |
8451 | vty_out (vty, "%s", VTY_NEWLINE); | |
8452 | } | |
8453 | ||
718e3744 | 8454 | return CMD_SUCCESS; |
8455 | } | |
8456 | ||
f186de26 | 8457 | static void |
8458 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8459 | { | |
8460 | struct listnode *node, *nnode; | |
8461 | struct bgp *bgp; | |
8462 | json_object *json = NULL; | |
9f689658 DD |
8463 | int is_first = 1; |
8464 | ||
8465 | if (use_json) | |
8466 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8467 | |
8468 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8469 | { | |
f186de26 | 8470 | if (use_json) |
9f689658 DD |
8471 | { |
8472 | if (!(json = json_object_new_object())) | |
8473 | { | |
8474 | zlog_err("Unable to allocate memory for JSON object"); | |
8475 | vty_out (vty, | |
8476 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8477 | VTY_NEWLINE); | |
8478 | return; | |
8479 | } | |
8480 | ||
8481 | json_object_int_add(json, "vrfId", | |
8482 | (bgp->vrf_id == VRF_UNKNOWN) | |
8483 | ? -1 : bgp->vrf_id); | |
8484 | json_object_string_add(json, "vrfName", | |
8485 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8486 | ? "Default" : bgp->name); | |
8487 | ||
8488 | if (! is_first) | |
8489 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8490 | else | |
8491 | is_first = 0; | |
8492 | ||
8493 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8494 | ? "Default" : bgp->name); | |
8495 | } | |
8496 | else | |
8497 | { | |
8498 | vty_out (vty, "%sInstance %s:%s", | |
8499 | VTY_NEWLINE, | |
8500 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8501 | ? "Default" : bgp->name, | |
8502 | VTY_NEWLINE); | |
8503 | } | |
f186de26 | 8504 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8505 | } | |
9f689658 DD |
8506 | |
8507 | if (use_json) | |
8508 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8509 | } |
8510 | ||
4fb25c53 DW |
8511 | static int |
8512 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8513 | enum show_type type, const char *ip_str, u_char use_json) | |
8514 | { | |
8515 | int ret; | |
8516 | struct bgp *bgp; | |
8517 | union sockunion su; | |
8518 | json_object *json = NULL; | |
8519 | ||
8520 | if (use_json) | |
8521 | json = json_object_new_object(); | |
8522 | ||
8523 | if (name) | |
8524 | { | |
8525 | if (strmatch(name, "all")) | |
8526 | { | |
8527 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8528 | return CMD_SUCCESS; | |
8529 | } | |
8530 | else | |
8531 | { | |
8532 | bgp = bgp_lookup_by_name (name); | |
8533 | if (! bgp) | |
8534 | { | |
8535 | if (use_json) | |
8536 | { | |
8537 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8538 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8539 | json_object_free(json); |
8540 | } | |
8541 | else | |
8542 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8543 | ||
8544 | return CMD_WARNING; | |
8545 | } | |
8546 | } | |
8547 | } | |
8548 | else | |
8549 | { | |
8550 | bgp = bgp_get_default (); | |
8551 | } | |
8552 | ||
8553 | if (bgp) | |
8554 | { | |
8555 | if (ip_str) | |
8556 | { | |
8557 | ret = str2sockunion (ip_str, &su); | |
8558 | if (ret < 0) | |
8559 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8560 | else | |
8561 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8562 | } | |
8563 | else | |
8564 | { | |
8565 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8566 | } | |
8567 | } | |
8568 | ||
8569 | return CMD_SUCCESS; | |
8570 | } | |
8571 | ||
716b2d8a | 8572 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8573 | DEFUN (show_ip_bgp_neighbors, |
8574 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8575 | "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 | 8576 | SHOW_STR |
8577 | IP_STR | |
8578 | BGP_STR | |
5bf15956 | 8579 | BGP_INSTANCE_ALL_HELP_STR |
8c3deaae QY |
8580 | "Address Family\n" |
8581 | "Address Family\n" | |
91d37724 QY |
8582 | "Address Family\n" |
8583 | "Display information about all VPNv4 NLRIs\n" | |
8584 | "Display information for a route distinguisher\n" | |
8585 | "VPN Route Distinguisher\n" | |
718e3744 | 8586 | "Detailed information on TCP and BGP neighbor connections\n" |
8587 | "Neighbor to display information about\n" | |
a80beece | 8588 | "Neighbor to display information about\n" |
91d37724 | 8589 | "Neighbor on BGP configured interface\n" |
9973d184 | 8590 | JSON_STR) |
718e3744 | 8591 | { |
5bf15956 DW |
8592 | char *vrf = NULL; |
8593 | char *sh_arg = NULL; | |
8594 | enum show_type sh_type; | |
718e3744 | 8595 | |
5bf15956 | 8596 | u_char uj = use_json(argc, argv); |
718e3744 | 8597 | |
630a298c | 8598 | int idx = 0; |
718e3744 | 8599 | |
630a298c QY |
8600 | if (argv_find (argv, argc, "WORD", &idx)) |
8601 | vrf = argv[idx]->arg; | |
718e3744 | 8602 | |
91d37724 QY |
8603 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8604 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8605 | argv_find (argv, argc, "WORD", &idx)) |
8606 | { | |
8607 | sh_type = show_peer; | |
8608 | sh_arg = argv[idx]->arg; | |
8609 | } | |
5bf15956 | 8610 | else |
630a298c | 8611 | sh_type = show_all; |
856ca177 | 8612 | |
5bf15956 | 8613 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8614 | } |
8615 | ||
716b2d8a | 8616 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8617 | paths' and `show ip mbgp paths'. Those functions results are the |
8618 | same.*/ | |
f412b39a | 8619 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8620 | show_ip_bgp_paths_cmd, |
46f296b4 | 8621 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8622 | SHOW_STR |
8623 | IP_STR | |
8624 | BGP_STR | |
46f296b4 | 8625 | BGP_SAFI_HELP_STR |
718e3744 | 8626 | "Path information\n") |
8627 | { | |
8628 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8629 | aspath_print_all_vty (vty); | |
8630 | return CMD_SUCCESS; | |
8631 | } | |
8632 | ||
718e3744 | 8633 | #include "hash.h" |
8634 | ||
94f2b392 | 8635 | static void |
718e3744 | 8636 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8637 | { | |
8638 | struct community *com; | |
8639 | ||
8640 | com = (struct community *) backet->data; | |
6c4f4e6e | 8641 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8642 | community_str (com), VTY_NEWLINE); |
8643 | } | |
8644 | ||
8645 | /* Show BGP's community internal data. */ | |
f412b39a | 8646 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8647 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8648 | "show [ip] bgp community-info", |
718e3744 | 8649 | SHOW_STR |
8650 | IP_STR | |
8651 | BGP_STR | |
8652 | "List all bgp community information\n") | |
8653 | { | |
8654 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8655 | ||
e52702f2 | 8656 | hash_iterate (community_hash (), |
718e3744 | 8657 | (void (*) (struct hash_backet *, void *)) |
8658 | community_show_all_iterator, | |
8659 | vty); | |
8660 | ||
8661 | return CMD_SUCCESS; | |
8662 | } | |
8663 | ||
f412b39a | 8664 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8665 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8666 | "show [ip] bgp attribute-info", |
718e3744 | 8667 | SHOW_STR |
8668 | IP_STR | |
8669 | BGP_STR | |
8670 | "List all bgp attribute information\n") | |
8671 | { | |
8672 | attr_show_all (vty); | |
8673 | return CMD_SUCCESS; | |
8674 | } | |
6b0655a2 | 8675 | |
f186de26 | 8676 | static void |
8677 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8678 | { | |
8679 | struct listnode *node, *nnode; | |
8680 | struct bgp *bgp; | |
8681 | ||
8682 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8683 | { | |
8684 | vty_out (vty, "%sInstance %s:%s", | |
8685 | VTY_NEWLINE, | |
8686 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8687 | VTY_NEWLINE); | |
8688 | update_group_show(bgp, afi, safi, vty, 0); | |
8689 | } | |
8690 | } | |
8691 | ||
4fb25c53 DW |
8692 | static int |
8693 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8694 | int afi, int safi, | |
8695 | uint64_t subgrp_id) | |
8696 | { | |
8697 | struct bgp *bgp; | |
8698 | ||
8699 | if (name) | |
8700 | { | |
8701 | if (strmatch (name, "all")) | |
8702 | { | |
8703 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8704 | return CMD_SUCCESS; | |
8705 | } | |
8706 | else | |
8707 | { | |
8708 | bgp = bgp_lookup_by_name (name); | |
8709 | } | |
8710 | } | |
8711 | else | |
8712 | { | |
8713 | bgp = bgp_get_default (); | |
8714 | } | |
8715 | ||
8716 | if (bgp) | |
8717 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8718 | return CMD_SUCCESS; | |
8719 | } | |
8720 | ||
8fe8a7f6 DS |
8721 | DEFUN (show_ip_bgp_updgrps, |
8722 | show_ip_bgp_updgrps_cmd, | |
c9e571b4 | 8723 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 8724 | SHOW_STR |
8725 | IP_STR | |
8726 | BGP_STR | |
8727 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 8728 | BGP_AFI_HELP_STR |
46f296b4 | 8729 | BGP_SAFI_HELP_STR |
5bf15956 DW |
8730 | "Detailed info about dynamic update groups\n" |
8731 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8732 | { |
5bf15956 | 8733 | char *vrf = NULL; |
ae19d7dd QY |
8734 | afi_t afi = AFI_IP6; |
8735 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8736 | uint64_t subgrp_id = 0; |
8737 | ||
ae19d7dd QY |
8738 | int idx = 0; |
8739 | ||
8740 | /* show [ip] bgp */ | |
8741 | if (argv_find (argv, argc, "ip", &idx)) | |
8742 | afi = AFI_IP; | |
8743 | /* [<view|vrf> WORD] */ | |
8744 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8745 | vrf = argv[++idx]->arg; | |
c9e571b4 LB |
8746 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8747 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
8748 | { | |
8749 | argv_find_and_parse_safi (argv, argc, &idx, &safi); | |
8750 | } | |
5bf15956 | 8751 | |
ae19d7dd QY |
8752 | /* get subgroup id, if provided */ |
8753 | idx = argc - 1; | |
8754 | if (argv[idx]->type == VARIABLE_TKN) | |
8755 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
8756 | |
8757 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
8758 | } |
8759 | ||
f186de26 | 8760 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
8761 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 8762 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 8763 | SHOW_STR |
716b2d8a | 8764 | IP_STR |
f186de26 | 8765 | BGP_STR |
8766 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 8767 | "Detailed info about dynamic update groups\n") |
f186de26 | 8768 | { |
8769 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
8770 | return CMD_SUCCESS; | |
8771 | } | |
8772 | ||
5bf15956 DW |
8773 | DEFUN (show_bgp_updgrps_stats, |
8774 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 8775 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 8776 | SHOW_STR |
716b2d8a | 8777 | IP_STR |
3f9c7369 | 8778 | BGP_STR |
0c7b1b01 | 8779 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8780 | "Statistics\n") |
8781 | { | |
8782 | struct bgp *bgp; | |
8783 | ||
8784 | bgp = bgp_get_default(); | |
8785 | if (bgp) | |
8786 | update_group_show_stats(bgp, vty); | |
8787 | ||
8788 | return CMD_SUCCESS; | |
8789 | } | |
8790 | ||
8386ac43 | 8791 | DEFUN (show_bgp_instance_updgrps_stats, |
8792 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 8793 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 8794 | SHOW_STR |
716b2d8a | 8795 | IP_STR |
8386ac43 | 8796 | BGP_STR |
8797 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8798 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8799 | "Statistics\n") |
8800 | { | |
c500ae40 | 8801 | int idx_word = 3; |
8386ac43 | 8802 | struct bgp *bgp; |
8803 | ||
c500ae40 | 8804 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 8805 | if (bgp) |
8806 | update_group_show_stats(bgp, vty); | |
8807 | ||
8808 | return CMD_SUCCESS; | |
8809 | } | |
8810 | ||
3f9c7369 | 8811 | static void |
8386ac43 | 8812 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
8813 | afi_t afi, safi_t safi, | |
f43e655e | 8814 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
8815 | { |
8816 | struct bgp *bgp; | |
8386ac43 | 8817 | |
8818 | if (name) | |
8819 | bgp = bgp_lookup_by_name (name); | |
8820 | else | |
8821 | bgp = bgp_get_default (); | |
8822 | ||
3f9c7369 DS |
8823 | if (bgp) |
8824 | { | |
8825 | if (!strcmp(what, "advertise-queue")) | |
8826 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
8827 | else if (!strcmp(what, "advertised-routes")) | |
8828 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
8829 | else if (!strcmp(what, "packet-queue")) | |
8830 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
8831 | } | |
8832 | } | |
8833 | ||
8834 | DEFUN (show_ip_bgp_updgrps_adj, | |
8835 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 8836 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8837 | SHOW_STR |
8838 | IP_STR | |
8839 | BGP_STR | |
0c7b1b01 | 8840 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8841 | "Advertisement queue\n" |
8842 | "Announced routes\n" | |
8843 | "Packet queue\n") | |
8fe8a7f6 | 8844 | |
3f9c7369 | 8845 | { |
c500ae40 DW |
8846 | int idx_type = 4; |
8847 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8848 | return CMD_SUCCESS; |
8849 | } | |
8850 | ||
8851 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
8852 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8853 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8854 | SHOW_STR |
8855 | IP_STR | |
8856 | BGP_STR | |
8857 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8858 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8859 | "Advertisement queue\n" |
8860 | "Announced routes\n" | |
8861 | "Packet queue\n") | |
8862 | ||
8863 | { | |
c500ae40 DW |
8864 | int idx_word = 4; |
8865 | int idx_type = 6; | |
8866 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8867 | return CMD_SUCCESS; |
8868 | } | |
8869 | ||
8870 | DEFUN (show_bgp_updgrps_afi_adj, | |
8871 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 8872 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8873 | SHOW_STR |
716b2d8a | 8874 | IP_STR |
3f9c7369 | 8875 | BGP_STR |
46f296b4 | 8876 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 8877 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8878 | "Advertisement queue\n" |
8879 | "Announced routes\n" | |
8fe8a7f6 DS |
8880 | "Packet queue\n" |
8881 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8882 | { |
c500ae40 DW |
8883 | int idx_afi = 2; |
8884 | int idx_safi = 3; | |
8885 | int idx_type = 5; | |
46f296b4 LB |
8886 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
8887 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
8888 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
8889 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 8890 | return CMD_SUCCESS; |
3f9c7369 DS |
8891 | } |
8892 | ||
8893 | DEFUN (show_bgp_updgrps_adj, | |
8894 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 8895 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8896 | SHOW_STR |
716b2d8a | 8897 | IP_STR |
3f9c7369 | 8898 | BGP_STR |
0c7b1b01 | 8899 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8900 | "Advertisement queue\n" |
8901 | "Announced routes\n" | |
8902 | "Packet queue\n") | |
8903 | { | |
c500ae40 DW |
8904 | int idx_type = 3; |
8905 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8906 | return CMD_SUCCESS; |
8907 | } | |
8908 | ||
8909 | DEFUN (show_bgp_instance_updgrps_adj, | |
8910 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8911 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8912 | SHOW_STR |
716b2d8a | 8913 | IP_STR |
8386ac43 | 8914 | BGP_STR |
8915 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8916 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8917 | "Advertisement queue\n" |
8918 | "Announced routes\n" | |
8919 | "Packet queue\n") | |
8920 | { | |
c500ae40 DW |
8921 | int idx_word = 3; |
8922 | int idx_type = 5; | |
8923 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8924 | return CMD_SUCCESS; |
8925 | } | |
8926 | ||
8927 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 8928 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 8929 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8930 | SHOW_STR |
8931 | IP_STR | |
8932 | BGP_STR | |
0c7b1b01 | 8933 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8934 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8935 | "Advertisement queue\n" |
8936 | "Announced routes\n" | |
8937 | "Packet queue\n") | |
3f9c7369 | 8938 | |
3f9c7369 | 8939 | { |
5bf15956 | 8940 | int idx_subgroup_id = 4; |
c500ae40 | 8941 | int idx_type = 5; |
f43e655e | 8942 | uint64_t subgrp_id; |
8fe8a7f6 | 8943 | |
5bf15956 | 8944 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8945 | |
5bf15956 | 8946 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 8947 | return CMD_SUCCESS; |
8948 | } | |
8949 | ||
8950 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
8951 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 8952 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8953 | SHOW_STR |
8954 | IP_STR | |
8955 | BGP_STR | |
8956 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8957 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8958 | "Specific subgroup to display info for\n" |
8959 | "Advertisement queue\n" | |
8960 | "Announced routes\n" | |
8961 | "Packet queue\n") | |
8962 | ||
8963 | { | |
5bf15956 DW |
8964 | int idx_vrf = 4; |
8965 | int idx_subgroup_id = 6; | |
c500ae40 | 8966 | int idx_type = 7; |
f43e655e | 8967 | uint64_t subgrp_id; |
8386ac43 | 8968 | |
5bf15956 | 8969 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 8970 | |
5bf15956 | 8971 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
8972 | return CMD_SUCCESS; |
8973 | } | |
8974 | ||
8fe8a7f6 DS |
8975 | DEFUN (show_bgp_updgrps_afi_adj_s, |
8976 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 8977 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8978 | SHOW_STR |
716b2d8a | 8979 | IP_STR |
3f9c7369 | 8980 | BGP_STR |
46f296b4 | 8981 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 8982 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8983 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8984 | "Advertisement queue\n" |
8985 | "Announced routes\n" | |
8fe8a7f6 DS |
8986 | "Packet queue\n" |
8987 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8988 | { |
c500ae40 DW |
8989 | int idx_afi = 2; |
8990 | int idx_safi = 3; | |
5bf15956 | 8991 | int idx_subgroup_id = 5; |
c500ae40 | 8992 | int idx_type = 6; |
f43e655e | 8993 | uint64_t subgrp_id; |
3f9c7369 | 8994 | |
5bf15956 | 8995 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8996 | |
46f296b4 LB |
8997 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
8998 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
8999 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
9000 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 9001 | return CMD_SUCCESS; |
3f9c7369 DS |
9002 | } |
9003 | ||
8fe8a7f6 DS |
9004 | DEFUN (show_bgp_updgrps_adj_s, |
9005 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 9006 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 9007 | SHOW_STR |
716b2d8a | 9008 | IP_STR |
8fe8a7f6 | 9009 | BGP_STR |
0c7b1b01 | 9010 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9011 | "Specific subgroup to display info for\n" |
9012 | "Advertisement queue\n" | |
9013 | "Announced routes\n" | |
9014 | "Packet queue\n") | |
9015 | { | |
5bf15956 | 9016 | int idx_subgroup_id = 3; |
c500ae40 | 9017 | int idx_type = 4; |
f43e655e | 9018 | uint64_t subgrp_id; |
8fe8a7f6 | 9019 | |
5bf15956 | 9020 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9021 | |
5bf15956 | 9022 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9023 | return CMD_SUCCESS; |
9024 | } | |
9025 | ||
8386ac43 | 9026 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9027 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 9028 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9029 | SHOW_STR |
716b2d8a | 9030 | IP_STR |
8386ac43 | 9031 | BGP_STR |
9032 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9033 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9034 | "Specific subgroup to display info for\n" |
9035 | "Advertisement queue\n" | |
9036 | "Announced routes\n" | |
9037 | "Packet queue\n") | |
9038 | { | |
5bf15956 DW |
9039 | int idx_vrf = 3; |
9040 | int idx_subgroup_id = 5; | |
c500ae40 | 9041 | int idx_type = 6; |
f43e655e | 9042 | uint64_t subgrp_id; |
8386ac43 | 9043 | |
5bf15956 | 9044 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9045 | |
5bf15956 | 9046 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9047 | return CMD_SUCCESS; |
9048 | } | |
9049 | ||
9050 | ||
8fe8a7f6 | 9051 | |
f14e6fdb DS |
9052 | static int |
9053 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9054 | { | |
9055 | struct listnode *node, *nnode; | |
9056 | struct prefix *range; | |
9057 | struct peer *conf; | |
9058 | struct peer *peer; | |
4690c7d7 | 9059 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9060 | afi_t afi; |
9061 | safi_t safi; | |
ffd0c037 DS |
9062 | const char *peer_status; |
9063 | const char *af_str; | |
f14e6fdb DS |
9064 | int lr_count; |
9065 | int dynamic; | |
9066 | int af_cfgd; | |
9067 | ||
9068 | conf = group->conf; | |
9069 | ||
0299c004 DS |
9070 | if (conf->as_type == AS_SPECIFIED || |
9071 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9072 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9073 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9074 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9075 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9076 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9077 | } else { |
9078 | vty_out (vty, "%sBGP peer-group %s%s", | |
9079 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9080 | } |
f14e6fdb | 9081 | |
0299c004 | 9082 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9083 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9084 | else | |
9085 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9086 | ||
9087 | /* Display AFs configured. */ | |
9088 | vty_out (vty, " Configured address-families:"); | |
9089 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9090 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9091 | { | |
9092 | if (conf->afc[afi][safi]) | |
9093 | { | |
9094 | af_cfgd = 1; | |
9095 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9096 | } | |
9097 | } | |
9098 | if (!af_cfgd) | |
9099 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9100 | else | |
9101 | vty_out (vty, "%s", VTY_NEWLINE); | |
9102 | ||
9103 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9104 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9105 | { | |
9106 | if (afi == AFI_IP) | |
9107 | af_str = "IPv4"; | |
9108 | else if (afi == AFI_IP6) | |
9109 | af_str = "IPv6"; | |
45ef4300 DL |
9110 | else |
9111 | af_str = "???"; | |
f14e6fdb DS |
9112 | lr_count = listcount(group->listen_range[afi]); |
9113 | if (lr_count) | |
9114 | { | |
9115 | vty_out(vty, | |
9116 | " %d %s listen range(s)%s", | |
9117 | lr_count, af_str, VTY_NEWLINE); | |
9118 | ||
9119 | ||
9120 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9121 | nnode, range)) | |
9122 | { | |
9123 | prefix2str(range, buf, sizeof(buf)); | |
9124 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9125 | } | |
9126 | } | |
9127 | } | |
9128 | ||
9129 | /* Display group members and their status */ | |
9130 | if (listcount(group->peer)) | |
9131 | { | |
9132 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9133 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9134 | { | |
9135 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9136 | peer_status = "Idle (Admin)"; | |
9137 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9138 | peer_status = "Idle (PfxCt)"; | |
9139 | else | |
9140 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9141 | ||
9142 | dynamic = peer_dynamic_neighbor(peer); | |
9143 | vty_out (vty, " %s %s %s %s", | |
9144 | peer->host, dynamic ? "(dynamic)" : "", | |
9145 | peer_status, VTY_NEWLINE); | |
9146 | } | |
9147 | } | |
9148 | ||
9149 | return CMD_SUCCESS; | |
9150 | } | |
9151 | ||
9152 | /* Show BGP peer group's information. */ | |
9153 | enum show_group_type | |
9154 | { | |
9155 | show_all_groups, | |
9156 | show_peer_group | |
9157 | }; | |
9158 | ||
9159 | static int | |
9160 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9161 | enum show_group_type type, const char *group_name) | |
9162 | { | |
9163 | struct listnode *node, *nnode; | |
9164 | struct peer_group *group; | |
9165 | int find = 0; | |
9166 | ||
9167 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9168 | { | |
9169 | switch (type) | |
9170 | { | |
9171 | case show_all_groups: | |
9172 | bgp_show_one_peer_group (vty, group); | |
9173 | break; | |
9174 | case show_peer_group: | |
9175 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9176 | { | |
9177 | find = 1; | |
9178 | bgp_show_one_peer_group (vty, group); | |
9179 | } | |
9180 | break; | |
9181 | } | |
9182 | } | |
9183 | ||
9184 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9185 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9186 | |
9187 | return CMD_SUCCESS; | |
9188 | } | |
9189 | ||
9190 | static int | |
9191 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9192 | enum show_group_type type, const char *group_name) | |
9193 | { | |
9194 | struct bgp *bgp; | |
9195 | int ret = CMD_SUCCESS; | |
9196 | ||
9197 | if (name) | |
8386ac43 | 9198 | bgp = bgp_lookup_by_name (name); |
9199 | else | |
9200 | bgp = bgp_get_default (); | |
f14e6fdb | 9201 | |
8386ac43 | 9202 | if (! bgp) |
9203 | { | |
9204 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9205 | return CMD_WARNING; | |
f14e6fdb DS |
9206 | } |
9207 | ||
8386ac43 | 9208 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9209 | |
9210 | return ret; | |
9211 | } | |
9212 | ||
9213 | DEFUN (show_ip_bgp_peer_groups, | |
9214 | show_ip_bgp_peer_groups_cmd, | |
d6e3c605 | 9215 | "show [ip] bgp [<view|vrf> VRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
9216 | SHOW_STR |
9217 | IP_STR | |
9218 | BGP_STR | |
8386ac43 | 9219 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9220 | "Detailed information on BGP peer groups\n" |
9221 | "Peer group name\n") | |
f14e6fdb | 9222 | { |
d6e3c605 QY |
9223 | char *vrf, *pg; |
9224 | vrf = pg = NULL; | |
9225 | int idx = 0; | |
f14e6fdb | 9226 | |
d6e3c605 QY |
9227 | vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; |
9228 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 9229 | |
d6e3c605 | 9230 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9231 | } |
3f9c7369 | 9232 | |
d6e3c605 | 9233 | |
718e3744 | 9234 | /* Redistribute VTY commands. */ |
9235 | ||
718e3744 | 9236 | DEFUN (bgp_redistribute_ipv4, |
9237 | bgp_redistribute_ipv4_cmd, | |
9ccf14f7 | 9238 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>", |
718e3744 | 9239 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9240 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9241 | { |
cdc2d765 | 9242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9243 | int idx_protocol = 1; |
718e3744 | 9244 | int type; |
9245 | ||
6d681bd8 QY |
9246 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9247 | if (type < 0) | |
718e3744 | 9248 | { |
9249 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9250 | return CMD_WARNING; | |
9251 | } | |
cdc2d765 DL |
9252 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9253 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9254 | } |
9255 | ||
9256 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9257 | bgp_redistribute_ipv4_rmap_cmd, | |
9ccf14f7 | 9258 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD", |
718e3744 | 9259 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9260 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9261 | "Route map reference\n" |
9262 | "Pointer to route-map entries\n") | |
9263 | { | |
cdc2d765 | 9264 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9265 | int idx_protocol = 1; |
9266 | int idx_word = 3; | |
718e3744 | 9267 | int type; |
7c8ff89e | 9268 | struct bgp_redist *red; |
718e3744 | 9269 | |
6d681bd8 QY |
9270 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9271 | if (type < 0) | |
718e3744 | 9272 | { |
9273 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9274 | return CMD_WARNING; | |
9275 | } | |
9276 | ||
cdc2d765 | 9277 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9278 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9279 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9280 | } |
9281 | ||
9282 | DEFUN (bgp_redistribute_ipv4_metric, | |
9283 | bgp_redistribute_ipv4_metric_cmd, | |
9ccf14f7 | 9284 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)", |
718e3744 | 9285 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9286 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9287 | "Metric for redistributed routes\n" |
9288 | "Default metric\n") | |
9289 | { | |
cdc2d765 | 9290 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9291 | int idx_protocol = 1; |
9292 | int idx_number = 3; | |
718e3744 | 9293 | int type; |
9294 | u_int32_t metric; | |
7c8ff89e | 9295 | struct bgp_redist *red; |
718e3744 | 9296 | |
6d681bd8 QY |
9297 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9298 | if (type < 0) | |
718e3744 | 9299 | { |
9300 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9301 | return CMD_WARNING; | |
9302 | } | |
c500ae40 | 9303 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9304 | |
cdc2d765 DL |
9305 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9306 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9307 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9308 | } |
9309 | ||
9310 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9311 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
9ccf14f7 | 9312 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9313 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9314 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9315 | "Route map reference\n" |
9316 | "Pointer to route-map entries\n" | |
9317 | "Metric for redistributed routes\n" | |
9318 | "Default metric\n") | |
9319 | { | |
cdc2d765 | 9320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9321 | int idx_protocol = 1; |
9322 | int idx_word = 3; | |
9323 | int idx_number = 5; | |
718e3744 | 9324 | int type; |
9325 | u_int32_t metric; | |
7c8ff89e | 9326 | struct bgp_redist *red; |
718e3744 | 9327 | |
6d681bd8 QY |
9328 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9329 | if (type < 0) | |
718e3744 | 9330 | { |
9331 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9332 | return CMD_WARNING; | |
9333 | } | |
c500ae40 | 9334 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9335 | |
cdc2d765 | 9336 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9337 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9338 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9339 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9340 | } |
9341 | ||
9342 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9343 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
9ccf14f7 | 9344 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9345 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9346 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9347 | "Metric for redistributed routes\n" |
9348 | "Default metric\n" | |
9349 | "Route map reference\n" | |
9350 | "Pointer to route-map entries\n") | |
9351 | { | |
cdc2d765 | 9352 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9353 | int idx_protocol = 1; |
9354 | int idx_number = 3; | |
9355 | int idx_word = 5; | |
718e3744 | 9356 | int type; |
9357 | u_int32_t metric; | |
7c8ff89e | 9358 | struct bgp_redist *red; |
718e3744 | 9359 | |
6d681bd8 QY |
9360 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9361 | if (type < 0) | |
718e3744 | 9362 | { |
9363 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9364 | return CMD_WARNING; | |
9365 | } | |
c500ae40 | 9366 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9367 | |
cdc2d765 DL |
9368 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9369 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9370 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9371 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9372 | } |
9373 | ||
7c8ff89e DS |
9374 | DEFUN (bgp_redistribute_ipv4_ospf, |
9375 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9376 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9377 | "Redistribute information from another routing protocol\n" |
9378 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9379 | "Non-main Kernel Routing Table\n" |
9380 | "Instance ID/Table ID\n") | |
7c8ff89e | 9381 | { |
cdc2d765 | 9382 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9383 | int idx_ospf_table = 1; |
9384 | int idx_number = 2; | |
7c8ff89e | 9385 | u_short instance; |
7a4bb9c5 | 9386 | u_short protocol; |
7c8ff89e | 9387 | |
c500ae40 | 9388 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9389 | |
c500ae40 | 9390 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9391 | protocol = ZEBRA_ROUTE_OSPF; |
9392 | else | |
9393 | protocol = ZEBRA_ROUTE_TABLE; | |
9394 | ||
cdc2d765 DL |
9395 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9396 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9397 | } |
9398 | ||
9399 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9400 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9401 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9402 | "Redistribute information from another routing protocol\n" |
9403 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9404 | "Non-main Kernel Routing Table\n" |
9405 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9406 | "Route map reference\n" |
9407 | "Pointer to route-map entries\n") | |
9408 | { | |
cdc2d765 | 9409 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9410 | int idx_ospf_table = 1; |
9411 | int idx_number = 2; | |
9412 | int idx_word = 4; | |
7c8ff89e DS |
9413 | struct bgp_redist *red; |
9414 | u_short instance; | |
7a4bb9c5 | 9415 | int protocol; |
7c8ff89e | 9416 | |
c500ae40 | 9417 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9418 | protocol = ZEBRA_ROUTE_OSPF; |
9419 | else | |
9420 | protocol = ZEBRA_ROUTE_TABLE; | |
9421 | ||
c500ae40 | 9422 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9423 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9424 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9425 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9426 | } |
9427 | ||
9428 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9429 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9430 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9431 | "Redistribute information from another routing protocol\n" |
9432 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9433 | "Non-main Kernel Routing Table\n" |
9434 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9435 | "Metric for redistributed routes\n" |
9436 | "Default metric\n") | |
9437 | { | |
cdc2d765 | 9438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9439 | int idx_ospf_table = 1; |
9440 | int idx_number = 2; | |
9441 | int idx_number_2 = 4; | |
7c8ff89e DS |
9442 | u_int32_t metric; |
9443 | struct bgp_redist *red; | |
9444 | u_short instance; | |
7a4bb9c5 | 9445 | int protocol; |
7c8ff89e | 9446 | |
c500ae40 | 9447 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9448 | protocol = ZEBRA_ROUTE_OSPF; |
9449 | else | |
9450 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9451 | |
c500ae40 DW |
9452 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9453 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9454 | |
cdc2d765 DL |
9455 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9456 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9457 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9458 | } |
9459 | ||
9460 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9461 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9462 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9463 | "Redistribute information from another routing protocol\n" |
9464 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9465 | "Non-main Kernel Routing Table\n" |
9466 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9467 | "Route map reference\n" |
9468 | "Pointer to route-map entries\n" | |
9469 | "Metric for redistributed routes\n" | |
9470 | "Default metric\n") | |
9471 | { | |
cdc2d765 | 9472 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9473 | int idx_ospf_table = 1; |
9474 | int idx_number = 2; | |
9475 | int idx_word = 4; | |
9476 | int idx_number_2 = 6; | |
7c8ff89e DS |
9477 | u_int32_t metric; |
9478 | struct bgp_redist *red; | |
9479 | u_short instance; | |
7a4bb9c5 | 9480 | int protocol; |
7c8ff89e | 9481 | |
c500ae40 | 9482 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9483 | protocol = ZEBRA_ROUTE_OSPF; |
9484 | else | |
9485 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9486 | |
c500ae40 DW |
9487 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9488 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9489 | |
cdc2d765 | 9490 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9491 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9492 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9493 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9494 | } |
9495 | ||
9496 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9497 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9498 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9499 | "Redistribute information from another routing protocol\n" |
9500 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9501 | "Non-main Kernel Routing Table\n" |
9502 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9503 | "Metric for redistributed routes\n" |
9504 | "Default metric\n" | |
9505 | "Route map reference\n" | |
9506 | "Pointer to route-map entries\n") | |
9507 | { | |
cdc2d765 | 9508 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9509 | int idx_ospf_table = 1; |
9510 | int idx_number = 2; | |
9511 | int idx_number_2 = 4; | |
9512 | int idx_word = 6; | |
7c8ff89e DS |
9513 | u_int32_t metric; |
9514 | struct bgp_redist *red; | |
9515 | u_short instance; | |
7a4bb9c5 | 9516 | int protocol; |
7c8ff89e | 9517 | |
c500ae40 | 9518 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9519 | protocol = ZEBRA_ROUTE_OSPF; |
9520 | else | |
9521 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9522 | |
c500ae40 DW |
9523 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9524 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9525 | |
cdc2d765 DL |
9526 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9527 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9528 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9529 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9530 | } |
9531 | ||
9532 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9533 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9534 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9535 | NO_STR |
9536 | "Redistribute information from another routing protocol\n" | |
9537 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9538 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9539 | "Instance ID/Table ID\n" |
9540 | "Metric for redistributed routes\n" | |
9541 | "Default metric\n" | |
9542 | "Route map reference\n" | |
9543 | "Pointer to route-map entries\n") | |
7c8ff89e | 9544 | { |
cdc2d765 | 9545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9546 | int idx_ospf_table = 2; |
9547 | int idx_number = 3; | |
7c8ff89e | 9548 | u_short instance; |
7a4bb9c5 DS |
9549 | int protocol; |
9550 | ||
c500ae40 | 9551 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9552 | protocol = ZEBRA_ROUTE_OSPF; |
9553 | else | |
9554 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9555 | |
c500ae40 | 9556 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9557 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9558 | } |
9559 | ||
718e3744 | 9560 | DEFUN (no_bgp_redistribute_ipv4, |
9561 | no_bgp_redistribute_ipv4_cmd, | |
d04c479d | 9562 | "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9563 | NO_STR |
9564 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9565 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9566 | "Metric for redistributed routes\n" |
9567 | "Default metric\n" | |
9568 | "Route map reference\n" | |
9569 | "Pointer to route-map entries\n") | |
718e3744 | 9570 | { |
cdc2d765 | 9571 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9572 | int idx_protocol = 2; |
718e3744 | 9573 | int type; |
9574 | ||
6d681bd8 QY |
9575 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9576 | if (type < 0) | |
718e3744 | 9577 | { |
9578 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9579 | return CMD_WARNING; | |
9580 | } | |
cdc2d765 | 9581 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9582 | } |
9583 | ||
718e3744 | 9584 | DEFUN (bgp_redistribute_ipv6, |
9585 | bgp_redistribute_ipv6_cmd, | |
9ccf14f7 | 9586 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table>", |
718e3744 | 9587 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9588 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9589 | { |
cdc2d765 | 9590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9591 | int idx_protocol = 1; |
718e3744 | 9592 | int type; |
9593 | ||
6d681bd8 QY |
9594 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9595 | if (type < 0) | |
718e3744 | 9596 | { |
9597 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9598 | return CMD_WARNING; | |
9599 | } | |
9600 | ||
cdc2d765 DL |
9601 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9602 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9603 | } |
9604 | ||
9605 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9606 | bgp_redistribute_ipv6_rmap_cmd, | |
9ccf14f7 | 9607 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD", |
718e3744 | 9608 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9609 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9610 | "Route map reference\n" |
9611 | "Pointer to route-map entries\n") | |
9612 | { | |
cdc2d765 | 9613 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9614 | int idx_protocol = 1; |
9615 | int idx_word = 3; | |
718e3744 | 9616 | int type; |
7c8ff89e | 9617 | struct bgp_redist *red; |
718e3744 | 9618 | |
6d681bd8 QY |
9619 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9620 | if (type < 0) | |
718e3744 | 9621 | { |
9622 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9623 | return CMD_WARNING; | |
9624 | } | |
9625 | ||
cdc2d765 | 9626 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9627 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9628 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9629 | } |
9630 | ||
9631 | DEFUN (bgp_redistribute_ipv6_metric, | |
9632 | bgp_redistribute_ipv6_metric_cmd, | |
9ccf14f7 | 9633 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)", |
718e3744 | 9634 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9635 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9636 | "Metric for redistributed routes\n" |
9637 | "Default metric\n") | |
9638 | { | |
cdc2d765 | 9639 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9640 | int idx_protocol = 1; |
9641 | int idx_number = 3; | |
718e3744 | 9642 | int type; |
9643 | u_int32_t metric; | |
7c8ff89e | 9644 | struct bgp_redist *red; |
718e3744 | 9645 | |
6d681bd8 QY |
9646 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9647 | if (type < 0) | |
718e3744 | 9648 | { |
9649 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9650 | return CMD_WARNING; | |
9651 | } | |
c500ae40 | 9652 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9653 | |
cdc2d765 DL |
9654 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9655 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9656 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9657 | } |
9658 | ||
9659 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9660 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
9ccf14f7 | 9661 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9662 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9663 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9664 | "Route map reference\n" |
9665 | "Pointer to route-map entries\n" | |
9666 | "Metric for redistributed routes\n" | |
9667 | "Default metric\n") | |
9668 | { | |
cdc2d765 | 9669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9670 | int idx_protocol = 1; |
9671 | int idx_word = 3; | |
9672 | int idx_number = 5; | |
718e3744 | 9673 | int type; |
9674 | u_int32_t metric; | |
7c8ff89e | 9675 | struct bgp_redist *red; |
718e3744 | 9676 | |
6d681bd8 QY |
9677 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9678 | if (type < 0) | |
718e3744 | 9679 | { |
9680 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9681 | return CMD_WARNING; | |
9682 | } | |
c500ae40 | 9683 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9684 | |
cdc2d765 | 9685 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9686 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9687 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9688 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9689 | } |
9690 | ||
9691 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9692 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
9ccf14f7 | 9693 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9694 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9695 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9696 | "Metric for redistributed routes\n" |
9697 | "Default metric\n" | |
9698 | "Route map reference\n" | |
9699 | "Pointer to route-map entries\n") | |
9700 | { | |
cdc2d765 | 9701 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9702 | int idx_protocol = 1; |
9703 | int idx_number = 3; | |
9704 | int idx_word = 5; | |
718e3744 | 9705 | int type; |
9706 | u_int32_t metric; | |
7c8ff89e | 9707 | struct bgp_redist *red; |
718e3744 | 9708 | |
6d681bd8 QY |
9709 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9710 | if (type < 0) | |
718e3744 | 9711 | { |
9712 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9713 | return CMD_WARNING; | |
9714 | } | |
c500ae40 | 9715 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9716 | |
cdc2d765 DL |
9717 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9718 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 9719 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9720 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9721 | } |
9722 | ||
9723 | DEFUN (no_bgp_redistribute_ipv6, | |
9724 | no_bgp_redistribute_ipv6_cmd, | |
d04c479d | 9725 | "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9726 | NO_STR |
9727 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9728 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
9729 | "Metric for redistributed routes\n" |
9730 | "Default metric\n" | |
9731 | "Route map reference\n" | |
9732 | "Pointer to route-map entries\n") | |
718e3744 | 9733 | { |
cdc2d765 | 9734 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9735 | int idx_protocol = 2; |
718e3744 | 9736 | int type; |
9737 | ||
6d681bd8 QY |
9738 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9739 | if (type < 0) | |
718e3744 | 9740 | { |
9741 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9742 | return CMD_WARNING; | |
9743 | } | |
9744 | ||
cdc2d765 | 9745 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 9746 | } |
6b0655a2 | 9747 | |
718e3744 | 9748 | int |
9749 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
9750 | safi_t safi, int *write) | |
9751 | { | |
9752 | int i; | |
718e3744 | 9753 | |
9754 | /* Unicast redistribution only. */ | |
9755 | if (safi != SAFI_UNICAST) | |
9756 | return 0; | |
9757 | ||
9758 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
9759 | { | |
9760 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 9761 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 9762 | { |
7c8ff89e DS |
9763 | struct list *red_list; |
9764 | struct listnode *node; | |
9765 | struct bgp_redist *red; | |
718e3744 | 9766 | |
7c8ff89e DS |
9767 | red_list = bgp->redist[afi][i]; |
9768 | if (!red_list) | |
9769 | continue; | |
718e3744 | 9770 | |
7c8ff89e DS |
9771 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
9772 | { | |
9773 | /* Display "address-family" when it is not yet diplayed. */ | |
9774 | bgp_config_write_family_header (vty, afi, safi, write); | |
9775 | ||
9776 | /* "redistribute" configuration. */ | |
0b960b4d | 9777 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
9778 | if (red->instance) |
9779 | vty_out (vty, " %d", red->instance); | |
9780 | if (red->redist_metric_flag) | |
9781 | vty_out (vty, " metric %u", red->redist_metric); | |
9782 | if (red->rmap.name) | |
9783 | vty_out (vty, " route-map %s", red->rmap.name); | |
9784 | vty_out (vty, "%s", VTY_NEWLINE); | |
9785 | } | |
718e3744 | 9786 | } |
9787 | } | |
9788 | return *write; | |
9789 | } | |
6b0655a2 | 9790 | |
718e3744 | 9791 | /* BGP node structure. */ |
7fc626de | 9792 | static struct cmd_node bgp_node = |
718e3744 | 9793 | { |
9794 | BGP_NODE, | |
9795 | "%s(config-router)# ", | |
9796 | 1, | |
9797 | }; | |
9798 | ||
7fc626de | 9799 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 9800 | { |
9801 | BGP_IPV4_NODE, | |
9802 | "%s(config-router-af)# ", | |
9803 | 1, | |
9804 | }; | |
9805 | ||
7fc626de | 9806 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 9807 | { |
9808 | BGP_IPV4M_NODE, | |
9809 | "%s(config-router-af)# ", | |
9810 | 1, | |
9811 | }; | |
9812 | ||
7fc626de | 9813 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 9814 | { |
9815 | BGP_IPV6_NODE, | |
9816 | "%s(config-router-af)# ", | |
9817 | 1, | |
9818 | }; | |
9819 | ||
7fc626de | 9820 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 9821 | { |
9822 | BGP_IPV6M_NODE, | |
9823 | "%s(config-router-af)# ", | |
9824 | 1, | |
9825 | }; | |
9826 | ||
7fc626de | 9827 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 9828 | { |
9829 | BGP_VPNV4_NODE, | |
9830 | "%s(config-router-af)# ", | |
9831 | 1 | |
9832 | }; | |
6b0655a2 | 9833 | |
8ecd3266 | 9834 | static struct cmd_node bgp_vpnv6_node = |
9835 | { | |
9836 | BGP_VPNV6_NODE, | |
9837 | "%s(config-router-af-vpnv6)# ", | |
9838 | 1 | |
9839 | }; | |
9840 | ||
8b1fb8be LB |
9841 | static struct cmd_node bgp_encap_node = |
9842 | { | |
9843 | BGP_ENCAP_NODE, | |
9844 | "%s(config-router-af-encap)# ", | |
9845 | 1 | |
9846 | }; | |
9847 | ||
9848 | static struct cmd_node bgp_encapv6_node = | |
9849 | { | |
9850 | BGP_ENCAPV6_NODE, | |
9851 | "%s(config-router-af-encapv6)# ", | |
9852 | 1 | |
9853 | }; | |
9854 | ||
1f8ae70b | 9855 | static void community_list_vty (void); |
9856 | ||
718e3744 | 9857 | void |
94f2b392 | 9858 | bgp_vty_init (void) |
718e3744 | 9859 | { |
718e3744 | 9860 | /* Install bgp top node. */ |
9861 | install_node (&bgp_node, bgp_config_write); | |
9862 | install_node (&bgp_ipv4_unicast_node, NULL); | |
9863 | install_node (&bgp_ipv4_multicast_node, NULL); | |
9864 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 9865 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 9866 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 9867 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
9868 | install_node (&bgp_encap_node, NULL); |
9869 | install_node (&bgp_encapv6_node, NULL); | |
718e3744 | 9870 | |
9871 | /* Install default VTY commands to new nodes. */ | |
9872 | install_default (BGP_NODE); | |
9873 | install_default (BGP_IPV4_NODE); | |
9874 | install_default (BGP_IPV4M_NODE); | |
9875 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 9876 | install_default (BGP_IPV6M_NODE); |
718e3744 | 9877 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 9878 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
9879 | install_default (BGP_ENCAP_NODE); |
9880 | install_default (BGP_ENCAPV6_NODE); | |
e52702f2 | 9881 | |
718e3744 | 9882 | /* "bgp multiple-instance" commands. */ |
9883 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
9884 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
9885 | ||
9886 | /* "bgp config-type" commands. */ | |
9887 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 9888 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 9889 | |
5fe9f963 | 9890 | /* bgp route-map delay-timer commands. */ |
9891 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
9892 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 9893 | |
718e3744 | 9894 | /* Dummy commands (Currently not supported) */ |
9895 | install_element (BGP_NODE, &no_synchronization_cmd); | |
9896 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
9897 | ||
9898 | /* "router bgp" commands. */ | |
9899 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 9900 | |
9901 | /* "no router bgp" commands. */ | |
9902 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 9903 | |
9904 | /* "bgp router-id" commands. */ | |
9905 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
9906 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 9907 | |
9908 | /* "bgp cluster-id" commands. */ | |
9909 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 9910 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 9911 | |
9912 | /* "bgp confederation" commands. */ | |
9913 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
9914 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 9915 | |
9916 | /* "bgp confederation peers" commands. */ | |
9917 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
9918 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
9919 | ||
abc920f8 DS |
9920 | /* bgp max-med command */ |
9921 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
9922 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
9923 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
9924 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
9925 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 9926 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 9927 | |
907f92c8 DS |
9928 | /* bgp disable-ebgp-connected-nh-check */ |
9929 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
9930 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
9931 | ||
f188f2c4 DS |
9932 | /* bgp update-delay command */ |
9933 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
9934 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
9935 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 9936 | |
cb1faec9 DS |
9937 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
9938 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
9939 | ||
3f9c7369 DS |
9940 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
9941 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
9942 | ||
165b5fff JB |
9943 | /* "maximum-paths" commands. */ |
9944 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
9945 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
9946 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
9947 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
9948 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
9949 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 9950 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9951 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9952 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9953 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9954 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9955 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 9956 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9957 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 9958 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9959 | |
718e3744 | 9960 | /* "timers bgp" commands. */ |
9961 | install_element (BGP_NODE, &bgp_timers_cmd); | |
9962 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 9963 | |
5fe9f963 | 9964 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
9965 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
9966 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
9967 | ||
718e3744 | 9968 | /* "bgp client-to-client reflection" commands */ |
9969 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
9970 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
9971 | ||
9972 | /* "bgp always-compare-med" commands */ | |
9973 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
9974 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 9975 | |
718e3744 | 9976 | /* "bgp deterministic-med" commands */ |
9977 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
9978 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 9979 | |
538621f2 | 9980 | /* "bgp graceful-restart" commands */ |
9981 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
9982 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 9983 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
9984 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
9985 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
9986 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 9987 | |
43fc21b3 JC |
9988 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
9989 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
9990 | ||
718e3744 | 9991 | /* "bgp fast-external-failover" commands */ |
9992 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
9993 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
9994 | ||
9995 | /* "bgp enforce-first-as" commands */ | |
9996 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
9997 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
9998 | ||
9999 | /* "bgp bestpath compare-routerid" commands */ | |
10000 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
10001 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
10002 | ||
10003 | /* "bgp bestpath as-path ignore" commands */ | |
10004 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
10005 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
10006 | ||
6811845b | 10007 | /* "bgp bestpath as-path confed" commands */ |
10008 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
10009 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
10010 | ||
2fdd455c PM |
10011 | /* "bgp bestpath as-path multipath-relax" commands */ |
10012 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
10013 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
10014 | ||
848973c7 | 10015 | /* "bgp log-neighbor-changes" commands */ |
10016 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
10017 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
10018 | ||
718e3744 | 10019 | /* "bgp bestpath med" commands */ |
10020 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 10021 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 10022 | |
10023 | /* "no bgp default ipv4-unicast" commands. */ | |
10024 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
10025 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 10026 | |
718e3744 | 10027 | /* "bgp network import-check" commands. */ |
10028 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10029 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10030 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10031 | ||
10032 | /* "bgp default local-preference" commands. */ | |
10033 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10034 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10035 | |
04b6bdc0 DW |
10036 | /* bgp default show-hostname */ |
10037 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10038 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10039 | ||
3f9c7369 DS |
10040 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10041 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10042 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10043 | ||
8bd9d948 DS |
10044 | /* bgp ibgp-allow-policy-mods command */ |
10045 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10046 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10047 | ||
f14e6fdb DS |
10048 | /* "bgp listen limit" commands. */ |
10049 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10050 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10051 | ||
10052 | /* "bgp listen range" commands. */ | |
10053 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10054 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10055 | ||
718e3744 | 10056 | /* "neighbor remote-as" commands. */ |
10057 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10058 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10059 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10060 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10061 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10062 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10063 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10064 | |
10065 | /* "neighbor peer-group" commands. */ | |
10066 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10067 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10068 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10069 | |
10070 | /* "neighbor local-as" commands. */ | |
10071 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10072 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10073 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10074 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10075 | |
3f9c7369 DS |
10076 | /* "neighbor solo" commands. */ |
10077 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10078 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10079 | ||
0df7c91f PJ |
10080 | /* "neighbor password" commands. */ |
10081 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10082 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10083 | ||
718e3744 | 10084 | /* "neighbor activate" commands. */ |
10085 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10086 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10087 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10088 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10089 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10090 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10091 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10092 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10093 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
718e3744 | 10094 | |
10095 | /* "no neighbor activate" commands. */ | |
10096 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10097 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10098 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10099 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10100 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10101 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10102 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10103 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10104 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
718e3744 | 10105 | |
c8560b44 DW |
10106 | /* "neighbor peer-group" set commands. |
10107 | * Long term we should only accept this command under BGP_NODE and not all of | |
10108 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10109 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10110 | * to their peer-group under each address-family sub-context. | |
10111 | */ | |
718e3744 | 10112 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10113 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10114 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10115 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10116 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10117 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10118 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10119 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10120 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10121 | |
718e3744 | 10122 | /* "no neighbor peer-group unset" commands. */ |
10123 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10124 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10125 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10126 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10127 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10128 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10129 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10130 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10131 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10132 | |
718e3744 | 10133 | /* "neighbor softreconfiguration inbound" commands.*/ |
10134 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10135 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10136 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10137 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10138 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10139 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10140 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10141 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10142 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10143 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10144 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10145 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10146 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10147 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10148 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10149 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10150 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10151 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10152 | |
10153 | /* "neighbor attribute-unchanged" commands. */ | |
10154 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10155 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10156 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10157 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10158 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10159 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10160 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10161 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10162 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10163 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10164 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10165 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10166 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10167 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10168 | |
8b1fb8be | 10169 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10170 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10171 | |
10172 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10173 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10174 | |
fee0f4c6 | 10175 | /* "nexthop-local unchanged" commands */ |
10176 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10177 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10178 | ||
718e3744 | 10179 | /* "neighbor next-hop-self" commands. */ |
10180 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10181 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10182 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10183 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10184 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10185 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10186 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10187 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10188 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10189 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10190 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10191 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10192 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10193 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10194 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10195 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10196 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10197 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10198 | |
a538debe DS |
10199 | /* "neighbor next-hop-self force" commands. */ |
10200 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10201 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10202 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10203 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10204 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10205 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10206 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10207 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10208 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10209 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10210 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10211 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10212 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10213 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10214 | |
c7122e14 DS |
10215 | /* "neighbor as-override" commands. */ |
10216 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10217 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10218 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10219 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10220 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10221 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10222 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10223 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10224 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10225 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10226 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10227 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10228 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10229 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10230 | |
718e3744 | 10231 | /* "neighbor remove-private-AS" commands. */ |
10232 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10233 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10234 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10235 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10236 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10237 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10238 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10239 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10240 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10241 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10242 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10243 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10244 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10245 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10246 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10247 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10248 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10249 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10250 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10251 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10252 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10253 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10254 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10255 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10256 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10257 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10258 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10259 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10260 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10261 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10262 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10263 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10264 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10265 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10266 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10267 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10268 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10269 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10270 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10271 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10272 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10273 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10274 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10275 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10276 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10277 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10278 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10279 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10280 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10281 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10282 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10283 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10284 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10285 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10286 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10287 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10288 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10289 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10290 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10291 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10292 | |
10293 | /* "neighbor send-community" commands.*/ | |
10294 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10295 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10296 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10297 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10298 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10299 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10300 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10301 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10302 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10303 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10304 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10305 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10306 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10307 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10308 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10309 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10310 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10311 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10312 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10313 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10314 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10315 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10316 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10317 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10318 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10319 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10320 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10321 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10322 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10323 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10324 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10325 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10326 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10327 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10328 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10329 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10330 | |
10331 | /* "neighbor route-reflector" commands.*/ | |
10332 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10333 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10334 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10335 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10336 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10337 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10338 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10339 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10340 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10341 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10342 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10343 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10344 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10345 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10346 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10347 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10348 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10349 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10350 | |
10351 | /* "neighbor route-server" commands.*/ | |
10352 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10353 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10354 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10355 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10356 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10357 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10358 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10359 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10360 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10361 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10362 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10363 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10364 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10365 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10366 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10367 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10368 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10369 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10370 | |
adbac85e DW |
10371 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10372 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10373 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10374 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10375 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10376 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10377 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10378 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10379 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10380 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10381 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10382 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10383 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10384 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10385 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10386 | |
06370dac DW |
10387 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10388 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10389 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10390 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10391 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10392 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10393 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10394 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10395 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10396 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10397 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10398 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10399 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10400 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10401 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10402 | |
718e3744 | 10403 | /* "neighbor passive" commands. */ |
10404 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10405 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10406 | ||
d5a5c8f0 | 10407 | |
718e3744 | 10408 | /* "neighbor shutdown" commands. */ |
10409 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10410 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
10411 | ||
8a92a8a0 DS |
10412 | /* "neighbor capability extended-nexthop" commands.*/ |
10413 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10414 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10415 | ||
718e3744 | 10416 | /* "neighbor capability orf prefix-list" commands.*/ |
10417 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10418 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10419 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10420 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10421 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10422 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10423 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10424 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10425 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10426 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10427 | |
10428 | /* "neighbor capability dynamic" commands.*/ | |
10429 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10430 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10431 | ||
10432 | /* "neighbor dont-capability-negotiate" commands. */ | |
10433 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10434 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10435 | ||
10436 | /* "neighbor ebgp-multihop" commands. */ | |
10437 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10438 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10439 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10440 | |
6ffd2079 | 10441 | /* "neighbor disable-connected-check" commands. */ |
10442 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10443 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10444 | |
10445 | /* "neighbor description" commands. */ | |
10446 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10447 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10448 | |
10449 | /* "neighbor update-source" commands. "*/ | |
10450 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10451 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10452 | ||
10453 | /* "neighbor default-originate" commands. */ | |
10454 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10455 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10456 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10457 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10458 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10459 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10460 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10461 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10462 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10463 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10464 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10465 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10466 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10467 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10468 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10469 | |
10470 | /* "neighbor port" commands. */ | |
10471 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10472 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10473 | |
10474 | /* "neighbor weight" commands. */ | |
10475 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10476 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10477 | |
d93f7ffc DW |
10478 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10479 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10480 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10481 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10482 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10483 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10484 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10485 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10486 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10487 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10488 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10489 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10490 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10491 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10492 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10493 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10494 | |
10495 | /* "neighbor override-capability" commands. */ | |
10496 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10497 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10498 | ||
10499 | /* "neighbor strict-capability-match" commands. */ | |
10500 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10501 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10502 | ||
10503 | /* "neighbor timers" commands. */ | |
10504 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10505 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10506 | ||
10507 | /* "neighbor timers connect" commands. */ | |
10508 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10509 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10510 | |
10511 | /* "neighbor advertisement-interval" commands. */ | |
10512 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10513 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10514 | |
718e3744 | 10515 | /* "neighbor interface" commands. */ |
10516 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10517 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10518 | ||
10519 | /* "neighbor distribute" commands. */ | |
10520 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10521 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10522 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10523 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10524 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10525 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10526 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10527 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10528 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10529 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10530 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10531 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10532 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10533 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10534 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10535 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10536 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10537 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10538 | |
10539 | /* "neighbor prefix-list" commands. */ | |
10540 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10541 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10542 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10543 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10544 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10545 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10546 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10547 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10548 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10549 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10550 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10551 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10552 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10553 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10554 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10555 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10556 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10557 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10558 | |
10559 | /* "neighbor filter-list" commands. */ | |
10560 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10561 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10562 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10563 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10564 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10565 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10566 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10567 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10568 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10569 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10570 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10571 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10572 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10573 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10574 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10575 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10576 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10577 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10578 | |
10579 | /* "neighbor route-map" commands. */ | |
10580 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10581 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10582 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10583 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10584 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10585 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10586 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10587 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10588 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10589 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10590 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10591 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10592 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10593 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10594 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10595 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10596 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10597 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10598 | |
10599 | /* "neighbor unsuppress-map" commands. */ | |
10600 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10601 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10602 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10603 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10604 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10605 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10606 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10607 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10608 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10609 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10610 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10611 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10612 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10613 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10614 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10615 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10616 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10617 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10618 | |
10619 | /* "neighbor maximum-prefix" commands. */ | |
10620 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10621 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10622 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10623 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10624 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10625 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10626 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10627 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10628 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10629 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10630 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10631 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10632 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10633 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10634 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10635 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10636 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10637 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10638 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10639 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10640 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10641 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10642 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10643 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10644 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10645 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10646 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10647 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10648 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10649 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10650 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10651 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10652 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10653 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10654 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10655 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10656 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10657 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10658 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10659 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10660 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10661 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10662 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10663 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10664 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10665 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10666 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10667 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10668 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10669 | |
8b1fb8be LB |
10670 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10671 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10672 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10673 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10674 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10675 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10676 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10677 | |
10678 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10679 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10680 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10681 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10682 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10683 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10684 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10685 | |
718e3744 | 10686 | /* "neighbor allowas-in" */ |
10687 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10688 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10689 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10690 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10691 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10692 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10693 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10694 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10695 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10696 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10697 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10698 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10699 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10700 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10701 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10702 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10703 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10704 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10705 | |
10706 | /* address-family commands. */ | |
10707 | install_element (BGP_NODE, &address_family_ipv4_cmd); | |
10708 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); | |
718e3744 | 10709 | install_element (BGP_NODE, &address_family_ipv6_cmd); |
25ffbdc1 | 10710 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
d6902373 | 10711 | #ifdef KEEP_OLD_VPN_COMMANDS |
718e3744 | 10712 | install_element (BGP_NODE, &address_family_vpnv4_cmd); |
8b1fb8be | 10713 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
d6902373 PG |
10714 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
10715 | install_element (BGP_NODE, &address_family_ipv4_vpn_cmd); | |
10716 | install_element (BGP_NODE, &address_family_ipv6_vpn_cmd); | |
8b1fb8be LB |
10717 | |
10718 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be | 10719 | install_element (BGP_NODE, &address_family_encapv6_cmd); |
8b1fb8be | 10720 | |
718e3744 | 10721 | /* "exit-address-family" command. */ |
10722 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10723 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10724 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10725 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10726 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10727 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10728 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10729 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
718e3744 | 10730 | |
10731 | /* "clear ip bgp commands" */ | |
10732 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 10733 | |
8ad7271d DS |
10734 | /* clear ip bgp prefix */ |
10735 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
10736 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 10737 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 10738 | |
716b2d8a | 10739 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 10740 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 10741 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 10742 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 10743 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 10744 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 10745 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 10746 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 10747 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 10748 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
10749 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
10750 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
10751 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
10752 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
10753 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
10754 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 10755 | |
716b2d8a | 10756 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10757 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 10758 | |
716b2d8a | 10759 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 10760 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 10761 | |
716b2d8a | 10762 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 10763 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 10764 | |
716b2d8a | 10765 | /* "show [ip] bgp community" commands. */ |
718e3744 | 10766 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 10767 | |
716b2d8a | 10768 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 10769 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 10770 | |
10771 | /* "redistribute" commands. */ | |
10772 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
10773 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10774 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 10775 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 10776 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10777 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
10778 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10779 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10780 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 10781 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 10782 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 10783 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
10784 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
10785 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10786 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 10787 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
10788 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10789 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
10790 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10791 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10792 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 10793 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 10794 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 10795 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 10796 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); |
10797 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
10798 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 10799 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 10800 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
10801 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 10802 | |
fa411a21 NH |
10803 | /* ttl_security commands */ |
10804 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
10805 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
10806 | ||
716b2d8a | 10807 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 10808 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 10809 | |
716b2d8a | 10810 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 10811 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 10812 | |
716b2d8a | 10813 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 10814 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 10815 | |
718e3744 | 10816 | /* Community-list. */ |
10817 | community_list_vty (); | |
10818 | } | |
6b0655a2 | 10819 | |
718e3744 | 10820 | #include "memory.h" |
10821 | #include "bgp_regex.h" | |
10822 | #include "bgp_clist.h" | |
10823 | #include "bgp_ecommunity.h" | |
10824 | ||
10825 | /* VTY functions. */ | |
10826 | ||
10827 | /* Direction value to string conversion. */ | |
94f2b392 | 10828 | static const char * |
718e3744 | 10829 | community_direct_str (int direct) |
10830 | { | |
10831 | switch (direct) | |
10832 | { | |
10833 | case COMMUNITY_DENY: | |
10834 | return "deny"; | |
718e3744 | 10835 | case COMMUNITY_PERMIT: |
10836 | return "permit"; | |
718e3744 | 10837 | default: |
10838 | return "unknown"; | |
718e3744 | 10839 | } |
10840 | } | |
10841 | ||
10842 | /* Display error string. */ | |
94f2b392 | 10843 | static void |
718e3744 | 10844 | community_list_perror (struct vty *vty, int ret) |
10845 | { | |
10846 | switch (ret) | |
10847 | { | |
10848 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 10849 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 10850 | break; |
10851 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
10852 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
10853 | break; | |
10854 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
10855 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
10856 | break; | |
10857 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
10858 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
10859 | break; | |
10860 | } | |
10861 | } | |
10862 | ||
5bf15956 DW |
10863 | /* "community-list" keyword help string. */ |
10864 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
10865 | ||
718e3744 | 10866 | |
5bf15956 | 10867 | /* ip community-list standard */ |
718e3744 | 10868 | DEFUN (ip_community_list_standard, |
10869 | ip_community_list_standard_cmd, | |
e961923c | 10870 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10871 | IP_STR |
10872 | COMMUNITY_LIST_STR | |
10873 | "Community list number (standard)\n" | |
5bf15956 | 10874 | "Add an standard community-list entry\n" |
718e3744 | 10875 | "Community list name\n" |
10876 | "Specify community to reject\n" | |
10877 | "Specify community to accept\n" | |
10878 | COMMUNITY_VAL_STR) | |
10879 | { | |
42f914d4 QY |
10880 | char *cl_name_or_number = NULL; |
10881 | int direct = 0; | |
10882 | int style = COMMUNITY_LIST_STANDARD; | |
10883 | ||
10884 | int idx = 0; | |
10885 | argv_find (argv, argc, "(1-99)", &idx); | |
10886 | argv_find (argv, argc, "WORD", &idx); | |
10887 | cl_name_or_number = argv[idx]->arg; | |
10888 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10889 | argv_find (argv, argc, "AA:NN", &idx); | |
10890 | char *str = argv_concat (argv, argc, idx); | |
10891 | ||
10892 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10893 | ||
10894 | XFREE (MTYPE_TMP, str); | |
10895 | ||
10896 | if (ret < 0) | |
10897 | { | |
10898 | /* Display error string. */ | |
10899 | community_list_perror (vty, ret); | |
10900 | return CMD_WARNING; | |
10901 | } | |
10902 | ||
10903 | return CMD_SUCCESS; | |
718e3744 | 10904 | } |
10905 | ||
fee6e4e4 | 10906 | DEFUN (no_ip_community_list_standard_all, |
10907 | no_ip_community_list_standard_all_cmd, | |
e961923c | 10908 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10909 | NO_STR |
10910 | IP_STR | |
10911 | COMMUNITY_LIST_STR | |
10912 | "Community list number (standard)\n" | |
5bf15956 DW |
10913 | "Add an standard community-list entry\n" |
10914 | "Community list name\n" | |
718e3744 | 10915 | "Specify community to reject\n" |
10916 | "Specify community to accept\n" | |
10917 | COMMUNITY_VAL_STR) | |
10918 | { | |
42f914d4 QY |
10919 | int delete_all = 0; |
10920 | ||
10921 | char *cl_name_or_number = NULL; | |
10922 | int direct = 0; | |
10923 | int style = COMMUNITY_LIST_STANDARD; | |
10924 | ||
10925 | int idx = 0; | |
10926 | argv_find (argv, argc, "(1-99)", &idx); | |
10927 | argv_find (argv, argc, "WORD", &idx); | |
10928 | cl_name_or_number = argv[idx]->arg; | |
10929 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10930 | argv_find (argv, argc, "AA:NN", &idx); | |
10931 | char *str = argv_concat (argv, argc, idx); | |
10932 | ||
10933 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10934 | ||
10935 | if (ret < 0) | |
10936 | { | |
10937 | community_list_perror (vty, ret); | |
10938 | return CMD_WARNING; | |
10939 | } | |
10940 | ||
10941 | return CMD_SUCCESS; | |
718e3744 | 10942 | } |
10943 | ||
5bf15956 DW |
10944 | /* ip community-list expanded */ |
10945 | DEFUN (ip_community_list_expanded_all, | |
10946 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 10947 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10948 | IP_STR |
10949 | COMMUNITY_LIST_STR | |
10950 | "Community list number (expanded)\n" | |
5bf15956 | 10951 | "Add an expanded community-list entry\n" |
718e3744 | 10952 | "Community list name\n" |
10953 | "Specify community to reject\n" | |
10954 | "Specify community to accept\n" | |
10955 | COMMUNITY_VAL_STR) | |
10956 | { | |
42f914d4 QY |
10957 | char *cl_name_or_number = NULL; |
10958 | int direct = 0; | |
10959 | int style = COMMUNITY_LIST_EXPANDED; | |
10960 | ||
10961 | int idx = 0; | |
10962 | argv_find (argv, argc, "(100-500)", &idx); | |
10963 | argv_find (argv, argc, "WORD", &idx); | |
10964 | cl_name_or_number = argv[idx]->arg; | |
10965 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10966 | argv_find (argv, argc, "AA:NN", &idx); | |
10967 | char *str = argv_concat (argv, argc, idx); | |
10968 | ||
10969 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10970 | ||
10971 | XFREE (MTYPE_TMP, str); | |
10972 | ||
10973 | if (ret < 0) | |
10974 | { | |
10975 | /* Display error string. */ | |
10976 | community_list_perror (vty, ret); | |
10977 | return CMD_WARNING; | |
10978 | } | |
10979 | ||
10980 | return CMD_SUCCESS; | |
718e3744 | 10981 | } |
10982 | ||
5bf15956 DW |
10983 | DEFUN (no_ip_community_list_expanded_all, |
10984 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 10985 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10986 | NO_STR |
10987 | IP_STR | |
10988 | COMMUNITY_LIST_STR | |
5bf15956 DW |
10989 | "Community list number (expanded)\n" |
10990 | "Add an expanded community-list entry\n" | |
718e3744 | 10991 | "Community list name\n" |
10992 | "Specify community to reject\n" | |
10993 | "Specify community to accept\n" | |
5bf15956 | 10994 | COMMUNITY_VAL_STR) |
718e3744 | 10995 | { |
42f914d4 QY |
10996 | int delete_all = 0; |
10997 | ||
10998 | char *cl_name_or_number = NULL; | |
10999 | int direct = 0; | |
11000 | int style = COMMUNITY_LIST_EXPANDED; | |
11001 | ||
11002 | int idx = 0; | |
11003 | argv_find (argv, argc, "(100-500)", &idx); | |
11004 | argv_find (argv, argc, "WORD", &idx); | |
11005 | cl_name_or_number = argv[idx]->arg; | |
11006 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11007 | argv_find (argv, argc, "AA:NN", &idx); | |
11008 | char *str = argv_concat (argv, argc, idx); | |
11009 | ||
11010 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
11011 | ||
11012 | if (ret < 0) | |
11013 | { | |
11014 | community_list_perror (vty, ret); | |
11015 | return CMD_WARNING; | |
11016 | } | |
11017 | ||
11018 | return CMD_SUCCESS; | |
718e3744 | 11019 | } |
11020 | ||
94f2b392 | 11021 | static void |
718e3744 | 11022 | community_list_show (struct vty *vty, struct community_list *list) |
11023 | { | |
11024 | struct community_entry *entry; | |
11025 | ||
11026 | for (entry = list->head; entry; entry = entry->next) | |
11027 | { | |
11028 | if (entry == list->head) | |
11029 | { | |
11030 | if (all_digit (list->name)) | |
11031 | vty_out (vty, "Community %s list %s%s", | |
11032 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11033 | "standard" : "(expanded) access", | |
11034 | list->name, VTY_NEWLINE); | |
11035 | else | |
11036 | vty_out (vty, "Named Community %s list %s%s", | |
11037 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11038 | "standard" : "expanded", | |
11039 | list->name, VTY_NEWLINE); | |
11040 | } | |
11041 | if (entry->any) | |
11042 | vty_out (vty, " %s%s", | |
11043 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11044 | else | |
11045 | vty_out (vty, " %s %s%s", | |
11046 | community_direct_str (entry->direct), | |
11047 | entry->style == COMMUNITY_LIST_STANDARD | |
11048 | ? community_str (entry->u.com) : entry->config, | |
11049 | VTY_NEWLINE); | |
11050 | } | |
11051 | } | |
11052 | ||
11053 | DEFUN (show_ip_community_list, | |
11054 | show_ip_community_list_cmd, | |
11055 | "show ip community-list", | |
11056 | SHOW_STR | |
11057 | IP_STR | |
11058 | "List community-list\n") | |
11059 | { | |
11060 | struct community_list *list; | |
11061 | struct community_list_master *cm; | |
11062 | ||
fee6e4e4 | 11063 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11064 | if (! cm) |
11065 | return CMD_SUCCESS; | |
11066 | ||
11067 | for (list = cm->num.head; list; list = list->next) | |
11068 | community_list_show (vty, list); | |
11069 | ||
11070 | for (list = cm->str.head; list; list = list->next) | |
11071 | community_list_show (vty, list); | |
11072 | ||
11073 | return CMD_SUCCESS; | |
11074 | } | |
11075 | ||
11076 | DEFUN (show_ip_community_list_arg, | |
11077 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11078 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11079 | SHOW_STR |
11080 | IP_STR | |
11081 | "List community-list\n" | |
11082 | "Community-list number\n" | |
11083 | "Community-list name\n") | |
11084 | { | |
c500ae40 | 11085 | int idx_comm_list = 3; |
718e3744 | 11086 | struct community_list *list; |
11087 | ||
c500ae40 | 11088 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11089 | if (! list) |
11090 | { | |
b729294c | 11091 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11092 | return CMD_WARNING; |
11093 | } | |
11094 | ||
11095 | community_list_show (vty, list); | |
11096 | ||
11097 | return CMD_SUCCESS; | |
11098 | } | |
6b0655a2 | 11099 | |
718e3744 | 11100 | /* "extcommunity-list" keyword help string. */ |
11101 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11102 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11103 | ||
11104 | DEFUN (ip_extcommunity_list_standard, | |
11105 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11106 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11107 | IP_STR |
11108 | EXTCOMMUNITY_LIST_STR | |
11109 | "Extended Community list number (standard)\n" | |
718e3744 | 11110 | "Specify standard extcommunity-list\n" |
5bf15956 | 11111 | "Community list name\n" |
718e3744 | 11112 | "Specify community to reject\n" |
11113 | "Specify community to accept\n" | |
11114 | EXTCOMMUNITY_VAL_STR) | |
11115 | { | |
42f914d4 QY |
11116 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11117 | int direct = 0; | |
11118 | char *cl_number_or_name = NULL; | |
11119 | ||
11120 | int idx = 0; | |
11121 | argv_find (argv, argc, "(1-99)", &idx); | |
11122 | argv_find (argv, argc, "WORD", &idx); | |
11123 | cl_number_or_name = argv[idx]->arg; | |
11124 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11125 | argv_find (argv, argc, "AA:NN", &idx); | |
11126 | char *str = argv_concat (argv, argc, idx); | |
11127 | ||
11128 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11129 | ||
11130 | XFREE (MTYPE_TMP, str); | |
11131 | ||
11132 | if (ret < 0) | |
11133 | { | |
11134 | community_list_perror (vty, ret); | |
11135 | return CMD_WARNING; | |
11136 | } | |
11137 | ||
11138 | return CMD_SUCCESS; | |
718e3744 | 11139 | } |
11140 | ||
718e3744 | 11141 | DEFUN (ip_extcommunity_list_name_expanded, |
11142 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11143 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11144 | IP_STR |
11145 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11146 | "Extended Community list number (expanded)\n" |
718e3744 | 11147 | "Specify expanded extcommunity-list\n" |
11148 | "Extended Community list name\n" | |
11149 | "Specify community to reject\n" | |
11150 | "Specify community to accept\n" | |
11151 | "An ordered list as a regular-expression\n") | |
11152 | { | |
42f914d4 QY |
11153 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11154 | int direct = 0; | |
11155 | char *cl_number_or_name = NULL; | |
11156 | ||
11157 | int idx = 0; | |
11158 | argv_find (argv, argc, "(100-500)", &idx); | |
11159 | argv_find (argv, argc, "WORD", &idx); | |
11160 | cl_number_or_name = argv[idx]->arg; | |
11161 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11162 | argv_find (argv, argc, "LINE", &idx); | |
11163 | char *str = argv_concat (argv, argc, idx); | |
11164 | ||
11165 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11166 | ||
11167 | XFREE (MTYPE_TMP, str); | |
11168 | ||
11169 | if (ret < 0) | |
11170 | { | |
11171 | community_list_perror (vty, ret); | |
11172 | return CMD_WARNING; | |
11173 | } | |
11174 | ||
11175 | return CMD_SUCCESS; | |
718e3744 | 11176 | } |
11177 | ||
fee6e4e4 | 11178 | DEFUN (no_ip_extcommunity_list_standard_all, |
11179 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11180 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11181 | NO_STR |
11182 | IP_STR | |
11183 | EXTCOMMUNITY_LIST_STR | |
11184 | "Extended Community list number (standard)\n" | |
718e3744 | 11185 | "Specify standard extcommunity-list\n" |
5bf15956 | 11186 | "Community list name\n" |
718e3744 | 11187 | "Specify community to reject\n" |
11188 | "Specify community to accept\n" | |
11189 | EXTCOMMUNITY_VAL_STR) | |
11190 | { | |
42f914d4 QY |
11191 | int deleteall = 0; |
11192 | ||
11193 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11194 | int direct = 0; | |
11195 | char *cl_number_or_name = NULL; | |
11196 | ||
11197 | int idx = 0; | |
11198 | argv_find (argv, argc, "(1-99)", &idx); | |
11199 | argv_find (argv, argc, "WORD", &idx); | |
11200 | cl_number_or_name = argv[idx]->arg; | |
11201 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11202 | argv_find (argv, argc, "AA:NN", &idx); | |
11203 | char *str = argv_concat (argv, argc, idx); | |
11204 | ||
11205 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11206 | ||
11207 | XFREE (MTYPE_TMP, str); | |
11208 | ||
11209 | if (ret < 0) | |
11210 | { | |
11211 | community_list_perror (vty, ret); | |
11212 | return CMD_WARNING; | |
11213 | } | |
11214 | ||
11215 | return CMD_SUCCESS; | |
718e3744 | 11216 | } |
11217 | ||
5bf15956 DW |
11218 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11219 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11220 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11221 | NO_STR |
11222 | IP_STR | |
11223 | EXTCOMMUNITY_LIST_STR | |
11224 | "Extended Community list number (expanded)\n" | |
718e3744 | 11225 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11226 | "Extended Community list name\n" |
718e3744 | 11227 | "Specify community to reject\n" |
11228 | "Specify community to accept\n" | |
11229 | "An ordered list as a regular-expression\n") | |
11230 | { | |
42f914d4 QY |
11231 | int deleteall = 0; |
11232 | ||
11233 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11234 | int direct = 0; | |
11235 | char *cl_number_or_name = NULL; | |
11236 | ||
11237 | int idx = 0; | |
11238 | argv_find (argv, argc, "(100-500)", &idx); | |
11239 | argv_find (argv, argc, "WORD", &idx); | |
11240 | cl_number_or_name = argv[idx]->arg; | |
11241 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11242 | argv_find (argv, argc, "LINE", &idx); | |
11243 | char *str = argv_concat (argv, argc, idx); | |
11244 | ||
11245 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11246 | ||
11247 | XFREE (MTYPE_TMP, str); | |
11248 | ||
11249 | if (ret < 0) | |
11250 | { | |
11251 | community_list_perror (vty, ret); | |
11252 | return CMD_WARNING; | |
11253 | } | |
11254 | ||
11255 | return CMD_SUCCESS; | |
718e3744 | 11256 | } |
11257 | ||
94f2b392 | 11258 | static void |
718e3744 | 11259 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11260 | { | |
11261 | struct community_entry *entry; | |
11262 | ||
11263 | for (entry = list->head; entry; entry = entry->next) | |
11264 | { | |
11265 | if (entry == list->head) | |
11266 | { | |
11267 | if (all_digit (list->name)) | |
11268 | vty_out (vty, "Extended community %s list %s%s", | |
11269 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11270 | "standard" : "(expanded) access", | |
11271 | list->name, VTY_NEWLINE); | |
11272 | else | |
11273 | vty_out (vty, "Named extended community %s list %s%s", | |
11274 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11275 | "standard" : "expanded", | |
11276 | list->name, VTY_NEWLINE); | |
11277 | } | |
11278 | if (entry->any) | |
11279 | vty_out (vty, " %s%s", | |
11280 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11281 | else | |
11282 | vty_out (vty, " %s %s%s", | |
11283 | community_direct_str (entry->direct), | |
11284 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11285 | entry->u.ecom->str : entry->config, | |
11286 | VTY_NEWLINE); | |
11287 | } | |
11288 | } | |
11289 | ||
11290 | DEFUN (show_ip_extcommunity_list, | |
11291 | show_ip_extcommunity_list_cmd, | |
11292 | "show ip extcommunity-list", | |
11293 | SHOW_STR | |
11294 | IP_STR | |
11295 | "List extended-community list\n") | |
11296 | { | |
11297 | struct community_list *list; | |
11298 | struct community_list_master *cm; | |
11299 | ||
fee6e4e4 | 11300 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11301 | if (! cm) |
11302 | return CMD_SUCCESS; | |
11303 | ||
11304 | for (list = cm->num.head; list; list = list->next) | |
11305 | extcommunity_list_show (vty, list); | |
11306 | ||
11307 | for (list = cm->str.head; list; list = list->next) | |
11308 | extcommunity_list_show (vty, list); | |
11309 | ||
11310 | return CMD_SUCCESS; | |
11311 | } | |
11312 | ||
11313 | DEFUN (show_ip_extcommunity_list_arg, | |
11314 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11315 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11316 | SHOW_STR |
11317 | IP_STR | |
11318 | "List extended-community list\n" | |
11319 | "Extcommunity-list number\n" | |
11320 | "Extcommunity-list name\n") | |
11321 | { | |
c500ae40 | 11322 | int idx_comm_list = 3; |
718e3744 | 11323 | struct community_list *list; |
11324 | ||
c500ae40 | 11325 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11326 | if (! list) |
11327 | { | |
b729294c | 11328 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11329 | return CMD_WARNING; |
11330 | } | |
11331 | ||
11332 | extcommunity_list_show (vty, list); | |
11333 | ||
11334 | return CMD_SUCCESS; | |
11335 | } | |
6b0655a2 | 11336 | |
718e3744 | 11337 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11338 | static const char * |
718e3744 | 11339 | community_list_config_str (struct community_entry *entry) |
11340 | { | |
fd79ac91 | 11341 | const char *str; |
718e3744 | 11342 | |
11343 | if (entry->any) | |
11344 | str = ""; | |
11345 | else | |
11346 | { | |
11347 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11348 | str = community_str (entry->u.com); | |
11349 | else | |
11350 | str = entry->config; | |
11351 | } | |
11352 | return str; | |
11353 | } | |
11354 | ||
11355 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11356 | static int |
718e3744 | 11357 | community_list_config_write (struct vty *vty) |
11358 | { | |
11359 | struct community_list *list; | |
11360 | struct community_entry *entry; | |
11361 | struct community_list_master *cm; | |
11362 | int write = 0; | |
11363 | ||
11364 | /* Community-list. */ | |
fee6e4e4 | 11365 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11366 | |
11367 | for (list = cm->num.head; list; list = list->next) | |
11368 | for (entry = list->head; entry; entry = entry->next) | |
11369 | { | |
fee6e4e4 | 11370 | vty_out (vty, "ip community-list %s %s %s%s", |
11371 | list->name, community_direct_str (entry->direct), | |
11372 | community_list_config_str (entry), | |
11373 | VTY_NEWLINE); | |
718e3744 | 11374 | write++; |
11375 | } | |
11376 | for (list = cm->str.head; list; list = list->next) | |
11377 | for (entry = list->head; entry; entry = entry->next) | |
11378 | { | |
11379 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11380 | entry->style == COMMUNITY_LIST_STANDARD | |
11381 | ? "standard" : "expanded", | |
11382 | list->name, community_direct_str (entry->direct), | |
11383 | community_list_config_str (entry), | |
11384 | VTY_NEWLINE); | |
11385 | write++; | |
11386 | } | |
11387 | ||
11388 | /* Extcommunity-list. */ | |
fee6e4e4 | 11389 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11390 | |
11391 | for (list = cm->num.head; list; list = list->next) | |
11392 | for (entry = list->head; entry; entry = entry->next) | |
11393 | { | |
fee6e4e4 | 11394 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
11395 | list->name, community_direct_str (entry->direct), | |
11396 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 11397 | write++; |
11398 | } | |
11399 | for (list = cm->str.head; list; list = list->next) | |
11400 | for (entry = list->head; entry; entry = entry->next) | |
11401 | { | |
11402 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
11403 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
11404 | ? "standard" : "expanded", | |
11405 | list->name, community_direct_str (entry->direct), | |
11406 | community_list_config_str (entry), VTY_NEWLINE); | |
11407 | write++; | |
11408 | } | |
11409 | return write; | |
11410 | } | |
11411 | ||
7fc626de | 11412 | static struct cmd_node community_list_node = |
718e3744 | 11413 | { |
11414 | COMMUNITY_LIST_NODE, | |
11415 | "", | |
11416 | 1 /* Export to vtysh. */ | |
11417 | }; | |
11418 | ||
94f2b392 | 11419 | static void |
11420 | community_list_vty (void) | |
718e3744 | 11421 | { |
11422 | install_node (&community_list_node, community_list_config_write); | |
11423 | ||
11424 | /* Community-list. */ | |
718e3744 | 11425 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 11426 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 11427 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
11428 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 11429 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
11430 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 11431 | |
11432 | /* Extcommunity-list. */ | |
11433 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 11434 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 11435 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
11436 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 11437 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
11438 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
5bf15956 | 11439 | } |