]>
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 | ||
8b1fb8be LB |
110 | int |
111 | bgp_parse_afi(const char *str, afi_t *afi) | |
112 | { | |
113 | if (!strcmp(str, "ipv4")) { | |
114 | *afi = AFI_IP; | |
115 | return 0; | |
116 | } | |
117 | #ifdef HAVE_IPV6 | |
118 | if (!strcmp(str, "ipv6")) { | |
119 | *afi = AFI_IP6; | |
120 | return 0; | |
121 | } | |
122 | #endif /* HAVE_IPV6 */ | |
123 | return -1; | |
124 | } | |
125 | ||
126 | int | |
127 | bgp_parse_safi(const char *str, safi_t *safi) | |
128 | { | |
129 | if (!strcmp(str, "encap")) { | |
130 | *safi = SAFI_ENCAP; | |
131 | return 0; | |
132 | } | |
133 | if (!strcmp(str, "multicast")) { | |
134 | *safi = SAFI_MULTICAST; | |
135 | return 0; | |
136 | } | |
137 | if (!strcmp(str, "unicast")) { | |
138 | *safi = SAFI_UNICAST; | |
139 | return 0; | |
140 | } | |
141 | if (!strcmp(str, "vpn")) { | |
142 | *safi = SAFI_MPLS_VPN; | |
143 | return 0; | |
144 | } | |
145 | return -1; | |
146 | } | |
147 | ||
94f2b392 | 148 | static int |
6aeb9e78 | 149 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 150 | { |
151 | struct interface *ifp = NULL; | |
152 | ||
153 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 154 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 155 | #ifdef HAVE_IPV6 |
156 | else if (su->sa.sa_family == AF_INET6) | |
f2345335 | 157 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 158 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 159 | #endif /* HAVE IPV6 */ |
160 | ||
161 | if (ifp) | |
162 | return 1; | |
163 | ||
164 | return 0; | |
165 | } | |
166 | ||
167 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
168 | /* This is used only for configuration, so disallow if attempted on |
169 | * a dynamic neighbor. | |
170 | */ | |
94f2b392 | 171 | static struct peer * |
fd79ac91 | 172 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 173 | { |
174 | int ret; | |
175 | struct bgp *bgp; | |
176 | union sockunion su; | |
177 | struct peer *peer; | |
178 | ||
179 | bgp = vty->index; | |
180 | ||
181 | ret = str2sockunion (ip_str, &su); | |
182 | if (ret < 0) | |
183 | { | |
a80beece DS |
184 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
185 | if (!peer) | |
186 | { | |
04b6bdc0 DW |
187 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
188 | { | |
189 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
190 | return NULL; | |
191 | } | |
a80beece | 192 | } |
718e3744 | 193 | } |
a80beece | 194 | else |
718e3744 | 195 | { |
a80beece DS |
196 | peer = peer_lookup (bgp, &su); |
197 | if (! peer) | |
198 | { | |
199 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
200 | VTY_NEWLINE); | |
201 | return NULL; | |
202 | } | |
f14e6fdb DS |
203 | if (peer_dynamic_neighbor (peer)) |
204 | { | |
205 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
206 | VTY_NEWLINE); | |
207 | return NULL; | |
208 | } | |
209 | ||
718e3744 | 210 | } |
211 | return peer; | |
212 | } | |
213 | ||
214 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
215 | /* This is used only for configuration, so disallow if attempted on |
216 | * a dynamic neighbor. | |
217 | */ | |
c43ed2e4 | 218 | struct peer * |
fd79ac91 | 219 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 220 | { |
221 | int ret; | |
222 | struct bgp *bgp; | |
223 | union sockunion su; | |
f14e6fdb DS |
224 | struct peer *peer = NULL; |
225 | struct peer_group *group = NULL; | |
718e3744 | 226 | |
227 | bgp = vty->index; | |
228 | ||
229 | ret = str2sockunion (peer_str, &su); | |
230 | if (ret == 0) | |
231 | { | |
f14e6fdb | 232 | /* IP address, locate peer. */ |
718e3744 | 233 | peer = peer_lookup (bgp, &su); |
718e3744 | 234 | } |
235 | else | |
236 | { | |
f14e6fdb | 237 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 238 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
239 | if (!peer) |
240 | group = peer_group_lookup (bgp, peer_str); | |
241 | } | |
a80beece | 242 | |
f14e6fdb DS |
243 | if (peer) |
244 | { | |
245 | if (peer_dynamic_neighbor (peer)) | |
246 | { | |
247 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
248 | VTY_NEWLINE); | |
249 | return NULL; | |
250 | } | |
251 | ||
252 | return peer; | |
718e3744 | 253 | } |
254 | ||
f14e6fdb DS |
255 | if (group) |
256 | return group->conf; | |
257 | ||
718e3744 | 258 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
259 | VTY_NEWLINE); | |
260 | ||
261 | return NULL; | |
262 | } | |
263 | ||
c43ed2e4 | 264 | int |
718e3744 | 265 | bgp_vty_return (struct vty *vty, int ret) |
266 | { | |
fd79ac91 | 267 | const char *str = NULL; |
718e3744 | 268 | |
269 | switch (ret) | |
270 | { | |
271 | case BGP_ERR_INVALID_VALUE: | |
272 | str = "Invalid value"; | |
273 | break; | |
274 | case BGP_ERR_INVALID_FLAG: | |
275 | str = "Invalid flag"; | |
276 | break; | |
718e3744 | 277 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
278 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
279 | break; | |
718e3744 | 280 | case BGP_ERR_PEER_FLAG_CONFLICT: |
281 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
282 | break; | |
718e3744 | 283 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
284 | str = "Specify remote-as or peer-group remote AS first"; | |
285 | break; | |
286 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
287 | str = "Cannot change the peer-group. Deconfigure first"; | |
288 | break; | |
289 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 290 | str = "Peer is not a member of this peer-group"; |
718e3744 | 291 | break; |
292 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
293 | str = "Prefix/distribute list can not co-exist"; | |
294 | break; | |
295 | case BGP_ERR_NOT_INTERNAL_PEER: | |
296 | str = "Invalid command. Not an internal neighbor"; | |
297 | break; | |
298 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 299 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 300 | break; |
301 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
302 | str = "Local-AS allowed only for EBGP peers"; | |
303 | break; | |
304 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
305 | str = "Cannot have local-as same as BGP AS number"; | |
306 | break; | |
0df7c91f PJ |
307 | case BGP_ERR_TCPSIG_FAILED: |
308 | str = "Error while applying TCP-Sig to session(s)"; | |
309 | break; | |
fa411a21 NH |
310 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
311 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
312 | break; | |
f5a4827d SH |
313 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
314 | str = "ttl-security only allowed for EBGP peers"; | |
315 | break; | |
c7122e14 DS |
316 | case BGP_ERR_AS_OVERRIDE: |
317 | str = "as-override cannot be configured for IBGP peers"; | |
318 | break; | |
f14e6fdb DS |
319 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
320 | str = "Invalid limit for number of dynamic neighbors"; | |
321 | break; | |
322 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
323 | str = "Dynamic neighbor listen range already exists"; | |
324 | break; | |
325 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
326 | str = "Operation not allowed on a dynamic neighbor"; | |
327 | break; | |
63fa10b5 QY |
328 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
329 | str = "Operation not allowed on a directly connected neighbor"; | |
330 | break; | |
718e3744 | 331 | } |
332 | if (str) | |
333 | { | |
334 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
335 | return CMD_WARNING; | |
336 | } | |
337 | return CMD_SUCCESS; | |
338 | } | |
339 | ||
7aafcaca DS |
340 | /* BGP clear sort. */ |
341 | enum clear_sort | |
342 | { | |
343 | clear_all, | |
344 | clear_peer, | |
345 | clear_group, | |
346 | clear_external, | |
347 | clear_as | |
348 | }; | |
349 | ||
7aafcaca DS |
350 | static void |
351 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
352 | safi_t safi, int error) | |
353 | { | |
354 | switch (error) | |
355 | { | |
356 | case BGP_ERR_AF_UNCONFIGURED: | |
357 | vty_out (vty, | |
358 | "%%BGP: Enable %s %s address family for the neighbor %s%s", | |
359 | afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4", | |
360 | safi == SAFI_MULTICAST ? "Multicast" : "Unicast", | |
361 | peer->host, VTY_NEWLINE); | |
362 | break; | |
363 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
364 | 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); | |
365 | break; | |
366 | default: | |
367 | break; | |
368 | } | |
369 | } | |
370 | ||
371 | /* `clear ip bgp' functions. */ | |
372 | static int | |
373 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
374 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
375 | { | |
376 | int ret; | |
377 | struct peer *peer; | |
378 | struct listnode *node, *nnode; | |
379 | ||
380 | /* Clear all neighbors. */ | |
381 | /* | |
382 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
383 | * on the BGP instance as that may get freed if it is a doppelganger | |
384 | */ | |
385 | if (sort == clear_all) | |
386 | { | |
387 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
388 | { | |
389 | if (stype == BGP_CLEAR_SOFT_NONE) | |
390 | ret = peer_clear (peer, &nnode); | |
391 | else if (peer->afc[afi][safi]) | |
392 | ret = peer_clear_soft (peer, afi, safi, stype); | |
393 | else | |
394 | ret = 0; | |
395 | ||
396 | if (ret < 0) | |
397 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
398 | } | |
399 | ||
400 | /* This is to apply read-only mode on this clear. */ | |
401 | if (stype == BGP_CLEAR_SOFT_NONE) | |
402 | bgp->update_delay_over = 0; | |
403 | ||
404 | return CMD_SUCCESS; | |
405 | } | |
406 | ||
407 | /* Clear specified neighbors. */ | |
408 | if (sort == clear_peer) | |
409 | { | |
410 | union sockunion su; | |
411 | int ret; | |
412 | ||
413 | /* Make sockunion for lookup. */ | |
414 | ret = str2sockunion (arg, &su); | |
415 | if (ret < 0) | |
416 | { | |
417 | peer = peer_lookup_by_conf_if (bgp, arg); | |
418 | if (!peer) | |
419 | { | |
04b6bdc0 DW |
420 | peer = peer_lookup_by_hostname(bgp, arg); |
421 | if (!peer) | |
422 | { | |
423 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
424 | return CMD_WARNING; | |
425 | } | |
7aafcaca DS |
426 | } |
427 | } | |
428 | else | |
429 | { | |
430 | peer = peer_lookup (bgp, &su); | |
431 | if (! peer) | |
432 | { | |
433 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
434 | return CMD_WARNING; | |
435 | } | |
436 | } | |
437 | ||
438 | if (stype == BGP_CLEAR_SOFT_NONE) | |
439 | ret = peer_clear (peer, NULL); | |
440 | else | |
441 | ret = peer_clear_soft (peer, afi, safi, stype); | |
442 | ||
443 | if (ret < 0) | |
444 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
445 | ||
446 | return CMD_SUCCESS; | |
447 | } | |
448 | ||
449 | /* Clear all peer-group members. */ | |
450 | if (sort == clear_group) | |
451 | { | |
452 | struct peer_group *group; | |
453 | ||
454 | group = peer_group_lookup (bgp, arg); | |
455 | if (! group) | |
456 | { | |
457 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
458 | return CMD_WARNING; | |
459 | } | |
460 | ||
461 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
462 | { | |
463 | if (stype == BGP_CLEAR_SOFT_NONE) | |
464 | { | |
18f1dc06 | 465 | peer_clear (peer, NULL); |
7aafcaca DS |
466 | continue; |
467 | } | |
468 | ||
c8560b44 | 469 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
470 | continue; |
471 | ||
472 | ret = peer_clear_soft (peer, afi, safi, stype); | |
473 | ||
474 | if (ret < 0) | |
475 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
476 | } | |
477 | return CMD_SUCCESS; | |
478 | } | |
479 | ||
480 | if (sort == clear_external) | |
481 | { | |
482 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
483 | { | |
484 | if (peer->sort == BGP_PEER_IBGP) | |
485 | continue; | |
486 | ||
487 | if (stype == BGP_CLEAR_SOFT_NONE) | |
488 | ret = peer_clear (peer, &nnode); | |
489 | else | |
490 | ret = peer_clear_soft (peer, afi, safi, stype); | |
491 | ||
492 | if (ret < 0) | |
493 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
494 | } | |
495 | return CMD_SUCCESS; | |
496 | } | |
497 | ||
498 | if (sort == clear_as) | |
499 | { | |
500 | as_t as; | |
501 | int find = 0; | |
502 | ||
503 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
504 | ||
505 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
506 | { | |
507 | if (peer->as != as) | |
508 | continue; | |
509 | ||
510 | find = 1; | |
511 | if (stype == BGP_CLEAR_SOFT_NONE) | |
512 | ret = peer_clear (peer, &nnode); | |
513 | else | |
514 | ret = peer_clear_soft (peer, afi, safi, stype); | |
515 | ||
516 | if (ret < 0) | |
517 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
518 | } | |
519 | if (! find) | |
520 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
521 | VTY_NEWLINE); | |
522 | return CMD_SUCCESS; | |
523 | } | |
524 | ||
525 | return CMD_SUCCESS; | |
526 | } | |
527 | ||
528 | static int | |
529 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
530 | enum clear_sort sort, enum bgp_clear_type stype, | |
531 | const char *arg) | |
532 | { | |
533 | struct bgp *bgp; | |
534 | ||
535 | /* BGP structure lookup. */ | |
536 | if (name) | |
537 | { | |
538 | bgp = bgp_lookup_by_name (name); | |
539 | if (bgp == NULL) | |
540 | { | |
6aeb9e78 | 541 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
542 | return CMD_WARNING; |
543 | } | |
544 | } | |
545 | else | |
546 | { | |
f31fa004 | 547 | bgp = bgp_get_default (); |
7aafcaca DS |
548 | if (bgp == NULL) |
549 | { | |
550 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
551 | return CMD_WARNING; | |
552 | } | |
553 | } | |
554 | ||
555 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
556 | } | |
557 | ||
558 | /* clear soft inbound */ | |
559 | static void | |
f31fa004 | 560 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 561 | { |
b09b5ae0 | 562 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 563 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 564 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 565 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
566 | } |
567 | ||
568 | /* clear soft outbound */ | |
569 | static void | |
f31fa004 | 570 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 571 | { |
f31fa004 | 572 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 573 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 574 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 575 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
576 | } |
577 | ||
578 | ||
718e3744 | 579 | /* BGP global configuration. */ |
580 | ||
581 | DEFUN (bgp_multiple_instance_func, | |
582 | bgp_multiple_instance_cmd, | |
583 | "bgp multiple-instance", | |
584 | BGP_STR | |
585 | "Enable bgp multiple instance\n") | |
586 | { | |
587 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
588 | return CMD_SUCCESS; | |
589 | } | |
590 | ||
591 | DEFUN (no_bgp_multiple_instance, | |
592 | no_bgp_multiple_instance_cmd, | |
593 | "no bgp multiple-instance", | |
594 | NO_STR | |
595 | BGP_STR | |
596 | "BGP multiple instance\n") | |
597 | { | |
598 | int ret; | |
599 | ||
600 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
601 | if (ret < 0) | |
602 | { | |
603 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
604 | return CMD_WARNING; | |
605 | } | |
606 | return CMD_SUCCESS; | |
607 | } | |
608 | ||
609 | DEFUN (bgp_config_type, | |
610 | bgp_config_type_cmd, | |
6147e2c6 | 611 | "bgp config-type <cisco|zebra>", |
718e3744 | 612 | BGP_STR |
613 | "Configuration type\n" | |
614 | "cisco\n" | |
615 | "zebra\n") | |
616 | { | |
c500ae40 DW |
617 | int idx_vendor = 2; |
618 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 619 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
620 | else | |
621 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
622 | ||
623 | return CMD_SUCCESS; | |
624 | } | |
625 | ||
626 | DEFUN (no_bgp_config_type, | |
627 | no_bgp_config_type_cmd, | |
c7178fe7 | 628 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 629 | NO_STR |
630 | BGP_STR | |
838758ac DW |
631 | "Display configuration type\n" |
632 | "cisco\n" | |
633 | "zebra\n") | |
718e3744 | 634 | { |
635 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
636 | return CMD_SUCCESS; | |
637 | } | |
638 | ||
813d4307 | 639 | |
718e3744 | 640 | DEFUN (no_synchronization, |
641 | no_synchronization_cmd, | |
642 | "no synchronization", | |
643 | NO_STR | |
644 | "Perform IGP synchronization\n") | |
645 | { | |
646 | return CMD_SUCCESS; | |
647 | } | |
648 | ||
649 | DEFUN (no_auto_summary, | |
650 | no_auto_summary_cmd, | |
651 | "no auto-summary", | |
652 | NO_STR | |
653 | "Enable automatic network number summarization\n") | |
654 | { | |
655 | return CMD_SUCCESS; | |
656 | } | |
3d515fd9 | 657 | |
718e3744 | 658 | /* "router bgp" commands. */ |
f412b39a DW |
659 | DEFUN (router_bgp, |
660 | router_bgp_cmd, | |
31500417 | 661 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 662 | ROUTER_STR |
663 | BGP_STR | |
31500417 DW |
664 | AS_STR |
665 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 666 | { |
31500417 DW |
667 | int idx_asn = 2; |
668 | int idx_view_vrf = 3; | |
669 | int idx_vrf = 4; | |
718e3744 | 670 | int ret; |
671 | as_t as; | |
672 | struct bgp *bgp; | |
fd79ac91 | 673 | const char *name = NULL; |
ad4cbda1 | 674 | enum bgp_instance_type inst_type; |
718e3744 | 675 | |
2385a876 | 676 | // "router bgp" without an ASN |
31500417 | 677 | if (argc == 2) |
2385a876 | 678 | { |
6aeb9e78 | 679 | //Pending: Make VRF option available for ASN less config |
2385a876 | 680 | bgp = bgp_get_default(); |
718e3744 | 681 | |
2385a876 DW |
682 | if (bgp == NULL) |
683 | { | |
684 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
685 | return CMD_WARNING; | |
686 | } | |
718e3744 | 687 | |
2385a876 DW |
688 | if (listcount(bm->bgp) > 1) |
689 | { | |
690 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
691 | return CMD_WARNING; | |
692 | } | |
693 | } | |
694 | ||
695 | // "router bgp X" | |
696 | else | |
718e3744 | 697 | { |
31500417 | 698 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 699 | |
ad4cbda1 | 700 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 701 | if (argc > 3) |
ad4cbda1 | 702 | { |
31500417 DW |
703 | name = argv[idx_vrf]->arg; |
704 | ||
e52702f2 | 705 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 706 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 707 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 708 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
709 | } | |
2385a876 | 710 | |
ad4cbda1 | 711 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
712 | switch (ret) |
713 | { | |
714 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
715 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
716 | VTY_NEWLINE); | |
717 | return CMD_WARNING; | |
718 | case BGP_ERR_AS_MISMATCH: | |
719 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
720 | return CMD_WARNING; | |
721 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 722 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
723 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
724 | as, VTY_NEWLINE); | |
725 | return CMD_WARNING; | |
726 | } | |
6aeb9e78 DS |
727 | |
728 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 729 | } |
730 | ||
731 | vty->node = BGP_NODE; | |
732 | vty->index = bgp; | |
733 | ||
734 | return CMD_SUCCESS; | |
735 | } | |
736 | ||
718e3744 | 737 | /* "no router bgp" commands. */ |
738 | DEFUN (no_router_bgp, | |
739 | no_router_bgp_cmd, | |
31500417 | 740 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 741 | NO_STR |
742 | ROUTER_STR | |
743 | BGP_STR | |
31500417 DW |
744 | AS_STR |
745 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 746 | { |
31500417 | 747 | int idx_asn = 3; |
31500417 | 748 | int idx_vrf = 5; |
718e3744 | 749 | as_t as; |
750 | struct bgp *bgp; | |
fd79ac91 | 751 | const char *name = NULL; |
718e3744 | 752 | |
7fb21a9f | 753 | // "no router bgp" without an ASN |
31500417 | 754 | if (argc == 3) |
7fb21a9f QY |
755 | { |
756 | //Pending: Make VRF option available for ASN less config | |
757 | bgp = bgp_get_default(); | |
718e3744 | 758 | |
7fb21a9f QY |
759 | if (bgp == NULL) |
760 | { | |
761 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
762 | return CMD_WARNING; | |
763 | } | |
764 | ||
765 | if (listcount(bm->bgp) > 1) | |
766 | { | |
767 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
768 | return CMD_WARNING; | |
769 | } | |
770 | } | |
771 | else | |
718e3744 | 772 | { |
31500417 | 773 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 774 | |
31500417 DW |
775 | if (argc > 4) |
776 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
777 | |
778 | /* Lookup bgp structure. */ | |
779 | bgp = bgp_lookup (as, name); | |
780 | if (! bgp) | |
781 | { | |
782 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
783 | return CMD_WARNING; | |
784 | } | |
718e3744 | 785 | } |
786 | ||
787 | bgp_delete (bgp); | |
788 | ||
789 | return CMD_SUCCESS; | |
790 | } | |
791 | ||
6b0655a2 | 792 | |
7fb21a9f | 793 | |
718e3744 | 794 | /* BGP router-id. */ |
795 | ||
796 | DEFUN (bgp_router_id, | |
797 | bgp_router_id_cmd, | |
798 | "bgp router-id A.B.C.D", | |
799 | BGP_STR | |
800 | "Override configured router identifier\n" | |
801 | "Manually configured router identifier\n") | |
802 | { | |
c500ae40 | 803 | int idx_ipv4 = 2; |
718e3744 | 804 | int ret; |
805 | struct in_addr id; | |
806 | struct bgp *bgp; | |
807 | ||
808 | bgp = vty->index; | |
809 | ||
c500ae40 | 810 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 811 | if (! ret) |
812 | { | |
813 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
814 | return CMD_WARNING; | |
815 | } | |
816 | ||
0e6cb743 | 817 | bgp_router_id_static_set (bgp, id); |
718e3744 | 818 | |
819 | return CMD_SUCCESS; | |
820 | } | |
821 | ||
822 | DEFUN (no_bgp_router_id, | |
823 | no_bgp_router_id_cmd, | |
31500417 | 824 | "no bgp router-id [A.B.C.D]", |
718e3744 | 825 | NO_STR |
826 | BGP_STR | |
31500417 DW |
827 | "Override configured router identifier\n" |
828 | "Manually configured router identifier\n") | |
718e3744 | 829 | { |
31500417 | 830 | int idx_router_id = 3; |
718e3744 | 831 | int ret; |
832 | struct in_addr id; | |
833 | struct bgp *bgp; | |
834 | ||
835 | bgp = vty->index; | |
836 | ||
31500417 | 837 | if (argc > idx_router_id) |
718e3744 | 838 | { |
31500417 | 839 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 840 | if (! ret) |
e018c7cc SK |
841 | { |
842 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
843 | return CMD_WARNING; | |
844 | } | |
718e3744 | 845 | |
18a6dce6 | 846 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
847 | { |
848 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
849 | return CMD_WARNING; | |
850 | } | |
718e3744 | 851 | } |
852 | ||
0e6cb743 DL |
853 | id.s_addr = 0; |
854 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 855 | |
856 | return CMD_SUCCESS; | |
857 | } | |
858 | ||
6b0655a2 | 859 | |
718e3744 | 860 | /* BGP Cluster ID. */ |
718e3744 | 861 | DEFUN (bgp_cluster_id, |
862 | bgp_cluster_id_cmd, | |
838758ac | 863 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 864 | BGP_STR |
865 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
866 | "Route-Reflector Cluster-id in IP address format\n" |
867 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 868 | { |
c500ae40 | 869 | int idx_ipv4 = 2; |
718e3744 | 870 | int ret; |
871 | struct bgp *bgp; | |
872 | struct in_addr cluster; | |
873 | ||
874 | bgp = vty->index; | |
875 | ||
c500ae40 | 876 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 877 | if (! ret) |
878 | { | |
879 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
880 | return CMD_WARNING; | |
881 | } | |
882 | ||
883 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 884 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 885 | |
886 | return CMD_SUCCESS; | |
887 | } | |
888 | ||
718e3744 | 889 | DEFUN (no_bgp_cluster_id, |
890 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 891 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 892 | NO_STR |
893 | BGP_STR | |
838758ac DW |
894 | "Configure Route-Reflector Cluster-id\n" |
895 | "Route-Reflector Cluster-id in IP address format\n" | |
896 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 897 | { |
718e3744 | 898 | struct bgp *bgp; |
718e3744 | 899 | |
900 | bgp = vty->index; | |
718e3744 | 901 | bgp_cluster_id_unset (bgp); |
f31fa004 | 902 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 903 | |
904 | return CMD_SUCCESS; | |
905 | } | |
906 | ||
718e3744 | 907 | DEFUN (bgp_confederation_identifier, |
908 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 909 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 910 | "BGP specific commands\n" |
911 | "AS confederation parameters\n" | |
912 | "AS number\n" | |
913 | "Set routing domain confederation AS\n") | |
914 | { | |
c500ae40 | 915 | int idx_number = 3; |
718e3744 | 916 | struct bgp *bgp; |
917 | as_t as; | |
918 | ||
919 | bgp = vty->index; | |
920 | ||
c500ae40 | 921 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 922 | |
923 | bgp_confederation_id_set (bgp, as); | |
924 | ||
925 | return CMD_SUCCESS; | |
926 | } | |
927 | ||
928 | DEFUN (no_bgp_confederation_identifier, | |
929 | no_bgp_confederation_identifier_cmd, | |
838758ac | 930 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 931 | NO_STR |
932 | "BGP specific commands\n" | |
933 | "AS confederation parameters\n" | |
3a2d747c QY |
934 | "AS number\n" |
935 | "Set routing domain confederation AS\n") | |
718e3744 | 936 | { |
937 | struct bgp *bgp; | |
718e3744 | 938 | |
939 | bgp = vty->index; | |
718e3744 | 940 | bgp_confederation_id_unset (bgp); |
941 | ||
942 | return CMD_SUCCESS; | |
943 | } | |
944 | ||
718e3744 | 945 | DEFUN (bgp_confederation_peers, |
946 | bgp_confederation_peers_cmd, | |
12dcf78e | 947 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 948 | "BGP specific commands\n" |
949 | "AS confederation parameters\n" | |
950 | "Peer ASs in BGP confederation\n" | |
951 | AS_STR) | |
952 | { | |
58749582 | 953 | int idx_asn = 3; |
718e3744 | 954 | struct bgp *bgp; |
955 | as_t as; | |
956 | int i; | |
957 | ||
958 | bgp = vty->index; | |
959 | ||
58749582 | 960 | for (i = idx_asn; i < argc; i++) |
718e3744 | 961 | { |
afec25d9 | 962 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 963 | |
964 | if (bgp->as == as) | |
965 | { | |
966 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
967 | VTY_NEWLINE); | |
968 | continue; | |
969 | } | |
970 | ||
971 | bgp_confederation_peers_add (bgp, as); | |
972 | } | |
973 | return CMD_SUCCESS; | |
974 | } | |
975 | ||
976 | DEFUN (no_bgp_confederation_peers, | |
977 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 978 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 979 | NO_STR |
980 | "BGP specific commands\n" | |
981 | "AS confederation parameters\n" | |
982 | "Peer ASs in BGP confederation\n" | |
983 | AS_STR) | |
984 | { | |
58749582 | 985 | int idx_asn = 4; |
718e3744 | 986 | struct bgp *bgp; |
987 | as_t as; | |
988 | int i; | |
989 | ||
990 | bgp = vty->index; | |
991 | ||
58749582 | 992 | for (i = idx_asn; i < argc; i++) |
718e3744 | 993 | { |
afec25d9 | 994 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 995 | |
718e3744 | 996 | bgp_confederation_peers_remove (bgp, as); |
997 | } | |
998 | return CMD_SUCCESS; | |
999 | } | |
6b0655a2 | 1000 | |
5e242b0d DS |
1001 | /** |
1002 | * Central routine for maximum-paths configuration. | |
1003 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1004 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1005 | */ | |
ffd0c037 DS |
1006 | static int |
1007 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1008 | u_int16_t options, int set) |
165b5fff JB |
1009 | { |
1010 | struct bgp *bgp; | |
4c9dee98 | 1011 | u_int16_t maxpaths = 0; |
165b5fff | 1012 | int ret; |
5e242b0d DS |
1013 | afi_t afi; |
1014 | safi_t safi; | |
165b5fff JB |
1015 | |
1016 | bgp = vty->index; | |
5e242b0d DS |
1017 | afi = bgp_node_afi (vty); |
1018 | safi = bgp_node_safi (vty); | |
165b5fff | 1019 | |
5e242b0d | 1020 | if (set) |
4c9dee98 | 1021 | { |
c59f2066 | 1022 | maxpaths = strtol(mpaths, NULL, 10); |
dff6764a | 1023 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1024 | } |
5e242b0d DS |
1025 | else |
1026 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1027 | |
165b5fff JB |
1028 | if (ret < 0) |
1029 | { | |
1030 | vty_out (vty, | |
5e242b0d DS |
1031 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1032 | (set == 1) ? "" : "un", | |
1033 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1034 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1035 | return CMD_WARNING; |
1036 | } | |
1037 | ||
7aafcaca DS |
1038 | bgp_recalculate_all_bestpaths (bgp); |
1039 | ||
165b5fff JB |
1040 | return CMD_SUCCESS; |
1041 | } | |
1042 | ||
abc920f8 DS |
1043 | DEFUN (bgp_maxmed_admin, |
1044 | bgp_maxmed_admin_cmd, | |
1045 | "bgp max-med administrative ", | |
1046 | BGP_STR | |
1047 | "Advertise routes with max-med\n" | |
1048 | "Administratively applied, for an indefinite period\n") | |
1049 | { | |
1050 | struct bgp *bgp; | |
1051 | ||
1052 | bgp = vty->index; | |
1053 | ||
1054 | bgp->v_maxmed_admin = 1; | |
1055 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1056 | ||
1057 | bgp_maxmed_update(bgp); | |
1058 | ||
1059 | return CMD_SUCCESS; | |
1060 | } | |
1061 | ||
1062 | DEFUN (bgp_maxmed_admin_medv, | |
1063 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1064 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1065 | BGP_STR |
1066 | "Advertise routes with max-med\n" | |
1067 | "Administratively applied, for an indefinite period\n" | |
1068 | "Max MED value to be used\n") | |
1069 | { | |
c500ae40 | 1070 | int idx_number = 3; |
abc920f8 DS |
1071 | struct bgp *bgp; |
1072 | ||
1073 | bgp = vty->index; | |
1074 | ||
1075 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1076 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1077 | |
1078 | bgp_maxmed_update(bgp); | |
1079 | ||
1080 | return CMD_SUCCESS; | |
1081 | } | |
1082 | ||
1083 | DEFUN (no_bgp_maxmed_admin, | |
1084 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1085 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1086 | NO_STR |
1087 | BGP_STR | |
1088 | "Advertise routes with max-med\n" | |
838758ac DW |
1089 | "Administratively applied, for an indefinite period\n" |
1090 | "Max MED value to be used\n") | |
abc920f8 DS |
1091 | { |
1092 | struct bgp *bgp; | |
1093 | ||
1094 | bgp = vty->index; | |
abc920f8 DS |
1095 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1096 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1097 | bgp_maxmed_update(bgp); |
1098 | ||
1099 | return CMD_SUCCESS; | |
1100 | } | |
1101 | ||
abc920f8 DS |
1102 | DEFUN (bgp_maxmed_onstartup, |
1103 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1104 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1105 | BGP_STR |
1106 | "Advertise routes with max-med\n" | |
1107 | "Effective on a startup\n" | |
1108 | "Time (seconds) period for max-med\n") | |
1109 | { | |
c500ae40 | 1110 | int idx_number = 3; |
abc920f8 DS |
1111 | struct bgp *bgp; |
1112 | ||
1113 | bgp = vty->index; | |
c500ae40 | 1114 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1115 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1116 | bgp_maxmed_update(bgp); |
1117 | ||
1118 | return CMD_SUCCESS; | |
1119 | } | |
1120 | ||
1121 | DEFUN (bgp_maxmed_onstartup_medv, | |
1122 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1123 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1124 | BGP_STR |
1125 | "Advertise routes with max-med\n" | |
1126 | "Effective on a startup\n" | |
1127 | "Time (seconds) period for max-med\n" | |
1128 | "Max MED value to be used\n") | |
1129 | { | |
c500ae40 DW |
1130 | int idx_number = 3; |
1131 | int idx_number_2 = 4; | |
abc920f8 DS |
1132 | struct bgp *bgp; |
1133 | ||
1134 | bgp = vty->index; | |
c500ae40 DW |
1135 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1136 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1137 | bgp_maxmed_update(bgp); |
1138 | ||
1139 | return CMD_SUCCESS; | |
1140 | } | |
1141 | ||
1142 | DEFUN (no_bgp_maxmed_onstartup, | |
1143 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1144 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1145 | NO_STR |
1146 | BGP_STR | |
1147 | "Advertise routes with max-med\n" | |
838758ac DW |
1148 | "Effective on a startup\n" |
1149 | "Time (seconds) period for max-med\n" | |
1150 | "Max MED value to be used\n") | |
abc920f8 DS |
1151 | { |
1152 | struct bgp *bgp; | |
1153 | ||
1154 | bgp = vty->index; | |
1155 | ||
1156 | /* Cancel max-med onstartup if its on */ | |
1157 | if (bgp->t_maxmed_onstartup) | |
1158 | { | |
1159 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1160 | bgp->maxmed_onstartup_over = 1; | |
1161 | } | |
1162 | ||
1163 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1164 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1165 | ||
1166 | bgp_maxmed_update(bgp); | |
1167 | ||
1168 | return CMD_SUCCESS; | |
1169 | } | |
1170 | ||
f188f2c4 DS |
1171 | static int |
1172 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1173 | const char *wait) | |
1174 | { | |
1175 | struct bgp *bgp; | |
1176 | u_int16_t update_delay; | |
1177 | u_int16_t establish_wait; | |
1178 | ||
1179 | ||
1180 | bgp = vty->index; | |
1181 | ||
1182 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, | |
1183 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1184 | ||
1185 | if (!wait) /* update-delay <delay> */ | |
1186 | { | |
1187 | bgp->v_update_delay = update_delay; | |
1188 | bgp->v_establish_wait = bgp->v_update_delay; | |
1189 | return CMD_SUCCESS; | |
1190 | } | |
1191 | ||
1192 | /* update-delay <delay> <establish-wait> */ | |
1193 | establish_wait = atoi (wait); | |
1194 | if (update_delay < establish_wait) | |
1195 | { | |
1196 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1197 | VTY_NEWLINE); | |
1198 | return CMD_WARNING; | |
1199 | } | |
1200 | ||
1201 | bgp->v_update_delay = update_delay; | |
1202 | bgp->v_establish_wait = establish_wait; | |
1203 | ||
1204 | return CMD_SUCCESS; | |
1205 | } | |
1206 | ||
1207 | static int | |
1208 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1209 | { | |
1210 | struct bgp *bgp; | |
1211 | ||
1212 | bgp = vty->index; | |
1213 | ||
1214 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1215 | bgp->v_establish_wait = bgp->v_update_delay; | |
1216 | ||
1217 | return CMD_SUCCESS; | |
1218 | } | |
1219 | ||
1220 | int | |
1221 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1222 | { | |
1223 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1224 | { | |
1225 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1226 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1227 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1228 | vty_out (vty, "%s", VTY_NEWLINE); | |
1229 | } | |
1230 | ||
1231 | return 0; | |
1232 | } | |
1233 | ||
1234 | ||
1235 | /* Update-delay configuration */ | |
1236 | DEFUN (bgp_update_delay, | |
1237 | bgp_update_delay_cmd, | |
6147e2c6 | 1238 | "update-delay (0-3600)", |
f188f2c4 DS |
1239 | "Force initial delay for best-path and updates\n" |
1240 | "Seconds\n") | |
1241 | { | |
c500ae40 DW |
1242 | int idx_number = 1; |
1243 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1244 | } |
1245 | ||
1246 | DEFUN (bgp_update_delay_establish_wait, | |
1247 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1248 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1249 | "Force initial delay for best-path and updates\n" |
1250 | "Seconds\n" | |
1251 | "Wait for peers to be established\n" | |
1252 | "Seconds\n") | |
1253 | { | |
c500ae40 DW |
1254 | int idx_number = 1; |
1255 | int idx_number_2 = 2; | |
1256 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1257 | } |
1258 | ||
1259 | /* Update-delay deconfiguration */ | |
1260 | DEFUN (no_bgp_update_delay, | |
1261 | no_bgp_update_delay_cmd, | |
838758ac DW |
1262 | "no update-delay [(0-3600) [(1-3600)]]", |
1263 | NO_STR | |
f188f2c4 | 1264 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1265 | "Seconds\n" |
1266 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1267 | { |
1268 | return bgp_update_delay_deconfig_vty(vty); | |
1269 | } | |
1270 | ||
5e242b0d | 1271 | |
ffd0c037 DS |
1272 | static int |
1273 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 DS |
1274 | { |
1275 | struct bgp *bgp; | |
cb1faec9 DS |
1276 | |
1277 | bgp = vty->index; | |
1278 | ||
1279 | if (set) | |
1280 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1281 | 1, 10000); |
cb1faec9 DS |
1282 | else |
1283 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1284 | ||
1285 | return CMD_SUCCESS; | |
1286 | } | |
1287 | ||
1288 | int | |
1289 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1290 | { | |
1291 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1292 | vty_out (vty, " write-quanta %d%s", | |
1293 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1294 | ||
1295 | return 0; | |
1296 | } | |
1297 | ||
1298 | ||
1299 | /* Update-delay configuration */ | |
1300 | DEFUN (bgp_wpkt_quanta, | |
1301 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1302 | "write-quanta (1-10000)", |
cb1faec9 DS |
1303 | "How many packets to write to peer socket per run\n" |
1304 | "Number of packets\n") | |
1305 | { | |
c500ae40 DW |
1306 | int idx_number = 1; |
1307 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1308 | } |
1309 | ||
1310 | /* Update-delay deconfiguration */ | |
1311 | DEFUN (no_bgp_wpkt_quanta, | |
1312 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1313 | "no write-quanta (1-10000)", |
d7fa34c1 | 1314 | NO_STR |
cb1faec9 DS |
1315 | "How many packets to write to peer socket per run\n" |
1316 | "Number of packets\n") | |
1317 | { | |
c500ae40 DW |
1318 | int idx_number = 2; |
1319 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1320 | } |
1321 | ||
ffd0c037 | 1322 | static int |
3f9c7369 DS |
1323 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1324 | { | |
1325 | struct bgp *bgp; | |
1326 | ||
1327 | bgp = vty->index; | |
1328 | ||
1329 | if (set) | |
1330 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1331 | 0, 4294967295); | |
1332 | else | |
1333 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1334 | ||
1335 | return CMD_SUCCESS; | |
1336 | } | |
1337 | ||
1338 | int | |
1339 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1340 | { | |
1341 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1342 | vty_out (vty, " coalesce-time %d%s", | |
1343 | bgp->coalesce_time, VTY_NEWLINE); | |
1344 | ||
1345 | return 0; | |
1346 | } | |
1347 | ||
1348 | ||
1349 | DEFUN (bgp_coalesce_time, | |
1350 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1351 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1352 | "Subgroup coalesce timer\n" |
1353 | "Subgroup coalesce timer value (in ms)\n") | |
1354 | { | |
c500ae40 DW |
1355 | int idx_number = 1; |
1356 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1357 | } |
1358 | ||
1359 | DEFUN (no_bgp_coalesce_time, | |
1360 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1361 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1362 | NO_STR |
3f9c7369 DS |
1363 | "Subgroup coalesce timer\n" |
1364 | "Subgroup coalesce timer value (in ms)\n") | |
1365 | { | |
c500ae40 DW |
1366 | int idx_number = 2; |
1367 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1368 | } |
1369 | ||
5e242b0d DS |
1370 | /* Maximum-paths configuration */ |
1371 | DEFUN (bgp_maxpaths, | |
1372 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1373 | "maximum-paths (1-255)", |
5e242b0d DS |
1374 | "Forward packets over multiple paths\n" |
1375 | "Number of paths\n") | |
1376 | { | |
c500ae40 DW |
1377 | int idx_number = 1; |
1378 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1379 | } |
1380 | ||
165b5fff JB |
1381 | DEFUN (bgp_maxpaths_ibgp, |
1382 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1383 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1384 | "Forward packets over multiple paths\n" |
1385 | "iBGP-multipath\n" | |
1386 | "Number of paths\n") | |
1387 | { | |
c500ae40 DW |
1388 | int idx_number = 2; |
1389 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1390 | } |
165b5fff | 1391 | |
5e242b0d DS |
1392 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1393 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1394 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1395 | "Forward packets over multiple paths\n" |
1396 | "iBGP-multipath\n" | |
1397 | "Number of paths\n" | |
1398 | "Match the cluster length\n") | |
1399 | { | |
c500ae40 DW |
1400 | int idx_number = 2; |
1401 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1402 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1403 | } |
1404 | ||
1405 | DEFUN (no_bgp_maxpaths, | |
1406 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1407 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1408 | NO_STR |
1409 | "Forward packets over multiple paths\n" | |
1410 | "Number of paths\n") | |
1411 | { | |
5e242b0d | 1412 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1413 | } |
1414 | ||
165b5fff JB |
1415 | DEFUN (no_bgp_maxpaths_ibgp, |
1416 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1417 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1418 | NO_STR |
1419 | "Forward packets over multiple paths\n" | |
1420 | "iBGP-multipath\n" | |
838758ac DW |
1421 | "Number of paths\n" |
1422 | "Match the cluster length\n") | |
165b5fff | 1423 | { |
5e242b0d | 1424 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1425 | } |
1426 | ||
165b5fff JB |
1427 | int |
1428 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1429 | safi_t safi, int *write) | |
1430 | { | |
d5b77cc2 | 1431 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1432 | { |
1433 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1434 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1435 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1436 | } | |
1437 | ||
d5b77cc2 | 1438 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1439 | { |
1440 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1441 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1442 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1443 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1444 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1445 | vty_out (vty, " equal-cluster-length"); | |
1446 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1447 | } |
1448 | ||
1449 | return 0; | |
1450 | } | |
6b0655a2 | 1451 | |
718e3744 | 1452 | /* BGP timers. */ |
1453 | ||
1454 | DEFUN (bgp_timers, | |
1455 | bgp_timers_cmd, | |
6147e2c6 | 1456 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1457 | "Adjust routing timers\n" |
1458 | "BGP timers\n" | |
1459 | "Keepalive interval\n" | |
1460 | "Holdtime\n") | |
1461 | { | |
c500ae40 DW |
1462 | int idx_number = 2; |
1463 | int idx_number_2 = 3; | |
718e3744 | 1464 | struct bgp *bgp; |
1465 | unsigned long keepalive = 0; | |
1466 | unsigned long holdtime = 0; | |
1467 | ||
1468 | bgp = vty->index; | |
1469 | ||
c500ae40 DW |
1470 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1471 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1472 | |
1473 | /* Holdtime value check. */ | |
1474 | if (holdtime < 3 && holdtime != 0) | |
1475 | { | |
1476 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1477 | VTY_NEWLINE); | |
1478 | return CMD_WARNING; | |
1479 | } | |
1480 | ||
1481 | bgp_timers_set (bgp, keepalive, holdtime); | |
1482 | ||
1483 | return CMD_SUCCESS; | |
1484 | } | |
1485 | ||
1486 | DEFUN (no_bgp_timers, | |
1487 | no_bgp_timers_cmd, | |
838758ac | 1488 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1489 | NO_STR |
1490 | "Adjust routing timers\n" | |
838758ac DW |
1491 | "BGP timers\n" |
1492 | "Keepalive interval\n" | |
1493 | "Holdtime\n") | |
718e3744 | 1494 | { |
1495 | struct bgp *bgp; | |
1496 | ||
1497 | bgp = vty->index; | |
1498 | bgp_timers_unset (bgp); | |
1499 | ||
1500 | return CMD_SUCCESS; | |
1501 | } | |
1502 | ||
6b0655a2 | 1503 | |
718e3744 | 1504 | DEFUN (bgp_client_to_client_reflection, |
1505 | bgp_client_to_client_reflection_cmd, | |
1506 | "bgp client-to-client reflection", | |
1507 | "BGP specific commands\n" | |
1508 | "Configure client to client route reflection\n" | |
1509 | "reflection of routes allowed\n") | |
1510 | { | |
1511 | struct bgp *bgp; | |
1512 | ||
1513 | bgp = vty->index; | |
1514 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
f31fa004 | 1515 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1516 | |
718e3744 | 1517 | return CMD_SUCCESS; |
1518 | } | |
1519 | ||
1520 | DEFUN (no_bgp_client_to_client_reflection, | |
1521 | no_bgp_client_to_client_reflection_cmd, | |
1522 | "no bgp client-to-client reflection", | |
1523 | NO_STR | |
1524 | "BGP specific commands\n" | |
1525 | "Configure client to client route reflection\n" | |
1526 | "reflection of routes allowed\n") | |
1527 | { | |
1528 | struct bgp *bgp; | |
1529 | ||
1530 | bgp = vty->index; | |
1531 | bgp_flag_set (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 | /* "bgp always-compare-med" configuration. */ | |
1538 | DEFUN (bgp_always_compare_med, | |
1539 | bgp_always_compare_med_cmd, | |
1540 | "bgp always-compare-med", | |
1541 | "BGP specific commands\n" | |
1542 | "Allow comparing MED from different neighbors\n") | |
1543 | { | |
1544 | struct bgp *bgp; | |
1545 | ||
1546 | bgp = vty->index; | |
1547 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
7aafcaca DS |
1548 | bgp_recalculate_all_bestpaths (bgp); |
1549 | ||
718e3744 | 1550 | return CMD_SUCCESS; |
1551 | } | |
1552 | ||
1553 | DEFUN (no_bgp_always_compare_med, | |
1554 | no_bgp_always_compare_med_cmd, | |
1555 | "no bgp always-compare-med", | |
1556 | NO_STR | |
1557 | "BGP specific commands\n" | |
1558 | "Allow comparing MED from different neighbors\n") | |
1559 | { | |
1560 | struct bgp *bgp; | |
1561 | ||
1562 | bgp = vty->index; | |
1563 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
7aafcaca DS |
1564 | bgp_recalculate_all_bestpaths (bgp); |
1565 | ||
718e3744 | 1566 | return CMD_SUCCESS; |
1567 | } | |
6b0655a2 | 1568 | |
718e3744 | 1569 | /* "bgp deterministic-med" configuration. */ |
1570 | DEFUN (bgp_deterministic_med, | |
1571 | bgp_deterministic_med_cmd, | |
1572 | "bgp deterministic-med", | |
1573 | "BGP specific commands\n" | |
1574 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1575 | { | |
1576 | struct bgp *bgp; | |
1577 | ||
1578 | bgp = vty->index; | |
1475ac87 DW |
1579 | |
1580 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1581 | { | |
1582 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1583 | bgp_recalculate_all_bestpaths (bgp); | |
1584 | } | |
7aafcaca | 1585 | |
718e3744 | 1586 | return CMD_SUCCESS; |
1587 | } | |
1588 | ||
1589 | DEFUN (no_bgp_deterministic_med, | |
1590 | no_bgp_deterministic_med_cmd, | |
1591 | "no bgp deterministic-med", | |
1592 | NO_STR | |
1593 | "BGP specific commands\n" | |
1594 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1595 | { | |
1596 | struct bgp *bgp; | |
06370dac DW |
1597 | int bestpath_per_as_used; |
1598 | afi_t afi; | |
1599 | safi_t safi; | |
1600 | struct peer *peer; | |
1601 | struct listnode *node, *nnode; | |
718e3744 | 1602 | |
1603 | bgp = vty->index; | |
1475ac87 DW |
1604 | |
1605 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1606 | { | |
06370dac DW |
1607 | bestpath_per_as_used = 0; |
1608 | ||
1609 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1610 | { | |
1611 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1612 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1613 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1614 | { | |
1615 | bestpath_per_as_used = 1; | |
1616 | break; | |
1617 | } | |
1618 | ||
1619 | if (bestpath_per_as_used) | |
1620 | break; | |
1621 | } | |
1622 | ||
1623 | if (bestpath_per_as_used) | |
1624 | { | |
1625 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1626 | VTY_NEWLINE); | |
1627 | return CMD_WARNING; | |
1628 | } | |
1629 | else | |
1630 | { | |
1631 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1632 | bgp_recalculate_all_bestpaths (bgp); | |
1633 | } | |
1475ac87 | 1634 | } |
7aafcaca | 1635 | |
718e3744 | 1636 | return CMD_SUCCESS; |
1637 | } | |
538621f2 | 1638 | |
1639 | /* "bgp graceful-restart" configuration. */ | |
1640 | DEFUN (bgp_graceful_restart, | |
1641 | bgp_graceful_restart_cmd, | |
1642 | "bgp graceful-restart", | |
1643 | "BGP specific commands\n" | |
1644 | "Graceful restart capability parameters\n") | |
1645 | { | |
1646 | struct bgp *bgp; | |
1647 | ||
1648 | bgp = vty->index; | |
1649 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1650 | return CMD_SUCCESS; | |
1651 | } | |
1652 | ||
1653 | DEFUN (no_bgp_graceful_restart, | |
1654 | no_bgp_graceful_restart_cmd, | |
1655 | "no bgp graceful-restart", | |
1656 | NO_STR | |
1657 | "BGP specific commands\n" | |
1658 | "Graceful restart capability parameters\n") | |
1659 | { | |
1660 | struct bgp *bgp; | |
1661 | ||
1662 | bgp = vty->index; | |
1663 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1664 | return CMD_SUCCESS; | |
1665 | } | |
1666 | ||
93406d87 | 1667 | DEFUN (bgp_graceful_restart_stalepath_time, |
1668 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1669 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1670 | "BGP specific commands\n" |
1671 | "Graceful restart capability parameters\n" | |
1672 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1673 | "Delay value (seconds)\n") | |
1674 | { | |
c500ae40 | 1675 | int idx_number = 3; |
93406d87 | 1676 | struct bgp *bgp; |
1677 | u_int32_t stalepath; | |
1678 | ||
1679 | bgp = vty->index; | |
1680 | if (! bgp) | |
1681 | return CMD_WARNING; | |
1682 | ||
c500ae40 | 1683 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1684 | bgp->stalepath_time = stalepath; |
1685 | return CMD_SUCCESS; | |
1686 | } | |
1687 | ||
eb6f1b41 PG |
1688 | DEFUN (bgp_graceful_restart_restart_time, |
1689 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1690 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1691 | "BGP specific commands\n" |
1692 | "Graceful restart capability parameters\n" | |
1693 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1694 | "Delay value (seconds)\n") | |
1695 | { | |
c500ae40 | 1696 | int idx_number = 3; |
eb6f1b41 PG |
1697 | struct bgp *bgp; |
1698 | u_int32_t restart; | |
1699 | ||
1700 | bgp = vty->index; | |
1701 | if (! bgp) | |
1702 | return CMD_WARNING; | |
1703 | ||
c500ae40 | 1704 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1705 | bgp->restart_time = restart; |
1706 | return CMD_SUCCESS; | |
1707 | } | |
1708 | ||
93406d87 | 1709 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1710 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1711 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1712 | NO_STR |
1713 | "BGP specific commands\n" | |
1714 | "Graceful restart capability parameters\n" | |
838758ac DW |
1715 | "Set the max time to hold onto restarting peer's stale paths\n" |
1716 | "Delay value (seconds)\n") | |
93406d87 | 1717 | { |
1718 | struct bgp *bgp; | |
1719 | ||
1720 | bgp = vty->index; | |
1721 | if (! bgp) | |
1722 | return CMD_WARNING; | |
1723 | ||
1724 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1725 | return CMD_SUCCESS; | |
1726 | } | |
1727 | ||
eb6f1b41 PG |
1728 | DEFUN (no_bgp_graceful_restart_restart_time, |
1729 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1730 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1731 | NO_STR |
1732 | "BGP specific commands\n" | |
1733 | "Graceful restart capability parameters\n" | |
838758ac DW |
1734 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1735 | "Delay value (seconds)\n") | |
eb6f1b41 PG |
1736 | { |
1737 | struct bgp *bgp; | |
1738 | ||
1739 | bgp = vty->index; | |
1740 | if (! bgp) | |
1741 | return CMD_WARNING; | |
1742 | ||
1743 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1744 | return CMD_SUCCESS; | |
1745 | } | |
1746 | ||
718e3744 | 1747 | /* "bgp fast-external-failover" configuration. */ |
1748 | DEFUN (bgp_fast_external_failover, | |
1749 | bgp_fast_external_failover_cmd, | |
1750 | "bgp fast-external-failover", | |
1751 | BGP_STR | |
1752 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1753 | { | |
1754 | struct bgp *bgp; | |
1755 | ||
1756 | bgp = vty->index; | |
1757 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1758 | return CMD_SUCCESS; | |
1759 | } | |
1760 | ||
1761 | DEFUN (no_bgp_fast_external_failover, | |
1762 | no_bgp_fast_external_failover_cmd, | |
1763 | "no bgp fast-external-failover", | |
1764 | NO_STR | |
1765 | BGP_STR | |
1766 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1767 | { | |
1768 | struct bgp *bgp; | |
1769 | ||
1770 | bgp = vty->index; | |
1771 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1772 | return CMD_SUCCESS; | |
1773 | } | |
6b0655a2 | 1774 | |
718e3744 | 1775 | /* "bgp enforce-first-as" configuration. */ |
1776 | DEFUN (bgp_enforce_first_as, | |
1777 | bgp_enforce_first_as_cmd, | |
1778 | "bgp enforce-first-as", | |
1779 | BGP_STR | |
1780 | "Enforce the first AS for EBGP routes\n") | |
1781 | { | |
1782 | struct bgp *bgp; | |
1783 | ||
1784 | bgp = vty->index; | |
1785 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
f31fa004 | 1786 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1787 | |
718e3744 | 1788 | return CMD_SUCCESS; |
1789 | } | |
1790 | ||
1791 | DEFUN (no_bgp_enforce_first_as, | |
1792 | no_bgp_enforce_first_as_cmd, | |
1793 | "no bgp enforce-first-as", | |
1794 | NO_STR | |
1795 | BGP_STR | |
1796 | "Enforce the first AS for EBGP routes\n") | |
1797 | { | |
1798 | struct bgp *bgp; | |
1799 | ||
1800 | bgp = vty->index; | |
1801 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
f31fa004 | 1802 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1803 | |
718e3744 | 1804 | return CMD_SUCCESS; |
1805 | } | |
6b0655a2 | 1806 | |
718e3744 | 1807 | /* "bgp bestpath compare-routerid" configuration. */ |
1808 | DEFUN (bgp_bestpath_compare_router_id, | |
1809 | bgp_bestpath_compare_router_id_cmd, | |
1810 | "bgp bestpath compare-routerid", | |
1811 | "BGP specific commands\n" | |
1812 | "Change the default bestpath selection\n" | |
1813 | "Compare router-id for identical EBGP paths\n") | |
1814 | { | |
1815 | struct bgp *bgp; | |
1816 | ||
1817 | bgp = vty->index; | |
1818 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
7aafcaca DS |
1819 | bgp_recalculate_all_bestpaths (bgp); |
1820 | ||
718e3744 | 1821 | return CMD_SUCCESS; |
1822 | } | |
1823 | ||
1824 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1825 | no_bgp_bestpath_compare_router_id_cmd, | |
1826 | "no bgp bestpath compare-routerid", | |
1827 | NO_STR | |
1828 | "BGP specific commands\n" | |
1829 | "Change the default bestpath selection\n" | |
1830 | "Compare router-id for identical EBGP paths\n") | |
1831 | { | |
1832 | struct bgp *bgp; | |
1833 | ||
1834 | bgp = vty->index; | |
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 | { | |
1850 | struct bgp *bgp; | |
1851 | ||
1852 | bgp = vty->index; | |
1853 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); | |
7aafcaca DS |
1854 | bgp_recalculate_all_bestpaths (bgp); |
1855 | ||
718e3744 | 1856 | return CMD_SUCCESS; |
1857 | } | |
1858 | ||
1859 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1860 | no_bgp_bestpath_aspath_ignore_cmd, | |
1861 | "no bgp bestpath as-path ignore", | |
1862 | NO_STR | |
1863 | "BGP specific commands\n" | |
1864 | "Change the default bestpath selection\n" | |
1865 | "AS-path attribute\n" | |
1866 | "Ignore as-path length in selecting a route\n") | |
1867 | { | |
1868 | struct bgp *bgp; | |
1869 | ||
1870 | bgp = vty->index; | |
1871 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); | |
7aafcaca DS |
1872 | bgp_recalculate_all_bestpaths (bgp); |
1873 | ||
718e3744 | 1874 | return CMD_SUCCESS; |
1875 | } | |
6b0655a2 | 1876 | |
6811845b | 1877 | /* "bgp bestpath as-path confed" configuration. */ |
1878 | DEFUN (bgp_bestpath_aspath_confed, | |
1879 | bgp_bestpath_aspath_confed_cmd, | |
1880 | "bgp bestpath as-path confed", | |
1881 | "BGP specific commands\n" | |
1882 | "Change the default bestpath selection\n" | |
1883 | "AS-path attribute\n" | |
1884 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1885 | { | |
1886 | struct bgp *bgp; | |
1887 | ||
1888 | bgp = vty->index; | |
1889 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); | |
7aafcaca DS |
1890 | bgp_recalculate_all_bestpaths (bgp); |
1891 | ||
6811845b | 1892 | return CMD_SUCCESS; |
1893 | } | |
1894 | ||
1895 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1896 | no_bgp_bestpath_aspath_confed_cmd, | |
1897 | "no bgp bestpath as-path confed", | |
1898 | NO_STR | |
1899 | "BGP specific commands\n" | |
1900 | "Change the default bestpath selection\n" | |
1901 | "AS-path attribute\n" | |
1902 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1903 | { | |
1904 | struct bgp *bgp; | |
1905 | ||
1906 | bgp = vty->index; | |
1907 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); | |
7aafcaca DS |
1908 | bgp_recalculate_all_bestpaths (bgp); |
1909 | ||
6811845b | 1910 | return CMD_SUCCESS; |
1911 | } | |
6b0655a2 | 1912 | |
2fdd455c PM |
1913 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1914 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1915 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1916 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1917 | "BGP specific commands\n" |
1918 | "Change the default bestpath selection\n" | |
1919 | "AS-path attribute\n" | |
1920 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1921 | "Generate an AS_SET\n" |
16fc1eec DS |
1922 | "Do not generate an AS_SET\n") |
1923 | { | |
4c4ff4c1 | 1924 | int idx = 0; |
16fc1eec DS |
1925 | struct bgp *bgp; |
1926 | ||
1927 | bgp = vty->index; | |
1928 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 DW |
1929 | |
1930 | /* no-as-set is now the default behavior so we can silently | |
1931 | * ignore it */ | |
4c4ff4c1 | 1932 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
1933 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
1934 | else | |
1935 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
1936 | ||
7aafcaca DS |
1937 | bgp_recalculate_all_bestpaths (bgp); |
1938 | ||
16fc1eec DS |
1939 | return CMD_SUCCESS; |
1940 | } | |
1941 | ||
219178b6 DW |
1942 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1943 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1944 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1945 | NO_STR |
1946 | "BGP specific commands\n" | |
1947 | "Change the default bestpath selection\n" | |
1948 | "AS-path attribute\n" | |
1949 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1950 | "Generate an AS_SET\n" |
16fc1eec DS |
1951 | "Do not generate an AS_SET\n") |
1952 | { | |
1953 | struct bgp *bgp; | |
1954 | ||
1955 | bgp = vty->index; | |
1956 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 1957 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
1958 | bgp_recalculate_all_bestpaths (bgp); |
1959 | ||
2fdd455c PM |
1960 | return CMD_SUCCESS; |
1961 | } | |
6b0655a2 | 1962 | |
848973c7 | 1963 | /* "bgp log-neighbor-changes" configuration. */ |
1964 | DEFUN (bgp_log_neighbor_changes, | |
1965 | bgp_log_neighbor_changes_cmd, | |
1966 | "bgp log-neighbor-changes", | |
1967 | "BGP specific commands\n" | |
1968 | "Log neighbor up/down and reset reason\n") | |
1969 | { | |
1970 | struct bgp *bgp; | |
1971 | ||
1972 | bgp = vty->index; | |
1973 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
1974 | return CMD_SUCCESS; | |
1975 | } | |
1976 | ||
1977 | DEFUN (no_bgp_log_neighbor_changes, | |
1978 | no_bgp_log_neighbor_changes_cmd, | |
1979 | "no bgp log-neighbor-changes", | |
1980 | NO_STR | |
1981 | "BGP specific commands\n" | |
1982 | "Log neighbor up/down and reset reason\n") | |
1983 | { | |
1984 | struct bgp *bgp; | |
1985 | ||
1986 | bgp = vty->index; | |
1987 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
1988 | return CMD_SUCCESS; | |
1989 | } | |
6b0655a2 | 1990 | |
718e3744 | 1991 | /* "bgp bestpath med" configuration. */ |
1992 | DEFUN (bgp_bestpath_med, | |
1993 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 1994 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 1995 | "BGP specific commands\n" |
1996 | "Change the default bestpath selection\n" | |
1997 | "MED attribute\n" | |
1998 | "Compare MED among confederation paths\n" | |
838758ac DW |
1999 | "Treat missing MED as the least preferred one\n" |
2000 | "Treat missing MED as the least preferred one\n" | |
2001 | "Compare MED among confederation paths\n") | |
718e3744 | 2002 | { |
6cbd1915 QY |
2003 | struct bgp *bgp = vty->index; |
2004 | ||
2005 | int idx = 0; | |
2006 | if (argv_find (argv, argc, "confed", &idx)) | |
2007 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
2008 | idx = 0; | |
2009 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
2010 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2011 | |
7aafcaca DS |
2012 | bgp_recalculate_all_bestpaths (bgp); |
2013 | ||
718e3744 | 2014 | return CMD_SUCCESS; |
2015 | } | |
2016 | ||
718e3744 | 2017 | DEFUN (no_bgp_bestpath_med, |
2018 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2019 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2020 | NO_STR |
2021 | "BGP specific commands\n" | |
2022 | "Change the default bestpath selection\n" | |
2023 | "MED attribute\n" | |
2024 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2025 | "Treat missing MED as the least preferred one\n" |
2026 | "Treat missing MED as the least preferred one\n" | |
2027 | "Compare MED among confederation paths\n") | |
718e3744 | 2028 | { |
6cbd1915 | 2029 | struct bgp *bgp = vty->index; |
e52702f2 | 2030 | |
6cbd1915 QY |
2031 | int idx = 0; |
2032 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2033 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2034 | idx = 0; |
2035 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2036 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2037 | ||
7aafcaca DS |
2038 | bgp_recalculate_all_bestpaths (bgp); |
2039 | ||
718e3744 | 2040 | return CMD_SUCCESS; |
2041 | } | |
2042 | ||
718e3744 | 2043 | /* "no bgp default ipv4-unicast". */ |
2044 | DEFUN (no_bgp_default_ipv4_unicast, | |
2045 | no_bgp_default_ipv4_unicast_cmd, | |
2046 | "no bgp default ipv4-unicast", | |
2047 | NO_STR | |
2048 | "BGP specific commands\n" | |
2049 | "Configure BGP defaults\n" | |
2050 | "Activate ipv4-unicast for a peer by default\n") | |
2051 | { | |
2052 | struct bgp *bgp; | |
2053 | ||
2054 | bgp = vty->index; | |
2055 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2056 | return CMD_SUCCESS; | |
2057 | } | |
2058 | ||
2059 | DEFUN (bgp_default_ipv4_unicast, | |
2060 | bgp_default_ipv4_unicast_cmd, | |
2061 | "bgp default ipv4-unicast", | |
2062 | "BGP specific commands\n" | |
2063 | "Configure BGP defaults\n" | |
2064 | "Activate ipv4-unicast for a peer by default\n") | |
2065 | { | |
2066 | struct bgp *bgp; | |
2067 | ||
2068 | bgp = vty->index; | |
2069 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2070 | return CMD_SUCCESS; | |
2071 | } | |
6b0655a2 | 2072 | |
04b6bdc0 DW |
2073 | /* Display hostname in certain command outputs */ |
2074 | DEFUN (bgp_default_show_hostname, | |
2075 | bgp_default_show_hostname_cmd, | |
2076 | "bgp default show-hostname", | |
2077 | "BGP specific commands\n" | |
2078 | "Configure BGP defaults\n" | |
2079 | "Show hostname in certain command ouputs\n") | |
2080 | { | |
2081 | struct bgp *bgp; | |
2082 | ||
2083 | bgp = vty->index; | |
2084 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2085 | return CMD_SUCCESS; | |
2086 | } | |
2087 | ||
2088 | DEFUN (no_bgp_default_show_hostname, | |
2089 | no_bgp_default_show_hostname_cmd, | |
2090 | "no bgp default show-hostname", | |
2091 | NO_STR | |
2092 | "BGP specific commands\n" | |
2093 | "Configure BGP defaults\n" | |
2094 | "Show hostname in certain command ouputs\n") | |
2095 | { | |
2096 | struct bgp *bgp; | |
2097 | ||
2098 | bgp = vty->index; | |
2099 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2100 | return CMD_SUCCESS; | |
2101 | } | |
2102 | ||
8233ef81 | 2103 | /* "bgp network import-check" configuration. */ |
718e3744 | 2104 | DEFUN (bgp_network_import_check, |
2105 | bgp_network_import_check_cmd, | |
5623e905 | 2106 | "bgp network import-check", |
718e3744 | 2107 | "BGP specific commands\n" |
2108 | "BGP network command\n" | |
5623e905 | 2109 | "Check BGP network route exists in IGP\n") |
718e3744 | 2110 | { |
2111 | struct bgp *bgp; | |
2112 | ||
2113 | bgp = vty->index; | |
078430f6 DS |
2114 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2115 | { | |
2116 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2117 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2118 | } |
2119 | ||
718e3744 | 2120 | return CMD_SUCCESS; |
2121 | } | |
2122 | ||
8233ef81 DW |
2123 | ALIAS_HIDDEN (bgp_network_import_check, |
2124 | bgp_network_import_check_exact_cmd, | |
2125 | "bgp network import-check exact", | |
2126 | "BGP specific commands\n" | |
2127 | "BGP network command\n" | |
2128 | "Check BGP network route exists in IGP\n" | |
2129 | "Match route precisely\n") | |
2130 | ||
718e3744 | 2131 | DEFUN (no_bgp_network_import_check, |
2132 | no_bgp_network_import_check_cmd, | |
5623e905 | 2133 | "no bgp network import-check", |
718e3744 | 2134 | NO_STR |
2135 | "BGP specific commands\n" | |
2136 | "BGP network command\n" | |
2137 | "Check BGP network route exists in IGP\n") | |
2138 | { | |
2139 | struct bgp *bgp; | |
2140 | ||
2141 | bgp = vty->index; | |
078430f6 DS |
2142 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2143 | { | |
2144 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2145 | bgp_static_redo_import_check(bgp); |
2146 | } | |
5623e905 | 2147 | |
718e3744 | 2148 | return CMD_SUCCESS; |
2149 | } | |
6b0655a2 | 2150 | |
718e3744 | 2151 | DEFUN (bgp_default_local_preference, |
2152 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2153 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2154 | "BGP specific commands\n" |
2155 | "Configure BGP defaults\n" | |
2156 | "local preference (higher=more preferred)\n" | |
2157 | "Configure default local preference value\n") | |
2158 | { | |
c500ae40 | 2159 | int idx_number = 3; |
718e3744 | 2160 | struct bgp *bgp; |
2161 | u_int32_t local_pref; | |
2162 | ||
2163 | bgp = vty->index; | |
2164 | ||
c500ae40 | 2165 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2166 | |
2167 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2168 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2169 | |
2170 | return CMD_SUCCESS; | |
2171 | } | |
2172 | ||
2173 | DEFUN (no_bgp_default_local_preference, | |
2174 | no_bgp_default_local_preference_cmd, | |
838758ac | 2175 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2176 | NO_STR |
2177 | "BGP specific commands\n" | |
2178 | "Configure BGP defaults\n" | |
838758ac DW |
2179 | "local preference (higher=more preferred)\n" |
2180 | "Configure default local preference value\n") | |
718e3744 | 2181 | { |
2182 | struct bgp *bgp; | |
2183 | ||
2184 | bgp = vty->index; | |
2185 | bgp_default_local_preference_unset (bgp); | |
f31fa004 | 2186 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2187 | |
718e3744 | 2188 | return CMD_SUCCESS; |
2189 | } | |
2190 | ||
6b0655a2 | 2191 | |
3f9c7369 DS |
2192 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2193 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2194 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2195 | "BGP specific commands\n" |
2196 | "Configure BGP defaults\n" | |
2197 | "subgroup-pkt-queue-max\n" | |
2198 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2199 | { |
c500ae40 | 2200 | int idx_number = 3; |
3f9c7369 DS |
2201 | struct bgp *bgp; |
2202 | u_int32_t max_size; | |
8bd9d948 | 2203 | |
3f9c7369 DS |
2204 | bgp = vty->index; |
2205 | ||
c500ae40 | 2206 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2207 | |
2208 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2209 | ||
2210 | return CMD_SUCCESS; | |
2211 | } | |
2212 | ||
2213 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2214 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2215 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2216 | NO_STR |
2217 | "BGP specific commands\n" | |
2218 | "Configure BGP defaults\n" | |
838758ac DW |
2219 | "subgroup-pkt-queue-max\n" |
2220 | "Configure subgroup packet queue max\n") | |
3f9c7369 DS |
2221 | { |
2222 | struct bgp *bgp; | |
2223 | ||
2224 | bgp = vty->index; | |
2225 | bgp_default_subgroup_pkt_queue_max_unset (bgp); | |
2226 | return CMD_SUCCESS; | |
8bd9d948 DS |
2227 | } |
2228 | ||
813d4307 | 2229 | |
8bd9d948 DS |
2230 | DEFUN (bgp_rr_allow_outbound_policy, |
2231 | bgp_rr_allow_outbound_policy_cmd, | |
2232 | "bgp route-reflector allow-outbound-policy", | |
2233 | "BGP specific commands\n" | |
2234 | "Allow modifications made by out route-map\n" | |
2235 | "on ibgp neighbors\n") | |
2236 | { | |
2237 | struct bgp *bgp; | |
8bd9d948 DS |
2238 | |
2239 | bgp = vty->index; | |
2240 | ||
2241 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2242 | { | |
2243 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2244 | update_group_announce_rrclients(bgp); |
f31fa004 | 2245 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2246 | } |
2247 | ||
2248 | return CMD_SUCCESS; | |
2249 | } | |
2250 | ||
2251 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2252 | no_bgp_rr_allow_outbound_policy_cmd, | |
2253 | "no bgp route-reflector allow-outbound-policy", | |
2254 | NO_STR | |
2255 | "BGP specific commands\n" | |
2256 | "Allow modifications made by out route-map\n" | |
2257 | "on ibgp neighbors\n") | |
2258 | { | |
2259 | struct bgp *bgp; | |
8bd9d948 DS |
2260 | |
2261 | bgp = vty->index; | |
2262 | ||
2263 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2264 | { | |
2265 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2266 | update_group_announce_rrclients(bgp); |
f31fa004 | 2267 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2268 | } |
2269 | ||
2270 | return CMD_SUCCESS; | |
2271 | } | |
2272 | ||
f14e6fdb DS |
2273 | DEFUN (bgp_listen_limit, |
2274 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2275 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2276 | "BGP specific commands\n" |
2277 | "Configure BGP defaults\n" | |
2278 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2279 | "Configure Dynamic Neighbors listen limit value\n") | |
2280 | { | |
c500ae40 | 2281 | int idx_number = 3; |
f14e6fdb DS |
2282 | struct bgp *bgp; |
2283 | int listen_limit; | |
2284 | ||
2285 | bgp = vty->index; | |
2286 | ||
c500ae40 | 2287 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2288 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2289 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2290 | ||
2291 | bgp_listen_limit_set (bgp, listen_limit); | |
2292 | ||
2293 | return CMD_SUCCESS; | |
2294 | } | |
2295 | ||
2296 | DEFUN (no_bgp_listen_limit, | |
2297 | no_bgp_listen_limit_cmd, | |
838758ac | 2298 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2299 | "BGP specific commands\n" |
2300 | "Configure BGP defaults\n" | |
2301 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2302 | "Configure Dynamic Neighbors listen limit value to default\n" |
2303 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb DS |
2304 | { |
2305 | struct bgp *bgp; | |
2306 | ||
2307 | bgp = vty->index; | |
2308 | bgp_listen_limit_unset (bgp); | |
2309 | return CMD_SUCCESS; | |
2310 | } | |
2311 | ||
2312 | ||
20eb8864 | 2313 | /* |
2314 | * Check if this listen range is already configured. Check for exact | |
2315 | * match or overlap based on input. | |
2316 | */ | |
2317 | static struct peer_group * | |
2318 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2319 | { | |
2320 | struct listnode *node, *nnode; | |
2321 | struct listnode *node1, *nnode1; | |
2322 | struct peer_group *group; | |
2323 | struct prefix *lr; | |
2324 | afi_t afi; | |
2325 | int match; | |
2326 | ||
2327 | afi = family2afi(range->family); | |
2328 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2329 | { | |
2330 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2331 | nnode1, lr)) | |
2332 | { | |
2333 | if (exact) | |
2334 | match = prefix_same (range, lr); | |
2335 | else | |
2336 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2337 | if (match) | |
2338 | return group; | |
2339 | } | |
2340 | } | |
2341 | ||
2342 | return NULL; | |
2343 | } | |
2344 | ||
f14e6fdb DS |
2345 | DEFUN (bgp_listen_range, |
2346 | bgp_listen_range_cmd, | |
9ccf14f7 | 2347 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2348 | "BGP specific commands\n" |
d7fa34c1 QY |
2349 | "Configure BGP dynamic neighbors listen range\n" |
2350 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2351 | NEIGHBOR_ADDR_STR |
2352 | "Member of the peer-group\n" | |
2353 | "Peer-group name\n") | |
f14e6fdb DS |
2354 | { |
2355 | struct bgp *bgp; | |
2356 | struct prefix range; | |
20eb8864 | 2357 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2358 | afi_t afi; |
2359 | int ret; | |
d7fa34c1 | 2360 | int idx = 0; |
f14e6fdb | 2361 | |
d7fa34c1 QY |
2362 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2363 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2364 | char *prefix = argv[idx]->arg; | |
2365 | argv_find (argv, argc, "WORD", &idx); | |
2366 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2367 | |
d7fa34c1 | 2368 | bgp = vty->index; |
f14e6fdb DS |
2369 | |
2370 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2371 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2372 | if (! ret) |
2373 | { | |
2374 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2375 | return CMD_WARNING; | |
2376 | } | |
2377 | ||
2378 | afi = family2afi(range.family); | |
2379 | ||
f14e6fdb DS |
2380 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2381 | { | |
2382 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2383 | VTY_NEWLINE); | |
2384 | return CMD_WARNING; | |
2385 | } | |
f14e6fdb DS |
2386 | |
2387 | apply_mask (&range); | |
2388 | ||
20eb8864 | 2389 | /* Check if same listen range is already configured. */ |
2390 | existing_group = listen_range_exists (bgp, &range, 1); | |
2391 | if (existing_group) | |
2392 | { | |
d7fa34c1 | 2393 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2394 | return CMD_SUCCESS; |
2395 | else | |
2396 | { | |
2397 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2398 | existing_group->name, VTY_NEWLINE); | |
2399 | return CMD_WARNING; | |
2400 | } | |
2401 | } | |
2402 | ||
2403 | /* Check if an overlapping listen range exists. */ | |
2404 | if (listen_range_exists (bgp, &range, 0)) | |
2405 | { | |
2406 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2407 | VTY_NEWLINE); | |
2408 | return CMD_WARNING; | |
2409 | } | |
f14e6fdb | 2410 | |
d7fa34c1 | 2411 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2412 | if (! group) |
2413 | { | |
2414 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2415 | return CMD_WARNING; | |
2416 | } | |
2417 | ||
2418 | ret = peer_group_listen_range_add(group, &range); | |
2419 | return bgp_vty_return (vty, ret); | |
2420 | } | |
2421 | ||
2422 | DEFUN (no_bgp_listen_range, | |
2423 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2424 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2425 | NO_STR | |
f14e6fdb | 2426 | "BGP specific commands\n" |
d7fa34c1 QY |
2427 | "Unconfigure BGP dynamic neighbors listen range\n" |
2428 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2429 | NEIGHBOR_ADDR_STR | |
2430 | "Member of the peer-group\n" | |
2431 | "Peer-group name\n") | |
f14e6fdb DS |
2432 | { |
2433 | struct bgp *bgp; | |
2434 | struct prefix range; | |
2435 | struct peer_group *group; | |
2436 | afi_t afi; | |
2437 | int ret; | |
d7fa34c1 QY |
2438 | int idx = 0; |
2439 | ||
2440 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2441 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2442 | char *prefix = argv[idx]->arg; | |
2443 | argv_find (argv, argc, "WORD", &idx); | |
2444 | char *peergroup = argv[idx]->arg; | |
f14e6fdb DS |
2445 | |
2446 | bgp = vty->index; | |
2447 | ||
c500ae40 | 2448 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2449 | |
2450 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2451 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2452 | if (! ret) |
2453 | { | |
2454 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2455 | return CMD_WARNING; | |
2456 | } | |
2457 | ||
2458 | afi = family2afi(range.family); | |
2459 | ||
f14e6fdb DS |
2460 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2461 | { | |
2462 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2463 | VTY_NEWLINE); | |
2464 | return CMD_WARNING; | |
2465 | } | |
f14e6fdb DS |
2466 | |
2467 | apply_mask (&range); | |
2468 | ||
d7fa34c1 | 2469 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2470 | if (! group) |
2471 | { | |
2472 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2473 | return CMD_WARNING; | |
2474 | } | |
2475 | ||
2476 | ret = peer_group_listen_range_del(group, &range); | |
2477 | return bgp_vty_return (vty, ret); | |
2478 | } | |
2479 | ||
2480 | int | |
2481 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2482 | { | |
2483 | struct peer_group *group; | |
2484 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2485 | struct prefix *range; | |
2486 | afi_t afi; | |
4690c7d7 | 2487 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2488 | |
2489 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2490 | vty_out (vty, " bgp listen limit %d%s", | |
2491 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2492 | ||
2493 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2494 | { | |
2495 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2496 | { | |
2497 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2498 | { | |
2499 | prefix2str(range, buf, sizeof(buf)); | |
2500 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2501 | buf, group->name, VTY_NEWLINE); | |
2502 | } | |
2503 | } | |
2504 | } | |
2505 | ||
2506 | return 0; | |
2507 | } | |
2508 | ||
2509 | ||
907f92c8 DS |
2510 | DEFUN (bgp_disable_connected_route_check, |
2511 | bgp_disable_connected_route_check_cmd, | |
2512 | "bgp disable-ebgp-connected-route-check", | |
2513 | "BGP specific commands\n" | |
2514 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2515 | { | |
2516 | struct bgp *bgp; | |
2517 | ||
2518 | bgp = vty->index; | |
2519 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
f31fa004 | 2520 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2521 | |
907f92c8 DS |
2522 | return CMD_SUCCESS; |
2523 | } | |
2524 | ||
2525 | DEFUN (no_bgp_disable_connected_route_check, | |
2526 | no_bgp_disable_connected_route_check_cmd, | |
2527 | "no bgp disable-ebgp-connected-route-check", | |
2528 | NO_STR | |
2529 | "BGP specific commands\n" | |
2530 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2531 | { | |
2532 | struct bgp *bgp; | |
2533 | ||
2534 | bgp = vty->index; | |
2535 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
f31fa004 | 2536 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2537 | |
907f92c8 DS |
2538 | return CMD_SUCCESS; |
2539 | } | |
2540 | ||
2541 | ||
718e3744 | 2542 | static int |
e52702f2 | 2543 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2544 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2545 | { |
2546 | int ret; | |
2547 | struct bgp *bgp; | |
2548 | as_t as; | |
0299c004 | 2549 | int as_type = AS_SPECIFIED; |
718e3744 | 2550 | union sockunion su; |
2551 | ||
2552 | bgp = vty->index; | |
2553 | ||
7ae5fc81 | 2554 | if (as_str[0] == 'i') |
0299c004 DS |
2555 | { |
2556 | as = 0; | |
2557 | as_type = AS_INTERNAL; | |
2558 | } | |
7ae5fc81 | 2559 | else if (as_str[0] == 'e') |
0299c004 DS |
2560 | { |
2561 | as = 0; | |
2562 | as_type = AS_EXTERNAL; | |
2563 | } | |
2564 | else | |
2565 | { | |
2566 | /* Get AS number. */ | |
2567 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2568 | } | |
718e3744 | 2569 | |
2570 | /* If peer is peer group, call proper function. */ | |
2571 | ret = str2sockunion (peer_str, &su); | |
2572 | if (ret < 0) | |
2573 | { | |
a80beece | 2574 | /* Check for peer by interface */ |
0299c004 | 2575 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2576 | if (ret < 0) |
a80beece | 2577 | { |
0299c004 | 2578 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2579 | if (ret < 0) |
2580 | { | |
2581 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2582 | VTY_NEWLINE); | |
2583 | return CMD_WARNING; | |
2584 | } | |
2585 | return CMD_SUCCESS; | |
2586 | } | |
718e3744 | 2587 | } |
a80beece | 2588 | else |
718e3744 | 2589 | { |
6aeb9e78 | 2590 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2591 | { |
2592 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2593 | VTY_NEWLINE); | |
2594 | return CMD_WARNING; | |
2595 | } | |
0299c004 | 2596 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2597 | } |
2598 | ||
718e3744 | 2599 | /* This peer belongs to peer group. */ |
2600 | switch (ret) | |
2601 | { | |
2602 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2603 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2604 | return CMD_WARNING; |
718e3744 | 2605 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2606 | 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 | 2607 | return CMD_WARNING; |
718e3744 | 2608 | } |
2609 | return bgp_vty_return (vty, ret); | |
2610 | } | |
2611 | ||
2612 | DEFUN (neighbor_remote_as, | |
2613 | neighbor_remote_as_cmd, | |
3a2d747c | 2614 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2615 | NEIGHBOR_STR |
2616 | NEIGHBOR_ADDR_STR2 | |
2617 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2618 | AS_STR |
3a2d747c QY |
2619 | "Internal BGP peer\n" |
2620 | "External BGP peer\n") | |
718e3744 | 2621 | { |
c500ae40 DW |
2622 | int idx_peer = 1; |
2623 | int idx_remote_as = 3; | |
2624 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2625 | } |
6b0655a2 | 2626 | |
4c48cf63 DW |
2627 | static int |
2628 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2629 | safi_t safi, int v6only, const char *peer_group_name, |
2630 | const char *as_str) | |
a80beece | 2631 | { |
b3a39dc5 DD |
2632 | as_t as = 0; |
2633 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2634 | struct bgp *bgp; |
2635 | struct peer *peer; | |
2636 | struct peer_group *group; | |
4c48cf63 DW |
2637 | int ret = 0; |
2638 | union sockunion su; | |
a80beece DS |
2639 | |
2640 | bgp = vty->index; | |
4c48cf63 DW |
2641 | group = peer_group_lookup (bgp, conf_if); |
2642 | ||
a80beece DS |
2643 | if (group) |
2644 | { | |
2645 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2646 | return CMD_WARNING; | |
2647 | } | |
2648 | ||
b3a39dc5 DD |
2649 | if (as_str) |
2650 | { | |
7ae5fc81 | 2651 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2652 | { |
2653 | as_type = AS_INTERNAL; | |
2654 | } | |
7ae5fc81 | 2655 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2656 | { |
2657 | as_type = AS_EXTERNAL; | |
2658 | } | |
2659 | else | |
2660 | { | |
2661 | /* Get AS number. */ | |
2662 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2663 | as_type = AS_SPECIFIED; | |
2664 | } | |
2665 | } | |
2666 | ||
4c48cf63 DW |
2667 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2668 | if (!peer) | |
2669 | { | |
2670 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2671 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2672 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2673 | NULL); | |
4c48cf63 | 2674 | else |
b3a39dc5 DD |
2675 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2676 | NULL); | |
4c48cf63 DW |
2677 | |
2678 | if (peer && v6only) | |
2679 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2680 | |
2681 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2682 | * any unnumbered peer in order to not worry about run-time transitions | |
2683 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2684 | * gets deleted later etc.) | |
2685 | */ | |
2686 | if (peer->ifp) | |
b3a39dc5 DD |
2687 | { |
2688 | bgp_zebra_initiate_radv (bgp, peer); | |
2689 | } | |
2690 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2691 | } |
2692 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2693 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2694 | { | |
2695 | if (v6only) | |
2696 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2697 | else | |
2698 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2699 | ||
2700 | /* v6only flag changed. Reset bgp seesion */ | |
2701 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2702 | { | |
2703 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2704 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2705 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2706 | } | |
2707 | else | |
2708 | bgp_session_reset(peer); | |
2709 | } | |
2710 | ||
a80beece DS |
2711 | if (!peer) |
2712 | return CMD_WARNING; | |
2713 | ||
4c48cf63 DW |
2714 | if (peer_group_name) |
2715 | { | |
2716 | group = peer_group_lookup (bgp, peer_group_name); | |
2717 | if (! group) | |
2718 | { | |
2719 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2720 | return CMD_WARNING; | |
2721 | } | |
2722 | ||
2723 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2724 | } | |
2725 | ||
2726 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2727 | } |
2728 | ||
4c48cf63 DW |
2729 | DEFUN (neighbor_interface_config, |
2730 | neighbor_interface_config_cmd, | |
31500417 | 2731 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2732 | NEIGHBOR_STR |
2733 | "Interface name or neighbor tag\n" | |
31500417 DW |
2734 | "Enable BGP on interface\n" |
2735 | "Member of the peer-group\n" | |
16cedbb0 | 2736 | "Peer-group name\n") |
4c48cf63 | 2737 | { |
c500ae40 | 2738 | int idx_word = 1; |
31500417 DW |
2739 | int idx_peer_group_word = 4; |
2740 | ||
2741 | if (argc > idx_peer_group_word) | |
c500ae40 | 2742 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2743 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2744 | else |
c500ae40 | 2745 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2746 | NULL, NULL); |
4c48cf63 DW |
2747 | } |
2748 | ||
4c48cf63 DW |
2749 | DEFUN (neighbor_interface_config_v6only, |
2750 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2751 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2752 | NEIGHBOR_STR |
2753 | "Interface name or neighbor tag\n" | |
2754 | "Enable BGP on interface\n" | |
31500417 DW |
2755 | "Enable BGP with v6 link-local only\n" |
2756 | "Member of the peer-group\n" | |
16cedbb0 | 2757 | "Peer-group name\n") |
4c48cf63 | 2758 | { |
c500ae40 | 2759 | int idx_word = 1; |
31500417 DW |
2760 | int idx_peer_group_word = 5; |
2761 | ||
2762 | if (argc > idx_peer_group_word) | |
2763 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2764 | argv[idx_peer_group_word]->arg, NULL); | |
2765 | ||
c500ae40 | 2766 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2767 | NULL, NULL); |
4c48cf63 DW |
2768 | } |
2769 | ||
a80beece | 2770 | |
b3a39dc5 DD |
2771 | DEFUN (neighbor_interface_config_remote_as, |
2772 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2773 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2774 | NEIGHBOR_STR |
2775 | "Interface name or neighbor tag\n" | |
2776 | "Enable BGP on interface\n" | |
3a2d747c | 2777 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2778 | AS_STR |
3a2d747c QY |
2779 | "Internal BGP peer\n" |
2780 | "External BGP peer\n") | |
b3a39dc5 | 2781 | { |
c500ae40 DW |
2782 | int idx_word = 1; |
2783 | int idx_remote_as = 4; | |
2784 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2785 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2786 | } |
2787 | ||
2788 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2789 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2790 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2791 | NEIGHBOR_STR |
2792 | "Interface name or neighbor tag\n" | |
3a2d747c | 2793 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2794 | "Enable BGP on interface\n" |
3a2d747c | 2795 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2796 | AS_STR |
3a2d747c QY |
2797 | "Internal BGP peer\n" |
2798 | "External BGP peer\n") | |
b3a39dc5 | 2799 | { |
c500ae40 DW |
2800 | int idx_word = 1; |
2801 | int idx_remote_as = 5; | |
2802 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2803 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2804 | } |
2805 | ||
718e3744 | 2806 | DEFUN (neighbor_peer_group, |
2807 | neighbor_peer_group_cmd, | |
2808 | "neighbor WORD peer-group", | |
2809 | NEIGHBOR_STR | |
a80beece | 2810 | "Interface name or neighbor tag\n" |
718e3744 | 2811 | "Configure peer-group\n") |
2812 | { | |
c500ae40 | 2813 | int idx_word = 1; |
718e3744 | 2814 | struct bgp *bgp; |
a80beece | 2815 | struct peer *peer; |
718e3744 | 2816 | struct peer_group *group; |
2817 | ||
2818 | bgp = vty->index; | |
c500ae40 | 2819 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2820 | if (peer) |
2821 | { | |
2822 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2823 | return CMD_WARNING; | |
2824 | } | |
718e3744 | 2825 | |
c500ae40 | 2826 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2827 | if (! group) |
2828 | return CMD_WARNING; | |
2829 | ||
2830 | return CMD_SUCCESS; | |
2831 | } | |
2832 | ||
2833 | DEFUN (no_neighbor, | |
2834 | no_neighbor_cmd, | |
a636c635 | 2835 | "no neighbor <A.B.C.D|X:X::X:X|WORD> [remote-as <(1-4294967295)|internal|external>]", |
718e3744 | 2836 | NO_STR |
2837 | NEIGHBOR_STR | |
3a2d747c QY |
2838 | NEIGHBOR_ADDR_STR2 |
2839 | "Specify a BGP neighbor\n" | |
2840 | AS_STR | |
2841 | "Internal BGP peer\n" | |
2842 | "External BGP peer\n") | |
718e3744 | 2843 | { |
c500ae40 | 2844 | int idx_peer = 2; |
718e3744 | 2845 | int ret; |
2846 | union sockunion su; | |
2847 | struct peer_group *group; | |
2848 | struct peer *peer; | |
1ff9a340 | 2849 | struct peer *other; |
718e3744 | 2850 | |
c500ae40 | 2851 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2852 | if (ret < 0) |
2853 | { | |
a80beece | 2854 | /* look up for neighbor by interface name config. */ |
c500ae40 | 2855 | peer = peer_lookup_by_conf_if (vty->index, argv[idx_peer]->arg); |
a80beece DS |
2856 | if (peer) |
2857 | { | |
4a04e5f7 | 2858 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2859 | if (peer->ifp) | |
2860 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2861 | peer_delete (peer); |
2862 | return CMD_SUCCESS; | |
2863 | } | |
2864 | ||
c500ae40 | 2865 | group = peer_group_lookup (vty->index, argv[idx_peer]->arg); |
718e3744 | 2866 | if (group) |
2867 | peer_group_delete (group); | |
2868 | else | |
2869 | { | |
2870 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2871 | return CMD_WARNING; | |
2872 | } | |
2873 | } | |
2874 | else | |
2875 | { | |
2876 | peer = peer_lookup (vty->index, &su); | |
2877 | if (peer) | |
1ff9a340 | 2878 | { |
f14e6fdb DS |
2879 | if (peer_dynamic_neighbor (peer)) |
2880 | { | |
2881 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2882 | VTY_NEWLINE); | |
2883 | return CMD_WARNING; | |
2884 | } | |
2885 | ||
1ff9a340 DS |
2886 | other = peer->doppelganger; |
2887 | peer_delete (peer); | |
2888 | if (other && other->status != Deleted) | |
2889 | peer_delete(other); | |
2890 | } | |
718e3744 | 2891 | } |
2892 | ||
2893 | return CMD_SUCCESS; | |
2894 | } | |
2895 | ||
a80beece DS |
2896 | DEFUN (no_neighbor_interface_config, |
2897 | no_neighbor_interface_config_cmd, | |
31500417 | 2898 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2899 | NO_STR |
2900 | NEIGHBOR_STR | |
2901 | "Interface name\n" | |
31500417 DW |
2902 | "Configure BGP on interface\n" |
2903 | "Enable BGP with v6 link-local only\n" | |
2904 | "Member of the peer-group\n" | |
16cedbb0 | 2905 | "Peer-group name\n" |
3a2d747c QY |
2906 | "Specify a BGP neighbor\n" |
2907 | AS_STR | |
2908 | "Internal BGP peer\n" | |
2909 | "External BGP peer\n") | |
a80beece | 2910 | { |
c500ae40 | 2911 | int idx_word = 2; |
a80beece DS |
2912 | struct peer *peer; |
2913 | ||
2914 | /* look up for neighbor by interface name config. */ | |
c500ae40 | 2915 | peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); |
a80beece DS |
2916 | if (peer) |
2917 | { | |
4a04e5f7 | 2918 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2919 | if (peer->ifp) | |
2920 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2921 | peer_delete (peer); |
2922 | } | |
2923 | else | |
2924 | { | |
2925 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2926 | return CMD_WARNING; | |
2927 | } | |
2928 | return CMD_SUCCESS; | |
2929 | } | |
2930 | ||
718e3744 | 2931 | DEFUN (no_neighbor_peer_group, |
2932 | no_neighbor_peer_group_cmd, | |
2933 | "no neighbor WORD peer-group", | |
2934 | NO_STR | |
2935 | NEIGHBOR_STR | |
2936 | "Neighbor tag\n" | |
2937 | "Configure peer-group\n") | |
2938 | { | |
c500ae40 | 2939 | int idx_word = 2; |
718e3744 | 2940 | struct peer_group *group; |
2941 | ||
c500ae40 | 2942 | group = peer_group_lookup (vty->index, argv[idx_word]->arg); |
718e3744 | 2943 | if (group) |
2944 | peer_group_delete (group); | |
2945 | else | |
2946 | { | |
2947 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2948 | return CMD_WARNING; | |
2949 | } | |
2950 | return CMD_SUCCESS; | |
2951 | } | |
2952 | ||
a80beece DS |
2953 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2954 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2955 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2956 | NO_STR |
2957 | NEIGHBOR_STR | |
a80beece | 2958 | "Interface name or neighbor tag\n" |
718e3744 | 2959 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2960 | AS_STR |
2961 | "Internal BGP peer\n" | |
2962 | "External BGP peer\n") | |
718e3744 | 2963 | { |
c500ae40 | 2964 | int idx_word = 2; |
718e3744 | 2965 | struct peer_group *group; |
a80beece DS |
2966 | struct peer *peer; |
2967 | ||
2968 | /* look up for neighbor by interface name config. */ | |
c500ae40 | 2969 | peer = peer_lookup_by_conf_if (vty->index, argv[idx_word]->arg); |
a80beece DS |
2970 | if (peer) |
2971 | { | |
0299c004 | 2972 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
2973 | return CMD_SUCCESS; |
2974 | } | |
718e3744 | 2975 | |
c500ae40 | 2976 | group = peer_group_lookup (vty->index, argv[idx_word]->arg); |
718e3744 | 2977 | if (group) |
2978 | peer_group_remote_as_delete (group); | |
2979 | else | |
2980 | { | |
a80beece | 2981 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 2982 | return CMD_WARNING; |
2983 | } | |
2984 | return CMD_SUCCESS; | |
2985 | } | |
6b0655a2 | 2986 | |
718e3744 | 2987 | DEFUN (neighbor_local_as, |
2988 | neighbor_local_as_cmd, | |
9ccf14f7 | 2989 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2990 | NEIGHBOR_STR |
2991 | NEIGHBOR_ADDR_STR2 | |
2992 | "Specify a local-as number\n" | |
2993 | "AS number used as local AS\n") | |
2994 | { | |
c500ae40 DW |
2995 | int idx_peer = 1; |
2996 | int idx_number = 3; | |
718e3744 | 2997 | struct peer *peer; |
2998 | int ret; | |
2999 | ||
c500ae40 | 3000 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3001 | if (! peer) |
3002 | return CMD_WARNING; | |
3003 | ||
c500ae40 | 3004 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 0, 0); |
718e3744 | 3005 | return bgp_vty_return (vty, ret); |
3006 | } | |
3007 | ||
3008 | DEFUN (neighbor_local_as_no_prepend, | |
3009 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3010 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3011 | NEIGHBOR_STR |
3012 | NEIGHBOR_ADDR_STR2 | |
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 | { | |
c500ae40 DW |
3017 | int idx_peer = 1; |
3018 | int idx_number = 3; | |
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 | ||
c500ae40 | 3026 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 0); |
718e3744 | 3027 | return bgp_vty_return (vty, ret); |
3028 | } | |
3029 | ||
9d3f9705 AC |
3030 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3031 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3032 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3033 | NEIGHBOR_STR |
3034 | NEIGHBOR_ADDR_STR2 | |
3035 | "Specify a local-as number\n" | |
3036 | "AS number used as local AS\n" | |
3037 | "Do not prepend local-as to updates from ebgp peers\n" | |
3038 | "Do not prepend local-as to updates from ibgp peers\n") | |
3039 | { | |
c500ae40 DW |
3040 | int idx_peer = 1; |
3041 | int idx_number = 3; | |
9d3f9705 AC |
3042 | struct peer *peer; |
3043 | int ret; | |
3044 | ||
c500ae40 | 3045 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
3046 | if (! peer) |
3047 | return CMD_WARNING; | |
3048 | ||
c500ae40 | 3049 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 1); |
9d3f9705 AC |
3050 | return bgp_vty_return (vty, ret); |
3051 | } | |
3052 | ||
718e3744 | 3053 | DEFUN (no_neighbor_local_as, |
3054 | no_neighbor_local_as_cmd, | |
a636c635 | 3055 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3056 | NO_STR |
3057 | NEIGHBOR_STR | |
3058 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3059 | "Specify a local-as number\n" |
3060 | "AS number used as local AS\n" | |
3061 | "Do not prepend local-as to updates from ebgp peers\n" | |
3062 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3063 | { |
c500ae40 | 3064 | int idx_peer = 2; |
718e3744 | 3065 | struct peer *peer; |
3066 | int ret; | |
3067 | ||
c500ae40 | 3068 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3069 | if (! peer) |
3070 | return CMD_WARNING; | |
3071 | ||
3072 | ret = peer_local_as_unset (peer); | |
3073 | return bgp_vty_return (vty, ret); | |
3074 | } | |
3075 | ||
718e3744 | 3076 | |
9d3f9705 | 3077 | |
6b0655a2 | 3078 | |
3f9c7369 DS |
3079 | DEFUN (neighbor_solo, |
3080 | neighbor_solo_cmd, | |
9ccf14f7 | 3081 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3082 | NEIGHBOR_STR |
3083 | NEIGHBOR_ADDR_STR2 | |
3084 | "Solo peer - part of its own update group\n") | |
3085 | { | |
c500ae40 | 3086 | int idx_peer = 1; |
3f9c7369 DS |
3087 | struct peer *peer; |
3088 | int ret; | |
3089 | ||
c500ae40 | 3090 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3091 | if (! peer) |
3092 | return CMD_WARNING; | |
3093 | ||
3094 | ret = update_group_adjust_soloness(peer, 1); | |
3095 | return bgp_vty_return (vty, ret); | |
3096 | } | |
3097 | ||
3098 | DEFUN (no_neighbor_solo, | |
3099 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3101 | NO_STR |
3102 | NEIGHBOR_STR | |
3103 | NEIGHBOR_ADDR_STR2 | |
3104 | "Solo peer - part of its own update group\n") | |
3105 | { | |
c500ae40 | 3106 | int idx_peer = 2; |
3f9c7369 DS |
3107 | struct peer *peer; |
3108 | int ret; | |
3109 | ||
c500ae40 | 3110 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3111 | if (! peer) |
3112 | return CMD_WARNING; | |
3113 | ||
3114 | ret = update_group_adjust_soloness(peer, 0); | |
3115 | return bgp_vty_return (vty, ret); | |
3116 | } | |
3117 | ||
0df7c91f PJ |
3118 | DEFUN (neighbor_password, |
3119 | neighbor_password_cmd, | |
9ccf14f7 | 3120 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3121 | NEIGHBOR_STR |
3122 | NEIGHBOR_ADDR_STR2 | |
3123 | "Set a password\n" | |
3124 | "The password\n") | |
3125 | { | |
c500ae40 DW |
3126 | int idx_peer = 1; |
3127 | int idx_line = 3; | |
0df7c91f PJ |
3128 | struct peer *peer; |
3129 | int ret; | |
3130 | ||
c500ae40 | 3131 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3132 | if (! peer) |
3133 | return CMD_WARNING; | |
3134 | ||
c500ae40 | 3135 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3136 | return bgp_vty_return (vty, ret); |
3137 | } | |
3138 | ||
3139 | DEFUN (no_neighbor_password, | |
3140 | no_neighbor_password_cmd, | |
a636c635 | 3141 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3142 | NO_STR |
3143 | NEIGHBOR_STR | |
3144 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3145 | "Set a password\n" |
3146 | "The password\n") | |
0df7c91f | 3147 | { |
c500ae40 | 3148 | int idx_peer = 2; |
0df7c91f PJ |
3149 | struct peer *peer; |
3150 | int ret; | |
3151 | ||
c500ae40 | 3152 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3153 | if (! peer) |
3154 | return CMD_WARNING; | |
3155 | ||
3156 | ret = peer_password_unset (peer); | |
3157 | return bgp_vty_return (vty, ret); | |
3158 | } | |
6b0655a2 | 3159 | |
813d4307 | 3160 | |
718e3744 | 3161 | DEFUN (neighbor_activate, |
3162 | neighbor_activate_cmd, | |
9ccf14f7 | 3163 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3164 | NEIGHBOR_STR |
3165 | NEIGHBOR_ADDR_STR2 | |
3166 | "Enable the Address Family for this Neighbor\n") | |
3167 | { | |
c500ae40 | 3168 | int idx_peer = 1; |
c8560b44 | 3169 | int ret; |
718e3744 | 3170 | struct peer *peer; |
3171 | ||
c500ae40 | 3172 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3173 | if (! peer) |
3174 | return CMD_WARNING; | |
3175 | ||
c8560b44 | 3176 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3177 | |
c8560b44 DW |
3178 | if (ret) |
3179 | return CMD_WARNING; | |
718e3744 | 3180 | return CMD_SUCCESS; |
3181 | } | |
3182 | ||
3183 | DEFUN (no_neighbor_activate, | |
3184 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3185 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3186 | NO_STR |
3187 | NEIGHBOR_STR | |
3188 | NEIGHBOR_ADDR_STR2 | |
3189 | "Enable the Address Family for this Neighbor\n") | |
3190 | { | |
c500ae40 | 3191 | int idx_peer = 2; |
718e3744 | 3192 | int ret; |
3193 | struct peer *peer; | |
3194 | ||
3195 | /* Lookup peer. */ | |
c500ae40 | 3196 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3197 | if (! peer) |
3198 | return CMD_WARNING; | |
3199 | ||
3200 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3201 | ||
c8560b44 DW |
3202 | if (ret) |
3203 | return CMD_WARNING; | |
3204 | return CMD_SUCCESS; | |
718e3744 | 3205 | } |
6b0655a2 | 3206 | |
718e3744 | 3207 | DEFUN (neighbor_set_peer_group, |
3208 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3209 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3210 | NEIGHBOR_STR |
a80beece | 3211 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3212 | "Member of the peer-group\n" |
16cedbb0 | 3213 | "Peer-group name\n") |
718e3744 | 3214 | { |
c500ae40 DW |
3215 | int idx_peer = 1; |
3216 | int idx_word = 3; | |
718e3744 | 3217 | int ret; |
3218 | as_t as; | |
3219 | union sockunion su; | |
3220 | struct bgp *bgp; | |
a80beece | 3221 | struct peer *peer; |
718e3744 | 3222 | struct peer_group *group; |
3223 | ||
3224 | bgp = vty->index; | |
a80beece | 3225 | peer = NULL; |
718e3744 | 3226 | |
c500ae40 | 3227 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3228 | if (ret < 0) |
3229 | { | |
c500ae40 | 3230 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3231 | if (!peer) |
3232 | { | |
c500ae40 | 3233 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3234 | return CMD_WARNING; |
3235 | } | |
3236 | } | |
3237 | else | |
3238 | { | |
6aeb9e78 | 3239 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3240 | { |
3241 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3242 | VTY_NEWLINE); | |
3243 | return CMD_WARNING; | |
3244 | } | |
f14e6fdb DS |
3245 | |
3246 | /* Disallow for dynamic neighbor. */ | |
3247 | peer = peer_lookup (bgp, &su); | |
3248 | if (peer && peer_dynamic_neighbor (peer)) | |
3249 | { | |
3250 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3251 | VTY_NEWLINE); | |
3252 | return CMD_WARNING; | |
3253 | } | |
718e3744 | 3254 | } |
3255 | ||
c500ae40 | 3256 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3257 | if (! group) |
3258 | { | |
3259 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3260 | return CMD_WARNING; | |
3261 | } | |
3262 | ||
c8560b44 | 3263 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3264 | |
3265 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3266 | { | |
aea339f7 | 3267 | 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 | 3268 | return CMD_WARNING; |
3269 | } | |
3270 | ||
3271 | return bgp_vty_return (vty, ret); | |
3272 | } | |
3273 | ||
3274 | DEFUN (no_neighbor_set_peer_group, | |
3275 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3276 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3277 | NO_STR |
3278 | NEIGHBOR_STR | |
a80beece | 3279 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3280 | "Member of the peer-group\n" |
16cedbb0 | 3281 | "Peer-group name\n") |
718e3744 | 3282 | { |
c500ae40 DW |
3283 | int idx_peer = 2; |
3284 | int idx_word = 4; | |
718e3744 | 3285 | int ret; |
3286 | struct bgp *bgp; | |
3287 | struct peer *peer; | |
3288 | struct peer_group *group; | |
3289 | ||
3290 | bgp = vty->index; | |
3291 | ||
c500ae40 | 3292 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3293 | if (! peer) |
3294 | return CMD_WARNING; | |
3295 | ||
c500ae40 | 3296 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3297 | if (! group) |
3298 | { | |
3299 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3300 | return CMD_WARNING; | |
3301 | } | |
3302 | ||
c8560b44 | 3303 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3304 | |
3305 | return bgp_vty_return (vty, ret); | |
3306 | } | |
6b0655a2 | 3307 | |
94f2b392 | 3308 | static int |
e52702f2 | 3309 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3310 | u_int16_t flag, int set) |
718e3744 | 3311 | { |
3312 | int ret; | |
3313 | struct peer *peer; | |
3314 | ||
3315 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3316 | if (! peer) | |
3317 | return CMD_WARNING; | |
3318 | ||
8cdabf90 SK |
3319 | /* |
3320 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3321 | * we should not accept disable-connected-check. | |
3322 | */ | |
3323 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3324 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3325 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3326 | return CMD_WARNING; | |
3327 | } | |
3328 | ||
718e3744 | 3329 | if (set) |
3330 | ret = peer_flag_set (peer, flag); | |
3331 | else | |
3332 | ret = peer_flag_unset (peer, flag); | |
3333 | ||
3334 | return bgp_vty_return (vty, ret); | |
3335 | } | |
3336 | ||
94f2b392 | 3337 | static int |
fd79ac91 | 3338 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3339 | { |
3340 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3341 | } | |
3342 | ||
94f2b392 | 3343 | static int |
fd79ac91 | 3344 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3345 | { |
3346 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3347 | } | |
3348 | ||
3349 | /* neighbor passive. */ | |
3350 | DEFUN (neighbor_passive, | |
3351 | neighbor_passive_cmd, | |
9ccf14f7 | 3352 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3353 | NEIGHBOR_STR |
3354 | NEIGHBOR_ADDR_STR2 | |
3355 | "Don't send open messages 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_PASSIVE); | |
718e3744 | 3359 | } |
3360 | ||
3361 | DEFUN (no_neighbor_passive, | |
3362 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3364 | NO_STR |
3365 | NEIGHBOR_STR | |
3366 | NEIGHBOR_ADDR_STR2 | |
3367 | "Don't send open messages to this neighbor\n") | |
3368 | { | |
c500ae40 DW |
3369 | int idx_peer = 2; |
3370 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3371 | } |
6b0655a2 | 3372 | |
718e3744 | 3373 | /* neighbor shutdown. */ |
3374 | DEFUN (neighbor_shutdown, | |
3375 | neighbor_shutdown_cmd, | |
9ccf14f7 | 3376 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3377 | NEIGHBOR_STR |
3378 | NEIGHBOR_ADDR_STR2 | |
3379 | "Administratively shut down this neighbor\n") | |
3380 | { | |
c500ae40 DW |
3381 | int idx_peer = 1; |
3382 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3383 | } |
3384 | ||
3385 | DEFUN (no_neighbor_shutdown, | |
3386 | no_neighbor_shutdown_cmd, | |
9ccf14f7 | 3387 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3388 | NO_STR |
3389 | NEIGHBOR_STR | |
3390 | NEIGHBOR_ADDR_STR2 | |
3391 | "Administratively shut down this neighbor\n") | |
3392 | { | |
c500ae40 DW |
3393 | int idx_peer = 2; |
3394 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3395 | } |
6b0655a2 | 3396 | |
718e3744 | 3397 | /* neighbor capability dynamic. */ |
3398 | DEFUN (neighbor_capability_dynamic, | |
3399 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3400 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3401 | NEIGHBOR_STR |
3402 | NEIGHBOR_ADDR_STR2 | |
3403 | "Advertise capability to the peer\n" | |
3404 | "Advertise dynamic capability to this neighbor\n") | |
3405 | { | |
c500ae40 DW |
3406 | int idx_peer = 1; |
3407 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3408 | } |
3409 | ||
3410 | DEFUN (no_neighbor_capability_dynamic, | |
3411 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3412 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3413 | NO_STR |
3414 | NEIGHBOR_STR | |
3415 | NEIGHBOR_ADDR_STR2 | |
3416 | "Advertise capability to the peer\n" | |
3417 | "Advertise dynamic capability to this neighbor\n") | |
3418 | { | |
c500ae40 DW |
3419 | int idx_peer = 2; |
3420 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3421 | } |
6b0655a2 | 3422 | |
718e3744 | 3423 | /* neighbor dont-capability-negotiate */ |
3424 | DEFUN (neighbor_dont_capability_negotiate, | |
3425 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3426 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3427 | NEIGHBOR_STR |
3428 | NEIGHBOR_ADDR_STR2 | |
3429 | "Do not perform capability negotiation\n") | |
3430 | { | |
c500ae40 DW |
3431 | int idx_peer = 1; |
3432 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3433 | } |
3434 | ||
3435 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3436 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3437 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3438 | NO_STR |
3439 | NEIGHBOR_STR | |
3440 | NEIGHBOR_ADDR_STR2 | |
3441 | "Do not perform capability negotiation\n") | |
3442 | { | |
c500ae40 DW |
3443 | int idx_peer = 2; |
3444 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3445 | } |
6b0655a2 | 3446 | |
8a92a8a0 DS |
3447 | /* neighbor capability extended next hop encoding */ |
3448 | DEFUN (neighbor_capability_enhe, | |
3449 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3450 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3451 | NEIGHBOR_STR |
3452 | NEIGHBOR_ADDR_STR2 | |
3453 | "Advertise capability to the peer\n" | |
3454 | "Advertise extended next-hop capability to the peer\n") | |
3455 | { | |
c500ae40 DW |
3456 | int idx_peer = 1; |
3457 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3458 | } |
3459 | ||
3460 | DEFUN (no_neighbor_capability_enhe, | |
3461 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3462 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3463 | NO_STR |
3464 | NEIGHBOR_STR | |
3465 | NEIGHBOR_ADDR_STR2 | |
3466 | "Advertise capability to the peer\n" | |
3467 | "Advertise extended next-hop capability to the peer\n") | |
3468 | { | |
c500ae40 DW |
3469 | int idx_peer = 2; |
3470 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3471 | } |
3472 | ||
94f2b392 | 3473 | static int |
fd79ac91 | 3474 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3475 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3476 | { |
3477 | int ret; | |
3478 | struct peer *peer; | |
3479 | ||
3480 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3481 | if (! peer) | |
3482 | return CMD_WARNING; | |
3483 | ||
3484 | if (set) | |
3485 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3486 | else | |
3487 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3488 | ||
3489 | return bgp_vty_return (vty, ret); | |
3490 | } | |
3491 | ||
94f2b392 | 3492 | static int |
fd79ac91 | 3493 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3494 | safi_t safi, u_int32_t flag) |
718e3744 | 3495 | { |
3496 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3497 | } | |
3498 | ||
94f2b392 | 3499 | static int |
fd79ac91 | 3500 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3501 | safi_t safi, u_int32_t flag) |
718e3744 | 3502 | { |
3503 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3504 | } | |
6b0655a2 | 3505 | |
718e3744 | 3506 | /* neighbor capability orf prefix-list. */ |
3507 | DEFUN (neighbor_capability_orf_prefix, | |
3508 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3509 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3510 | NEIGHBOR_STR |
3511 | NEIGHBOR_ADDR_STR2 | |
3512 | "Advertise capability to the peer\n" | |
3513 | "Advertise ORF capability to the peer\n" | |
3514 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3515 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3516 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3517 | "Capability to SEND the ORF to this neighbor\n") | |
3518 | { | |
c500ae40 DW |
3519 | int idx_peer = 1; |
3520 | int idx_send_recv = 5; | |
718e3744 | 3521 | u_int16_t flag = 0; |
3522 | ||
c500ae40 | 3523 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3524 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3525 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3526 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3527 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3528 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3529 | else | |
3530 | return CMD_WARNING; | |
3531 | ||
c500ae40 | 3532 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3533 | bgp_node_safi (vty), flag); |
3534 | } | |
3535 | ||
3536 | DEFUN (no_neighbor_capability_orf_prefix, | |
3537 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3538 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3539 | NO_STR |
3540 | NEIGHBOR_STR | |
3541 | NEIGHBOR_ADDR_STR2 | |
3542 | "Advertise capability to the peer\n" | |
3543 | "Advertise ORF capability to the peer\n" | |
3544 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3545 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3546 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3547 | "Capability to SEND the ORF to this neighbor\n") | |
3548 | { | |
c500ae40 DW |
3549 | int idx_peer = 2; |
3550 | int idx_send_recv = 6; | |
718e3744 | 3551 | u_int16_t flag = 0; |
3552 | ||
c500ae40 | 3553 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3554 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3555 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3556 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3557 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3558 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3559 | else | |
3560 | return CMD_WARNING; | |
3561 | ||
c500ae40 | 3562 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3563 | bgp_node_safi (vty), flag); |
3564 | } | |
6b0655a2 | 3565 | |
718e3744 | 3566 | /* neighbor next-hop-self. */ |
3567 | DEFUN (neighbor_nexthop_self, | |
3568 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3569 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3570 | NEIGHBOR_STR |
3571 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3572 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3573 | { |
c500ae40 DW |
3574 | int idx_peer = 1; |
3575 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3576 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3577 | } | |
9e7a53c1 | 3578 | |
a538debe DS |
3579 | /* neighbor next-hop-self. */ |
3580 | DEFUN (neighbor_nexthop_self_force, | |
3581 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3582 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3583 | NEIGHBOR_STR |
3584 | NEIGHBOR_ADDR_STR2 | |
3585 | "Disable the next hop calculation for this neighbor\n" | |
3586 | "Set the next hop to self for reflected routes\n") | |
3587 | { | |
c500ae40 DW |
3588 | int idx_peer = 1; |
3589 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3590 | bgp_node_safi (vty), |
88b8ed8d | 3591 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3592 | } |
3593 | ||
3594 | DEFUN (no_neighbor_nexthop_self, | |
3595 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3596 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3597 | NO_STR |
3598 | NEIGHBOR_STR | |
3599 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3600 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3601 | { |
c500ae40 DW |
3602 | int idx_peer = 2; |
3603 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3604 | bgp_node_safi (vty), |
88b8ed8d | 3605 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3606 | } |
6b0655a2 | 3607 | |
88b8ed8d | 3608 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3609 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3610 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3611 | NO_STR |
3612 | NEIGHBOR_STR | |
3613 | NEIGHBOR_ADDR_STR2 | |
3614 | "Disable the next hop calculation for this neighbor\n" | |
3615 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3616 | { |
c500ae40 DW |
3617 | int idx_peer = 2; |
3618 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3619 | bgp_node_safi (vty), |
3620 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3621 | } | |
a538debe | 3622 | |
c7122e14 DS |
3623 | /* neighbor as-override */ |
3624 | DEFUN (neighbor_as_override, | |
3625 | neighbor_as_override_cmd, | |
9ccf14f7 | 3626 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3627 | NEIGHBOR_STR |
3628 | NEIGHBOR_ADDR_STR2 | |
3629 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3630 | { | |
c500ae40 DW |
3631 | int idx_peer = 1; |
3632 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3633 | bgp_node_safi (vty), |
3634 | PEER_FLAG_AS_OVERRIDE); | |
3635 | } | |
3636 | ||
3637 | DEFUN (no_neighbor_as_override, | |
3638 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3640 | NO_STR |
3641 | NEIGHBOR_STR | |
3642 | NEIGHBOR_ADDR_STR2 | |
3643 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3644 | { | |
c500ae40 DW |
3645 | int idx_peer = 2; |
3646 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3647 | bgp_node_safi (vty), |
3648 | PEER_FLAG_AS_OVERRIDE); | |
3649 | } | |
3650 | ||
718e3744 | 3651 | /* neighbor remove-private-AS. */ |
3652 | DEFUN (neighbor_remove_private_as, | |
3653 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3654 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3655 | NEIGHBOR_STR |
3656 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3657 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3658 | { |
c500ae40 DW |
3659 | int idx_peer = 1; |
3660 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3661 | bgp_node_safi (vty), |
3662 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3663 | } | |
3664 | ||
5000f21c DS |
3665 | DEFUN (neighbor_remove_private_as_all, |
3666 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3667 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3668 | NEIGHBOR_STR |
3669 | NEIGHBOR_ADDR_STR2 | |
3670 | "Remove private ASNs in outbound updates\n" | |
3671 | "Apply to all AS numbers") | |
3672 | { | |
c500ae40 DW |
3673 | int idx_peer = 1; |
3674 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3675 | bgp_node_safi (vty), |
5000f21c DS |
3676 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3677 | } | |
3678 | ||
3679 | DEFUN (neighbor_remove_private_as_replace_as, | |
3680 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3681 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3682 | NEIGHBOR_STR |
3683 | NEIGHBOR_ADDR_STR2 | |
3684 | "Remove private ASNs in outbound updates\n" | |
3685 | "Replace private ASNs with our ASN in outbound updates\n") | |
3686 | { | |
c500ae40 DW |
3687 | int idx_peer = 1; |
3688 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3689 | bgp_node_safi (vty), |
5000f21c DS |
3690 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3691 | } | |
3692 | ||
3693 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3694 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3695 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3696 | NEIGHBOR_STR |
3697 | NEIGHBOR_ADDR_STR2 | |
3698 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3699 | "Apply to all AS numbers\n" |
5000f21c DS |
3700 | "Replace private ASNs with our ASN in outbound updates\n") |
3701 | { | |
c500ae40 DW |
3702 | int idx_peer = 1; |
3703 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3704 | bgp_node_safi (vty), |
88b8ed8d | 3705 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3706 | } |
3707 | ||
718e3744 | 3708 | DEFUN (no_neighbor_remove_private_as, |
3709 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3710 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3711 | NO_STR |
3712 | NEIGHBOR_STR | |
3713 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3714 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3715 | { |
c500ae40 DW |
3716 | int idx_peer = 2; |
3717 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3718 | bgp_node_safi (vty), |
88b8ed8d | 3719 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3720 | } |
6b0655a2 | 3721 | |
88b8ed8d | 3722 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3723 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3725 | NO_STR |
3726 | NEIGHBOR_STR | |
3727 | NEIGHBOR_ADDR_STR2 | |
3728 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3729 | "Apply to all AS numbers\n") |
88b8ed8d | 3730 | { |
c500ae40 DW |
3731 | int idx_peer = 2; |
3732 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3733 | bgp_node_safi (vty), |
3734 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3735 | } | |
5000f21c | 3736 | |
88b8ed8d | 3737 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3738 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3740 | NO_STR |
3741 | NEIGHBOR_STR | |
3742 | NEIGHBOR_ADDR_STR2 | |
3743 | "Remove private ASNs in outbound updates\n" | |
3744 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3745 | { |
c500ae40 DW |
3746 | int idx_peer = 2; |
3747 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3748 | bgp_node_safi (vty), |
3749 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3750 | } | |
5000f21c | 3751 | |
88b8ed8d | 3752 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3753 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3755 | NO_STR |
3756 | NEIGHBOR_STR | |
3757 | NEIGHBOR_ADDR_STR2 | |
3758 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3759 | "Apply to all AS numbers\n" |
5000f21c | 3760 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3761 | { |
c500ae40 DW |
3762 | int idx_peer = 2; |
3763 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3764 | bgp_node_safi (vty), |
3765 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3766 | } | |
5000f21c DS |
3767 | |
3768 | ||
718e3744 | 3769 | /* neighbor send-community. */ |
3770 | DEFUN (neighbor_send_community, | |
3771 | neighbor_send_community_cmd, | |
9ccf14f7 | 3772 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3773 | NEIGHBOR_STR |
3774 | NEIGHBOR_ADDR_STR2 | |
3775 | "Send Community attribute to this neighbor\n") | |
3776 | { | |
c500ae40 DW |
3777 | int idx_peer = 1; |
3778 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3779 | bgp_node_safi (vty), |
3780 | PEER_FLAG_SEND_COMMUNITY); | |
3781 | } | |
3782 | ||
3783 | DEFUN (no_neighbor_send_community, | |
3784 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3786 | NO_STR |
3787 | NEIGHBOR_STR | |
3788 | NEIGHBOR_ADDR_STR2 | |
3789 | "Send Community attribute to this neighbor\n") | |
3790 | { | |
c500ae40 DW |
3791 | int idx_peer = 2; |
3792 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3793 | bgp_node_safi (vty), |
3794 | PEER_FLAG_SEND_COMMUNITY); | |
3795 | } | |
6b0655a2 | 3796 | |
718e3744 | 3797 | /* neighbor send-community extended. */ |
3798 | DEFUN (neighbor_send_community_type, | |
3799 | neighbor_send_community_type_cmd, | |
9ccf14f7 | 3800 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3801 | NEIGHBOR_STR |
3802 | NEIGHBOR_ADDR_STR2 | |
3803 | "Send Community attribute to this neighbor\n" | |
3804 | "Send Standard and Extended Community attributes\n" | |
3805 | "Send Extended Community attributes\n" | |
3806 | "Send Standard Community attributes\n") | |
3807 | { | |
4c4ff4c1 QY |
3808 | int idx = 0; |
3809 | u_int32_t flag = 0; | |
718e3744 | 3810 | |
4c4ff4c1 QY |
3811 | char *peer = argv[1]->arg; |
3812 | ||
3813 | if (argv_find (argv, argc, "standard", &idx)) | |
3814 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3815 | else if (argv_find (argv, argc, "extended", &idx)) | |
3816 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3817 | else | |
3818 | { | |
3819 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3820 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3821 | } | |
3822 | ||
3823 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3824 | } |
3825 | ||
3826 | DEFUN (no_neighbor_send_community_type, | |
3827 | no_neighbor_send_community_type_cmd, | |
9ccf14f7 | 3828 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3829 | NO_STR |
3830 | NEIGHBOR_STR | |
3831 | NEIGHBOR_ADDR_STR2 | |
3832 | "Send Community attribute to this neighbor\n" | |
3833 | "Send Standard and Extended Community attributes\n" | |
3834 | "Send Extended Community attributes\n" | |
3835 | "Send Standard Community attributes\n") | |
3836 | { | |
c500ae40 DW |
3837 | int idx_peer = 2; |
3838 | int idx_type = 4; | |
3839 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3840 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3841 | bgp_node_safi (vty), |
3842 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3843 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3844 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3845 | bgp_node_safi (vty), |
3846 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
3847 | ||
c500ae40 | 3848 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3849 | bgp_node_safi (vty), |
3850 | (PEER_FLAG_SEND_COMMUNITY | | |
3851 | PEER_FLAG_SEND_EXT_COMMUNITY)); | |
3852 | } | |
6b0655a2 | 3853 | |
718e3744 | 3854 | /* neighbor soft-reconfig. */ |
3855 | DEFUN (neighbor_soft_reconfiguration, | |
3856 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3857 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3858 | NEIGHBOR_STR |
3859 | NEIGHBOR_ADDR_STR2 | |
3860 | "Per neighbor soft reconfiguration\n" | |
3861 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3862 | { | |
c500ae40 DW |
3863 | int idx_peer = 1; |
3864 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3865 | bgp_node_afi (vty), bgp_node_safi (vty), |
3866 | PEER_FLAG_SOFT_RECONFIG); | |
3867 | } | |
3868 | ||
3869 | DEFUN (no_neighbor_soft_reconfiguration, | |
3870 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3871 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3872 | NO_STR |
3873 | NEIGHBOR_STR | |
3874 | NEIGHBOR_ADDR_STR2 | |
3875 | "Per neighbor soft reconfiguration\n" | |
3876 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3877 | { | |
c500ae40 DW |
3878 | int idx_peer = 2; |
3879 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3880 | bgp_node_afi (vty), bgp_node_safi (vty), |
3881 | PEER_FLAG_SOFT_RECONFIG); | |
3882 | } | |
6b0655a2 | 3883 | |
718e3744 | 3884 | DEFUN (neighbor_route_reflector_client, |
3885 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3886 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3887 | NEIGHBOR_STR |
3888 | NEIGHBOR_ADDR_STR2 | |
3889 | "Configure a neighbor as Route Reflector client\n") | |
3890 | { | |
c500ae40 | 3891 | int idx_peer = 1; |
718e3744 | 3892 | struct peer *peer; |
3893 | ||
3894 | ||
c500ae40 | 3895 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3896 | if (! peer) |
3897 | return CMD_WARNING; | |
3898 | ||
c500ae40 | 3899 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3900 | bgp_node_safi (vty), |
3901 | PEER_FLAG_REFLECTOR_CLIENT); | |
3902 | } | |
3903 | ||
3904 | DEFUN (no_neighbor_route_reflector_client, | |
3905 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3907 | NO_STR |
3908 | NEIGHBOR_STR | |
3909 | NEIGHBOR_ADDR_STR2 | |
3910 | "Configure a neighbor as Route Reflector client\n") | |
3911 | { | |
c500ae40 DW |
3912 | int idx_peer = 2; |
3913 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3914 | bgp_node_safi (vty), |
3915 | PEER_FLAG_REFLECTOR_CLIENT); | |
3916 | } | |
6b0655a2 | 3917 | |
718e3744 | 3918 | /* neighbor route-server-client. */ |
3919 | DEFUN (neighbor_route_server_client, | |
3920 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 3921 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3922 | NEIGHBOR_STR |
3923 | NEIGHBOR_ADDR_STR2 | |
3924 | "Configure a neighbor as Route Server client\n") | |
3925 | { | |
c500ae40 | 3926 | int idx_peer = 1; |
2a3d5731 DW |
3927 | struct peer *peer; |
3928 | ||
c500ae40 | 3929 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
3930 | if (! peer) |
3931 | return CMD_WARNING; | |
c500ae40 | 3932 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
3933 | bgp_node_safi (vty), |
3934 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 3935 | } |
3936 | ||
3937 | DEFUN (no_neighbor_route_server_client, | |
3938 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 3939 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3940 | NO_STR |
3941 | NEIGHBOR_STR | |
3942 | NEIGHBOR_ADDR_STR2 | |
3943 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 3944 | { |
c500ae40 DW |
3945 | int idx_peer = 2; |
3946 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
3947 | bgp_node_safi (vty), |
3948 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 3949 | } |
6b0655a2 | 3950 | |
fee0f4c6 | 3951 | DEFUN (neighbor_nexthop_local_unchanged, |
3952 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3953 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3954 | NEIGHBOR_STR |
3955 | NEIGHBOR_ADDR_STR2 | |
3956 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
3957 | "Leave link-local nexthop unchanged for this peer\n") | |
3958 | { | |
c500ae40 DW |
3959 | int idx_peer = 1; |
3960 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 3961 | bgp_node_safi (vty), |
3962 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
3963 | } | |
6b0655a2 | 3964 | |
fee0f4c6 | 3965 | DEFUN (no_neighbor_nexthop_local_unchanged, |
3966 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3967 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3968 | NO_STR |
3969 | NEIGHBOR_STR | |
3970 | NEIGHBOR_ADDR_STR2 | |
3971 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
3972 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 3973 | { |
c500ae40 DW |
3974 | int idx_peer = 2; |
3975 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3976 | bgp_node_safi (vty), |
fee0f4c6 | 3977 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 3978 | } |
6b0655a2 | 3979 | |
718e3744 | 3980 | DEFUN (neighbor_attr_unchanged, |
3981 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
3982 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3983 | [<\ | |
ddbaf941 QY |
3984 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3985 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3986 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3987 | >]", |
718e3744 | 3988 | NEIGHBOR_STR |
3989 | NEIGHBOR_ADDR_STR2 | |
3990 | "BGP attribute is propagated unchanged to this neighbor\n" | |
3991 | "As-path attribute\n" | |
3992 | "Nexthop attribute\n" | |
40e718b5 | 3993 | "Med attribute\n" |
1084263f QY |
3994 | "Med attribute\n" |
3995 | "Nexthop attribute\n" | |
3996 | "Nexthop attribute\n" | |
3997 | "As-path attribute\n" | |
3998 | "Med attribute\n" | |
40e718b5 | 3999 | "Med attribute\n" |
718e3744 | 4000 | "As-path attribute\n" |
1084263f QY |
4001 | "Med attribute\n" |
4002 | "As-path attribute\n" | |
4003 | "Nexthop attribute\n" | |
40e718b5 | 4004 | "Nexthop attribute\n" |
1084263f | 4005 | "As-path attribute\n") |
718e3744 | 4006 | { |
40e718b5 QY |
4007 | int idx = 0; |
4008 | char *peer = argv[1]->arg; | |
4009 | u_int16_t flags = 0; | |
718e3744 | 4010 | |
40e718b5 | 4011 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4012 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4013 | idx = 0; |
4014 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4015 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4016 | idx = 0; | |
4017 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4018 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4019 | ||
40e718b5 QY |
4020 | if (!flags) // no flags means all of them! |
4021 | { | |
718e3744 | 4022 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4023 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4024 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4025 | } | |
718e3744 | 4026 | |
40e718b5 | 4027 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4028 | } |
4029 | ||
718e3744 | 4030 | DEFUN (no_neighbor_attr_unchanged, |
4031 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
4032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
4033 | [<\ | |
ddbaf941 QY |
4034 | as-path [<next-hop [med]|med [next-hop]>]|\ |
4035 | next-hop [<as-path [med]|med [as-path]>]|\ | |
4036 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 4037 | >]", |
e52702f2 | 4038 | NO_STR |
718e3744 | 4039 | NEIGHBOR_STR |
4040 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4041 | "BGP attribute is propagated unchanged to this neighbor\n" |
4042 | "As-path attribute\n" | |
40e718b5 | 4043 | "Nexthop attribute\n" |
31500417 | 4044 | "Med attribute\n" |
1084263f QY |
4045 | "Med attribute\n" |
4046 | "Nexthop attribute\n" | |
4047 | "Nexthop attribute\n" | |
4048 | "As-path attribute\n" | |
4049 | "Med attribute\n" | |
40e718b5 | 4050 | "Med attribute\n" |
718e3744 | 4051 | "As-path attribute\n" |
1084263f QY |
4052 | "Med attribute\n" |
4053 | "As-path attribute\n" | |
4054 | "Nexthop attribute\n" | |
718e3744 | 4055 | "Nexthop attribute\n" |
1084263f | 4056 | "As-path attribute\n") |
718e3744 | 4057 | { |
40e718b5 QY |
4058 | int idx = 0; |
4059 | char *peer = argv[2]->arg; | |
4060 | u_int16_t flags = 0; | |
718e3744 | 4061 | |
40e718b5 | 4062 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4063 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4064 | idx = 0; |
4065 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4066 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4067 | idx = 0; | |
4068 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4069 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4070 | ||
40e718b5 QY |
4071 | if (!flags) // no flags means all of them! |
4072 | { | |
718e3744 | 4073 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4074 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4075 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4076 | } | |
718e3744 | 4077 | |
40e718b5 | 4078 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4079 | } |
4080 | ||
718e3744 | 4081 | |
718e3744 | 4082 | /* EBGP multihop configuration. */ |
94f2b392 | 4083 | static int |
e52702f2 | 4084 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4085 | const char *ttl_str) |
718e3744 | 4086 | { |
4087 | struct peer *peer; | |
fd79ac91 | 4088 | unsigned int ttl; |
718e3744 | 4089 | |
4090 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4091 | if (! peer) | |
4092 | return CMD_WARNING; | |
4093 | ||
63fa10b5 QY |
4094 | if (peer->conf_if) |
4095 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4096 | ||
718e3744 | 4097 | if (! ttl_str) |
9b1be336 | 4098 | ttl = MAXTTL; |
718e3744 | 4099 | else |
9b1be336 | 4100 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4101 | |
89b6d1f8 | 4102 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4103 | } |
4104 | ||
94f2b392 | 4105 | static int |
e52702f2 | 4106 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4107 | { |
4108 | struct peer *peer; | |
4109 | ||
4110 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4111 | if (! peer) | |
4112 | return CMD_WARNING; | |
4113 | ||
89b6d1f8 | 4114 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4115 | } |
4116 | ||
4117 | /* neighbor ebgp-multihop. */ | |
4118 | DEFUN (neighbor_ebgp_multihop, | |
4119 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4120 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4121 | NEIGHBOR_STR |
4122 | NEIGHBOR_ADDR_STR2 | |
4123 | "Allow EBGP neighbors not on directly connected networks\n") | |
4124 | { | |
c500ae40 DW |
4125 | int idx_peer = 1; |
4126 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4127 | } |
4128 | ||
4129 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4130 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4131 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4132 | NEIGHBOR_STR |
4133 | NEIGHBOR_ADDR_STR2 | |
4134 | "Allow EBGP neighbors not on directly connected networks\n" | |
4135 | "maximum hop count\n") | |
4136 | { | |
c500ae40 DW |
4137 | int idx_peer = 1; |
4138 | int idx_number = 3; | |
4139 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4140 | } |
4141 | ||
4142 | DEFUN (no_neighbor_ebgp_multihop, | |
4143 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4144 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4145 | NO_STR |
4146 | NEIGHBOR_STR | |
4147 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4148 | "Allow EBGP neighbors not on directly connected networks\n" |
4149 | "maximum hop count\n") | |
718e3744 | 4150 | { |
c500ae40 DW |
4151 | int idx_peer = 2; |
4152 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4153 | } |
4154 | ||
6b0655a2 | 4155 | |
6ffd2079 | 4156 | /* disable-connected-check */ |
4157 | DEFUN (neighbor_disable_connected_check, | |
4158 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4159 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4160 | NEIGHBOR_STR |
4161 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4162 | "one-hop away EBGP peer using loopback address\n" |
4163 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4164 | { |
c500ae40 DW |
4165 | int idx_peer = 1; |
4166 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4167 | } |
4168 | ||
4169 | DEFUN (no_neighbor_disable_connected_check, | |
4170 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4171 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4172 | NO_STR |
4173 | NEIGHBOR_STR | |
4174 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4175 | "one-hop away EBGP peer using loopback address\n" |
4176 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4177 | { |
c500ae40 DW |
4178 | int idx_peer = 2; |
4179 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4180 | } |
4181 | ||
718e3744 | 4182 | DEFUN (neighbor_description, |
4183 | neighbor_description_cmd, | |
e961923c | 4184 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4185 | NEIGHBOR_STR |
4186 | NEIGHBOR_ADDR_STR2 | |
4187 | "Neighbor specific description\n" | |
4188 | "Up to 80 characters describing this neighbor\n") | |
4189 | { | |
c500ae40 | 4190 | int idx_peer = 1; |
58749582 | 4191 | int idx_line = 3; |
718e3744 | 4192 | struct peer *peer; |
718e3744 | 4193 | char *str; |
718e3744 | 4194 | |
c500ae40 | 4195 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4196 | if (! peer) |
4197 | return CMD_WARNING; | |
4198 | ||
58749582 | 4199 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4200 | |
4201 | peer_description_set (peer, str); | |
4202 | ||
3b8b1855 | 4203 | XFREE (MTYPE_TMP, str); |
718e3744 | 4204 | |
4205 | return CMD_SUCCESS; | |
4206 | } | |
4207 | ||
4208 | DEFUN (no_neighbor_description, | |
4209 | no_neighbor_description_cmd, | |
a636c635 | 4210 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4211 | NO_STR |
4212 | NEIGHBOR_STR | |
4213 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4214 | "Neighbor specific description\n" |
4215 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4216 | { |
c500ae40 | 4217 | int idx_peer = 2; |
718e3744 | 4218 | struct peer *peer; |
4219 | ||
c500ae40 | 4220 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4221 | if (! peer) |
4222 | return CMD_WARNING; | |
4223 | ||
4224 | peer_description_unset (peer); | |
4225 | ||
4226 | return CMD_SUCCESS; | |
4227 | } | |
4228 | ||
6b0655a2 | 4229 | |
718e3744 | 4230 | /* Neighbor update-source. */ |
94f2b392 | 4231 | static int |
e52702f2 | 4232 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4233 | const char *source_str) |
718e3744 | 4234 | { |
4235 | struct peer *peer; | |
718e3744 | 4236 | |
4237 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4238 | if (! peer) | |
4239 | return CMD_WARNING; | |
4240 | ||
a80beece DS |
4241 | if (peer->conf_if) |
4242 | return CMD_WARNING; | |
4243 | ||
718e3744 | 4244 | if (source_str) |
4245 | { | |
c63b83fe JBD |
4246 | union sockunion su; |
4247 | int ret = str2sockunion (source_str, &su); | |
4248 | ||
4249 | if (ret == 0) | |
4250 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4251 | else |
4252 | peer_update_source_if_set (peer, source_str); | |
4253 | } | |
4254 | else | |
4255 | peer_update_source_unset (peer); | |
4256 | ||
4257 | return CMD_SUCCESS; | |
4258 | } | |
4259 | ||
369688c0 PJ |
4260 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4261 | "IPv4 address\n" \ | |
9a1a331d PJ |
4262 | "IPv6 address\n" \ |
4263 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4264 | |
718e3744 | 4265 | DEFUN (neighbor_update_source, |
4266 | neighbor_update_source_cmd, | |
9ccf14f7 | 4267 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4268 | NEIGHBOR_STR |
4269 | NEIGHBOR_ADDR_STR2 | |
4270 | "Source of routing updates\n" | |
369688c0 | 4271 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4272 | { |
c500ae40 DW |
4273 | int idx_peer = 1; |
4274 | int idx_peer_2 = 3; | |
4275 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4276 | } |
4277 | ||
4278 | DEFUN (no_neighbor_update_source, | |
4279 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4280 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4281 | NO_STR |
4282 | NEIGHBOR_STR | |
4283 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4284 | "Source of routing updates\n" |
4285 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4286 | { |
c500ae40 DW |
4287 | int idx_peer = 2; |
4288 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4289 | } |
6b0655a2 | 4290 | |
94f2b392 | 4291 | static int |
e52702f2 QY |
4292 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4293 | afi_t afi, safi_t safi, | |
fd79ac91 | 4294 | const char *rmap, int set) |
718e3744 | 4295 | { |
4296 | int ret; | |
4297 | struct peer *peer; | |
4298 | ||
4299 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4300 | if (! peer) | |
4301 | return CMD_WARNING; | |
4302 | ||
4303 | if (set) | |
4304 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4305 | else | |
4306 | ret = peer_default_originate_unset (peer, afi, safi); | |
4307 | ||
4308 | return bgp_vty_return (vty, ret); | |
4309 | } | |
4310 | ||
4311 | /* neighbor default-originate. */ | |
4312 | DEFUN (neighbor_default_originate, | |
4313 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4314 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4315 | NEIGHBOR_STR |
4316 | NEIGHBOR_ADDR_STR2 | |
4317 | "Originate default route to this neighbor\n") | |
4318 | { | |
c500ae40 DW |
4319 | int idx_peer = 1; |
4320 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4321 | bgp_node_safi (vty), NULL, 1); |
4322 | } | |
4323 | ||
4324 | DEFUN (neighbor_default_originate_rmap, | |
4325 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4326 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4327 | NEIGHBOR_STR |
4328 | NEIGHBOR_ADDR_STR2 | |
4329 | "Originate default route to this neighbor\n" | |
4330 | "Route-map to specify criteria to originate default\n" | |
4331 | "route-map name\n") | |
4332 | { | |
c500ae40 DW |
4333 | int idx_peer = 1; |
4334 | int idx_word = 4; | |
4335 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4336 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4337 | } |
4338 | ||
4339 | DEFUN (no_neighbor_default_originate, | |
4340 | no_neighbor_default_originate_cmd, | |
a636c635 | 4341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4342 | NO_STR |
4343 | NEIGHBOR_STR | |
4344 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4345 | "Originate default route to this neighbor\n" |
4346 | "Route-map to specify criteria to originate default\n" | |
4347 | "route-map name\n") | |
718e3744 | 4348 | { |
c500ae40 DW |
4349 | int idx_peer = 2; |
4350 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4351 | bgp_node_safi (vty), NULL, 0); |
4352 | } | |
4353 | ||
6b0655a2 | 4354 | |
718e3744 | 4355 | /* Set neighbor's BGP port. */ |
94f2b392 | 4356 | static int |
e52702f2 | 4357 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4358 | const char *port_str) |
718e3744 | 4359 | { |
4360 | struct peer *peer; | |
4361 | u_int16_t port; | |
4362 | struct servent *sp; | |
4363 | ||
4364 | peer = peer_lookup_vty (vty, ip_str); | |
4365 | if (! peer) | |
4366 | return CMD_WARNING; | |
4367 | ||
4368 | if (! port_str) | |
e52702f2 | 4369 | { |
718e3744 | 4370 | sp = getservbyname ("bgp", "tcp"); |
4371 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4372 | } | |
4373 | else | |
4374 | { | |
4375 | VTY_GET_INTEGER("port", port, port_str); | |
4376 | } | |
4377 | ||
4378 | peer_port_set (peer, port); | |
4379 | ||
4380 | return CMD_SUCCESS; | |
4381 | } | |
4382 | ||
f418446b | 4383 | /* Set specified peer's BGP port. */ |
718e3744 | 4384 | DEFUN (neighbor_port, |
4385 | neighbor_port_cmd, | |
9ccf14f7 | 4386 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4387 | NEIGHBOR_STR |
4388 | NEIGHBOR_ADDR_STR | |
4389 | "Neighbor's BGP port\n" | |
4390 | "TCP port number\n") | |
4391 | { | |
c500ae40 DW |
4392 | int idx_ip = 1; |
4393 | int idx_number = 3; | |
4394 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4395 | } |
4396 | ||
4397 | DEFUN (no_neighbor_port, | |
4398 | no_neighbor_port_cmd, | |
9ccf14f7 | 4399 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4400 | NO_STR |
4401 | NEIGHBOR_STR | |
4402 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4403 | "Neighbor's BGP port\n" |
4404 | "TCP port number\n") | |
718e3744 | 4405 | { |
c500ae40 DW |
4406 | int idx_ip = 2; |
4407 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4408 | } |
4409 | ||
6b0655a2 | 4410 | |
718e3744 | 4411 | /* neighbor weight. */ |
94f2b392 | 4412 | static int |
e52702f2 | 4413 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4414 | afi_t afi, safi_t safi, |
fd79ac91 | 4415 | const char *weight_str) |
718e3744 | 4416 | { |
1f9a9fff | 4417 | int ret; |
718e3744 | 4418 | struct peer *peer; |
4419 | unsigned long weight; | |
4420 | ||
4421 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4422 | if (! peer) | |
4423 | return CMD_WARNING; | |
4424 | ||
4425 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4426 | ||
d93f7ffc | 4427 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4428 | return bgp_vty_return (vty, ret); |
718e3744 | 4429 | } |
4430 | ||
94f2b392 | 4431 | static int |
d93f7ffc DW |
4432 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4433 | afi_t afi, safi_t safi) | |
718e3744 | 4434 | { |
1f9a9fff | 4435 | int ret; |
718e3744 | 4436 | struct peer *peer; |
4437 | ||
4438 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4439 | if (! peer) | |
4440 | return CMD_WARNING; | |
4441 | ||
d93f7ffc | 4442 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4443 | return bgp_vty_return (vty, ret); |
718e3744 | 4444 | } |
4445 | ||
4446 | DEFUN (neighbor_weight, | |
4447 | neighbor_weight_cmd, | |
9ccf14f7 | 4448 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4449 | NEIGHBOR_STR |
4450 | NEIGHBOR_ADDR_STR2 | |
4451 | "Set default weight for routes from this neighbor\n" | |
4452 | "default weight\n") | |
4453 | { | |
c500ae40 DW |
4454 | int idx_peer = 1; |
4455 | int idx_number = 3; | |
e52702f2 QY |
4456 | return peer_weight_set_vty (vty, |
4457 | argv[idx_peer]->arg, | |
4458 | bgp_node_afi (vty), | |
4459 | bgp_node_safi (vty), | |
4460 | argv[idx_number]->arg); | |
718e3744 | 4461 | } |
4462 | ||
4463 | DEFUN (no_neighbor_weight, | |
4464 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4465 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4466 | NO_STR |
4467 | NEIGHBOR_STR | |
4468 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4469 | "Set default weight for routes from this neighbor\n" |
4470 | "default weight\n") | |
718e3744 | 4471 | { |
c500ae40 | 4472 | int idx_peer = 2; |
e52702f2 | 4473 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4474 | } |
4475 | ||
6b0655a2 | 4476 | |
718e3744 | 4477 | /* Override capability negotiation. */ |
4478 | DEFUN (neighbor_override_capability, | |
4479 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4480 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4481 | NEIGHBOR_STR |
4482 | NEIGHBOR_ADDR_STR2 | |
4483 | "Override capability negotiation result\n") | |
4484 | { | |
c500ae40 DW |
4485 | int idx_peer = 1; |
4486 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4487 | } |
4488 | ||
4489 | DEFUN (no_neighbor_override_capability, | |
4490 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4491 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4492 | NO_STR |
4493 | NEIGHBOR_STR | |
4494 | NEIGHBOR_ADDR_STR2 | |
4495 | "Override capability negotiation result\n") | |
4496 | { | |
c500ae40 DW |
4497 | int idx_peer = 2; |
4498 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4499 | } |
6b0655a2 | 4500 | |
718e3744 | 4501 | DEFUN (neighbor_strict_capability, |
4502 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4503 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4504 | NEIGHBOR_STR |
4505 | NEIGHBOR_ADDR_STR | |
4506 | "Strict capability negotiation match\n") | |
4507 | { | |
c500ae40 DW |
4508 | int idx_ip = 1; |
4509 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4510 | } |
4511 | ||
4512 | DEFUN (no_neighbor_strict_capability, | |
4513 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4514 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4515 | NO_STR |
4516 | NEIGHBOR_STR | |
4517 | NEIGHBOR_ADDR_STR | |
4518 | "Strict capability negotiation match\n") | |
4519 | { | |
c500ae40 DW |
4520 | int idx_ip = 2; |
4521 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4522 | } |
6b0655a2 | 4523 | |
94f2b392 | 4524 | static int |
e52702f2 | 4525 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4526 | const char *keep_str, const char *hold_str) |
718e3744 | 4527 | { |
4528 | int ret; | |
4529 | struct peer *peer; | |
4530 | u_int32_t keepalive; | |
4531 | u_int32_t holdtime; | |
4532 | ||
4533 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4534 | if (! peer) | |
4535 | return CMD_WARNING; | |
4536 | ||
4537 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4538 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4539 | ||
4540 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4541 | ||
4542 | return bgp_vty_return (vty, ret); | |
4543 | } | |
6b0655a2 | 4544 | |
94f2b392 | 4545 | static int |
fd79ac91 | 4546 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4547 | { |
4548 | int ret; | |
4549 | struct peer *peer; | |
4550 | ||
0c412461 | 4551 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4552 | if (! peer) |
4553 | return CMD_WARNING; | |
4554 | ||
4555 | ret = peer_timers_unset (peer); | |
4556 | ||
4557 | return bgp_vty_return (vty, ret); | |
4558 | } | |
4559 | ||
4560 | DEFUN (neighbor_timers, | |
4561 | neighbor_timers_cmd, | |
9ccf14f7 | 4562 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4563 | NEIGHBOR_STR |
4564 | NEIGHBOR_ADDR_STR2 | |
4565 | "BGP per neighbor timers\n" | |
4566 | "Keepalive interval\n" | |
4567 | "Holdtime\n") | |
4568 | { | |
c500ae40 DW |
4569 | int idx_peer = 1; |
4570 | int idx_number = 3; | |
4571 | int idx_number_2 = 4; | |
4572 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4573 | } |
4574 | ||
4575 | DEFUN (no_neighbor_timers, | |
4576 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4578 | NO_STR |
4579 | NEIGHBOR_STR | |
4580 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4581 | "BGP per neighbor timers\n" |
4582 | "Keepalive interval\n" | |
4583 | "Holdtime\n") | |
718e3744 | 4584 | { |
c500ae40 DW |
4585 | int idx_peer = 2; |
4586 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4587 | } |
6b0655a2 | 4588 | |
813d4307 | 4589 | |
94f2b392 | 4590 | static int |
e52702f2 | 4591 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4592 | const char *time_str) |
718e3744 | 4593 | { |
4594 | int ret; | |
4595 | struct peer *peer; | |
4596 | u_int32_t connect; | |
4597 | ||
966f821c | 4598 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4599 | if (! peer) |
4600 | return CMD_WARNING; | |
4601 | ||
4602 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4603 | ||
4604 | ret = peer_timers_connect_set (peer, connect); | |
4605 | ||
966f821c | 4606 | return bgp_vty_return (vty, ret); |
718e3744 | 4607 | } |
4608 | ||
94f2b392 | 4609 | static int |
fd79ac91 | 4610 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4611 | { |
4612 | int ret; | |
4613 | struct peer *peer; | |
4614 | ||
4615 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4616 | if (! peer) | |
4617 | return CMD_WARNING; | |
4618 | ||
4619 | ret = peer_timers_connect_unset (peer); | |
4620 | ||
966f821c | 4621 | return bgp_vty_return (vty, ret); |
718e3744 | 4622 | } |
4623 | ||
4624 | DEFUN (neighbor_timers_connect, | |
4625 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4626 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4627 | NEIGHBOR_STR |
966f821c | 4628 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4629 | "BGP per neighbor timers\n" |
4630 | "BGP connect timer\n" | |
4631 | "Connect timer\n") | |
4632 | { | |
c500ae40 DW |
4633 | int idx_peer = 1; |
4634 | int idx_number = 4; | |
4635 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4636 | } |
4637 | ||
4638 | DEFUN (no_neighbor_timers_connect, | |
4639 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4640 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4641 | NO_STR |
4642 | NEIGHBOR_STR | |
966f821c | 4643 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4644 | "BGP per neighbor timers\n" |
8334fd5a DW |
4645 | "BGP connect timer\n" |
4646 | "Connect timer\n") | |
718e3744 | 4647 | { |
c500ae40 DW |
4648 | int idx_peer = 2; |
4649 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4650 | } |
4651 | ||
6b0655a2 | 4652 | |
94f2b392 | 4653 | static int |
e52702f2 QY |
4654 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4655 | const char *time_str, int set) | |
718e3744 | 4656 | { |
4657 | int ret; | |
4658 | struct peer *peer; | |
4659 | u_int32_t routeadv = 0; | |
4660 | ||
966f821c | 4661 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4662 | if (! peer) |
4663 | return CMD_WARNING; | |
4664 | ||
4665 | if (time_str) | |
4666 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4667 | ||
4668 | if (set) | |
4669 | ret = peer_advertise_interval_set (peer, routeadv); | |
4670 | else | |
4671 | ret = peer_advertise_interval_unset (peer); | |
4672 | ||
966f821c | 4673 | return bgp_vty_return (vty, ret); |
718e3744 | 4674 | } |
4675 | ||
4676 | DEFUN (neighbor_advertise_interval, | |
4677 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4678 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4679 | NEIGHBOR_STR |
966f821c | 4680 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4681 | "Minimum interval between sending BGP routing updates\n" |
4682 | "time in seconds\n") | |
4683 | { | |
c500ae40 DW |
4684 | int idx_peer = 1; |
4685 | int idx_number = 3; | |
4686 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4687 | } |
4688 | ||
4689 | DEFUN (no_neighbor_advertise_interval, | |
4690 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4692 | NO_STR |
4693 | NEIGHBOR_STR | |
966f821c | 4694 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4695 | "Minimum interval between sending BGP routing updates\n" |
4696 | "time in seconds\n") | |
718e3744 | 4697 | { |
c500ae40 DW |
4698 | int idx_peer = 2; |
4699 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4700 | } |
4701 | ||
6b0655a2 | 4702 | |
518f0eb1 DS |
4703 | /* Time to wait before processing route-map updates */ |
4704 | DEFUN (bgp_set_route_map_delay_timer, | |
4705 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4706 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4707 | SET_STR |
4708 | "BGP route-map delay timer\n" | |
4709 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4710 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4711 | { |
c500ae40 | 4712 | int idx_number = 3; |
518f0eb1 | 4713 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4714 | |
c500ae40 | 4715 | if (argv[idx_number]->arg) |
518f0eb1 | 4716 | { |
c500ae40 | 4717 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4718 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4719 | |
4720 | /* if the dynamic update handling is being disabled, and a timer is | |
4721 | * running, stop the timer and act as if the timer has already fired. | |
4722 | */ | |
5fe9f963 | 4723 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4724 | { |
5fe9f963 | 4725 | BGP_TIMER_OFF(bm->t_rmap_update); |
4726 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4727 | } |
4728 | return CMD_SUCCESS; | |
4729 | } | |
4730 | else | |
ffd0c037 | 4731 | return CMD_WARNING; |
518f0eb1 DS |
4732 | } |
4733 | ||
4734 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4735 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4736 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4737 | NO_STR |
3a2d747c | 4738 | BGP_STR |
518f0eb1 | 4739 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4740 | "Reset to default time to wait for processing route-map changes\n" |
4741 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4742 | { |
518f0eb1 | 4743 | |
5fe9f963 | 4744 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4745 | |
4746 | return CMD_SUCCESS; | |
4747 | } | |
4748 | ||
f414725f | 4749 | |
718e3744 | 4750 | /* neighbor interface */ |
94f2b392 | 4751 | static int |
fd79ac91 | 4752 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4753 | { |
718e3744 | 4754 | struct peer *peer; |
4755 | ||
4756 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4757 | if (! peer || peer->conf_if) |
718e3744 | 4758 | return CMD_WARNING; |
4759 | ||
4760 | if (str) | |
ffd0c037 | 4761 | peer_interface_set (peer, str); |
718e3744 | 4762 | else |
ffd0c037 | 4763 | peer_interface_unset (peer); |
718e3744 | 4764 | |
4765 | return CMD_SUCCESS; | |
4766 | } | |
4767 | ||
4768 | DEFUN (neighbor_interface, | |
4769 | neighbor_interface_cmd, | |
9ccf14f7 | 4770 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4771 | NEIGHBOR_STR |
4772 | NEIGHBOR_ADDR_STR | |
4773 | "Interface\n" | |
4774 | "Interface name\n") | |
4775 | { | |
c500ae40 DW |
4776 | int idx_ip = 1; |
4777 | int idx_word = 3; | |
00d7d2d3 | 4778 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4779 | } |
4780 | ||
4781 | DEFUN (no_neighbor_interface, | |
4782 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4784 | NO_STR |
4785 | NEIGHBOR_STR | |
16cedbb0 | 4786 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4787 | "Interface\n" |
4788 | "Interface name\n") | |
4789 | { | |
c500ae40 DW |
4790 | int idx_peer = 2; |
4791 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4792 | } |
6b0655a2 | 4793 | |
718e3744 | 4794 | /* Set distribute list to the peer. */ |
94f2b392 | 4795 | static int |
e52702f2 | 4796 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4797 | afi_t afi, safi_t safi, |
4798 | const char *name_str, const char *direct_str) | |
718e3744 | 4799 | { |
4800 | int ret; | |
4801 | struct peer *peer; | |
4802 | int direct = FILTER_IN; | |
4803 | ||
4804 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4805 | if (! peer) | |
4806 | return CMD_WARNING; | |
4807 | ||
4808 | /* Check filter direction. */ | |
4809 | if (strncmp (direct_str, "i", 1) == 0) | |
4810 | direct = FILTER_IN; | |
4811 | else if (strncmp (direct_str, "o", 1) == 0) | |
4812 | direct = FILTER_OUT; | |
4813 | ||
4814 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4815 | ||
4816 | return bgp_vty_return (vty, ret); | |
4817 | } | |
4818 | ||
94f2b392 | 4819 | static int |
fd79ac91 | 4820 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4821 | safi_t safi, const char *direct_str) | |
718e3744 | 4822 | { |
4823 | int ret; | |
4824 | struct peer *peer; | |
4825 | int direct = FILTER_IN; | |
4826 | ||
4827 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4828 | if (! peer) | |
4829 | return CMD_WARNING; | |
4830 | ||
4831 | /* Check filter direction. */ | |
4832 | if (strncmp (direct_str, "i", 1) == 0) | |
4833 | direct = FILTER_IN; | |
4834 | else if (strncmp (direct_str, "o", 1) == 0) | |
4835 | direct = FILTER_OUT; | |
4836 | ||
4837 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
4838 | ||
4839 | return bgp_vty_return (vty, ret); | |
4840 | } | |
4841 | ||
4842 | DEFUN (neighbor_distribute_list, | |
4843 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4844 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4845 | NEIGHBOR_STR |
4846 | NEIGHBOR_ADDR_STR2 | |
4847 | "Filter updates to/from this neighbor\n" | |
4848 | "IP access-list number\n" | |
4849 | "IP access-list number (expanded range)\n" | |
4850 | "IP Access-list name\n" | |
4851 | "Filter incoming updates\n" | |
4852 | "Filter outgoing updates\n") | |
4853 | { | |
c500ae40 DW |
4854 | int idx_peer = 1; |
4855 | int idx_acl = 3; | |
4856 | int idx_in_out = 4; | |
4857 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4858 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4859 | } |
4860 | ||
4861 | DEFUN (no_neighbor_distribute_list, | |
4862 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4864 | NO_STR |
4865 | NEIGHBOR_STR | |
4866 | NEIGHBOR_ADDR_STR2 | |
4867 | "Filter updates to/from this neighbor\n" | |
4868 | "IP access-list number\n" | |
4869 | "IP access-list number (expanded range)\n" | |
4870 | "IP Access-list name\n" | |
4871 | "Filter incoming updates\n" | |
4872 | "Filter outgoing updates\n") | |
4873 | { | |
c500ae40 DW |
4874 | int idx_peer = 2; |
4875 | int idx_in_out = 5; | |
4876 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4877 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4878 | } |
6b0655a2 | 4879 | |
718e3744 | 4880 | /* Set prefix list to the peer. */ |
94f2b392 | 4881 | static int |
fd79ac91 | 4882 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4883 | safi_t safi, const char *name_str, |
fd79ac91 | 4884 | const char *direct_str) |
718e3744 | 4885 | { |
4886 | int ret; | |
4887 | struct peer *peer; | |
4888 | int direct = FILTER_IN; | |
4889 | ||
4890 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4891 | if (! peer) | |
4892 | return CMD_WARNING; | |
4893 | ||
4894 | /* Check filter direction. */ | |
4895 | if (strncmp (direct_str, "i", 1) == 0) | |
4896 | direct = FILTER_IN; | |
4897 | else if (strncmp (direct_str, "o", 1) == 0) | |
4898 | direct = FILTER_OUT; | |
4899 | ||
4900 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
4901 | ||
4902 | return bgp_vty_return (vty, ret); | |
4903 | } | |
4904 | ||
94f2b392 | 4905 | static int |
fd79ac91 | 4906 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4907 | safi_t safi, const char *direct_str) | |
718e3744 | 4908 | { |
4909 | int ret; | |
4910 | struct peer *peer; | |
4911 | int direct = FILTER_IN; | |
4912 | ||
4913 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4914 | if (! peer) | |
4915 | return CMD_WARNING; | |
e52702f2 | 4916 | |
718e3744 | 4917 | /* Check filter direction. */ |
4918 | if (strncmp (direct_str, "i", 1) == 0) | |
4919 | direct = FILTER_IN; | |
4920 | else if (strncmp (direct_str, "o", 1) == 0) | |
4921 | direct = FILTER_OUT; | |
4922 | ||
4923 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
4924 | ||
4925 | return bgp_vty_return (vty, ret); | |
4926 | } | |
4927 | ||
4928 | DEFUN (neighbor_prefix_list, | |
4929 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 4930 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4931 | NEIGHBOR_STR |
4932 | NEIGHBOR_ADDR_STR2 | |
4933 | "Filter updates to/from this neighbor\n" | |
4934 | "Name of a prefix list\n" | |
4935 | "Filter incoming updates\n" | |
4936 | "Filter outgoing updates\n") | |
4937 | { | |
c500ae40 DW |
4938 | int idx_peer = 1; |
4939 | int idx_word = 3; | |
4940 | int idx_in_out = 4; | |
4941 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4942 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4943 | } |
4944 | ||
4945 | DEFUN (no_neighbor_prefix_list, | |
4946 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 4947 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4948 | NO_STR |
4949 | NEIGHBOR_STR | |
4950 | NEIGHBOR_ADDR_STR2 | |
4951 | "Filter updates to/from this neighbor\n" | |
4952 | "Name of a prefix list\n" | |
4953 | "Filter incoming updates\n" | |
4954 | "Filter outgoing updates\n") | |
4955 | { | |
c500ae40 DW |
4956 | int idx_peer = 2; |
4957 | int idx_in_out = 5; | |
4958 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4959 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4960 | } |
6b0655a2 | 4961 | |
94f2b392 | 4962 | static int |
e52702f2 | 4963 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4964 | afi_t afi, safi_t safi, |
4965 | const char *name_str, const char *direct_str) | |
718e3744 | 4966 | { |
4967 | int ret; | |
4968 | struct peer *peer; | |
4969 | int direct = FILTER_IN; | |
4970 | ||
4971 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4972 | if (! peer) | |
4973 | return CMD_WARNING; | |
4974 | ||
4975 | /* Check filter direction. */ | |
4976 | if (strncmp (direct_str, "i", 1) == 0) | |
4977 | direct = FILTER_IN; | |
4978 | else if (strncmp (direct_str, "o", 1) == 0) | |
4979 | direct = FILTER_OUT; | |
4980 | ||
4981 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
4982 | ||
4983 | return bgp_vty_return (vty, ret); | |
4984 | } | |
4985 | ||
94f2b392 | 4986 | static int |
e52702f2 | 4987 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4988 | afi_t afi, safi_t safi, |
4989 | const char *direct_str) | |
718e3744 | 4990 | { |
4991 | int ret; | |
4992 | struct peer *peer; | |
4993 | int direct = FILTER_IN; | |
4994 | ||
4995 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4996 | if (! peer) | |
4997 | return CMD_WARNING; | |
4998 | ||
4999 | /* Check filter direction. */ | |
5000 | if (strncmp (direct_str, "i", 1) == 0) | |
5001 | direct = FILTER_IN; | |
5002 | else if (strncmp (direct_str, "o", 1) == 0) | |
5003 | direct = FILTER_OUT; | |
5004 | ||
5005 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
5006 | ||
5007 | return bgp_vty_return (vty, ret); | |
5008 | } | |
5009 | ||
5010 | DEFUN (neighbor_filter_list, | |
5011 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5012 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5013 | NEIGHBOR_STR |
5014 | NEIGHBOR_ADDR_STR2 | |
5015 | "Establish BGP filters\n" | |
5016 | "AS path access-list name\n" | |
5017 | "Filter incoming routes\n" | |
5018 | "Filter outgoing routes\n") | |
5019 | { | |
c500ae40 DW |
5020 | int idx_peer = 1; |
5021 | int idx_word = 3; | |
5022 | int idx_in_out = 4; | |
5023 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5024 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5025 | } |
5026 | ||
5027 | DEFUN (no_neighbor_filter_list, | |
5028 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5029 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5030 | NO_STR |
5031 | NEIGHBOR_STR | |
5032 | NEIGHBOR_ADDR_STR2 | |
5033 | "Establish BGP filters\n" | |
5034 | "AS path access-list name\n" | |
5035 | "Filter incoming routes\n" | |
5036 | "Filter outgoing routes\n") | |
5037 | { | |
c500ae40 DW |
5038 | int idx_peer = 2; |
5039 | int idx_in_out = 5; | |
5040 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5041 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5042 | } |
6b0655a2 | 5043 | |
718e3744 | 5044 | /* Set route-map to the peer. */ |
94f2b392 | 5045 | static int |
e52702f2 | 5046 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 5047 | afi_t afi, safi_t safi, |
5048 | const char *name_str, const char *direct_str) | |
718e3744 | 5049 | { |
5050 | int ret; | |
5051 | struct peer *peer; | |
fee0f4c6 | 5052 | int direct = RMAP_IN; |
718e3744 | 5053 | |
5054 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5055 | if (! peer) | |
5056 | return CMD_WARNING; | |
5057 | ||
5058 | /* Check filter direction. */ | |
fee0f4c6 | 5059 | if (strncmp (direct_str, "in", 2) == 0) |
5060 | direct = RMAP_IN; | |
718e3744 | 5061 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5062 | direct = RMAP_OUT; |
718e3744 | 5063 | |
5064 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5065 | ||
5066 | return bgp_vty_return (vty, ret); | |
5067 | } | |
5068 | ||
94f2b392 | 5069 | static int |
fd79ac91 | 5070 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5071 | safi_t safi, const char *direct_str) | |
718e3744 | 5072 | { |
5073 | int ret; | |
5074 | struct peer *peer; | |
fee0f4c6 | 5075 | int direct = RMAP_IN; |
718e3744 | 5076 | |
5077 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5078 | if (! peer) | |
5079 | return CMD_WARNING; | |
5080 | ||
5081 | /* Check filter direction. */ | |
fee0f4c6 | 5082 | if (strncmp (direct_str, "in", 2) == 0) |
5083 | direct = RMAP_IN; | |
718e3744 | 5084 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5085 | direct = RMAP_OUT; |
718e3744 | 5086 | |
5087 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5088 | ||
5089 | return bgp_vty_return (vty, ret); | |
5090 | } | |
5091 | ||
5092 | DEFUN (neighbor_route_map, | |
5093 | neighbor_route_map_cmd, | |
9ccf14f7 | 5094 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5095 | NEIGHBOR_STR |
5096 | NEIGHBOR_ADDR_STR2 | |
5097 | "Apply route map to neighbor\n" | |
5098 | "Name of route map\n" | |
5099 | "Apply map to incoming routes\n" | |
2a3d5731 | 5100 | "Apply map to outbound routes\n") |
718e3744 | 5101 | { |
c500ae40 DW |
5102 | int idx_peer = 1; |
5103 | int idx_word = 3; | |
5104 | int idx_in_out = 4; | |
5105 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5106 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5107 | } |
5108 | ||
5109 | DEFUN (no_neighbor_route_map, | |
5110 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5112 | NO_STR |
5113 | NEIGHBOR_STR | |
5114 | NEIGHBOR_ADDR_STR2 | |
5115 | "Apply route map to neighbor\n" | |
5116 | "Name of route map\n" | |
5117 | "Apply map to incoming routes\n" | |
2a3d5731 | 5118 | "Apply map to outbound routes\n") |
718e3744 | 5119 | { |
c500ae40 DW |
5120 | int idx_peer = 2; |
5121 | int idx_in_out = 5; | |
5122 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5123 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5124 | } |
6b0655a2 | 5125 | |
718e3744 | 5126 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5127 | static int |
fd79ac91 | 5128 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5129 | safi_t safi, const char *name_str) | |
718e3744 | 5130 | { |
5131 | int ret; | |
5132 | struct peer *peer; | |
5133 | ||
5134 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5135 | if (! peer) | |
5136 | return CMD_WARNING; | |
5137 | ||
5138 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5139 | ||
5140 | return bgp_vty_return (vty, ret); | |
5141 | } | |
5142 | ||
5143 | /* Unset route-map from the peer. */ | |
94f2b392 | 5144 | static int |
fd79ac91 | 5145 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5146 | safi_t safi) |
5147 | { | |
5148 | int ret; | |
5149 | struct peer *peer; | |
5150 | ||
5151 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5152 | if (! peer) | |
5153 | return CMD_WARNING; | |
5154 | ||
5155 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5156 | ||
5157 | return bgp_vty_return (vty, ret); | |
5158 | } | |
5159 | ||
5160 | DEFUN (neighbor_unsuppress_map, | |
5161 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5162 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5163 | NEIGHBOR_STR |
5164 | NEIGHBOR_ADDR_STR2 | |
5165 | "Route-map to selectively unsuppress suppressed routes\n" | |
5166 | "Name of route map\n") | |
5167 | { | |
c500ae40 DW |
5168 | int idx_peer = 1; |
5169 | int idx_word = 3; | |
5170 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5171 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5172 | } |
5173 | ||
5174 | DEFUN (no_neighbor_unsuppress_map, | |
5175 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5176 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5177 | NO_STR |
5178 | NEIGHBOR_STR | |
5179 | NEIGHBOR_ADDR_STR2 | |
5180 | "Route-map to selectively unsuppress suppressed routes\n" | |
5181 | "Name of route map\n") | |
5182 | { | |
c500ae40 DW |
5183 | int idx_peer = 2; |
5184 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5185 | bgp_node_safi (vty)); |
5186 | } | |
6b0655a2 | 5187 | |
94f2b392 | 5188 | static int |
fd79ac91 | 5189 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5190 | safi_t safi, const char *num_str, |
0a486e5f | 5191 | const char *threshold_str, int warning, |
5192 | const char *restart_str) | |
718e3744 | 5193 | { |
5194 | int ret; | |
5195 | struct peer *peer; | |
5196 | u_int32_t max; | |
e0701b79 | 5197 | u_char threshold; |
0a486e5f | 5198 | u_int16_t restart; |
718e3744 | 5199 | |
5200 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5201 | if (! peer) | |
5202 | return CMD_WARNING; | |
5203 | ||
e6ec1c36 | 5204 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5205 | if (threshold_str) |
5206 | threshold = atoi (threshold_str); | |
5207 | else | |
5208 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5209 | |
0a486e5f | 5210 | if (restart_str) |
5211 | restart = atoi (restart_str); | |
5212 | else | |
5213 | restart = 0; | |
5214 | ||
5215 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5216 | |
5217 | return bgp_vty_return (vty, ret); | |
5218 | } | |
5219 | ||
94f2b392 | 5220 | static int |
fd79ac91 | 5221 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5222 | safi_t safi) |
5223 | { | |
5224 | int ret; | |
5225 | struct peer *peer; | |
5226 | ||
5227 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5228 | if (! peer) | |
5229 | return CMD_WARNING; | |
5230 | ||
5231 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5232 | ||
5233 | return bgp_vty_return (vty, ret); | |
5234 | } | |
5235 | ||
5236 | /* Maximum number of prefix configuration. prefix count is different | |
5237 | for each peer configuration. So this configuration can be set for | |
5238 | each peer configuration. */ | |
5239 | DEFUN (neighbor_maximum_prefix, | |
5240 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5241 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5242 | NEIGHBOR_STR |
5243 | NEIGHBOR_ADDR_STR2 | |
5244 | "Maximum number of prefix accept from this peer\n" | |
5245 | "maximum no. of prefix limit\n") | |
5246 | { | |
c500ae40 DW |
5247 | int idx_peer = 1; |
5248 | int idx_number = 3; | |
5249 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5250 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5251 | NULL); |
718e3744 | 5252 | } |
5253 | ||
e0701b79 | 5254 | DEFUN (neighbor_maximum_prefix_threshold, |
5255 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5256 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5257 | NEIGHBOR_STR |
5258 | NEIGHBOR_ADDR_STR2 | |
5259 | "Maximum number of prefix accept from this peer\n" | |
5260 | "maximum no. of prefix limit\n" | |
5261 | "Threshold value (%) at which to generate a warning msg\n") | |
5262 | { | |
c500ae40 DW |
5263 | int idx_peer = 1; |
5264 | int idx_number = 3; | |
5265 | int idx_number_2 = 4; | |
5266 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5267 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5268 | NULL); |
5269 | } | |
e0701b79 | 5270 | |
718e3744 | 5271 | DEFUN (neighbor_maximum_prefix_warning, |
5272 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5273 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5274 | NEIGHBOR_STR |
5275 | NEIGHBOR_ADDR_STR2 | |
5276 | "Maximum number of prefix accept from this peer\n" | |
5277 | "maximum no. of prefix limit\n" | |
5278 | "Only give warning message when limit is exceeded\n") | |
5279 | { | |
c500ae40 DW |
5280 | int idx_peer = 1; |
5281 | int idx_number = 3; | |
5282 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5283 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5284 | NULL); |
718e3744 | 5285 | } |
5286 | ||
e0701b79 | 5287 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5288 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5289 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5290 | NEIGHBOR_STR |
5291 | NEIGHBOR_ADDR_STR2 | |
5292 | "Maximum number of prefix accept from this peer\n" | |
5293 | "maximum no. of prefix limit\n" | |
5294 | "Threshold value (%) at which to generate a warning msg\n" | |
5295 | "Only give warning message when limit is exceeded\n") | |
5296 | { | |
c500ae40 DW |
5297 | int idx_peer = 1; |
5298 | int idx_number = 3; | |
5299 | int idx_number_2 = 4; | |
5300 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5301 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5302 | } |
5303 | ||
5304 | DEFUN (neighbor_maximum_prefix_restart, | |
5305 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5306 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5307 | NEIGHBOR_STR |
5308 | NEIGHBOR_ADDR_STR2 | |
5309 | "Maximum number of prefix accept from this peer\n" | |
5310 | "maximum no. of prefix limit\n" | |
5311 | "Restart bgp connection after limit is exceeded\n" | |
5312 | "Restart interval in minutes") | |
5313 | { | |
c500ae40 DW |
5314 | int idx_peer = 1; |
5315 | int idx_number = 3; | |
5316 | int idx_number_2 = 5; | |
5317 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5318 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5319 | } |
5320 | ||
5321 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5322 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5323 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5324 | NEIGHBOR_STR |
5325 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5326 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5327 | "maximum no. of prefix limit\n" |
5328 | "Threshold value (%) at which to generate a warning msg\n" | |
5329 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5330 | "Restart interval in minutes\n") |
0a486e5f | 5331 | { |
c500ae40 DW |
5332 | int idx_peer = 1; |
5333 | int idx_number = 3; | |
5334 | int idx_number_2 = 4; | |
5335 | int idx_number_3 = 6; | |
5336 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5337 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5338 | } |
e0701b79 | 5339 | |
718e3744 | 5340 | DEFUN (no_neighbor_maximum_prefix, |
5341 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5342 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5343 | NO_STR |
5344 | NEIGHBOR_STR | |
5345 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5346 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5347 | "maximum no. of prefix limit\n" |
5348 | "Threshold value (%) at which to generate a warning msg\n" | |
5349 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5350 | "Restart interval in minutes\n" |
31500417 | 5351 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5352 | { |
c500ae40 DW |
5353 | int idx_peer = 2; |
5354 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5355 | bgp_node_safi (vty)); |
5356 | } | |
e52702f2 | 5357 | |
718e3744 | 5358 | |
718e3744 | 5359 | /* "neighbor allowas-in" */ |
5360 | DEFUN (neighbor_allowas_in, | |
5361 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5362 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5363 | NEIGHBOR_STR |
5364 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5365 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5366 | "Number of occurances of AS number\n" |
5367 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5368 | { |
c500ae40 | 5369 | int idx_peer = 1; |
fd8503f5 | 5370 | int idx_number_origin = 3; |
718e3744 | 5371 | int ret; |
aac9ef6c | 5372 | int origin = 0; |
718e3744 | 5373 | struct peer *peer; |
aac9ef6c | 5374 | int allow_num = 0; |
718e3744 | 5375 | |
c500ae40 | 5376 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5377 | if (! peer) |
5378 | return CMD_WARNING; | |
5379 | ||
fd8503f5 | 5380 | if (argc <= idx_number_origin) |
718e3744 | 5381 | allow_num = 3; |
5382 | else | |
aac9ef6c | 5383 | { |
fd8503f5 | 5384 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5385 | origin = 1; |
5386 | else | |
fd8503f5 | 5387 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5388 | } |
718e3744 | 5389 | |
5390 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5391 | allow_num, origin); |
718e3744 | 5392 | |
5393 | return bgp_vty_return (vty, ret); | |
5394 | } | |
5395 | ||
718e3744 | 5396 | DEFUN (no_neighbor_allowas_in, |
5397 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5398 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5399 | NO_STR |
5400 | NEIGHBOR_STR | |
5401 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5402 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5403 | "Number of occurances of AS number\n" |
5404 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5405 | { |
c500ae40 | 5406 | int idx_peer = 2; |
718e3744 | 5407 | int ret; |
5408 | struct peer *peer; | |
5409 | ||
c500ae40 | 5410 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5411 | if (! peer) |
5412 | return CMD_WARNING; | |
5413 | ||
5414 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5415 | ||
5416 | return bgp_vty_return (vty, ret); | |
5417 | } | |
6b0655a2 | 5418 | |
fa411a21 NH |
5419 | DEFUN (neighbor_ttl_security, |
5420 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5421 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5422 | NEIGHBOR_STR |
5423 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5424 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5425 | "Specify the maximum number of hops to the BGP peer\n" |
5426 | "Number of hops to BGP peer\n") | |
fa411a21 | 5427 | { |
c500ae40 DW |
5428 | int idx_peer = 1; |
5429 | int idx_number = 4; | |
fa411a21 | 5430 | struct peer *peer; |
89b6d1f8 | 5431 | int gtsm_hops; |
fa411a21 | 5432 | |
c500ae40 | 5433 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5434 | if (! peer) |
5435 | return CMD_WARNING; | |
e52702f2 | 5436 | |
c500ae40 | 5437 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5438 | |
8cdabf90 SK |
5439 | /* |
5440 | * If 'neighbor swpX', then this is for directly connected peers, | |
5441 | * we should not accept a ttl-security hops value greater than 1. | |
5442 | */ | |
5443 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5444 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5445 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5446 | return CMD_WARNING; |
5447 | } | |
5448 | ||
89b6d1f8 | 5449 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5450 | } |
5451 | ||
5452 | DEFUN (no_neighbor_ttl_security, | |
5453 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5455 | NO_STR |
5456 | NEIGHBOR_STR | |
5457 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5458 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5459 | "Specify the maximum number of hops to the BGP peer\n" |
5460 | "Number of hops to BGP peer\n") | |
fa411a21 | 5461 | { |
c500ae40 | 5462 | int idx_peer = 2; |
fa411a21 | 5463 | struct peer *peer; |
fa411a21 | 5464 | |
c500ae40 | 5465 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5466 | if (! peer) |
5467 | return CMD_WARNING; | |
5468 | ||
89b6d1f8 | 5469 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5470 | } |
6b0655a2 | 5471 | |
adbac85e DW |
5472 | DEFUN (neighbor_addpath_tx_all_paths, |
5473 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5474 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5475 | NEIGHBOR_STR |
5476 | NEIGHBOR_ADDR_STR2 | |
5477 | "Use addpath to advertise all paths to a neighbor\n") | |
5478 | { | |
c500ae40 | 5479 | int idx_peer = 1; |
adbac85e DW |
5480 | struct peer *peer; |
5481 | ||
c500ae40 | 5482 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5483 | if (! peer) |
5484 | return CMD_WARNING; | |
5485 | ||
c500ae40 | 5486 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5487 | bgp_node_safi (vty), |
5488 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5489 | } | |
5490 | ||
5491 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5492 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5494 | NO_STR |
5495 | NEIGHBOR_STR | |
5496 | NEIGHBOR_ADDR_STR2 | |
5497 | "Use addpath to advertise all paths to a neighbor\n") | |
5498 | { | |
c500ae40 DW |
5499 | int idx_peer = 2; |
5500 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5501 | bgp_node_safi (vty), |
5502 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5503 | } | |
5504 | ||
06370dac DW |
5505 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5506 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5507 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5508 | NEIGHBOR_STR |
5509 | NEIGHBOR_ADDR_STR2 | |
5510 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5511 | { | |
c500ae40 | 5512 | int idx_peer = 1; |
06370dac DW |
5513 | struct peer *peer; |
5514 | ||
c500ae40 | 5515 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5516 | if (! peer) |
5517 | return CMD_WARNING; | |
5518 | ||
c500ae40 | 5519 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5520 | bgp_node_safi (vty), |
5521 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5522 | } | |
5523 | ||
5524 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5525 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5526 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5527 | NO_STR |
5528 | NEIGHBOR_STR | |
5529 | NEIGHBOR_ADDR_STR2 | |
5530 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5531 | { | |
c500ae40 DW |
5532 | int idx_peer = 2; |
5533 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5534 | bgp_node_safi (vty), |
5535 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5536 | } | |
5537 | ||
5538 | ||
8c3deaae | 5539 | /* Address Family configuration. */ |
718e3744 | 5540 | DEFUN (address_family_ipv4, |
5541 | address_family_ipv4_cmd, | |
5542 | "address-family ipv4", | |
5543 | "Enter Address Family command mode\n" | |
8c3deaae | 5544 | "Address Family\n") |
718e3744 | 5545 | { |
5546 | vty->node = BGP_IPV4_NODE; | |
5547 | return CMD_SUCCESS; | |
5548 | } | |
5549 | ||
5550 | DEFUN (address_family_ipv4_safi, | |
5551 | address_family_ipv4_safi_cmd, | |
6147e2c6 | 5552 | "address-family ipv4 <unicast|multicast>", |
718e3744 | 5553 | "Enter Address Family command mode\n" |
8c3deaae | 5554 | "Address Family\n" |
718e3744 | 5555 | "Address Family modifier\n" |
5556 | "Address Family modifier\n") | |
5557 | { | |
c500ae40 DW |
5558 | int idx_safi = 2; |
5559 | if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) | |
718e3744 | 5560 | vty->node = BGP_IPV4M_NODE; |
5561 | else | |
5562 | vty->node = BGP_IPV4_NODE; | |
5563 | ||
5564 | return CMD_SUCCESS; | |
5565 | } | |
5566 | ||
25ffbdc1 | 5567 | DEFUN (address_family_ipv6, |
5568 | address_family_ipv6_cmd, | |
5569 | "address-family ipv6", | |
718e3744 | 5570 | "Enter Address Family command mode\n" |
8c3deaae | 5571 | "Address Family\n") |
718e3744 | 5572 | { |
5573 | vty->node = BGP_IPV6_NODE; | |
5574 | return CMD_SUCCESS; | |
5575 | } | |
5576 | ||
25ffbdc1 | 5577 | DEFUN (address_family_ipv6_safi, |
5578 | address_family_ipv6_safi_cmd, | |
6147e2c6 | 5579 | "address-family ipv6 <unicast|multicast>", |
718e3744 | 5580 | "Enter Address Family command mode\n" |
8c3deaae | 5581 | "Address Family\n" |
25ffbdc1 | 5582 | "Address Family modifier\n" |
5583 | "Address Family modifier\n") | |
5584 | { | |
c500ae40 DW |
5585 | int idx_safi = 2; |
5586 | if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) | |
25ffbdc1 | 5587 | vty->node = BGP_IPV6M_NODE; |
5588 | else | |
5589 | vty->node = BGP_IPV6_NODE; | |
5590 | ||
5591 | return CMD_SUCCESS; | |
5592 | } | |
718e3744 | 5593 | |
5594 | DEFUN (address_family_vpnv4, | |
5595 | address_family_vpnv4_cmd, | |
8334fd5a | 5596 | "address-family vpnv4 [unicast]", |
718e3744 | 5597 | "Enter Address Family command mode\n" |
8c3deaae | 5598 | "Address Family\n" |
3a2d747c | 5599 | "Address Family modifier\n") |
718e3744 | 5600 | { |
5601 | vty->node = BGP_VPNV4_NODE; | |
5602 | return CMD_SUCCESS; | |
5603 | } | |
5604 | ||
8ecd3266 | 5605 | DEFUN (address_family_vpnv6, |
5606 | address_family_vpnv6_cmd, | |
8334fd5a | 5607 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5608 | "Enter Address Family command mode\n" |
8c3deaae | 5609 | "Address Family\n" |
3a2d747c | 5610 | "Address Family modifier\n") |
8ecd3266 | 5611 | { |
5612 | vty->node = BGP_VPNV6_NODE; | |
5613 | return CMD_SUCCESS; | |
5614 | } | |
5615 | ||
8b1fb8be LB |
5616 | DEFUN (address_family_encap, |
5617 | address_family_encap_cmd, | |
8334fd5a | 5618 | "address-family <encap|encapv4>", |
8b1fb8be | 5619 | "Enter Address Family command mode\n" |
8c3deaae QY |
5620 | "Address Family\n" |
5621 | "Address Family\n") | |
8b1fb8be LB |
5622 | { |
5623 | vty->node = BGP_ENCAP_NODE; | |
5624 | return CMD_SUCCESS; | |
5625 | } | |
5626 | ||
8b1fb8be LB |
5627 | |
5628 | DEFUN (address_family_encapv6, | |
5629 | address_family_encapv6_cmd, | |
5630 | "address-family encapv6", | |
5631 | "Enter Address Family command mode\n" | |
8c3deaae | 5632 | "Address Family\n") |
8b1fb8be LB |
5633 | { |
5634 | vty->node = BGP_ENCAPV6_NODE; | |
5635 | return CMD_SUCCESS; | |
5636 | } | |
5637 | ||
718e3744 | 5638 | DEFUN (exit_address_family, |
5639 | exit_address_family_cmd, | |
5640 | "exit-address-family", | |
5641 | "Exit from Address Family configuration mode\n") | |
5642 | { | |
a8a80d53 | 5643 | if (vty->node == BGP_IPV4_NODE |
5644 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5645 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5646 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5647 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5648 | || vty->node == BGP_VPNV6_NODE |
5649 | || vty->node == BGP_ENCAP_NODE | |
5650 | || vty->node == BGP_ENCAPV6_NODE) | |
718e3744 | 5651 | vty->node = BGP_NODE; |
5652 | return CMD_SUCCESS; | |
5653 | } | |
6b0655a2 | 5654 | |
8ad7271d DS |
5655 | /* Recalculate bestpath and re-advertise a prefix */ |
5656 | static int | |
01080f7c | 5657 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5658 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5659 | { | |
5660 | int ret; | |
5661 | struct prefix match; | |
5662 | struct bgp_node *rn; | |
5663 | struct bgp_node *rm; | |
8ad7271d DS |
5664 | struct bgp *bgp; |
5665 | struct bgp_table *table; | |
5666 | struct bgp_table *rib; | |
5667 | ||
5668 | /* BGP structure lookup. */ | |
5669 | if (view_name) | |
5670 | { | |
5671 | bgp = bgp_lookup_by_name (view_name); | |
5672 | if (bgp == NULL) | |
5673 | { | |
6aeb9e78 | 5674 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5675 | return CMD_WARNING; |
5676 | } | |
5677 | } | |
5678 | else | |
5679 | { | |
5680 | bgp = bgp_get_default (); | |
5681 | if (bgp == NULL) | |
5682 | { | |
5683 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5684 | return CMD_WARNING; | |
5685 | } | |
5686 | } | |
5687 | ||
5688 | /* Check IP address argument. */ | |
5689 | ret = str2prefix (ip_str, &match); | |
5690 | if (! ret) | |
5691 | { | |
5692 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5693 | return CMD_WARNING; | |
5694 | } | |
5695 | ||
5696 | match.family = afi2family (afi); | |
5697 | rib = bgp->rib[afi][safi]; | |
5698 | ||
5699 | if (safi == SAFI_MPLS_VPN) | |
5700 | { | |
5701 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5702 | { | |
5703 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5704 | continue; | |
5705 | ||
5706 | if ((table = rn->info) != NULL) | |
5707 | { | |
5708 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5709 | { | |
5710 | if (rm->p.prefixlen == match.prefixlen) | |
5711 | { | |
5712 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5713 | bgp_process (bgp, rm, afi, safi); | |
5714 | } | |
5715 | bgp_unlock_node (rm); | |
5716 | } | |
5717 | } | |
5718 | } | |
5719 | } | |
5720 | else | |
5721 | { | |
5722 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5723 | { | |
5724 | if (rn->p.prefixlen == match.prefixlen) | |
5725 | { | |
5726 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5727 | bgp_process (bgp, rn, afi, safi); | |
5728 | } | |
5729 | bgp_unlock_node (rn); | |
5730 | } | |
5731 | } | |
5732 | ||
5733 | return CMD_SUCCESS; | |
5734 | } | |
5735 | ||
b09b5ae0 | 5736 | /* one clear bgp command to rule them all */ |
718e3744 | 5737 | DEFUN (clear_ip_bgp_all, |
5738 | clear_ip_bgp_all_cmd, | |
91d37724 | 5739 | "clear [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 5740 | CLEAR_STR |
5741 | IP_STR | |
5742 | BGP_STR | |
838758ac | 5743 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5744 | "Clear all peers\n" |
5745 | "BGP neighbor address to clear\n" | |
a80beece | 5746 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5747 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5748 | "Clear peers with the AS number\n" |
5749 | "Clear all external peers\n" | |
718e3744 | 5750 | "Clear all members of peer-group\n" |
b09b5ae0 | 5751 | "BGP peer-group name\n" |
8c3deaae | 5752 | "Address Family\n" |
8de197ce | 5753 | "Address Family modifier\n" |
8de197ce | 5754 | "Address Family modifier\n" |
8c3deaae | 5755 | "Address Family\n" |
8de197ce | 5756 | "Address Family modifier\n" |
b09b5ae0 | 5757 | "Address Family modifier\n" |
8c3deaae QY |
5758 | "Address Family\n" |
5759 | "Address Family modifier\n" | |
5760 | "Address Family\n" | |
b09b5ae0 | 5761 | "Address Family modifier\n" |
b09b5ae0 DW |
5762 | BGP_SOFT_STR |
5763 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5764 | BGP_SOFT_OUT_STR |
5765 | BGP_SOFT_IN_STR | |
5766 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5767 | BGP_SOFT_OUT_STR) |
718e3744 | 5768 | { |
8334fd5a | 5769 | char *vrf = NULL; |
630a298c | 5770 | |
ae19d7dd QY |
5771 | afi_t afi = AFI_IP6; |
5772 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5773 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5774 | enum bgp_clear_type clr_type; |
5775 | char *clr_arg = NULL; | |
718e3744 | 5776 | |
ae19d7dd | 5777 | int idx = 0; |
01080f7c | 5778 | |
ae19d7dd QY |
5779 | /* clear [ip] bgp */ |
5780 | if (argv_find (argv, argc, "ip", &idx)) | |
5781 | afi = AFI_IP; | |
5782 | /* [<view|vrf> WORD] */ | |
5783 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5784 | { |
ae19d7dd QY |
5785 | vrf = argv[idx + 1]->arg; |
5786 | idx += 2; | |
838758ac | 5787 | } |
ae19d7dd QY |
5788 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5789 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5790 | { |
ae19d7dd | 5791 | clr_sort = clear_all; |
b09b5ae0 | 5792 | } |
ae19d7dd | 5793 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5794 | { |
5795 | clr_sort = clear_peer; | |
ae19d7dd | 5796 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5797 | } |
ae19d7dd | 5798 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5799 | { |
ae19d7dd QY |
5800 | clr_sort = clear_peer; |
5801 | clr_arg = argv[idx]->arg; | |
838758ac | 5802 | } |
ae19d7dd | 5803 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5804 | { |
5805 | clr_sort = clear_group; | |
ae19d7dd QY |
5806 | idx++; |
5807 | clr_arg = argv[idx]->arg; | |
718e3744 | 5808 | |
b09b5ae0 DW |
5809 | if (! peer_group_lookup (vty->index, clr_arg)) |
5810 | { | |
5811 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5812 | return CMD_WARNING; |
b09b5ae0 DW |
5813 | } |
5814 | } | |
ae19d7dd | 5815 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5816 | { |
ae19d7dd | 5817 | if (peer_lookup_by_conf_if (vty->index, argv[idx]->arg)) |
b09b5ae0 DW |
5818 | { |
5819 | clr_sort = clear_peer; | |
ae19d7dd | 5820 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5821 | } |
5822 | else | |
5823 | { | |
5824 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5825 | return CMD_WARNING; | |
5826 | } | |
5827 | } | |
ae19d7dd QY |
5828 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5829 | { | |
5830 | clr_sort = clear_as; | |
5831 | clr_arg = argv[idx]->arg; | |
5832 | } | |
5833 | else if (argv_find (argv, argc, "external", &idx)) | |
5834 | { | |
5835 | clr_sort = clear_external; | |
5836 | } | |
5837 | /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]||vpnv4 [unicast]>] */ | |
5838 | if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) | |
5839 | { | |
5840 | afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; | |
5841 | if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) | |
5842 | safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; | |
5843 | } | |
5844 | else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) | |
5845 | { | |
5846 | afi = AFI_IP; | |
5847 | safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; | |
5848 | // advance idx if necessary | |
5849 | argv_find (argv, argc, "unicast", &idx); | |
5850 | } | |
5851 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5852 | if (argv_find (argv, argc, "soft", &idx)) | |
5853 | { | |
5854 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5855 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5856 | else | |
5857 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5858 | } | |
5859 | else if (argv_find (argv, argc, "in", &idx)) | |
5860 | { | |
5861 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5862 | } | |
5863 | else if (argv_find (argv, argc, "out", &idx)) | |
5864 | { | |
5daa3e5e | 5865 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5866 | } |
5867 | else | |
5868 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5869 | |
b09b5ae0 | 5870 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5871 | } |
01080f7c | 5872 | |
8ad7271d DS |
5873 | DEFUN (clear_ip_bgp_prefix, |
5874 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5875 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5876 | CLEAR_STR |
5877 | IP_STR | |
5878 | BGP_STR | |
838758ac | 5879 | BGP_INSTANCE_HELP_STR |
8ad7271d | 5880 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5881 | "IPv4 prefix\n") |
8ad7271d | 5882 | { |
8334fd5a | 5883 | char *vrf = NULL; |
630a298c | 5884 | char *prefix = NULL; |
8ad7271d | 5885 | |
630a298c | 5886 | int idx = 0; |
01080f7c | 5887 | |
630a298c QY |
5888 | /* [<view|vrf> WORD] */ |
5889 | if (argv_find (argv, argc, "WORD", &idx)) | |
5890 | vrf = argv[idx]->arg; | |
0c7b1b01 | 5891 | |
630a298c | 5892 | prefix = argv[argc-1]->arg; |
8ad7271d | 5893 | |
630a298c | 5894 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 5895 | } |
8ad7271d | 5896 | |
b09b5ae0 DW |
5897 | DEFUN (clear_bgp_ipv6_safi_prefix, |
5898 | clear_bgp_ipv6_safi_prefix_cmd, | |
91d37724 | 5899 | "clear [ip] bgp ipv6 <unicast|multicast> prefix X:X::X:X/M", |
718e3744 | 5900 | CLEAR_STR |
3a2d747c | 5901 | IP_STR |
718e3744 | 5902 | BGP_STR |
8c3deaae | 5903 | "Address Family\n" |
3a2d747c QY |
5904 | "Address Family modifier\n" |
5905 | "Address Family modifier\n" | |
b09b5ae0 | 5906 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5907 | "IPv6 prefix\n") |
718e3744 | 5908 | { |
b09b5ae0 DW |
5909 | int idx_safi = 3; |
5910 | int idx_ipv6_prefixlen = 5; | |
5911 | if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) | |
5912 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); | |
838758ac | 5913 | else |
b09b5ae0 | 5914 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); |
838758ac | 5915 | } |
01080f7c | 5916 | |
b09b5ae0 DW |
5917 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
5918 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
91d37724 | 5919 | "clear [ip] bgp <view|vrf> WORD ipv6 <unicast|multicast> prefix X:X::X:X/M", |
718e3744 | 5920 | CLEAR_STR |
3a2d747c | 5921 | IP_STR |
718e3744 | 5922 | BGP_STR |
838758ac | 5923 | BGP_INSTANCE_HELP_STR |
8c3deaae | 5924 | "Address Family\n" |
3a2d747c QY |
5925 | "Address Family modifier\n" |
5926 | "Address Family modifier\n" | |
b09b5ae0 | 5927 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5928 | "IPv6 prefix\n") |
718e3744 | 5929 | { |
b09b5ae0 | 5930 | int idx_word = 3; |
c500ae40 | 5931 | int idx_safi = 5; |
b09b5ae0 | 5932 | int idx_ipv6_prefixlen = 7; |
c500ae40 | 5933 | if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) |
b09b5ae0 DW |
5934 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_MULTICAST, NULL); |
5935 | else | |
5936 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, SAFI_UNICAST, NULL); | |
718e3744 | 5937 | } |
5938 | ||
b09b5ae0 DW |
5939 | DEFUN (show_bgp_views, |
5940 | show_bgp_views_cmd, | |
d6e3c605 | 5941 | "show [ip] bgp views", |
b09b5ae0 | 5942 | SHOW_STR |
d6e3c605 | 5943 | IP_STR |
01080f7c | 5944 | BGP_STR |
b09b5ae0 | 5945 | "Show the defined BGP views\n") |
01080f7c | 5946 | { |
b09b5ae0 DW |
5947 | struct list *inst = bm->bgp; |
5948 | struct listnode *node; | |
5949 | struct bgp *bgp; | |
01080f7c | 5950 | |
b09b5ae0 DW |
5951 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
5952 | { | |
5953 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5954 | return CMD_WARNING; | |
5955 | } | |
e52702f2 | 5956 | |
b09b5ae0 DW |
5957 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
5958 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5959 | { | |
5960 | /* Skip VRFs. */ | |
5961 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
5962 | continue; | |
5963 | vty_out (vty, "\t%s (AS%u)%s", | |
5964 | bgp->name ? bgp->name : "(null)", | |
5965 | bgp->as, VTY_NEWLINE); | |
5966 | } | |
e52702f2 | 5967 | |
b09b5ae0 | 5968 | return CMD_SUCCESS; |
e0081f70 ML |
5969 | } |
5970 | ||
8386ac43 | 5971 | DEFUN (show_bgp_vrfs, |
5972 | show_bgp_vrfs_cmd, | |
d6e3c605 | 5973 | "show [ip] bgp vrfs [json]", |
8386ac43 | 5974 | SHOW_STR |
d6e3c605 | 5975 | IP_STR |
8386ac43 | 5976 | BGP_STR |
5977 | "Show BGP VRFs\n" | |
9973d184 | 5978 | JSON_STR) |
8386ac43 | 5979 | { |
5980 | struct list *inst = bm->bgp; | |
5981 | struct listnode *node; | |
5982 | struct bgp *bgp; | |
5983 | u_char uj = use_json(argc, argv); | |
5984 | json_object *json = NULL; | |
5985 | json_object *json_vrfs = NULL; | |
5986 | int count = 0; | |
5987 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
5988 | ||
5989 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
5990 | { | |
5991 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5992 | return CMD_WARNING; | |
5993 | } | |
5994 | ||
5995 | if (uj) | |
5996 | { | |
5997 | json = json_object_new_object(); | |
5998 | json_vrfs = json_object_new_object(); | |
5999 | } | |
6000 | ||
6001 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
6002 | { | |
6003 | const char *name, *type; | |
6004 | struct peer *peer; | |
6005 | struct listnode *node, *nnode; | |
6006 | int peers_cfg, peers_estb; | |
6007 | json_object *json_vrf = NULL; | |
5c81a5f3 | 6008 | int vrf_id_ui; |
8386ac43 | 6009 | |
6010 | /* Skip Views. */ | |
6011 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6012 | continue; | |
6013 | ||
6014 | count++; | |
6015 | if (!uj && count == 1) | |
6016 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
6017 | ||
6018 | peers_cfg = peers_estb = 0; | |
6019 | if (uj) | |
6020 | json_vrf = json_object_new_object(); | |
6021 | ||
6022 | ||
6023 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6024 | { | |
6025 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6026 | continue; | |
6027 | peers_cfg++; | |
6028 | if (peer->status == Established) | |
6029 | peers_estb++; | |
6030 | } | |
6031 | ||
6032 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6033 | { | |
6034 | name = "Default"; | |
6035 | type = "DFLT"; | |
6036 | } | |
6037 | else | |
6038 | { | |
6039 | name = bgp->name; | |
6040 | type = "VRF"; | |
6041 | } | |
6042 | ||
5c81a5f3 | 6043 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 6044 | if (uj) |
6045 | { | |
6046 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 6047 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 6048 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
6049 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
6050 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6051 | ||
6052 | json_object_object_add(json_vrfs, name, json_vrf); | |
6053 | } | |
6054 | else | |
5c81a5f3 | 6055 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6056 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6057 | peers_cfg, peers_estb, name, |
6058 | VTY_NEWLINE); | |
6059 | } | |
6060 | ||
6061 | if (uj) | |
6062 | { | |
6063 | json_object_object_add(json, "vrfs", json_vrfs); | |
6064 | ||
6065 | json_object_int_add(json, "totalVrfs", count); | |
6066 | ||
2aac5767 | 6067 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6068 | json_object_free(json); |
6069 | } | |
6070 | else | |
6071 | { | |
6072 | if (count) | |
6073 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6074 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6075 | } | |
6076 | ||
6077 | return CMD_SUCCESS; | |
6078 | } | |
6079 | ||
f412b39a | 6080 | DEFUN (show_bgp_memory, |
4bf6a362 | 6081 | show_bgp_memory_cmd, |
7fa12b13 | 6082 | "show [ip] bgp memory", |
4bf6a362 | 6083 | SHOW_STR |
3a2d747c | 6084 | IP_STR |
4bf6a362 PJ |
6085 | BGP_STR |
6086 | "Global BGP memory statistics\n") | |
6087 | { | |
6088 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6089 | unsigned long count; | |
e52702f2 | 6090 | |
4bf6a362 PJ |
6091 | /* RIB related usage stats */ |
6092 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6093 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6094 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6095 | count * sizeof (struct bgp_node)), | |
6096 | VTY_NEWLINE); | |
e52702f2 | 6097 | |
4bf6a362 PJ |
6098 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6099 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6100 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6101 | count * sizeof (struct bgp_info)), | |
6102 | VTY_NEWLINE); | |
fb982c25 PJ |
6103 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6104 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6105 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6106 | count * sizeof (struct bgp_info_extra)), | |
6107 | VTY_NEWLINE); | |
e52702f2 | 6108 | |
4bf6a362 PJ |
6109 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6110 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6111 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6112 | count * sizeof (struct bgp_static)), | |
6113 | VTY_NEWLINE); | |
3f9c7369 DS |
6114 | |
6115 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6116 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6117 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6118 | count * sizeof (struct bpacket)), | |
6119 | VTY_NEWLINE); | |
e52702f2 | 6120 | |
4bf6a362 PJ |
6121 | /* Adj-In/Out */ |
6122 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6123 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6124 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6125 | count * sizeof (struct bgp_adj_in)), | |
6126 | VTY_NEWLINE); | |
6127 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6128 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6129 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6130 | count * sizeof (struct bgp_adj_out)), | |
6131 | VTY_NEWLINE); | |
e52702f2 | 6132 | |
4bf6a362 PJ |
6133 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6134 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6135 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6136 | count * sizeof (struct bgp_nexthop_cache)), | |
6137 | VTY_NEWLINE); | |
6138 | ||
6139 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6140 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6141 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6142 | count * sizeof (struct bgp_damp_info)), | |
6143 | VTY_NEWLINE); | |
6144 | ||
6145 | /* Attributes */ | |
6146 | count = attr_count(); | |
e52702f2 QY |
6147 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6148 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6149 | count * sizeof(struct attr)), | |
4bf6a362 | 6150 | VTY_NEWLINE); |
fb982c25 | 6151 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6152 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6153 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6154 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6155 | VTY_NEWLINE); |
e52702f2 | 6156 | |
4bf6a362 PJ |
6157 | if ((count = attr_unknown_count())) |
6158 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6159 | |
4bf6a362 PJ |
6160 | /* AS_PATH attributes */ |
6161 | count = aspath_count (); | |
6162 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6163 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6164 | count * sizeof (struct aspath)), | |
6165 | VTY_NEWLINE); | |
e52702f2 | 6166 | |
4bf6a362 PJ |
6167 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6168 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6169 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6170 | count * sizeof (struct assegment)), | |
6171 | VTY_NEWLINE); | |
e52702f2 | 6172 | |
4bf6a362 PJ |
6173 | /* Other attributes */ |
6174 | if ((count = community_count ())) | |
6175 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6176 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6177 | count * sizeof (struct community)), | |
6178 | VTY_NEWLINE); | |
6179 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6180 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6181 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6182 | count * sizeof (struct ecommunity)), | |
6183 | VTY_NEWLINE); | |
e52702f2 | 6184 | |
4bf6a362 PJ |
6185 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6186 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6187 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6188 | count * sizeof (struct cluster_list)), | |
6189 | VTY_NEWLINE); | |
e52702f2 | 6190 | |
4bf6a362 PJ |
6191 | /* Peer related usage */ |
6192 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6193 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6194 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6195 | count * sizeof (struct peer)), | |
6196 | VTY_NEWLINE); | |
e52702f2 | 6197 | |
4a1ab8e4 | 6198 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6199 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6200 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6201 | count * sizeof (struct peer_group)), | |
6202 | VTY_NEWLINE); | |
e52702f2 | 6203 | |
4bf6a362 PJ |
6204 | /* Other */ |
6205 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6206 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6207 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6208 | count * sizeof (struct hash)), | |
6209 | VTY_NEWLINE); | |
6210 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6211 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6212 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6213 | count * sizeof (struct hash_backet)), | |
6214 | VTY_NEWLINE); | |
6215 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6216 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6217 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6218 | count * sizeof (regex_t)), | |
6219 | VTY_NEWLINE); | |
6220 | return CMD_SUCCESS; | |
6221 | } | |
fee0f4c6 | 6222 | |
718e3744 | 6223 | /* Show BGP peer's summary information. */ |
94f2b392 | 6224 | static int |
b05a1c8b | 6225 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6226 | u_char use_json, json_object *json) |
718e3744 | 6227 | { |
6228 | struct peer *peer; | |
1eb8ef25 | 6229 | struct listnode *node, *nnode; |
f14e6fdb DS |
6230 | unsigned int count = 0, dn_count = 0; |
6231 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6232 | char neighbor_buf[VTY_BUFSIZ]; |
6233 | int neighbor_col_default_width = 16; | |
718e3744 | 6234 | int len; |
f933309e | 6235 | int max_neighbor_width = 0; |
ffd0c037 DS |
6236 | json_object *json_peer = NULL; |
6237 | json_object *json_peers = NULL; | |
718e3744 | 6238 | |
b05a1c8b DS |
6239 | if (use_json) |
6240 | { | |
9f689658 DD |
6241 | if (json == NULL) |
6242 | json = json_object_new_object(); | |
6243 | ||
f1aa5d8a | 6244 | json_peers = json_object_new_object(); |
b05a1c8b | 6245 | } |
f933309e DW |
6246 | else |
6247 | { | |
6248 | /* Loop over all neighbors that will be displayed to determine how many | |
6249 | * characters are needed for the Neighbor column | |
6250 | */ | |
6251 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6252 | { | |
6253 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6254 | continue; | |
6255 | ||
6256 | if (peer->afc[afi][safi]) | |
6257 | { | |
6258 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
6259 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6260 | else | |
6261 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6262 | ||
6263 | len = strlen(neighbor_buf); | |
6264 | ||
6265 | if (len > max_neighbor_width) | |
6266 | max_neighbor_width = len; | |
6267 | } | |
6268 | } | |
6269 | ||
6270 | /* Originally we displayed the Neighbor column as 16 | |
6271 | * characters wide so make that the default | |
6272 | */ | |
6273 | if (max_neighbor_width < neighbor_col_default_width) | |
6274 | max_neighbor_width = neighbor_col_default_width; | |
6275 | } | |
b05a1c8b | 6276 | |
1eb8ef25 | 6277 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6278 | { |
1ff9a340 DS |
6279 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6280 | continue; | |
6281 | ||
718e3744 | 6282 | if (peer->afc[afi][safi]) |
6283 | { | |
b05a1c8b | 6284 | if (!count) |
4bf6a362 PJ |
6285 | { |
6286 | unsigned long ents; | |
6287 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6288 | int vrf_id_ui; |
6289 | ||
6290 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6291 | |
4bf6a362 | 6292 | /* Usage summary and header */ |
b05a1c8b DS |
6293 | if (use_json) |
6294 | { | |
62d6dca0 | 6295 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6296 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6297 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6298 | json_object_string_add(json, "vrfName", | |
6299 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6300 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6301 | } |
6302 | else | |
6303 | { | |
6304 | vty_out (vty, | |
5c81a5f3 | 6305 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6306 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6307 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6308 | } |
6309 | ||
f188f2c4 DS |
6310 | if (bgp_update_delay_configured(bgp)) |
6311 | { | |
b05a1c8b | 6312 | if (use_json) |
f188f2c4 | 6313 | { |
62d6dca0 | 6314 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6315 | |
6316 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6317 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6318 | |
6319 | if (bgp_update_delay_active(bgp)) | |
6320 | { | |
62d6dca0 DS |
6321 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6322 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6323 | } |
6324 | else | |
6325 | { | |
6326 | if (bgp->update_delay_over) | |
6327 | { | |
62d6dca0 | 6328 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6329 | bgp->update_delay_begin_time); |
62d6dca0 | 6330 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6331 | bgp->update_delay_end_time); |
62d6dca0 | 6332 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6333 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6334 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6335 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6336 | } |
6337 | } | |
f188f2c4 DS |
6338 | } |
6339 | else | |
6340 | { | |
b05a1c8b DS |
6341 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6342 | bgp->v_update_delay, VTY_NEWLINE); | |
6343 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6344 | vty_out (vty, " Establish wait: %d seconds%s", | |
6345 | bgp->v_establish_wait, VTY_NEWLINE); | |
6346 | ||
6347 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6348 | { |
6349 | vty_out (vty, " First neighbor established: %s%s", | |
6350 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6351 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6352 | } | |
6353 | else | |
6354 | { | |
6355 | if (bgp->update_delay_over) | |
6356 | { | |
6357 | vty_out (vty, " First neighbor established: %s%s", | |
6358 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6359 | vty_out (vty, " Best-paths resumed: %s%s", | |
6360 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6361 | vty_out (vty, " zebra update resumed: %s%s", | |
6362 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6363 | vty_out (vty, " peers update resumed: %s%s", | |
6364 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6365 | } | |
f188f2c4 DS |
6366 | } |
6367 | } | |
6368 | } | |
4bf6a362 | 6369 | |
b05a1c8b DS |
6370 | if (use_json) |
6371 | { | |
6372 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6373 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6374 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6375 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6376 | |
62d6dca0 | 6377 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6378 | |
6379 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6380 | json_object_int_add(json, "ribCount", ents); |
6381 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6382 | |
6383 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6384 | json_object_int_add(json, "peerCount", ents); |
6385 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6386 | |
b05a1c8b DS |
6387 | if ((ents = listcount (bgp->group))) |
6388 | { | |
62d6dca0 DS |
6389 | json_object_int_add(json, "peerGroupCount", ents); |
6390 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6391 | } |
3f9c7369 | 6392 | |
b05a1c8b | 6393 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6394 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6395 | } |
6396 | else | |
6397 | { | |
6398 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6399 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6400 | if (bgp->v_maxmed_admin) | |
6401 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6402 | ||
ffd0c037 | 6403 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6404 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6405 | ||
6406 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6407 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6408 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6409 | ents * sizeof (struct bgp_node)), | |
6410 | VTY_NEWLINE); | |
6411 | ||
6412 | /* Peer related usage */ | |
6413 | ents = listcount (bgp->peer); | |
6414 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6415 | ents, | |
6416 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6417 | ents * sizeof (struct peer)), | |
6418 | VTY_NEWLINE); | |
6419 | ||
b05a1c8b DS |
6420 | if ((ents = listcount (bgp->group))) |
6421 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6422 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6423 | ents * sizeof (struct peer_group)), | |
6424 | VTY_NEWLINE); | |
6425 | ||
6426 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6427 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6428 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6429 | |
6430 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6431 | vty_out (vty, "Neighbor"); | |
6432 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6433 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6434 | } |
4bf6a362 | 6435 | } |
e52702f2 | 6436 | |
b05a1c8b | 6437 | count++; |
718e3744 | 6438 | |
b05a1c8b DS |
6439 | if (use_json) |
6440 | { | |
6441 | json_peer = json_object_new_object(); | |
f14e6fdb | 6442 | |
b05a1c8b | 6443 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6444 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6445 | |
04b6bdc0 DW |
6446 | if (peer->hostname) |
6447 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6448 | ||
6449 | if (peer->domainname) | |
6450 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6451 | ||
62d6dca0 | 6452 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6453 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6454 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6455 | peer->open_in + peer->update_in + peer->keepalive_in |
6456 | + peer->notify_in + peer->refresh_in | |
6457 | + peer->dynamic_cap_in); | |
62d6dca0 | 6458 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6459 | peer->open_out + peer->update_out + peer->keepalive_out |
6460 | + peer->notify_out + peer->refresh_out | |
6461 | + peer->dynamic_cap_out); | |
6462 | ||
62d6dca0 | 6463 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6464 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6465 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6466 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6467 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6468 | |
6469 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6470 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6471 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6472 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6473 | else |
f1aa5d8a | 6474 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6475 | |
f1aa5d8a | 6476 | if (peer->conf_if) |
62d6dca0 | 6477 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6478 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6479 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6480 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6481 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6482 | |
f1aa5d8a | 6483 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6484 | } |
6485 | else | |
6486 | { | |
6487 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6488 | if (peer_dynamic_neighbor(peer)) | |
6489 | { | |
6490 | dn_count++; | |
6491 | dn_flag[0] = '*'; | |
6492 | } | |
6493 | ||
04b6bdc0 DW |
6494 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6495 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6496 | peer->host); | |
6497 | else | |
6498 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6499 | |
f933309e DW |
6500 | /* pad the neighbor column with spaces */ |
6501 | if (len < max_neighbor_width) | |
6502 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6503 | |
f933309e | 6504 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6505 | peer->as, |
6506 | peer->open_in + peer->update_in + peer->keepalive_in | |
6507 | + peer->notify_in + peer->refresh_in | |
6508 | + peer->dynamic_cap_in, | |
6509 | peer->open_out + peer->update_out + peer->keepalive_out | |
6510 | + peer->notify_out + peer->refresh_out | |
6511 | + peer->dynamic_cap_out, | |
6512 | peer->version[afi][safi], | |
6513 | 0, | |
f933309e | 6514 | peer->obuf->count, |
856ca177 | 6515 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6516 | |
6517 | if (peer->status == Established) | |
46f8c104 | 6518 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6519 | else |
6520 | { | |
6521 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6522 | vty_out (vty, " Idle (Admin)"); | |
6523 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6524 | vty_out (vty, " Idle (PfxCt)"); | |
6525 | else | |
f933309e | 6526 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6527 | } |
6528 | vty_out (vty, "%s", VTY_NEWLINE); | |
6529 | } | |
718e3744 | 6530 | } |
6531 | } | |
6532 | ||
b05a1c8b DS |
6533 | if (use_json) |
6534 | { | |
6535 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6536 | |
62d6dca0 DS |
6537 | json_object_int_add(json, "totalPeers", count); |
6538 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6539 | |
2aac5767 | 6540 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6541 | json_object_free(json); |
b05a1c8b DS |
6542 | } |
6543 | else | |
f14e6fdb | 6544 | { |
b05a1c8b DS |
6545 | if (count) |
6546 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6547 | count, VTY_NEWLINE); | |
6548 | else | |
9f689658 DD |
6549 | { |
6550 | if (use_json) | |
6551 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
6552 | afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); | |
6553 | else | |
6554 | vty_out (vty, "No %s neighbor is configured%s", | |
6555 | afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); | |
6556 | } | |
b05a1c8b | 6557 | |
9f689658 | 6558 | if (dn_count && ! use_json) |
b05a1c8b DS |
6559 | { |
6560 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6561 | vty_out(vty, | |
6562 | "%d dynamic neighbor(s), limit %d%s", | |
6563 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6564 | } | |
f14e6fdb DS |
6565 | } |
6566 | ||
718e3744 | 6567 | return CMD_SUCCESS; |
6568 | } | |
6569 | ||
f186de26 | 6570 | static void |
6571 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6572 | u_char use_json) | |
6573 | { | |
6574 | struct listnode *node, *nnode; | |
6575 | struct bgp *bgp; | |
9f689658 DD |
6576 | json_object *json = NULL; |
6577 | int is_first = 1; | |
6578 | ||
6579 | if (use_json) | |
6580 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6581 | |
6582 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6583 | { | |
9f689658 DD |
6584 | if (use_json) |
6585 | { | |
4fb25c53 | 6586 | json = json_object_new_object(); |
9f689658 DD |
6587 | |
6588 | if (! is_first) | |
6589 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6590 | else | |
6591 | is_first = 0; | |
6592 | ||
6593 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6594 | ? "Default" : bgp->name); | |
6595 | } | |
6596 | else | |
6597 | { | |
6598 | vty_out (vty, "%sInstance %s:%s", | |
6599 | VTY_NEWLINE, | |
6600 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6601 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6602 | } | |
6603 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); | |
f186de26 | 6604 | } |
9f689658 DD |
6605 | |
6606 | if (use_json) | |
6607 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6608 | ||
f186de26 | 6609 | } |
6610 | ||
4fb25c53 DW |
6611 | static int |
6612 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6613 | afi_t afi, safi_t safi, u_char use_json) | |
6614 | { | |
6615 | struct bgp *bgp; | |
6616 | ||
6617 | if (name) | |
6618 | { | |
6619 | if (strmatch(name, "all")) | |
6620 | { | |
6621 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6622 | return CMD_SUCCESS; | |
6623 | } | |
6624 | else | |
6625 | { | |
6626 | bgp = bgp_lookup_by_name (name); | |
6627 | ||
6628 | if (! bgp) | |
6629 | { | |
6630 | if (use_json) | |
6631 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6632 | else | |
6633 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6634 | return CMD_WARNING; | |
6635 | } | |
6636 | ||
6637 | bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); | |
6638 | return CMD_SUCCESS; | |
6639 | } | |
6640 | } | |
6641 | ||
6642 | bgp = bgp_get_default (); | |
6643 | ||
6644 | if (bgp) | |
6645 | bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); | |
6646 | ||
6647 | return CMD_SUCCESS; | |
6648 | } | |
6649 | ||
718e3744 | 6650 | /* `show ip bgp summary' commands. */ |
47fc97cc | 6651 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6652 | show_ip_bgp_summary_cmd, |
91d37724 | 6653 | "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] summary [json]", |
718e3744 | 6654 | SHOW_STR |
6655 | IP_STR | |
6656 | BGP_STR | |
8386ac43 | 6657 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6658 | "Address Family\n" |
8de197ce | 6659 | "Address Family modifier\n" |
8de197ce | 6660 | "Address Family modifier\n" |
8c3deaae | 6661 | "Address Family\n" |
8de197ce | 6662 | "Address Family modifier\n" |
0c7b1b01 | 6663 | "Address Family modifier\n" |
8c3deaae | 6664 | "Address Family\n" |
718e3744 | 6665 | "Address Family modifier\n" |
8c3deaae | 6666 | "Address Family\n" |
91d37724 QY |
6667 | "Display information about all VPNv4 NLRIs\n" |
6668 | "Display information for a route distinguisher\n" | |
6669 | "VPN Route Distinguisher\n" | |
b05a1c8b | 6670 | "Summary of BGP neighbor status\n" |
9973d184 | 6671 | JSON_STR) |
718e3744 | 6672 | { |
74ca3d33 | 6673 | char *vrf = NULL; |
ae19d7dd QY |
6674 | afi_t afi = AFI_IP6; |
6675 | safi_t safi = SAFI_UNICAST; | |
6676 | ||
6677 | int idx = 0; | |
6678 | ||
6679 | /* show [ip] bgp */ | |
6680 | if (argv_find (argv, argc, "ip", &idx)) | |
6681 | afi = AFI_IP; | |
6682 | /* [<view|vrf> WORD] */ | |
6683 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6684 | vrf = argv[++idx]->arg; | |
6685 | /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ | |
6686 | if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) | |
6687 | { | |
6688 | afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; | |
6689 | if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) | |
6690 | safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; | |
6691 | } | |
91d37724 | 6692 | else if (argv_find (argv, argc, "encap", &idx)) |
ae19d7dd QY |
6693 | { |
6694 | afi = AFI_IP; | |
91d37724 | 6695 | safi = SAFI_ENCAP; |
ae19d7dd | 6696 | } |
91d37724 QY |
6697 | else if (argv_find (argv, argc, "vpnv4", &idx)) |
6698 | { | |
6699 | // we show the same thing regardless of rd and all | |
6700 | afi = AFI_IP; | |
6701 | safi = SAFI_MPLS_VPN; | |
6702 | } | |
6703 | ||
ae19d7dd | 6704 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6705 | |
6706 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6707 | } |
6708 | ||
fd79ac91 | 6709 | const char * |
538621f2 | 6710 | afi_safi_print (afi_t afi, safi_t safi) |
6711 | { | |
6712 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6713 | return "IPv4 Unicast"; | |
6714 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6715 | return "IPv4 Multicast"; | |
6716 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
945c8fe9 | 6717 | return "VPN-IPv4 Unicast"; |
8b1fb8be LB |
6718 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
6719 | return "ENCAP-IPv4 Unicast"; | |
538621f2 | 6720 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6721 | return "IPv6 Unicast"; | |
6722 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6723 | return "IPv6 Multicast"; | |
945c8fe9 LB |
6724 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
6725 | return "VPN-IPv6 Unicast"; | |
8b1fb8be LB |
6726 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
6727 | return "ENCAP-IPv6 Unicast"; | |
538621f2 | 6728 | else |
6729 | return "Unknown"; | |
6730 | } | |
6731 | ||
718e3744 | 6732 | /* Show BGP peer's information. */ |
6733 | enum show_type | |
6734 | { | |
6735 | show_all, | |
6736 | show_peer | |
6737 | }; | |
6738 | ||
94f2b392 | 6739 | static void |
856ca177 MS |
6740 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6741 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6742 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6743 | { |
6744 | /* Send-Mode */ | |
6745 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6746 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6747 | { | |
856ca177 MS |
6748 | if (use_json) |
6749 | { | |
6750 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6751 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6752 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6753 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6754 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6755 | json_object_string_add(json_pref, "sendMode", "received"); | |
6756 | } | |
6757 | else | |
6758 | { | |
6759 | vty_out (vty, " Send-mode: "); | |
6760 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6761 | vty_out (vty, "advertised"); | |
6762 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6763 | vty_out (vty, "%sreceived", | |
6764 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6765 | ", " : ""); | |
6766 | vty_out (vty, "%s", VTY_NEWLINE); | |
6767 | } | |
718e3744 | 6768 | } |
6769 | ||
6770 | /* Receive-Mode */ | |
6771 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6772 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6773 | { | |
856ca177 MS |
6774 | if (use_json) |
6775 | { | |
6776 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6777 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6778 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6779 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6780 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6781 | json_object_string_add(json_pref, "recvMode", "received"); | |
6782 | } | |
6783 | else | |
6784 | { | |
6785 | vty_out (vty, " Receive-mode: "); | |
6786 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6787 | vty_out (vty, "advertised"); | |
6788 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6789 | vty_out (vty, "%sreceived", | |
6790 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
6791 | ", " : ""); | |
6792 | vty_out (vty, "%s", VTY_NEWLINE); | |
6793 | } | |
718e3744 | 6794 | } |
6795 | } | |
6796 | ||
94f2b392 | 6797 | static void |
856ca177 MS |
6798 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6799 | u_char use_json, json_object *json_neigh) | |
718e3744 | 6800 | { |
6801 | struct bgp_filter *filter; | |
3f9c7369 | 6802 | struct peer_af *paf; |
718e3744 | 6803 | char orf_pfx_name[BUFSIZ]; |
6804 | int orf_pfx_count; | |
856ca177 MS |
6805 | json_object *json_af = NULL; |
6806 | json_object *json_prefA = NULL; | |
6807 | json_object *json_prefB = NULL; | |
6808 | json_object *json_addr = NULL; | |
718e3744 | 6809 | |
856ca177 MS |
6810 | if (use_json) |
6811 | { | |
6812 | json_addr = json_object_new_object(); | |
6813 | json_af = json_object_new_object(); | |
856ca177 | 6814 | filter = &p->filter[afi][safi]; |
718e3744 | 6815 | |
c8560b44 | 6816 | if (peer_group_active(p)) |
856ca177 | 6817 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 6818 | |
856ca177 MS |
6819 | paf = peer_af_find(p, afi, safi); |
6820 | if (paf && PAF_SUBGRP(paf)) | |
6821 | { | |
6822 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
6823 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
6824 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
6825 | } | |
6826 | ||
6827 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6828 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6829 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6830 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6831 | { | |
6832 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 6833 | json_prefA = json_object_new_object(); |
856ca177 MS |
6834 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6835 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6836 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6837 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6838 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
6839 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
6840 | } | |
6841 | ||
6842 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6843 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6844 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6845 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6846 | { | |
6847 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 6848 | json_prefB = json_object_new_object(); |
856ca177 MS |
6849 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6850 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6851 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6852 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6853 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
6854 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
6855 | } | |
6856 | ||
6857 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6858 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6859 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6860 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6861 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6862 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6863 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
6864 | else |
6865 | json_object_free(json_af); | |
856ca177 MS |
6866 | |
6867 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
6868 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
6869 | ||
6870 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
6871 | || orf_pfx_count) | |
6872 | { | |
6873 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
6874 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
6875 | if (orf_pfx_count) | |
6876 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
6877 | } | |
6878 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
6879 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
6880 | ||
6881 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
6882 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
6883 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6884 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
6885 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
6886 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
6887 | ||
88b8ed8d DW |
6888 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
6889 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
6890 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 6891 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
6892 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
6893 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
6894 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
6895 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
6896 | ||
adbac85e DW |
6897 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
6898 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
6899 | ||
06370dac DW |
6900 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
6901 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
6902 | ||
856ca177 MS |
6903 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
6904 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
6905 | ||
6906 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
6907 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
6908 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
6909 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
6910 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
6911 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
6912 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
6913 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
6914 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 6915 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
6916 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
6917 | { | |
6918 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
6919 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6920 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
6921 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6922 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
6923 | else | |
6924 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
6925 | } | |
6926 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
6927 | { | |
6928 | if (p->default_rmap[afi][safi].name) | |
6929 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
6930 | ||
6931 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
6932 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
6933 | else | |
6934 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
6935 | } | |
6936 | ||
6937 | if (filter->plist[FILTER_IN].name | |
6938 | || filter->dlist[FILTER_IN].name | |
6939 | || filter->aslist[FILTER_IN].name | |
6940 | || filter->map[RMAP_IN].name) | |
6941 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
6942 | if (filter->plist[FILTER_OUT].name | |
6943 | || filter->dlist[FILTER_OUT].name | |
6944 | || filter->aslist[FILTER_OUT].name | |
6945 | || filter->map[RMAP_OUT].name | |
6946 | || filter->usmap.name) | |
6947 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
6948 | |
6949 | /* prefix-list */ | |
6950 | if (filter->plist[FILTER_IN].name) | |
6951 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
6952 | if (filter->plist[FILTER_OUT].name) | |
6953 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
6954 | ||
6955 | /* distribute-list */ | |
6956 | if (filter->dlist[FILTER_IN].name) | |
6957 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
6958 | if (filter->dlist[FILTER_OUT].name) | |
6959 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
6960 | ||
6961 | /* filter-list. */ | |
6962 | if (filter->aslist[FILTER_IN].name) | |
6963 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
6964 | if (filter->aslist[FILTER_OUT].name) | |
6965 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
6966 | ||
6967 | /* route-map. */ | |
6968 | if (filter->map[RMAP_IN].name) | |
6969 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
6970 | if (filter->map[RMAP_OUT].name) | |
6971 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
6972 | |
6973 | /* unsuppress-map */ | |
6974 | if (filter->usmap.name) | |
6975 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
6976 | ||
6977 | /* Receive prefix count */ | |
6978 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
6979 | ||
6980 | /* Maximum prefix */ | |
6981 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
6982 | { | |
6983 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
6984 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
6985 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
6986 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
6987 | if (p->pmax_restart[afi][safi]) | |
6988 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
6989 | } | |
6990 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
6991 | ||
6992 | } | |
6993 | else | |
6994 | { | |
6995 | filter = &p->filter[afi][safi]; | |
6996 | ||
6997 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
6998 | VTY_NEWLINE); | |
6999 | ||
c8560b44 | 7000 | if (peer_group_active(p)) |
856ca177 MS |
7001 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
7002 | ||
7003 | paf = peer_af_find(p, afi, safi); | |
7004 | if (paf && PAF_SUBGRP(paf)) | |
7005 | { | |
7006 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
7007 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
7008 | vty_out (vty, " Packet Queue length %d%s", | |
7009 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
7010 | } | |
718e3744 | 7011 | else |
856ca177 MS |
7012 | { |
7013 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
7014 | } | |
7015 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7016 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7017 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7018 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7019 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
7020 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7021 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
7022 | ||
7023 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7024 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
7025 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7026 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
7027 | { | |
7028 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7029 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
7030 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7031 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7032 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7033 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7034 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7035 | } | |
7036 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7037 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7038 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
7039 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7040 | { | |
7041 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
7042 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
7043 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
7044 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7045 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7046 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7047 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7048 | } | |
718e3744 | 7049 | |
856ca177 MS |
7050 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
7051 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 7052 | |
856ca177 MS |
7053 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
7054 | || orf_pfx_count) | |
7055 | { | |
7056 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
7057 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
7058 | vty_out (vty, " sent;"); | |
7059 | if (orf_pfx_count) | |
7060 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
7061 | vty_out (vty, "%s", VTY_NEWLINE); | |
7062 | } | |
7063 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
7064 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
7065 | ||
7066 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
7067 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
7068 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
7069 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7070 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7071 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7072 | ||
88b8ed8d DW |
7073 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7074 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7075 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7076 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7077 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7078 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7079 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7080 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7081 | ||
adbac85e DW |
7082 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7083 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7084 | ||
06370dac DW |
7085 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7086 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7087 | ||
856ca177 MS |
7088 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7089 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7090 | ||
7091 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7092 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7093 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7094 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7095 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7096 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7097 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7098 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7099 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7100 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7101 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7102 | { | |
7103 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7104 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7105 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7106 | vty_out (vty, "(both)%s", VTY_NEWLINE); | |
7107 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7108 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7109 | else | |
7110 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7111 | } | |
7112 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7113 | { | |
7114 | vty_out (vty, " Default information originate,"); | |
7115 | ||
7116 | if (p->default_rmap[afi][safi].name) | |
7117 | vty_out (vty, " default route-map %s%s,", | |
7118 | p->default_rmap[afi][safi].map ? "*" : "", | |
7119 | p->default_rmap[afi][safi].name); | |
7120 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7121 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7122 | else | |
7123 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7124 | } | |
718e3744 | 7125 | |
856ca177 MS |
7126 | if (filter->plist[FILTER_IN].name |
7127 | || filter->dlist[FILTER_IN].name | |
7128 | || filter->aslist[FILTER_IN].name | |
7129 | || filter->map[RMAP_IN].name) | |
7130 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7131 | if (filter->plist[FILTER_OUT].name | |
7132 | || filter->dlist[FILTER_OUT].name | |
7133 | || filter->aslist[FILTER_OUT].name | |
7134 | || filter->map[RMAP_OUT].name | |
7135 | || filter->usmap.name) | |
7136 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7137 | |
7138 | /* prefix-list */ | |
7139 | if (filter->plist[FILTER_IN].name) | |
7140 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7141 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7142 | filter->plist[FILTER_IN].name, | |
7143 | VTY_NEWLINE); | |
7144 | if (filter->plist[FILTER_OUT].name) | |
7145 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7146 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7147 | filter->plist[FILTER_OUT].name, | |
7148 | VTY_NEWLINE); | |
7149 | ||
7150 | /* distribute-list */ | |
7151 | if (filter->dlist[FILTER_IN].name) | |
7152 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7153 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7154 | filter->dlist[FILTER_IN].name, | |
7155 | VTY_NEWLINE); | |
7156 | if (filter->dlist[FILTER_OUT].name) | |
7157 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7158 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7159 | filter->dlist[FILTER_OUT].name, | |
7160 | VTY_NEWLINE); | |
7161 | ||
7162 | /* filter-list. */ | |
7163 | if (filter->aslist[FILTER_IN].name) | |
7164 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7165 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7166 | filter->aslist[FILTER_IN].name, | |
7167 | VTY_NEWLINE); | |
7168 | if (filter->aslist[FILTER_OUT].name) | |
7169 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7170 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7171 | filter->aslist[FILTER_OUT].name, | |
7172 | VTY_NEWLINE); | |
7173 | ||
7174 | /* route-map. */ | |
7175 | if (filter->map[RMAP_IN].name) | |
7176 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7177 | filter->map[RMAP_IN].map ? "*" : "", | |
7178 | filter->map[RMAP_IN].name, | |
7179 | VTY_NEWLINE); | |
7180 | if (filter->map[RMAP_OUT].name) | |
7181 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7182 | filter->map[RMAP_OUT].map ? "*" : "", | |
7183 | filter->map[RMAP_OUT].name, | |
7184 | VTY_NEWLINE); | |
856ca177 MS |
7185 | |
7186 | /* unsuppress-map */ | |
7187 | if (filter->usmap.name) | |
7188 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7189 | filter->usmap.map ? "*" : "", | |
7190 | filter->usmap.name, VTY_NEWLINE); | |
7191 | ||
7192 | /* Receive prefix count */ | |
7193 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7194 | ||
7195 | /* Maximum prefix */ | |
7196 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7197 | { | |
7198 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7199 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7200 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7201 | vty_out (vty, " Threshold for warning message %d%%", | |
7202 | p->pmax_threshold[afi][safi]); | |
7203 | if (p->pmax_restart[afi][safi]) | |
7204 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7205 | vty_out (vty, "%s", VTY_NEWLINE); | |
7206 | } | |
718e3744 | 7207 | |
0a486e5f | 7208 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7209 | } |
718e3744 | 7210 | } |
7211 | ||
94f2b392 | 7212 | static void |
e8f7da3a | 7213 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7214 | { |
7215 | struct bgp *bgp; | |
4690c7d7 | 7216 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7217 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7218 | char dn_flag[2]; |
3a8c7ba1 DW |
7219 | const char *subcode_str; |
7220 | const char *code_str; | |
538621f2 | 7221 | afi_t afi; |
7222 | safi_t safi; | |
d6661008 DS |
7223 | u_int16_t i; |
7224 | u_char *msg; | |
e8f7da3a | 7225 | json_object *json_neigh = NULL; |
718e3744 | 7226 | |
7227 | bgp = p->bgp; | |
7228 | ||
e8f7da3a DW |
7229 | if (use_json) |
7230 | json_neigh = json_object_new_object(); | |
7231 | ||
856ca177 | 7232 | if (!use_json) |
f14e6fdb | 7233 | { |
856ca177 MS |
7234 | if (p->conf_if) /* Configured interface name. */ |
7235 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7236 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7237 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7238 | else /* Configured IP address. */ | |
7239 | { | |
7240 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7241 | if (peer_dynamic_neighbor(p)) | |
7242 | dn_flag[0] = '*'; | |
f14e6fdb | 7243 | |
856ca177 MS |
7244 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
7245 | } | |
f14e6fdb DS |
7246 | } |
7247 | ||
856ca177 MS |
7248 | if (use_json) |
7249 | { | |
7250 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7251 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7252 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7253 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7254 | ||
7255 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7256 | ||
7257 | if (p->change_local_as) | |
7258 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7259 | else | |
7260 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7261 | ||
7262 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7263 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7264 | |
856ca177 MS |
7265 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7266 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7267 | } | |
7268 | else | |
7269 | { | |
f8cfafda DS |
7270 | if ((p->as_type == AS_SPECIFIED) || |
7271 | (p->as_type == AS_EXTERNAL) || | |
7272 | (p->as_type == AS_INTERNAL)) | |
7273 | vty_out (vty, "remote AS %u, ", p->as); | |
7274 | else | |
7275 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7276 | vty_out (vty, "local AS %u%s%s, ", |
7277 | p->change_local_as ? p->change_local_as : p->local_as, | |
7278 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7279 | " no-prepend" : "", | |
7280 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7281 | " replace-as" : ""); | |
7282 | } | |
66b199b2 DS |
7283 | /* peer type internal, external, confed-internal or confed-external */ |
7284 | if (p->as == p->local_as) | |
7285 | { | |
856ca177 MS |
7286 | if (use_json) |
7287 | { | |
7288 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7289 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7290 | else | |
7291 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7292 | } | |
66b199b2 | 7293 | else |
856ca177 MS |
7294 | { |
7295 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7296 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7297 | else | |
7298 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7299 | } | |
66b199b2 DS |
7300 | } |
7301 | else | |
7302 | { | |
856ca177 MS |
7303 | if (use_json) |
7304 | { | |
7305 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7306 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7307 | else | |
7308 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7309 | } | |
66b199b2 | 7310 | else |
856ca177 MS |
7311 | { |
7312 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7313 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7314 | else | |
7315 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7316 | } | |
66b199b2 | 7317 | } |
718e3744 | 7318 | |
7319 | /* Description. */ | |
7320 | if (p->desc) | |
856ca177 MS |
7321 | { |
7322 | if (use_json) | |
7323 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7324 | else | |
7325 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7326 | } | |
6410e93a | 7327 | |
04b6bdc0 DW |
7328 | if (p->hostname) |
7329 | { | |
d1570739 DW |
7330 | if (use_json) |
7331 | { | |
7332 | if (p->hostname) | |
7333 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7334 | ||
7335 | if (p->domainname) | |
7336 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7337 | } | |
04b6bdc0 | 7338 | else |
d1570739 DW |
7339 | { |
7340 | if (p->domainname && (p->domainname[0] != '\0')) | |
7341 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7342 | VTY_NEWLINE); | |
7343 | else | |
7344 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7345 | } | |
7346 | ||
04b6bdc0 DW |
7347 | } |
7348 | ||
c744aa9f | 7349 | /* Peer-group */ |
718e3744 | 7350 | if (p->group) |
f14e6fdb | 7351 | { |
856ca177 MS |
7352 | if (use_json) |
7353 | { | |
7354 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7355 | ||
7356 | if (dn_flag[0]) | |
7357 | { | |
40ee54a7 | 7358 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7359 | |
40ee54a7 TT |
7360 | sockunion2hostprefix(&(p->su), &prefix); |
7361 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7362 | |
7363 | if (range) | |
7364 | { | |
7365 | prefix2str(range, buf1, sizeof(buf1)); | |
7366 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7367 | } | |
7368 | } | |
7369 | } | |
7370 | else | |
f14e6fdb | 7371 | { |
856ca177 MS |
7372 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7373 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7374 | |
856ca177 | 7375 | if (dn_flag[0]) |
f14e6fdb | 7376 | { |
40ee54a7 | 7377 | struct prefix prefix, *range = NULL; |
856ca177 | 7378 | |
40ee54a7 TT |
7379 | sockunion2hostprefix(&(p->su), &prefix); |
7380 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7381 | |
7382 | if (range) | |
7383 | { | |
7384 | prefix2str(range, buf1, sizeof(buf1)); | |
7385 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7386 | } | |
f14e6fdb DS |
7387 | } |
7388 | } | |
7389 | } | |
718e3744 | 7390 | |
856ca177 MS |
7391 | if (use_json) |
7392 | { | |
7393 | /* Administrative shutdown. */ | |
7394 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7395 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7396 | |
856ca177 MS |
7397 | /* BGP Version. */ |
7398 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
7399 | json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ)); | |
718e3744 | 7400 | |
856ca177 MS |
7401 | /* Confederation */ |
7402 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7403 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7404 | ||
7405 | /* Status. */ | |
7406 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7407 | ||
7408 | if (p->status == Established) | |
7409 | { | |
7410 | time_t uptime; | |
7411 | struct tm *tm; | |
7412 | ||
7413 | uptime = bgp_clock(); | |
7414 | uptime -= p->uptime; | |
7415 | tm = gmtime(&uptime); | |
7416 | ||
7417 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7418 | } | |
7419 | ||
7420 | else if (p->status == Active) | |
7421 | { | |
7422 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7423 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7424 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7425 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7426 | } | |
7427 | ||
7428 | /* read timer */ | |
7429 | time_t uptime; | |
7430 | struct tm *tm; | |
7431 | ||
7432 | uptime = bgp_clock(); | |
7433 | uptime -= p->readtime; | |
7434 | tm = gmtime(&uptime); | |
7435 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7436 | ||
7437 | uptime = bgp_clock(); | |
7438 | uptime -= p->last_write; | |
7439 | tm = gmtime(&uptime); | |
39e871e6 ST |
7440 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7441 | ||
7442 | uptime = bgp_clock(); | |
7443 | uptime -= p->update_time; | |
7444 | tm = gmtime(&uptime); | |
7445 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7446 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7447 | |
7448 | /* Configured timer values. */ | |
7449 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7450 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7451 | ||
7452 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7453 | { | |
7454 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7455 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7456 | } | |
93406d87 | 7457 | } |
856ca177 MS |
7458 | else |
7459 | { | |
7460 | /* Administrative shutdown. */ | |
7461 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7462 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7463 | ||
7464 | /* BGP Version. */ | |
7465 | vty_out (vty, " BGP version 4"); | |
7466 | vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ), | |
7467 | VTY_NEWLINE); | |
7468 | ||
7469 | /* Confederation */ | |
7470 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7471 | && bgp_confederation_peers_check (bgp, p->as)) | |
7472 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7473 | |
856ca177 MS |
7474 | /* Status. */ |
7475 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7476 | |
856ca177 MS |
7477 | if (p->status == Established) |
7478 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7479 | ||
7480 | else if (p->status == Active) | |
7481 | { | |
7482 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7483 | vty_out (vty, " (passive)"); | |
7484 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7485 | vty_out (vty, " (NSF passive)"); | |
7486 | } | |
7487 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7488 | |
856ca177 MS |
7489 | /* read timer */ |
7490 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7491 | vty_out (vty, ", Last write %s%s", | |
7492 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7493 | ||
7494 | /* Configured timer values. */ | |
7495 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7496 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7497 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7498 | { | |
7499 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7500 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7501 | p->keepalive, VTY_NEWLINE); | |
7502 | } | |
7503 | } | |
718e3744 | 7504 | /* Capability. */ |
e52702f2 | 7505 | if (p->status == Established) |
718e3744 | 7506 | { |
538621f2 | 7507 | if (p->cap |
718e3744 | 7508 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7509 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7510 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7511 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
7512 | #ifdef HAVE_IPV6 | |
7513 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
7514 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7515 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7516 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7517 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7518 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7519 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7520 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
718e3744 | 7521 | #endif /* HAVE_IPV6 */ |
8b1fb8be LB |
7522 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7523 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7524 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7525 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7526 | { | |
856ca177 MS |
7527 | if (use_json) |
7528 | { | |
7529 | json_object *json_cap = NULL; | |
7530 | ||
7531 | json_cap = json_object_new_object(); | |
7532 | ||
7533 | /* AS4 */ | |
7534 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7535 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7536 | { | |
7537 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7538 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7539 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7540 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7541 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7542 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7543 | } | |
7544 | ||
7545 | /* AddPath */ | |
7546 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7547 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7548 | { | |
7549 | json_object *json_add = NULL; | |
7550 | const char *print_store; | |
718e3744 | 7551 | |
856ca177 | 7552 | json_add = json_object_new_object(); |
a82478b9 | 7553 | |
856ca177 MS |
7554 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7555 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7556 | { | |
7557 | json_object *json_sub = NULL; | |
7558 | json_sub = json_object_new_object(); | |
7559 | print_store = afi_safi_print (afi, safi); | |
7560 | ||
7561 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7562 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7563 | { | |
7564 | 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)) | |
7565 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7566 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7567 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7568 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7569 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7570 | } | |
7571 | ||
7572 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7573 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7574 | { | |
7575 | 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)) | |
7576 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7577 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7578 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7579 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7580 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7581 | } | |
7582 | ||
7583 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7584 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7585 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7586 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7587 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7588 | else |
7589 | json_object_free(json_sub); | |
856ca177 | 7590 | } |
a82478b9 | 7591 | |
856ca177 MS |
7592 | json_object_object_add(json_cap, "addPath", json_add); |
7593 | } | |
7594 | ||
7595 | /* Dynamic */ | |
7596 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7597 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7598 | { | |
7599 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7600 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7601 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7602 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7603 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7604 | json_object_string_add(json_cap, "dynamic", "received"); | |
7605 | } | |
7606 | ||
7607 | /* Extended nexthop */ | |
7608 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7609 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7610 | { | |
7611 | json_object *json_nxt = NULL; | |
7612 | const char *print_store; | |
7613 | ||
856ca177 MS |
7614 | |
7615 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7616 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7617 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7618 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7619 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7620 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7621 | ||
7622 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7623 | { | |
b6df4090 DS |
7624 | json_nxt = json_object_new_object(); |
7625 | ||
856ca177 MS |
7626 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7627 | { | |
7628 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7629 | { | |
7630 | print_store = afi_safi_print (AFI_IP, safi); | |
7631 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7632 | } | |
7633 | } | |
7634 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7635 | } | |
7636 | } | |
7637 | ||
7638 | /* Route Refresh */ | |
7639 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7640 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7641 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7642 | { | |
7643 | 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))) | |
7644 | { | |
7645 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7646 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7647 | else | |
7648 | { | |
7649 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7650 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7651 | else | |
7652 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7653 | } | |
7654 | } | |
7655 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7656 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7657 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7658 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7659 | } | |
7660 | ||
7661 | /* Multiprotocol Extensions */ | |
7662 | json_object *json_multi = NULL; | |
7663 | json_multi = json_object_new_object(); | |
7664 | ||
7665 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7666 | { | |
7667 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7668 | { | |
7669 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7670 | { | |
7671 | json_object *json_exten = NULL; | |
7672 | json_exten = json_object_new_object(); | |
7673 | ||
7674 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7675 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7676 | else if (p->afc_adv[afi][safi]) | |
7677 | json_object_boolean_true_add(json_exten, "advertised"); | |
7678 | else if (p->afc_recv[afi][safi]) | |
7679 | json_object_boolean_true_add(json_exten, "received"); | |
7680 | ||
7681 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7682 | } | |
7683 | } | |
7684 | } | |
7685 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7686 | ||
7687 | /* Gracefull Restart */ | |
7688 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7689 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7690 | { | |
7691 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7692 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7693 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7694 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7695 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7696 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7697 | ||
7698 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7699 | { | |
7700 | int restart_af_count = 0; | |
7701 | json_object *json_restart = NULL; | |
7702 | json_restart = json_object_new_object(); | |
7703 | ||
7704 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7705 | ||
7706 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7707 | { | |
7708 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7709 | { | |
7710 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7711 | { | |
7712 | json_object *json_sub = NULL; | |
7713 | json_sub = json_object_new_object(); | |
7714 | ||
7715 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7716 | json_object_boolean_true_add(json_sub, "preserved"); | |
7717 | restart_af_count++; | |
7718 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7719 | } | |
7720 | } | |
7721 | } | |
7722 | if (! restart_af_count) | |
b6df4090 | 7723 | { |
856ca177 | 7724 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7725 | json_object_free(json_restart); |
7726 | } | |
856ca177 MS |
7727 | else |
7728 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7729 | } | |
7730 | } | |
7731 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7732 | } | |
7733 | else | |
7734 | { | |
7735 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7736 | ||
7737 | /* AS4 */ | |
7738 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7739 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7740 | { | |
7741 | vty_out (vty, " 4 Byte AS:"); | |
7742 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7743 | vty_out (vty, " advertised"); | |
7744 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7745 | vty_out (vty, " %sreceived", | |
7746 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7747 | vty_out (vty, "%s", VTY_NEWLINE); | |
7748 | } | |
7749 | ||
7750 | /* AddPath */ | |
7751 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7752 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7753 | { | |
7754 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7755 | |
856ca177 MS |
7756 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7757 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7758 | { |
856ca177 MS |
7759 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7760 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7761 | { | |
7762 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7763 | |
856ca177 MS |
7764 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7765 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7766 | |
856ca177 MS |
7767 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7768 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7769 | |
856ca177 MS |
7770 | vty_out (vty, "%s", VTY_NEWLINE); |
7771 | } | |
a82478b9 | 7772 | |
856ca177 | 7773 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7774 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7775 | { |
7776 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7777 | |
856ca177 MS |
7778 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7779 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7780 | |
856ca177 MS |
7781 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7782 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7783 | |
856ca177 MS |
7784 | vty_out (vty, "%s", VTY_NEWLINE); |
7785 | } | |
a82478b9 | 7786 | } |
856ca177 | 7787 | } |
a82478b9 | 7788 | |
856ca177 MS |
7789 | /* Dynamic */ |
7790 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7791 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7792 | { | |
7793 | vty_out (vty, " Dynamic:"); | |
7794 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7795 | vty_out (vty, " advertised"); | |
7796 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7797 | vty_out (vty, " %sreceived", | |
7798 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
7799 | vty_out (vty, "%s", VTY_NEWLINE); | |
7800 | } | |
7801 | ||
7802 | /* Extended nexthop */ | |
7803 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7804 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7805 | { | |
7806 | vty_out (vty, " Extended nexthop:"); | |
7807 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7808 | vty_out (vty, " advertised"); | |
7809 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7810 | vty_out (vty, " %sreceived", | |
7811 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
7812 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7813 | |
856ca177 MS |
7814 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
7815 | { | |
7816 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7817 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7818 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7819 | vty_out (vty, " %s%s", | |
7820 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
7821 | } | |
7822 | } | |
8a92a8a0 | 7823 | |
856ca177 MS |
7824 | /* Route Refresh */ |
7825 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7826 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7827 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7828 | { | |
7829 | vty_out (vty, " Route refresh:"); | |
7830 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7831 | vty_out (vty, " advertised"); | |
7832 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7833 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7834 | vty_out (vty, " %sreceived(%s)", | |
7835 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
7836 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
7837 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
7838 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 7839 | |
856ca177 MS |
7840 | vty_out (vty, "%s", VTY_NEWLINE); |
7841 | } | |
718e3744 | 7842 | |
856ca177 MS |
7843 | /* Multiprotocol Extensions */ |
7844 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7845 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7846 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7847 | { | |
8c3deaae | 7848 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
7849 | if (p->afc_adv[afi][safi]) |
7850 | vty_out (vty, " advertised"); | |
7851 | if (p->afc_recv[afi][safi]) | |
7852 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
7853 | vty_out (vty, "%s", VTY_NEWLINE); | |
7854 | } | |
538621f2 | 7855 | |
04b6bdc0 DW |
7856 | /* Hostname capability */ |
7857 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
7858 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7859 | { | |
7860 | vty_out (vty, " Hostname Capability:"); | |
7861 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
7862 | vty_out (vty, " advertised"); | |
7863 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7864 | vty_out (vty, " %sreceived", | |
7865 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
7866 | vty_out (vty, "%s", VTY_NEWLINE); | |
7867 | } | |
7868 | ||
856ca177 MS |
7869 | /* Gracefull Restart */ |
7870 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7871 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7872 | { | |
7873 | vty_out (vty, " Graceful Restart Capabilty:"); | |
7874 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 7875 | vty_out (vty, " advertised"); |
856ca177 MS |
7876 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7877 | vty_out (vty, " %sreceived", | |
7878 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
7879 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 7880 | |
856ca177 MS |
7881 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7882 | { | |
7883 | int restart_af_count = 0; | |
7884 | ||
7885 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
7886 | p->v_gr_restart, VTY_NEWLINE); | |
7887 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7888 | ||
7889 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7890 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7891 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7892 | { | |
7893 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
7894 | afi_safi_print (afi, safi), | |
7895 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
7896 | "preserved" : "not preserved"); | |
7897 | restart_af_count++; | |
7898 | } | |
7899 | if (! restart_af_count) | |
7900 | vty_out (vty, "none"); | |
7901 | vty_out (vty, "%s", VTY_NEWLINE); | |
7902 | } | |
7903 | } | |
7904 | } | |
718e3744 | 7905 | } |
7906 | } | |
7907 | ||
93406d87 | 7908 | /* graceful restart information */ |
7909 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7910 | || p->t_gr_restart | |
7911 | || p->t_gr_stale) | |
7912 | { | |
856ca177 MS |
7913 | json_object *json_grace = NULL; |
7914 | json_object *json_grace_send = NULL; | |
7915 | json_object *json_grace_recv = NULL; | |
93406d87 | 7916 | int eor_send_af_count = 0; |
7917 | int eor_receive_af_count = 0; | |
7918 | ||
856ca177 MS |
7919 | if (use_json) |
7920 | { | |
7921 | json_grace = json_object_new_object(); | |
7922 | json_grace_send = json_object_new_object(); | |
7923 | json_grace_recv = json_object_new_object(); | |
7924 | ||
7925 | if (p->status == Established) | |
7926 | { | |
7927 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7928 | { | |
7929 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7930 | { | |
7931 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7932 | { | |
7933 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
7934 | eor_send_af_count++; | |
7935 | } | |
7936 | } | |
7937 | } | |
7938 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7939 | { | |
7940 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7941 | { | |
7942 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7943 | { | |
7944 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
7945 | eor_receive_af_count++; | |
7946 | } | |
7947 | } | |
7948 | } | |
7949 | } | |
7950 | ||
7951 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
7952 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
7953 | ||
7954 | if (p->t_gr_restart) | |
7955 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
7956 | ||
7957 | if (p->t_gr_stale) | |
7958 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
7959 | ||
7960 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
7961 | } | |
7962 | else | |
7963 | { | |
7964 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
7965 | if (p->status == Established) | |
7966 | { | |
7967 | vty_out (vty, " End-of-RIB send: "); | |
7968 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7969 | { | |
7970 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7971 | { | |
7972 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7973 | { | |
7974 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
7975 | afi_safi_print (afi, safi)); | |
7976 | eor_send_af_count++; | |
7977 | } | |
7978 | } | |
7979 | } | |
7980 | vty_out (vty, "%s", VTY_NEWLINE); | |
7981 | vty_out (vty, " End-of-RIB received: "); | |
7982 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7983 | { | |
7984 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7985 | { | |
7986 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7987 | { | |
7988 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
7989 | afi_safi_print (afi, safi)); | |
7990 | eor_receive_af_count++; | |
7991 | } | |
7992 | } | |
7993 | } | |
7994 | vty_out (vty, "%s", VTY_NEWLINE); | |
7995 | } | |
93406d87 | 7996 | |
856ca177 MS |
7997 | if (p->t_gr_restart) |
7998 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
7999 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 8000 | |
856ca177 MS |
8001 | if (p->t_gr_stale) |
8002 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
8003 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
8004 | } | |
8005 | } | |
8006 | if (use_json) | |
8007 | { | |
8008 | json_object *json_stat = NULL; | |
8009 | json_stat = json_object_new_object(); | |
8010 | /* Packet counts. */ | |
8011 | json_object_int_add(json_stat, "depthInq", 0); | |
8012 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
8013 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
8014 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
8015 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
8016 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
8017 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
8018 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
8019 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
8020 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
8021 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
8022 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
8023 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
8024 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
8025 | 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); | |
8026 | 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); | |
8027 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
8028 | } | |
8029 | else | |
8030 | { | |
8031 | /* Packet counts. */ | |
8032 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
8033 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
8034 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
8035 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
8036 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
8037 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
8038 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
8039 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
8040 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
8041 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
8042 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
8043 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
8044 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
8045 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 8046 | } |
8047 | ||
856ca177 MS |
8048 | if (use_json) |
8049 | { | |
8050 | /* advertisement-interval */ | |
8051 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 8052 | |
856ca177 MS |
8053 | /* Update-source. */ |
8054 | if (p->update_if || p->update_source) | |
8055 | { | |
8056 | if (p->update_if) | |
8057 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
8058 | else if (p->update_source) | |
8059 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8060 | } | |
856ca177 MS |
8061 | } |
8062 | else | |
8063 | { | |
8064 | /* advertisement-interval */ | |
8065 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
8066 | p->v_routeadv, VTY_NEWLINE); | |
8067 | ||
8068 | /* Update-source. */ | |
8069 | if (p->update_if || p->update_source) | |
8070 | { | |
8071 | vty_out (vty, " Update source is "); | |
8072 | if (p->update_if) | |
8073 | vty_out (vty, "%s", p->update_if); | |
8074 | else if (p->update_source) | |
8075 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8076 | vty_out (vty, "%s", VTY_NEWLINE); | |
8077 | } | |
8078 | ||
856ca177 MS |
8079 | vty_out (vty, "%s", VTY_NEWLINE); |
8080 | } | |
718e3744 | 8081 | |
8082 | /* Address Family Information */ | |
856ca177 MS |
8083 | json_object *json_hold = NULL; |
8084 | ||
8085 | if (use_json) | |
8086 | json_hold = json_object_new_object(); | |
8087 | ||
538621f2 | 8088 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8089 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8090 | if (p->afc[afi][safi]) | |
856ca177 | 8091 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8092 | |
856ca177 MS |
8093 | if (use_json) |
8094 | { | |
58433ae6 | 8095 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8096 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8097 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8098 | } |
8099 | else | |
8100 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8101 | VTY_NEWLINE); | |
718e3744 | 8102 | |
d6661008 | 8103 | if (! p->last_reset) |
856ca177 MS |
8104 | { |
8105 | if (use_json) | |
e08ac8b7 | 8106 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8107 | else |
8108 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8109 | } | |
e0701b79 | 8110 | else |
d6661008 | 8111 | { |
856ca177 MS |
8112 | if (use_json) |
8113 | { | |
8114 | time_t uptime; | |
8115 | struct tm *tm; | |
8116 | ||
8117 | uptime = bgp_clock(); | |
8118 | uptime -= p->resettime; | |
8119 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8120 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8121 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
856ca177 MS |
8122 | if (p->last_reset_cause_size) |
8123 | { | |
39e871e6 ST |
8124 | char errorcodesubcode_hexstr[5]; |
8125 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); | |
e08ac8b7 | 8126 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
856ca177 MS |
8127 | } |
8128 | } | |
8129 | else | |
d6661008 | 8130 | { |
3a8c7ba1 DW |
8131 | vty_out (vty, " Last reset %s, ", |
8132 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8133 | ||
8134 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8135 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8136 | { | |
8137 | code_str = bgp_notify_code_str(p->notify.code); | |
8138 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8139 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8140 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8141 | code_str, subcode_str, VTY_NEWLINE); | |
8142 | } | |
8143 | else | |
8144 | { | |
8145 | vty_out (vty, "due to %s%s", | |
8146 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8147 | } | |
856ca177 MS |
8148 | |
8149 | if (p->last_reset_cause_size) | |
d6661008 | 8150 | { |
856ca177 MS |
8151 | msg = p->last_reset_cause; |
8152 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8153 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8154 | { | |
8155 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8156 | |
856ca177 MS |
8157 | if (i != p->last_reset_cause_size) |
8158 | { | |
8159 | if (i % 16 == 0) | |
8160 | { | |
8161 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8162 | } | |
8163 | else if (i % 4 == 0) | |
8164 | { | |
8165 | vty_out(vty, " "); | |
8166 | } | |
8167 | } | |
8168 | } | |
8169 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8170 | } |
d6661008 DS |
8171 | } |
8172 | } | |
848973c7 | 8173 | |
718e3744 | 8174 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8175 | { | |
856ca177 | 8176 | if (use_json) |
e08ac8b7 | 8177 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8178 | else |
8179 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8180 | |
8181 | if (p->t_pmax_restart) | |
856ca177 MS |
8182 | { |
8183 | if (use_json) | |
8184 | { | |
e08ac8b7 DW |
8185 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8186 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8187 | } |
8188 | else | |
8189 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8190 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8191 | VTY_NEWLINE); | |
8192 | } | |
0a486e5f | 8193 | else |
856ca177 MS |
8194 | { |
8195 | if (use_json) | |
e08ac8b7 | 8196 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8197 | else |
8198 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8199 | p->host, VTY_NEWLINE); | |
8200 | } | |
718e3744 | 8201 | } |
8202 | ||
f5a4827d | 8203 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8204 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8205 | { |
856ca177 MS |
8206 | if (use_json) |
8207 | { | |
8208 | if (p->gtsm_hops > 0) | |
8209 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8210 | else if (p->ttl > 1) | |
8211 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8212 | } | |
8213 | else | |
8214 | { | |
8215 | if (p->gtsm_hops > 0) | |
8216 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8217 | p->gtsm_hops, VTY_NEWLINE); | |
8218 | else if (p->ttl > 1) | |
8219 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8220 | p->ttl, VTY_NEWLINE); | |
8221 | } | |
f5a4827d | 8222 | } |
5d804b43 PM |
8223 | else |
8224 | { | |
8225 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8226 | { |
8227 | if (use_json) | |
8228 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8229 | else | |
8230 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8231 | p->gtsm_hops, VTY_NEWLINE); | |
8232 | } | |
5d804b43 | 8233 | } |
718e3744 | 8234 | |
8235 | /* Local address. */ | |
8236 | if (p->su_local) | |
8237 | { | |
856ca177 MS |
8238 | if (use_json) |
8239 | { | |
8240 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8241 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8242 | } | |
8243 | else | |
8244 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8245 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8246 | ntohs (p->su_local->sin.sin_port), | |
8247 | VTY_NEWLINE); | |
718e3744 | 8248 | } |
e52702f2 | 8249 | |
718e3744 | 8250 | /* Remote address. */ |
8251 | if (p->su_remote) | |
8252 | { | |
856ca177 MS |
8253 | if (use_json) |
8254 | { | |
8255 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8256 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8257 | } | |
8258 | else | |
8259 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8260 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8261 | ntohs (p->su_remote->sin.sin_port), | |
8262 | VTY_NEWLINE); | |
8263 | } | |
8264 | ||
8265 | /* Nexthop display. */ | |
8266 | if (p->su_local) | |
8267 | { | |
856ca177 MS |
8268 | if (use_json) |
8269 | { | |
8270 | json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); | |
718e3744 | 8271 | #ifdef HAVE_IPV6 |
856ca177 MS |
8272 | json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); |
8273 | json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); | |
8274 | if (p->shared_network) | |
8275 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8276 | else | |
8277 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
8278 | #endif /* HAVE_IPV6 */ | |
8279 | } | |
8280 | else | |
8281 | { | |
8282 | vty_out (vty, "Nexthop: %s%s", | |
8283 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), | |
8284 | VTY_NEWLINE); | |
8285 | #ifdef HAVE_IPV6 | |
8286 | vty_out (vty, "Nexthop global: %s%s", | |
8287 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), | |
8288 | VTY_NEWLINE); | |
8289 | vty_out (vty, "Nexthop local: %s%s", | |
8290 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ), | |
8291 | VTY_NEWLINE); | |
8292 | vty_out (vty, "BGP connection: %s%s", | |
8293 | p->shared_network ? "shared network" : "non shared network", | |
8294 | VTY_NEWLINE); | |
718e3744 | 8295 | #endif /* HAVE_IPV6 */ |
856ca177 | 8296 | } |
718e3744 | 8297 | } |
8298 | ||
8299 | /* Timer information. */ | |
856ca177 MS |
8300 | if (use_json) |
8301 | { | |
39e871e6 | 8302 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8303 | if (p->status == Established && p->rtt) |
8304 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8305 | if (p->t_start) |
8306 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8307 | if (p->t_connect) | |
8308 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8309 | if (p->t_routeadv) | |
8310 | { | |
8311 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8312 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8313 | } | |
cb1faec9 | 8314 | |
856ca177 MS |
8315 | if (p->t_read) |
8316 | json_object_string_add(json_neigh, "readThread", "on"); | |
8317 | else | |
8318 | json_object_string_add(json_neigh, "readThread", "off"); | |
8319 | if (p->t_write) | |
8320 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8321 | else | |
8322 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8323 | } | |
8324 | else | |
8325 | { | |
39e871e6 ST |
8326 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8327 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8328 | if (p->status == Established && p->rtt) |
8329 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8330 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8331 | if (p->t_start) |
8332 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8333 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8334 | if (p->t_connect) | |
8335 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8336 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8337 | if (p->t_routeadv) | |
8338 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8339 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8340 | VTY_NEWLINE); | |
8341 | ||
8342 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8343 | p->t_read ? "on" : "off", | |
8344 | p->t_write ? "on" : "off", | |
8345 | VTY_NEWLINE); | |
8346 | } | |
718e3744 | 8347 | |
8348 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8349 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8350 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8351 | ||
8352 | if (!use_json) | |
8353 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8354 | |
8355 | /* BFD information. */ | |
856ca177 MS |
8356 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8357 | ||
8358 | if (use_json) | |
8359 | { | |
8360 | if (p->conf_if) /* Configured interface name. */ | |
8361 | json_object_object_add(json, p->conf_if, json_neigh); | |
8362 | else /* Configured IP address. */ | |
8363 | json_object_object_add(json, p->host, json_neigh); | |
8364 | } | |
718e3744 | 8365 | } |
8366 | ||
94f2b392 | 8367 | static int |
856ca177 MS |
8368 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8369 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8370 | { |
1eb8ef25 | 8371 | struct listnode *node, *nnode; |
718e3744 | 8372 | struct peer *peer; |
8373 | int find = 0; | |
8374 | ||
1eb8ef25 | 8375 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8376 | { |
1ff9a340 DS |
8377 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8378 | continue; | |
8379 | ||
718e3744 | 8380 | switch (type) |
856ca177 MS |
8381 | { |
8382 | case show_all: | |
e8f7da3a | 8383 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8384 | break; |
8385 | case show_peer: | |
8386 | if (conf_if) | |
8387 | { | |
4873b3b9 DW |
8388 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8389 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8390 | { |
8391 | find = 1; | |
e8f7da3a | 8392 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8393 | } |
8394 | } | |
8395 | else | |
8396 | { | |
8397 | if (sockunion_same (&peer->su, su)) | |
8398 | { | |
8399 | find = 1; | |
e8f7da3a | 8400 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8401 | } |
8402 | } | |
8403 | break; | |
718e3744 | 8404 | } |
8405 | } | |
8406 | ||
8407 | if (type == show_peer && ! find) | |
856ca177 MS |
8408 | { |
8409 | if (use_json) | |
8410 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8411 | else | |
8412 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8413 | } | |
8414 | ||
8415 | if (use_json) | |
8416 | { | |
2aac5767 | 8417 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8418 | json_object_free(json); |
8419 | } | |
8420 | else | |
8421 | { | |
8422 | vty_out (vty, "%s", VTY_NEWLINE); | |
8423 | } | |
8424 | ||
718e3744 | 8425 | return CMD_SUCCESS; |
8426 | } | |
8427 | ||
f186de26 | 8428 | static void |
8429 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8430 | { | |
8431 | struct listnode *node, *nnode; | |
8432 | struct bgp *bgp; | |
8433 | json_object *json = NULL; | |
9f689658 DD |
8434 | int is_first = 1; |
8435 | ||
8436 | if (use_json) | |
8437 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8438 | |
8439 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8440 | { | |
f186de26 | 8441 | if (use_json) |
9f689658 DD |
8442 | { |
8443 | if (!(json = json_object_new_object())) | |
8444 | { | |
8445 | zlog_err("Unable to allocate memory for JSON object"); | |
8446 | vty_out (vty, | |
8447 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8448 | VTY_NEWLINE); | |
8449 | return; | |
8450 | } | |
8451 | ||
8452 | json_object_int_add(json, "vrfId", | |
8453 | (bgp->vrf_id == VRF_UNKNOWN) | |
8454 | ? -1 : bgp->vrf_id); | |
8455 | json_object_string_add(json, "vrfName", | |
8456 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8457 | ? "Default" : bgp->name); | |
8458 | ||
8459 | if (! is_first) | |
8460 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8461 | else | |
8462 | is_first = 0; | |
8463 | ||
8464 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8465 | ? "Default" : bgp->name); | |
8466 | } | |
8467 | else | |
8468 | { | |
8469 | vty_out (vty, "%sInstance %s:%s", | |
8470 | VTY_NEWLINE, | |
8471 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8472 | ? "Default" : bgp->name, | |
8473 | VTY_NEWLINE); | |
8474 | } | |
f186de26 | 8475 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8476 | } | |
9f689658 DD |
8477 | |
8478 | if (use_json) | |
8479 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8480 | } |
8481 | ||
4fb25c53 DW |
8482 | static int |
8483 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8484 | enum show_type type, const char *ip_str, u_char use_json) | |
8485 | { | |
8486 | int ret; | |
8487 | struct bgp *bgp; | |
8488 | union sockunion su; | |
8489 | json_object *json = NULL; | |
8490 | ||
8491 | if (use_json) | |
8492 | json = json_object_new_object(); | |
8493 | ||
8494 | if (name) | |
8495 | { | |
8496 | if (strmatch(name, "all")) | |
8497 | { | |
8498 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8499 | return CMD_SUCCESS; | |
8500 | } | |
8501 | else | |
8502 | { | |
8503 | bgp = bgp_lookup_by_name (name); | |
8504 | if (! bgp) | |
8505 | { | |
8506 | if (use_json) | |
8507 | { | |
8508 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8509 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8510 | json_object_free(json); |
8511 | } | |
8512 | else | |
8513 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8514 | ||
8515 | return CMD_WARNING; | |
8516 | } | |
8517 | } | |
8518 | } | |
8519 | else | |
8520 | { | |
8521 | bgp = bgp_get_default (); | |
8522 | } | |
8523 | ||
8524 | if (bgp) | |
8525 | { | |
8526 | if (ip_str) | |
8527 | { | |
8528 | ret = str2sockunion (ip_str, &su); | |
8529 | if (ret < 0) | |
8530 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8531 | else | |
8532 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8533 | } | |
8534 | else | |
8535 | { | |
8536 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8537 | } | |
8538 | } | |
8539 | ||
8540 | return CMD_SUCCESS; | |
8541 | } | |
8542 | ||
718e3744 | 8543 | /* "show ip bgp neighbors" commands. */ |
8544 | DEFUN (show_ip_bgp_neighbors, | |
8545 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8546 | "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 | 8547 | SHOW_STR |
8548 | IP_STR | |
8549 | BGP_STR | |
5bf15956 | 8550 | BGP_INSTANCE_ALL_HELP_STR |
8c3deaae QY |
8551 | "Address Family\n" |
8552 | "Address Family\n" | |
91d37724 QY |
8553 | "Address Family\n" |
8554 | "Display information about all VPNv4 NLRIs\n" | |
8555 | "Display information for a route distinguisher\n" | |
8556 | "VPN Route Distinguisher\n" | |
718e3744 | 8557 | "Detailed information on TCP and BGP neighbor connections\n" |
8558 | "Neighbor to display information about\n" | |
a80beece | 8559 | "Neighbor to display information about\n" |
91d37724 | 8560 | "Neighbor on BGP configured interface\n" |
9973d184 | 8561 | JSON_STR) |
718e3744 | 8562 | { |
5bf15956 DW |
8563 | char *vrf = NULL; |
8564 | char *sh_arg = NULL; | |
8565 | enum show_type sh_type; | |
718e3744 | 8566 | |
5bf15956 | 8567 | u_char uj = use_json(argc, argv); |
718e3744 | 8568 | |
630a298c | 8569 | int idx = 0; |
718e3744 | 8570 | |
630a298c QY |
8571 | if (argv_find (argv, argc, "WORD", &idx)) |
8572 | vrf = argv[idx]->arg; | |
718e3744 | 8573 | |
91d37724 QY |
8574 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8575 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8576 | argv_find (argv, argc, "WORD", &idx)) |
8577 | { | |
8578 | sh_type = show_peer; | |
8579 | sh_arg = argv[idx]->arg; | |
8580 | } | |
5bf15956 | 8581 | else |
630a298c | 8582 | sh_type = show_all; |
856ca177 | 8583 | |
5bf15956 | 8584 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8585 | } |
8586 | ||
718e3744 | 8587 | /* Show BGP's AS paths internal data. There are both `show ip bgp |
8588 | paths' and `show ip mbgp paths'. Those functions results are the | |
8589 | same.*/ | |
f412b39a | 8590 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8591 | show_ip_bgp_paths_cmd, |
7fa12b13 | 8592 | "show [ip] bgp [<unicast|multicast>] paths", |
718e3744 | 8593 | SHOW_STR |
8594 | IP_STR | |
8595 | BGP_STR | |
3a2d747c QY |
8596 | "Address Family modifier\n" |
8597 | "Address Family modifier\n" | |
718e3744 | 8598 | "Path information\n") |
8599 | { | |
8600 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8601 | aspath_print_all_vty (vty); | |
8602 | return CMD_SUCCESS; | |
8603 | } | |
8604 | ||
718e3744 | 8605 | #include "hash.h" |
8606 | ||
94f2b392 | 8607 | static void |
718e3744 | 8608 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8609 | { | |
8610 | struct community *com; | |
8611 | ||
8612 | com = (struct community *) backet->data; | |
6c4f4e6e | 8613 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8614 | community_str (com), VTY_NEWLINE); |
8615 | } | |
8616 | ||
8617 | /* Show BGP's community internal data. */ | |
f412b39a | 8618 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8619 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8620 | "show [ip] bgp community-info", |
718e3744 | 8621 | SHOW_STR |
8622 | IP_STR | |
8623 | BGP_STR | |
8624 | "List all bgp community information\n") | |
8625 | { | |
8626 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8627 | ||
e52702f2 | 8628 | hash_iterate (community_hash (), |
718e3744 | 8629 | (void (*) (struct hash_backet *, void *)) |
8630 | community_show_all_iterator, | |
8631 | vty); | |
8632 | ||
8633 | return CMD_SUCCESS; | |
8634 | } | |
8635 | ||
f412b39a | 8636 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8637 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8638 | "show [ip] bgp attribute-info", |
718e3744 | 8639 | SHOW_STR |
8640 | IP_STR | |
8641 | BGP_STR | |
8642 | "List all bgp attribute information\n") | |
8643 | { | |
8644 | attr_show_all (vty); | |
8645 | return CMD_SUCCESS; | |
8646 | } | |
6b0655a2 | 8647 | |
f186de26 | 8648 | static void |
8649 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8650 | { | |
8651 | struct listnode *node, *nnode; | |
8652 | struct bgp *bgp; | |
8653 | ||
8654 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8655 | { | |
8656 | vty_out (vty, "%sInstance %s:%s", | |
8657 | VTY_NEWLINE, | |
8658 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8659 | VTY_NEWLINE); | |
8660 | update_group_show(bgp, afi, safi, vty, 0); | |
8661 | } | |
8662 | } | |
8663 | ||
4fb25c53 DW |
8664 | static int |
8665 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8666 | int afi, int safi, | |
8667 | uint64_t subgrp_id) | |
8668 | { | |
8669 | struct bgp *bgp; | |
8670 | ||
8671 | if (name) | |
8672 | { | |
8673 | if (strmatch (name, "all")) | |
8674 | { | |
8675 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8676 | return CMD_SUCCESS; | |
8677 | } | |
8678 | else | |
8679 | { | |
8680 | bgp = bgp_lookup_by_name (name); | |
8681 | } | |
8682 | } | |
8683 | else | |
8684 | { | |
8685 | bgp = bgp_get_default (); | |
8686 | } | |
8687 | ||
8688 | if (bgp) | |
8689 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8690 | return CMD_SUCCESS; | |
8691 | } | |
8692 | ||
8fe8a7f6 DS |
8693 | DEFUN (show_ip_bgp_updgrps, |
8694 | show_ip_bgp_updgrps_cmd, | |
ae19d7dd | 8695 | "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] update-groups [SUBGROUP-ID]", |
8386ac43 | 8696 | SHOW_STR |
8697 | IP_STR | |
8698 | BGP_STR | |
8699 | BGP_INSTANCE_HELP_STR | |
8c3deaae | 8700 | "Address Family\n" |
5bf15956 | 8701 | "Address Family modifier\n" |
5bf15956 | 8702 | "Address Family modifier\n" |
8c3deaae | 8703 | "Address Family\n" |
5bf15956 | 8704 | "Address Family modifier\n" |
0c7b1b01 | 8705 | "Address Family modifier\n" |
8c3deaae | 8706 | "Address Family\n" |
5bf15956 | 8707 | "Address Family modifier\n" |
8c3deaae | 8708 | "Address Family\n" |
5bf15956 DW |
8709 | "Address Family modifier\n" |
8710 | "Detailed info about dynamic update groups\n" | |
8711 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8712 | { |
5bf15956 | 8713 | char *vrf = NULL; |
ae19d7dd QY |
8714 | afi_t afi = AFI_IP6; |
8715 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8716 | uint64_t subgrp_id = 0; |
8717 | ||
ae19d7dd QY |
8718 | int idx = 0; |
8719 | ||
8720 | /* show [ip] bgp */ | |
8721 | if (argv_find (argv, argc, "ip", &idx)) | |
8722 | afi = AFI_IP; | |
8723 | /* [<view|vrf> WORD] */ | |
8724 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8725 | vrf = argv[++idx]->arg; | |
8726 | /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */ | |
8727 | if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) | |
8728 | { | |
8729 | afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; | |
8730 | if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) | |
8731 | safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST; | |
8732 | } | |
8733 | else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) | |
8734 | { | |
8735 | afi = AFI_IP; | |
8736 | safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN; | |
8737 | // advance idx if necessary | |
8738 | argv_find (argv, argc, "unicast", &idx); | |
8739 | } | |
5bf15956 | 8740 | |
ae19d7dd QY |
8741 | /* get subgroup id, if provided */ |
8742 | idx = argc - 1; | |
8743 | if (argv[idx]->type == VARIABLE_TKN) | |
8744 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
8745 | |
8746 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
8747 | } |
8748 | ||
f186de26 | 8749 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
8750 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
9ccf14f7 | 8751 | "show bgp <view|vrf> all update-groups", |
f186de26 | 8752 | SHOW_STR |
8753 | BGP_STR | |
8754 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 8755 | "Detailed info about dynamic update groups\n") |
f186de26 | 8756 | { |
8757 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
8758 | return CMD_SUCCESS; | |
8759 | } | |
8760 | ||
5bf15956 DW |
8761 | DEFUN (show_bgp_updgrps_stats, |
8762 | show_bgp_updgrps_stats_cmd, | |
8763 | "show bgp update-groups statistics", | |
3f9c7369 DS |
8764 | SHOW_STR |
8765 | BGP_STR | |
0c7b1b01 | 8766 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8767 | "Statistics\n") |
8768 | { | |
8769 | struct bgp *bgp; | |
8770 | ||
8771 | bgp = bgp_get_default(); | |
8772 | if (bgp) | |
8773 | update_group_show_stats(bgp, vty); | |
8774 | ||
8775 | return CMD_SUCCESS; | |
8776 | } | |
8777 | ||
8386ac43 | 8778 | DEFUN (show_bgp_instance_updgrps_stats, |
8779 | show_bgp_instance_updgrps_stats_cmd, | |
9ccf14f7 | 8780 | "show bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 8781 | SHOW_STR |
8782 | BGP_STR | |
8783 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8784 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8785 | "Statistics\n") |
8786 | { | |
c500ae40 | 8787 | int idx_word = 3; |
8386ac43 | 8788 | struct bgp *bgp; |
8789 | ||
c500ae40 | 8790 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 8791 | if (bgp) |
8792 | update_group_show_stats(bgp, vty); | |
8793 | ||
8794 | return CMD_SUCCESS; | |
8795 | } | |
8796 | ||
3f9c7369 | 8797 | static void |
8386ac43 | 8798 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
8799 | afi_t afi, safi_t safi, | |
f43e655e | 8800 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
8801 | { |
8802 | struct bgp *bgp; | |
8386ac43 | 8803 | |
8804 | if (name) | |
8805 | bgp = bgp_lookup_by_name (name); | |
8806 | else | |
8807 | bgp = bgp_get_default (); | |
8808 | ||
3f9c7369 DS |
8809 | if (bgp) |
8810 | { | |
8811 | if (!strcmp(what, "advertise-queue")) | |
8812 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
8813 | else if (!strcmp(what, "advertised-routes")) | |
8814 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
8815 | else if (!strcmp(what, "packet-queue")) | |
8816 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
8817 | } | |
8818 | } | |
8819 | ||
8820 | DEFUN (show_ip_bgp_updgrps_adj, | |
8821 | show_ip_bgp_updgrps_adj_cmd, | |
6147e2c6 | 8822 | "show ip bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8823 | SHOW_STR |
8824 | IP_STR | |
8825 | BGP_STR | |
0c7b1b01 | 8826 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8827 | "Advertisement queue\n" |
8828 | "Announced routes\n" | |
8829 | "Packet queue\n") | |
8fe8a7f6 | 8830 | |
3f9c7369 | 8831 | { |
c500ae40 DW |
8832 | int idx_type = 4; |
8833 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8834 | return CMD_SUCCESS; |
8835 | } | |
8836 | ||
8837 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
8838 | show_ip_bgp_instance_updgrps_adj_cmd, | |
9ccf14f7 | 8839 | "show ip bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8840 | SHOW_STR |
8841 | IP_STR | |
8842 | BGP_STR | |
8843 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8844 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8845 | "Advertisement queue\n" |
8846 | "Announced routes\n" | |
8847 | "Packet queue\n") | |
8848 | ||
8849 | { | |
c500ae40 DW |
8850 | int idx_word = 4; |
8851 | int idx_type = 6; | |
8852 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8853 | return CMD_SUCCESS; |
8854 | } | |
8855 | ||
8856 | DEFUN (show_bgp_updgrps_afi_adj, | |
8857 | show_bgp_updgrps_afi_adj_cmd, | |
6147e2c6 | 8858 | "show bgp <ipv4|ipv6> <unicast|multicast> update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8859 | SHOW_STR |
8860 | BGP_STR | |
8c3deaae QY |
8861 | "Address Family\n" |
8862 | "Address Family\n" | |
3f9c7369 DS |
8863 | "Address Family modifier\n" |
8864 | "Address Family modifier\n" | |
0c7b1b01 | 8865 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8866 | "Advertisement queue\n" |
8867 | "Announced routes\n" | |
8fe8a7f6 DS |
8868 | "Packet queue\n" |
8869 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8870 | { |
c500ae40 DW |
8871 | int idx_afi = 2; |
8872 | int idx_safi = 3; | |
8873 | int idx_type = 5; | |
3f9c7369 DS |
8874 | afi_t afi; |
8875 | safi_t safi; | |
8876 | ||
c500ae40 DW |
8877 | afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; |
8878 | safi = (strncmp (argv[idx_safi]->arg, "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; | |
8879 | show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0); | |
8fe8a7f6 | 8880 | return CMD_SUCCESS; |
3f9c7369 DS |
8881 | } |
8882 | ||
8883 | DEFUN (show_bgp_updgrps_adj, | |
8884 | show_bgp_updgrps_adj_cmd, | |
6147e2c6 | 8885 | "show bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8886 | SHOW_STR |
8887 | BGP_STR | |
0c7b1b01 | 8888 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8889 | "Advertisement queue\n" |
8890 | "Announced routes\n" | |
8891 | "Packet queue\n") | |
8892 | { | |
c500ae40 DW |
8893 | int idx_type = 3; |
8894 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8895 | return CMD_SUCCESS; |
8896 | } | |
8897 | ||
8898 | DEFUN (show_bgp_instance_updgrps_adj, | |
8899 | show_bgp_instance_updgrps_adj_cmd, | |
9ccf14f7 | 8900 | "show bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8901 | SHOW_STR |
8902 | BGP_STR | |
8903 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8904 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8905 | "Advertisement queue\n" |
8906 | "Announced routes\n" | |
8907 | "Packet queue\n") | |
8908 | { | |
c500ae40 DW |
8909 | int idx_word = 3; |
8910 | int idx_type = 5; | |
8911 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8912 | return CMD_SUCCESS; |
8913 | } | |
8914 | ||
8915 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 8916 | show_ip_bgp_updgrps_adj_s_cmd, |
6147e2c6 | 8917 | "show ip bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8918 | SHOW_STR |
8919 | IP_STR | |
8920 | BGP_STR | |
0c7b1b01 | 8921 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8922 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8923 | "Advertisement queue\n" |
8924 | "Announced routes\n" | |
8925 | "Packet queue\n") | |
3f9c7369 | 8926 | |
3f9c7369 | 8927 | { |
5bf15956 | 8928 | int idx_subgroup_id = 4; |
c500ae40 | 8929 | int idx_type = 5; |
f43e655e | 8930 | uint64_t subgrp_id; |
8fe8a7f6 | 8931 | |
5bf15956 | 8932 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8933 | |
5bf15956 | 8934 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 8935 | return CMD_SUCCESS; |
8936 | } | |
8937 | ||
8938 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
8939 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
9ccf14f7 | 8940 | "show ip bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8941 | SHOW_STR |
8942 | IP_STR | |
8943 | BGP_STR | |
8944 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8945 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8946 | "Specific subgroup to display info for\n" |
8947 | "Advertisement queue\n" | |
8948 | "Announced routes\n" | |
8949 | "Packet queue\n") | |
8950 | ||
8951 | { | |
5bf15956 DW |
8952 | int idx_vrf = 4; |
8953 | int idx_subgroup_id = 6; | |
c500ae40 | 8954 | int idx_type = 7; |
f43e655e | 8955 | uint64_t subgrp_id; |
8386ac43 | 8956 | |
5bf15956 | 8957 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 8958 | |
5bf15956 | 8959 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
8960 | return CMD_SUCCESS; |
8961 | } | |
8962 | ||
8fe8a7f6 DS |
8963 | DEFUN (show_bgp_updgrps_afi_adj_s, |
8964 | show_bgp_updgrps_afi_adj_s_cmd, | |
6147e2c6 | 8965 | "show bgp <ipv4|ipv6> <unicast|multicast> update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8966 | SHOW_STR |
8967 | BGP_STR | |
8c3deaae QY |
8968 | "Address Family\n" |
8969 | "Address Family\n" | |
3f9c7369 DS |
8970 | "Address Family modifier\n" |
8971 | "Address Family modifier\n" | |
0c7b1b01 | 8972 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8973 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8974 | "Advertisement queue\n" |
8975 | "Announced routes\n" | |
8fe8a7f6 DS |
8976 | "Packet queue\n" |
8977 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8978 | { |
c500ae40 DW |
8979 | int idx_afi = 2; |
8980 | int idx_safi = 3; | |
5bf15956 | 8981 | int idx_subgroup_id = 5; |
c500ae40 | 8982 | int idx_type = 6; |
3f9c7369 DS |
8983 | afi_t afi; |
8984 | safi_t safi; | |
f43e655e | 8985 | uint64_t subgrp_id; |
3f9c7369 | 8986 | |
5bf15956 DW |
8987 | afi = (strmatch(argv[idx_afi]->text, "ipv4")) ? AFI_IP : AFI_IP6; |
8988 | safi = (strmatch(argv[idx_safi]->text, "unicast")) ? SAFI_UNICAST : SAFI_MULTICAST; | |
8989 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); | |
8fe8a7f6 | 8990 | |
5bf15956 | 8991 | show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 | 8992 | return CMD_SUCCESS; |
3f9c7369 DS |
8993 | } |
8994 | ||
8fe8a7f6 DS |
8995 | DEFUN (show_bgp_updgrps_adj_s, |
8996 | show_bgp_updgrps_adj_s_cmd, | |
6147e2c6 | 8997 | "show bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 DS |
8998 | SHOW_STR |
8999 | BGP_STR | |
0c7b1b01 | 9000 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
9001 | "Specific subgroup to display info for\n" |
9002 | "Advertisement queue\n" | |
9003 | "Announced routes\n" | |
9004 | "Packet queue\n") | |
9005 | { | |
5bf15956 | 9006 | int idx_subgroup_id = 3; |
c500ae40 | 9007 | int idx_type = 4; |
f43e655e | 9008 | uint64_t subgrp_id; |
8fe8a7f6 | 9009 | |
5bf15956 | 9010 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 9011 | |
5bf15956 | 9012 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
9013 | return CMD_SUCCESS; |
9014 | } | |
9015 | ||
8386ac43 | 9016 | DEFUN (show_bgp_instance_updgrps_adj_s, |
9017 | show_bgp_instance_updgrps_adj_s_cmd, | |
9ccf14f7 | 9018 | "show bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 9019 | SHOW_STR |
9020 | BGP_STR | |
9021 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9022 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9023 | "Specific subgroup to display info for\n" |
9024 | "Advertisement queue\n" | |
9025 | "Announced routes\n" | |
9026 | "Packet queue\n") | |
9027 | { | |
5bf15956 DW |
9028 | int idx_vrf = 3; |
9029 | int idx_subgroup_id = 5; | |
c500ae40 | 9030 | int idx_type = 6; |
f43e655e | 9031 | uint64_t subgrp_id; |
8386ac43 | 9032 | |
5bf15956 | 9033 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 9034 | |
5bf15956 | 9035 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 9036 | return CMD_SUCCESS; |
9037 | } | |
9038 | ||
9039 | ||
8fe8a7f6 | 9040 | |
f14e6fdb DS |
9041 | static int |
9042 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
9043 | { | |
9044 | struct listnode *node, *nnode; | |
9045 | struct prefix *range; | |
9046 | struct peer *conf; | |
9047 | struct peer *peer; | |
4690c7d7 | 9048 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
9049 | afi_t afi; |
9050 | safi_t safi; | |
ffd0c037 DS |
9051 | const char *peer_status; |
9052 | const char *af_str; | |
f14e6fdb DS |
9053 | int lr_count; |
9054 | int dynamic; | |
9055 | int af_cfgd; | |
9056 | ||
9057 | conf = group->conf; | |
9058 | ||
0299c004 DS |
9059 | if (conf->as_type == AS_SPECIFIED || |
9060 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 9061 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 9062 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 9063 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 9064 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 9065 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
9066 | } else { |
9067 | vty_out (vty, "%sBGP peer-group %s%s", | |
9068 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 9069 | } |
f14e6fdb | 9070 | |
0299c004 | 9071 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9072 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9073 | else | |
9074 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9075 | ||
9076 | /* Display AFs configured. */ | |
9077 | vty_out (vty, " Configured address-families:"); | |
9078 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9079 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9080 | { | |
9081 | if (conf->afc[afi][safi]) | |
9082 | { | |
9083 | af_cfgd = 1; | |
9084 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9085 | } | |
9086 | } | |
9087 | if (!af_cfgd) | |
9088 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9089 | else | |
9090 | vty_out (vty, "%s", VTY_NEWLINE); | |
9091 | ||
9092 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9093 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9094 | { | |
9095 | if (afi == AFI_IP) | |
9096 | af_str = "IPv4"; | |
9097 | else if (afi == AFI_IP6) | |
9098 | af_str = "IPv6"; | |
9099 | lr_count = listcount(group->listen_range[afi]); | |
9100 | if (lr_count) | |
9101 | { | |
9102 | vty_out(vty, | |
9103 | " %d %s listen range(s)%s", | |
9104 | lr_count, af_str, VTY_NEWLINE); | |
9105 | ||
9106 | ||
9107 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9108 | nnode, range)) | |
9109 | { | |
9110 | prefix2str(range, buf, sizeof(buf)); | |
9111 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9112 | } | |
9113 | } | |
9114 | } | |
9115 | ||
9116 | /* Display group members and their status */ | |
9117 | if (listcount(group->peer)) | |
9118 | { | |
9119 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9120 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9121 | { | |
9122 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9123 | peer_status = "Idle (Admin)"; | |
9124 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9125 | peer_status = "Idle (PfxCt)"; | |
9126 | else | |
9127 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9128 | ||
9129 | dynamic = peer_dynamic_neighbor(peer); | |
9130 | vty_out (vty, " %s %s %s %s", | |
9131 | peer->host, dynamic ? "(dynamic)" : "", | |
9132 | peer_status, VTY_NEWLINE); | |
9133 | } | |
9134 | } | |
9135 | ||
9136 | return CMD_SUCCESS; | |
9137 | } | |
9138 | ||
9139 | /* Show BGP peer group's information. */ | |
9140 | enum show_group_type | |
9141 | { | |
9142 | show_all_groups, | |
9143 | show_peer_group | |
9144 | }; | |
9145 | ||
9146 | static int | |
9147 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9148 | enum show_group_type type, const char *group_name) | |
9149 | { | |
9150 | struct listnode *node, *nnode; | |
9151 | struct peer_group *group; | |
9152 | int find = 0; | |
9153 | ||
9154 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9155 | { | |
9156 | switch (type) | |
9157 | { | |
9158 | case show_all_groups: | |
9159 | bgp_show_one_peer_group (vty, group); | |
9160 | break; | |
9161 | case show_peer_group: | |
9162 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9163 | { | |
9164 | find = 1; | |
9165 | bgp_show_one_peer_group (vty, group); | |
9166 | } | |
9167 | break; | |
9168 | } | |
9169 | } | |
9170 | ||
9171 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9172 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9173 | |
9174 | return CMD_SUCCESS; | |
9175 | } | |
9176 | ||
9177 | static int | |
9178 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9179 | enum show_group_type type, const char *group_name) | |
9180 | { | |
9181 | struct bgp *bgp; | |
9182 | int ret = CMD_SUCCESS; | |
9183 | ||
9184 | if (name) | |
8386ac43 | 9185 | bgp = bgp_lookup_by_name (name); |
9186 | else | |
9187 | bgp = bgp_get_default (); | |
f14e6fdb | 9188 | |
8386ac43 | 9189 | if (! bgp) |
9190 | { | |
9191 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9192 | return CMD_WARNING; | |
f14e6fdb DS |
9193 | } |
9194 | ||
8386ac43 | 9195 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9196 | |
9197 | return ret; | |
9198 | } | |
9199 | ||
9200 | DEFUN (show_ip_bgp_peer_groups, | |
9201 | show_ip_bgp_peer_groups_cmd, | |
d6e3c605 | 9202 | "show [ip] bgp [<view|vrf> VRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
9203 | SHOW_STR |
9204 | IP_STR | |
9205 | BGP_STR | |
8386ac43 | 9206 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9207 | "Detailed information on BGP peer groups\n" |
9208 | "Peer group name\n") | |
f14e6fdb | 9209 | { |
d6e3c605 QY |
9210 | char *vrf, *pg; |
9211 | vrf = pg = NULL; | |
9212 | int idx = 0; | |
f14e6fdb | 9213 | |
d6e3c605 QY |
9214 | vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; |
9215 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 9216 | |
d6e3c605 | 9217 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9218 | } |
3f9c7369 | 9219 | |
d6e3c605 | 9220 | |
718e3744 | 9221 | /* Redistribute VTY commands. */ |
9222 | ||
718e3744 | 9223 | DEFUN (bgp_redistribute_ipv4, |
9224 | bgp_redistribute_ipv4_cmd, | |
9ccf14f7 | 9225 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>", |
718e3744 | 9226 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9227 | QUAGGA_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9228 | { |
c500ae40 | 9229 | int idx_protocol = 1; |
718e3744 | 9230 | int type; |
9231 | ||
c500ae40 | 9232 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9233 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9234 | { |
9235 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9236 | return CMD_WARNING; | |
9237 | } | |
7c8ff89e | 9238 | bgp_redist_add(vty->index, AFI_IP, type, 0); |
6aeb9e78 | 9239 | return bgp_redistribute_set (vty->index, AFI_IP, type, 0); |
718e3744 | 9240 | } |
9241 | ||
9242 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9243 | bgp_redistribute_ipv4_rmap_cmd, | |
9ccf14f7 | 9244 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD", |
718e3744 | 9245 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9246 | QUAGGA_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9247 | "Route map reference\n" |
9248 | "Pointer to route-map entries\n") | |
9249 | { | |
c500ae40 DW |
9250 | int idx_protocol = 1; |
9251 | int idx_word = 3; | |
718e3744 | 9252 | int type; |
7c8ff89e | 9253 | struct bgp_redist *red; |
718e3744 | 9254 | |
c500ae40 | 9255 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9256 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9257 | { |
9258 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9259 | return CMD_WARNING; | |
9260 | } | |
9261 | ||
7c8ff89e | 9262 | red = bgp_redist_add(vty->index, AFI_IP, type, 0); |
c500ae40 | 9263 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9264 | return bgp_redistribute_set (vty->index, AFI_IP, type, 0); |
718e3744 | 9265 | } |
9266 | ||
9267 | DEFUN (bgp_redistribute_ipv4_metric, | |
9268 | bgp_redistribute_ipv4_metric_cmd, | |
9ccf14f7 | 9269 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)", |
718e3744 | 9270 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9271 | QUAGGA_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9272 | "Metric for redistributed routes\n" |
9273 | "Default metric\n") | |
9274 | { | |
c500ae40 DW |
9275 | int idx_protocol = 1; |
9276 | int idx_number = 3; | |
718e3744 | 9277 | int type; |
9278 | u_int32_t metric; | |
7c8ff89e | 9279 | struct bgp_redist *red; |
718e3744 | 9280 | |
c500ae40 | 9281 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9282 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9283 | { |
9284 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9285 | return CMD_WARNING; | |
9286 | } | |
c500ae40 | 9287 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9288 | |
7c8ff89e | 9289 | red = bgp_redist_add(vty->index, AFI_IP, type, 0); |
caf958b4 | 9290 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); |
6aeb9e78 | 9291 | return bgp_redistribute_set (vty->index, AFI_IP, type, 0); |
718e3744 | 9292 | } |
9293 | ||
9294 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9295 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
9ccf14f7 | 9296 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9297 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9298 | QUAGGA_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9299 | "Route map reference\n" |
9300 | "Pointer to route-map entries\n" | |
9301 | "Metric for redistributed routes\n" | |
9302 | "Default metric\n") | |
9303 | { | |
c500ae40 DW |
9304 | int idx_protocol = 1; |
9305 | int idx_word = 3; | |
9306 | int idx_number = 5; | |
718e3744 | 9307 | int type; |
9308 | u_int32_t metric; | |
7c8ff89e | 9309 | struct bgp_redist *red; |
718e3744 | 9310 | |
c500ae40 | 9311 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9312 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9313 | { |
9314 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9315 | return CMD_WARNING; | |
9316 | } | |
c500ae40 | 9317 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9318 | |
7c8ff89e | 9319 | red = bgp_redist_add(vty->index, AFI_IP, type, 0); |
c500ae40 | 9320 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
caf958b4 | 9321 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); |
6aeb9e78 | 9322 | return bgp_redistribute_set (vty->index, AFI_IP, type, 0); |
718e3744 | 9323 | } |
9324 | ||
9325 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9326 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
9ccf14f7 | 9327 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9328 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9329 | QUAGGA_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9330 | "Metric for redistributed routes\n" |
9331 | "Default metric\n" | |
9332 | "Route map reference\n" | |
9333 | "Pointer to route-map entries\n") | |
9334 | { | |
c500ae40 DW |
9335 | int idx_protocol = 1; |
9336 | int idx_number = 3; | |
9337 | int idx_word = 5; | |
718e3744 | 9338 | int type; |
9339 | u_int32_t metric; | |
7c8ff89e | 9340 | struct bgp_redist *red; |
718e3744 | 9341 | |
c500ae40 | 9342 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9343 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9344 | { |
9345 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9346 | return CMD_WARNING; | |
9347 | } | |
c500ae40 | 9348 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9349 | |
7c8ff89e | 9350 | red = bgp_redist_add(vty->index, AFI_IP, type, 0); |
caf958b4 | 9351 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric); |
c500ae40 | 9352 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9353 | return bgp_redistribute_set (vty->index, AFI_IP, type, 0); |
718e3744 | 9354 | } |
9355 | ||
7c8ff89e DS |
9356 | DEFUN (bgp_redistribute_ipv4_ospf, |
9357 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9358 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9359 | "Redistribute information from another routing protocol\n" |
9360 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9361 | "Non-main Kernel Routing Table\n" |
9362 | "Instance ID/Table ID\n") | |
7c8ff89e | 9363 | { |
c500ae40 DW |
9364 | int idx_ospf_table = 1; |
9365 | int idx_number = 2; | |
7c8ff89e | 9366 | u_short instance; |
7a4bb9c5 | 9367 | u_short protocol; |
7c8ff89e | 9368 | |
c500ae40 | 9369 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9370 | |
c500ae40 | 9371 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9372 | protocol = ZEBRA_ROUTE_OSPF; |
9373 | else | |
9374 | protocol = ZEBRA_ROUTE_TABLE; | |
9375 | ||
9376 | bgp_redist_add(vty->index, AFI_IP, protocol, instance); | |
6aeb9e78 | 9377 | return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9378 | } |
9379 | ||
9380 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9381 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9382 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9383 | "Redistribute information from another routing protocol\n" |
9384 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9385 | "Non-main Kernel Routing Table\n" |
9386 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9387 | "Route map reference\n" |
9388 | "Pointer to route-map entries\n") | |
9389 | { | |
c500ae40 DW |
9390 | int idx_ospf_table = 1; |
9391 | int idx_number = 2; | |
9392 | int idx_word = 4; | |
7c8ff89e DS |
9393 | struct bgp_redist *red; |
9394 | u_short instance; | |
7a4bb9c5 | 9395 | int protocol; |
7c8ff89e | 9396 | |
c500ae40 | 9397 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9398 | protocol = ZEBRA_ROUTE_OSPF; |
9399 | else | |
9400 | protocol = ZEBRA_ROUTE_TABLE; | |
9401 | ||
c500ae40 | 9402 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9403 | red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); |
c500ae40 | 9404 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9405 | return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9406 | } |
9407 | ||
9408 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9409 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9410 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9411 | "Redistribute information from another routing protocol\n" |
9412 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9413 | "Non-main Kernel Routing Table\n" |
9414 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9415 | "Metric for redistributed routes\n" |
9416 | "Default metric\n") | |
9417 | { | |
c500ae40 DW |
9418 | int idx_ospf_table = 1; |
9419 | int idx_number = 2; | |
9420 | int idx_number_2 = 4; | |
7c8ff89e DS |
9421 | u_int32_t metric; |
9422 | struct bgp_redist *red; | |
9423 | u_short instance; | |
7a4bb9c5 | 9424 | int protocol; |
7c8ff89e | 9425 | |
c500ae40 | 9426 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9427 | protocol = ZEBRA_ROUTE_OSPF; |
9428 | else | |
9429 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9430 | |
c500ae40 DW |
9431 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9432 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 DS |
9433 | |
9434 | red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); | |
caf958b4 | 9435 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); |
6aeb9e78 | 9436 | return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9437 | } |
9438 | ||
9439 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9440 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9441 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9442 | "Redistribute information from another routing protocol\n" |
9443 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9444 | "Non-main Kernel Routing Table\n" |
9445 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9446 | "Route map reference\n" |
9447 | "Pointer to route-map entries\n" | |
9448 | "Metric for redistributed routes\n" | |
9449 | "Default metric\n") | |
9450 | { | |
c500ae40 DW |
9451 | int idx_ospf_table = 1; |
9452 | int idx_number = 2; | |
9453 | int idx_word = 4; | |
9454 | int idx_number_2 = 6; | |
7c8ff89e DS |
9455 | u_int32_t metric; |
9456 | struct bgp_redist *red; | |
9457 | u_short instance; | |
7a4bb9c5 | 9458 | int protocol; |
7c8ff89e | 9459 | |
c500ae40 | 9460 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9461 | protocol = ZEBRA_ROUTE_OSPF; |
9462 | else | |
9463 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9464 | |
c500ae40 DW |
9465 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9466 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 DS |
9467 | |
9468 | red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); | |
c500ae40 | 9469 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
caf958b4 | 9470 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); |
6aeb9e78 | 9471 | return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9472 | } |
9473 | ||
9474 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9475 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9476 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9477 | "Redistribute information from another routing protocol\n" |
9478 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9479 | "Non-main Kernel Routing Table\n" |
9480 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9481 | "Metric for redistributed routes\n" |
9482 | "Default metric\n" | |
9483 | "Route map reference\n" | |
9484 | "Pointer to route-map entries\n") | |
9485 | { | |
c500ae40 DW |
9486 | int idx_ospf_table = 1; |
9487 | int idx_number = 2; | |
9488 | int idx_number_2 = 4; | |
9489 | int idx_word = 6; | |
7c8ff89e DS |
9490 | u_int32_t metric; |
9491 | struct bgp_redist *red; | |
9492 | u_short instance; | |
7a4bb9c5 | 9493 | int protocol; |
7c8ff89e | 9494 | |
c500ae40 | 9495 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9496 | protocol = ZEBRA_ROUTE_OSPF; |
9497 | else | |
9498 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9499 | |
c500ae40 DW |
9500 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9501 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 DS |
9502 | |
9503 | red = bgp_redist_add(vty->index, AFI_IP, protocol, instance); | |
caf958b4 | 9504 | bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric); |
c500ae40 | 9505 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9506 | return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9507 | } |
9508 | ||
9509 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9510 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9511 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9512 | NO_STR |
9513 | "Redistribute information from another routing protocol\n" | |
9514 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9515 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9516 | "Instance ID/Table ID\n" |
9517 | "Metric for redistributed routes\n" | |
9518 | "Default metric\n" | |
9519 | "Route map reference\n" | |
9520 | "Pointer to route-map entries\n") | |
7c8ff89e | 9521 | { |
c500ae40 DW |
9522 | int idx_ospf_table = 2; |
9523 | int idx_number = 3; | |
7c8ff89e | 9524 | u_short instance; |
7a4bb9c5 DS |
9525 | int protocol; |
9526 | ||
c500ae40 | 9527 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9528 | protocol = ZEBRA_ROUTE_OSPF; |
9529 | else | |
9530 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9531 | |
c500ae40 | 9532 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9533 | return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance); |
7c8ff89e DS |
9534 | } |
9535 | ||
718e3744 | 9536 | DEFUN (no_bgp_redistribute_ipv4, |
9537 | no_bgp_redistribute_ipv4_cmd, | |
d04c479d | 9538 | "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9539 | NO_STR |
9540 | "Redistribute information from another routing protocol\n" | |
31500417 DW |
9541 | QUAGGA_IP_REDIST_HELP_STR_BGPD |
9542 | "Metric for redistributed routes\n" | |
9543 | "Default metric\n" | |
9544 | "Route map reference\n" | |
9545 | "Pointer to route-map entries\n") | |
718e3744 | 9546 | { |
c500ae40 | 9547 | int idx_protocol = 2; |
718e3744 | 9548 | int type; |
9549 | ||
c500ae40 | 9550 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); |
e0ca5fde | 9551 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9552 | { |
9553 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9554 | return CMD_WARNING; | |
9555 | } | |
7c8ff89e | 9556 | return bgp_redistribute_unset (vty->index, AFI_IP, type, 0); |
718e3744 | 9557 | } |
9558 | ||
718e3744 | 9559 | #ifdef HAVE_IPV6 |
9560 | DEFUN (bgp_redistribute_ipv6, | |
9561 | bgp_redistribute_ipv6_cmd, | |
9ccf14f7 | 9562 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table>", |
718e3744 | 9563 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9564 | QUAGGA_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9565 | { |
c500ae40 | 9566 | int idx_protocol = 1; |
718e3744 | 9567 | int type; |
9568 | ||
c500ae40 | 9569 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9570 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9571 | { |
9572 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9573 | return CMD_WARNING; | |
9574 | } | |
9575 | ||
7c8ff89e | 9576 | bgp_redist_add(vty->index, AFI_IP6, type, 0); |
6aeb9e78 | 9577 | return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); |
718e3744 | 9578 | } |
9579 | ||
9580 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9581 | bgp_redistribute_ipv6_rmap_cmd, | |
9ccf14f7 | 9582 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD", |
718e3744 | 9583 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9584 | QUAGGA_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9585 | "Route map reference\n" |
9586 | "Pointer to route-map entries\n") | |
9587 | { | |
c500ae40 DW |
9588 | int idx_protocol = 1; |
9589 | int idx_word = 3; | |
718e3744 | 9590 | int type; |
7c8ff89e | 9591 | struct bgp_redist *red; |
718e3744 | 9592 | |
c500ae40 | 9593 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9594 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9595 | { |
9596 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9597 | return CMD_WARNING; | |
9598 | } | |
9599 | ||
7c8ff89e | 9600 | red = bgp_redist_add(vty->index, AFI_IP6, type, 0); |
c500ae40 | 9601 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9602 | return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); |
718e3744 | 9603 | } |
9604 | ||
9605 | DEFUN (bgp_redistribute_ipv6_metric, | |
9606 | bgp_redistribute_ipv6_metric_cmd, | |
9ccf14f7 | 9607 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)", |
718e3744 | 9608 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9609 | QUAGGA_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9610 | "Metric for redistributed routes\n" |
9611 | "Default metric\n") | |
9612 | { | |
c500ae40 DW |
9613 | int idx_protocol = 1; |
9614 | int idx_number = 3; | |
718e3744 | 9615 | int type; |
9616 | u_int32_t metric; | |
7c8ff89e | 9617 | struct bgp_redist *red; |
718e3744 | 9618 | |
c500ae40 | 9619 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9620 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9621 | { |
9622 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9623 | return CMD_WARNING; | |
9624 | } | |
c500ae40 | 9625 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9626 | |
7c8ff89e | 9627 | red = bgp_redist_add(vty->index, AFI_IP6, type, 0); |
caf958b4 | 9628 | bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); |
6aeb9e78 | 9629 | return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); |
718e3744 | 9630 | } |
9631 | ||
9632 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9633 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
9ccf14f7 | 9634 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9635 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9636 | QUAGGA_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9637 | "Route map reference\n" |
9638 | "Pointer to route-map entries\n" | |
9639 | "Metric for redistributed routes\n" | |
9640 | "Default metric\n") | |
9641 | { | |
c500ae40 DW |
9642 | int idx_protocol = 1; |
9643 | int idx_word = 3; | |
9644 | int idx_number = 5; | |
718e3744 | 9645 | int type; |
9646 | u_int32_t metric; | |
7c8ff89e | 9647 | struct bgp_redist *red; |
718e3744 | 9648 | |
c500ae40 | 9649 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9650 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9651 | { |
9652 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9653 | return CMD_WARNING; | |
9654 | } | |
c500ae40 | 9655 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9656 | |
7c8ff89e | 9657 | red = bgp_redist_add(vty->index, AFI_IP6, type, 0); |
c500ae40 | 9658 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
caf958b4 | 9659 | bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric); |
6aeb9e78 | 9660 | return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); |
718e3744 | 9661 | } |
9662 | ||
9663 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9664 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
9ccf14f7 | 9665 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9666 | "Redistribute information from another routing protocol\n" |
e0ca5fde | 9667 | QUAGGA_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9668 | "Metric for redistributed routes\n" |
9669 | "Default metric\n" | |
9670 | "Route map reference\n" | |
9671 | "Pointer to route-map entries\n") | |
9672 | { | |
c500ae40 DW |
9673 | int idx_protocol = 1; |
9674 | int idx_number = 3; | |
9675 | int idx_word = 5; | |
718e3744 | 9676 | int type; |
9677 | u_int32_t metric; | |
7c8ff89e | 9678 | struct bgp_redist *red; |
718e3744 | 9679 | |
c500ae40 | 9680 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9681 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9682 | { |
9683 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9684 | return CMD_WARNING; | |
9685 | } | |
c500ae40 | 9686 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9687 | |
7c8ff89e | 9688 | red = bgp_redist_add(vty->index, AFI_IP6, type, 0); |
caf958b4 | 9689 | bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric); |
c500ae40 | 9690 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
6aeb9e78 | 9691 | return bgp_redistribute_set (vty->index, AFI_IP6, type, 0); |
718e3744 | 9692 | } |
9693 | ||
9694 | DEFUN (no_bgp_redistribute_ipv6, | |
9695 | no_bgp_redistribute_ipv6_cmd, | |
d04c479d | 9696 | "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9697 | NO_STR |
9698 | "Redistribute information from another routing protocol\n" | |
31500417 DW |
9699 | QUAGGA_IP6_REDIST_HELP_STR_BGPD |
9700 | "Metric for redistributed routes\n" | |
9701 | "Default metric\n" | |
9702 | "Route map reference\n" | |
9703 | "Pointer to route-map entries\n") | |
718e3744 | 9704 | { |
c500ae40 | 9705 | int idx_protocol = 2; |
718e3744 | 9706 | int type; |
9707 | ||
c500ae40 | 9708 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); |
e0ca5fde | 9709 | if (type < 0 || type == ZEBRA_ROUTE_BGP) |
718e3744 | 9710 | { |
9711 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9712 | return CMD_WARNING; | |
9713 | } | |
9714 | ||
7c8ff89e | 9715 | return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0); |
718e3744 | 9716 | } |
9717 | ||
718e3744 | 9718 | |
718e3744 | 9719 | |
718e3744 | 9720 | |
718e3744 | 9721 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 9722 | |
718e3744 | 9723 | int |
9724 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
9725 | safi_t safi, int *write) | |
9726 | { | |
9727 | int i; | |
718e3744 | 9728 | |
9729 | /* Unicast redistribution only. */ | |
9730 | if (safi != SAFI_UNICAST) | |
9731 | return 0; | |
9732 | ||
9733 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
9734 | { | |
9735 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 9736 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 9737 | { |
7c8ff89e DS |
9738 | struct list *red_list; |
9739 | struct listnode *node; | |
9740 | struct bgp_redist *red; | |
718e3744 | 9741 | |
7c8ff89e DS |
9742 | red_list = bgp->redist[afi][i]; |
9743 | if (!red_list) | |
9744 | continue; | |
718e3744 | 9745 | |
7c8ff89e DS |
9746 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
9747 | { | |
9748 | /* Display "address-family" when it is not yet diplayed. */ | |
9749 | bgp_config_write_family_header (vty, afi, safi, write); | |
9750 | ||
9751 | /* "redistribute" configuration. */ | |
0b960b4d | 9752 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
9753 | if (red->instance) |
9754 | vty_out (vty, " %d", red->instance); | |
9755 | if (red->redist_metric_flag) | |
9756 | vty_out (vty, " metric %u", red->redist_metric); | |
9757 | if (red->rmap.name) | |
9758 | vty_out (vty, " route-map %s", red->rmap.name); | |
9759 | vty_out (vty, "%s", VTY_NEWLINE); | |
9760 | } | |
718e3744 | 9761 | } |
9762 | } | |
9763 | return *write; | |
9764 | } | |
6b0655a2 | 9765 | |
718e3744 | 9766 | /* BGP node structure. */ |
7fc626de | 9767 | static struct cmd_node bgp_node = |
718e3744 | 9768 | { |
9769 | BGP_NODE, | |
9770 | "%s(config-router)# ", | |
9771 | 1, | |
9772 | }; | |
9773 | ||
7fc626de | 9774 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 9775 | { |
9776 | BGP_IPV4_NODE, | |
9777 | "%s(config-router-af)# ", | |
9778 | 1, | |
9779 | }; | |
9780 | ||
7fc626de | 9781 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 9782 | { |
9783 | BGP_IPV4M_NODE, | |
9784 | "%s(config-router-af)# ", | |
9785 | 1, | |
9786 | }; | |
9787 | ||
7fc626de | 9788 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 9789 | { |
9790 | BGP_IPV6_NODE, | |
9791 | "%s(config-router-af)# ", | |
9792 | 1, | |
9793 | }; | |
9794 | ||
7fc626de | 9795 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 9796 | { |
9797 | BGP_IPV6M_NODE, | |
9798 | "%s(config-router-af)# ", | |
9799 | 1, | |
9800 | }; | |
9801 | ||
7fc626de | 9802 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 9803 | { |
9804 | BGP_VPNV4_NODE, | |
9805 | "%s(config-router-af)# ", | |
9806 | 1 | |
9807 | }; | |
6b0655a2 | 9808 | |
8ecd3266 | 9809 | static struct cmd_node bgp_vpnv6_node = |
9810 | { | |
9811 | BGP_VPNV6_NODE, | |
9812 | "%s(config-router-af-vpnv6)# ", | |
9813 | 1 | |
9814 | }; | |
9815 | ||
8b1fb8be LB |
9816 | static struct cmd_node bgp_encap_node = |
9817 | { | |
9818 | BGP_ENCAP_NODE, | |
9819 | "%s(config-router-af-encap)# ", | |
9820 | 1 | |
9821 | }; | |
9822 | ||
9823 | static struct cmd_node bgp_encapv6_node = | |
9824 | { | |
9825 | BGP_ENCAPV6_NODE, | |
9826 | "%s(config-router-af-encapv6)# ", | |
9827 | 1 | |
9828 | }; | |
9829 | ||
1f8ae70b | 9830 | static void community_list_vty (void); |
9831 | ||
718e3744 | 9832 | void |
94f2b392 | 9833 | bgp_vty_init (void) |
718e3744 | 9834 | { |
718e3744 | 9835 | /* Install bgp top node. */ |
9836 | install_node (&bgp_node, bgp_config_write); | |
9837 | install_node (&bgp_ipv4_unicast_node, NULL); | |
9838 | install_node (&bgp_ipv4_multicast_node, NULL); | |
9839 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 9840 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 9841 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 9842 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
9843 | install_node (&bgp_encap_node, NULL); |
9844 | install_node (&bgp_encapv6_node, NULL); | |
718e3744 | 9845 | |
9846 | /* Install default VTY commands to new nodes. */ | |
9847 | install_default (BGP_NODE); | |
9848 | install_default (BGP_IPV4_NODE); | |
9849 | install_default (BGP_IPV4M_NODE); | |
9850 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 9851 | install_default (BGP_IPV6M_NODE); |
718e3744 | 9852 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 9853 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
9854 | install_default (BGP_ENCAP_NODE); |
9855 | install_default (BGP_ENCAPV6_NODE); | |
e52702f2 | 9856 | |
718e3744 | 9857 | /* "bgp multiple-instance" commands. */ |
9858 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
9859 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
9860 | ||
9861 | /* "bgp config-type" commands. */ | |
9862 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 9863 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 9864 | |
5fe9f963 | 9865 | /* bgp route-map delay-timer commands. */ |
9866 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
9867 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 9868 | |
718e3744 | 9869 | /* Dummy commands (Currently not supported) */ |
9870 | install_element (BGP_NODE, &no_synchronization_cmd); | |
9871 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
9872 | ||
9873 | /* "router bgp" commands. */ | |
9874 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 9875 | |
9876 | /* "no router bgp" commands. */ | |
9877 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 9878 | |
9879 | /* "bgp router-id" commands. */ | |
9880 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
9881 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 9882 | |
9883 | /* "bgp cluster-id" commands. */ | |
9884 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 9885 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 9886 | |
9887 | /* "bgp confederation" commands. */ | |
9888 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
9889 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 9890 | |
9891 | /* "bgp confederation peers" commands. */ | |
9892 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
9893 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
9894 | ||
abc920f8 DS |
9895 | /* bgp max-med command */ |
9896 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
9897 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
9898 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
9899 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
9900 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 9901 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 9902 | |
907f92c8 DS |
9903 | /* bgp disable-ebgp-connected-nh-check */ |
9904 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
9905 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
9906 | ||
f188f2c4 DS |
9907 | /* bgp update-delay command */ |
9908 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
9909 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
9910 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 9911 | |
cb1faec9 DS |
9912 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
9913 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
9914 | ||
3f9c7369 DS |
9915 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
9916 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
9917 | ||
165b5fff JB |
9918 | /* "maximum-paths" commands. */ |
9919 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
9920 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
9921 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
9922 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
9923 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
9924 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 9925 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9926 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9927 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9928 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9929 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9930 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 9931 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9932 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 9933 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9934 | |
718e3744 | 9935 | /* "timers bgp" commands. */ |
9936 | install_element (BGP_NODE, &bgp_timers_cmd); | |
9937 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 9938 | |
5fe9f963 | 9939 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
9940 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
9941 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
9942 | ||
718e3744 | 9943 | /* "bgp client-to-client reflection" commands */ |
9944 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
9945 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
9946 | ||
9947 | /* "bgp always-compare-med" commands */ | |
9948 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
9949 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 9950 | |
718e3744 | 9951 | /* "bgp deterministic-med" commands */ |
9952 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
9953 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 9954 | |
538621f2 | 9955 | /* "bgp graceful-restart" commands */ |
9956 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
9957 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 9958 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
9959 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
9960 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
9961 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 9962 | |
718e3744 | 9963 | /* "bgp fast-external-failover" commands */ |
9964 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
9965 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
9966 | ||
9967 | /* "bgp enforce-first-as" commands */ | |
9968 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
9969 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
9970 | ||
9971 | /* "bgp bestpath compare-routerid" commands */ | |
9972 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
9973 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
9974 | ||
9975 | /* "bgp bestpath as-path ignore" commands */ | |
9976 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
9977 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
9978 | ||
6811845b | 9979 | /* "bgp bestpath as-path confed" commands */ |
9980 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
9981 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
9982 | ||
2fdd455c PM |
9983 | /* "bgp bestpath as-path multipath-relax" commands */ |
9984 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
9985 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
9986 | ||
848973c7 | 9987 | /* "bgp log-neighbor-changes" commands */ |
9988 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
9989 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
9990 | ||
718e3744 | 9991 | /* "bgp bestpath med" commands */ |
9992 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 9993 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 9994 | |
9995 | /* "no bgp default ipv4-unicast" commands. */ | |
9996 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
9997 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 9998 | |
718e3744 | 9999 | /* "bgp network import-check" commands. */ |
10000 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 10001 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 10002 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
10003 | ||
10004 | /* "bgp default local-preference" commands. */ | |
10005 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
10006 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 10007 | |
04b6bdc0 DW |
10008 | /* bgp default show-hostname */ |
10009 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
10010 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
10011 | ||
3f9c7369 DS |
10012 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
10013 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
10014 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
10015 | ||
8bd9d948 DS |
10016 | /* bgp ibgp-allow-policy-mods command */ |
10017 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
10018 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
10019 | ||
f14e6fdb DS |
10020 | /* "bgp listen limit" commands. */ |
10021 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
10022 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
10023 | ||
10024 | /* "bgp listen range" commands. */ | |
10025 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
10026 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
10027 | ||
718e3744 | 10028 | /* "neighbor remote-as" commands. */ |
10029 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 10030 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 10031 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
10032 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
10033 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 10034 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 10035 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 10036 | |
10037 | /* "neighbor peer-group" commands. */ | |
10038 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
10039 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 10040 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 10041 | |
10042 | /* "neighbor local-as" commands. */ | |
10043 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
10044 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 10045 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 10046 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 10047 | |
3f9c7369 DS |
10048 | /* "neighbor solo" commands. */ |
10049 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
10050 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10051 | ||
0df7c91f PJ |
10052 | /* "neighbor password" commands. */ |
10053 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10054 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10055 | ||
718e3744 | 10056 | /* "neighbor activate" commands. */ |
10057 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10058 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10059 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10060 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10061 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10062 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10063 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10064 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10065 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
718e3744 | 10066 | |
10067 | /* "no neighbor activate" commands. */ | |
10068 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10069 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10070 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10071 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10072 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10073 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10074 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10075 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10076 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
718e3744 | 10077 | |
c8560b44 DW |
10078 | /* "neighbor peer-group" set commands. |
10079 | * Long term we should only accept this command under BGP_NODE and not all of | |
10080 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10081 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10082 | * to their peer-group under each address-family sub-context. | |
10083 | */ | |
718e3744 | 10084 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10085 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10086 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10087 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10088 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10089 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10090 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10091 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10092 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10093 | |
718e3744 | 10094 | /* "no neighbor peer-group unset" commands. */ |
10095 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10096 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10097 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10098 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10099 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10100 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10101 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10102 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10103 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10104 | |
718e3744 | 10105 | /* "neighbor softreconfiguration inbound" commands.*/ |
10106 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10107 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10108 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10109 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10110 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10111 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10112 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10113 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10114 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10115 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10116 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10117 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10118 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10119 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10120 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10121 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10122 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10123 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10124 | |
10125 | /* "neighbor attribute-unchanged" commands. */ | |
10126 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10127 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10128 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10129 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10130 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10131 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10132 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10133 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10134 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10135 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10136 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10137 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10138 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10139 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10140 | |
8b1fb8be | 10141 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10142 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10143 | |
10144 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10145 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10146 | |
fee0f4c6 | 10147 | /* "nexthop-local unchanged" commands */ |
10148 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10149 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10150 | ||
718e3744 | 10151 | /* "neighbor next-hop-self" commands. */ |
10152 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10153 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10154 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10155 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10156 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10157 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10158 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10159 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10160 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10161 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10162 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10163 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10164 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10165 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10166 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10167 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10168 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10169 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10170 | |
a538debe DS |
10171 | /* "neighbor next-hop-self force" commands. */ |
10172 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10173 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10174 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10175 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10176 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10177 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10178 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10179 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10180 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10181 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10182 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10183 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10184 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10185 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10186 | |
c7122e14 DS |
10187 | /* "neighbor as-override" commands. */ |
10188 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10189 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10190 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10191 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10192 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10193 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10194 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10195 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10196 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10197 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10198 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10199 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10200 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10201 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10202 | |
718e3744 | 10203 | /* "neighbor remove-private-AS" commands. */ |
10204 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10205 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10206 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10207 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10208 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10209 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10210 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10211 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10212 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10213 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10214 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10215 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10216 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10217 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10218 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10219 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10220 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10221 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10222 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10223 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10224 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10225 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10226 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10227 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10228 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10229 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10230 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10231 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10232 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10233 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10234 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10235 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10236 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10237 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10238 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10239 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10240 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10241 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10242 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10243 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10244 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10245 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10246 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10247 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10248 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10249 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10250 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10251 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10252 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10253 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10254 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10255 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10256 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10257 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10258 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10259 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10260 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10261 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10262 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10263 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10264 | |
10265 | /* "neighbor send-community" commands.*/ | |
10266 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10267 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10268 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10269 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10270 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10271 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10272 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10273 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10274 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10275 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10276 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10277 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10278 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10279 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10280 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10281 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10282 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10283 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10284 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10285 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10286 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10287 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10288 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10289 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10290 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10291 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10292 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10293 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10294 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10295 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10296 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10297 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10298 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10299 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10300 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10301 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10302 | |
10303 | /* "neighbor route-reflector" commands.*/ | |
10304 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10305 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10306 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10307 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10308 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10309 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10310 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10311 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10312 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10313 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10314 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10315 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10316 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10317 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10318 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10319 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10320 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10321 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10322 | |
10323 | /* "neighbor route-server" commands.*/ | |
10324 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10325 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10326 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10327 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10328 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10329 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10330 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10331 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10332 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10333 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10334 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10335 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10336 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10337 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10338 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10339 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10340 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10341 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10342 | |
adbac85e DW |
10343 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10344 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10345 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10346 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10347 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10348 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10349 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10350 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10351 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10352 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10353 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10354 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10355 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10356 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10357 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10358 | |
06370dac DW |
10359 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10360 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10361 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10362 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10363 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10364 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10365 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10366 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10367 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10368 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10369 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10370 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10371 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10372 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10373 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10374 | |
718e3744 | 10375 | /* "neighbor passive" commands. */ |
10376 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10377 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10378 | ||
d5a5c8f0 | 10379 | |
718e3744 | 10380 | /* "neighbor shutdown" commands. */ |
10381 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10382 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
10383 | ||
8a92a8a0 DS |
10384 | /* "neighbor capability extended-nexthop" commands.*/ |
10385 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10386 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10387 | ||
718e3744 | 10388 | /* "neighbor capability orf prefix-list" commands.*/ |
10389 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10390 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10391 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10392 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10393 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10394 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10395 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10396 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10397 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10398 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10399 | |
10400 | /* "neighbor capability dynamic" commands.*/ | |
10401 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10402 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10403 | ||
10404 | /* "neighbor dont-capability-negotiate" commands. */ | |
10405 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10406 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10407 | ||
10408 | /* "neighbor ebgp-multihop" commands. */ | |
10409 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10410 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10411 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10412 | |
6ffd2079 | 10413 | /* "neighbor disable-connected-check" commands. */ |
10414 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10415 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10416 | |
10417 | /* "neighbor description" commands. */ | |
10418 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10419 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10420 | |
10421 | /* "neighbor update-source" commands. "*/ | |
10422 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10423 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10424 | ||
10425 | /* "neighbor default-originate" commands. */ | |
10426 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10427 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10428 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10429 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10430 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10431 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10432 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10433 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10434 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10435 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10436 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10437 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10438 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10439 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10440 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10441 | |
10442 | /* "neighbor port" commands. */ | |
10443 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10444 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10445 | |
10446 | /* "neighbor weight" commands. */ | |
10447 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10448 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10449 | |
d93f7ffc DW |
10450 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10451 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10452 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10453 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10454 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10455 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10456 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10457 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10458 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10459 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10460 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10461 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10462 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10463 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10464 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10465 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10466 | |
10467 | /* "neighbor override-capability" commands. */ | |
10468 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10469 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10470 | ||
10471 | /* "neighbor strict-capability-match" commands. */ | |
10472 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10473 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10474 | ||
10475 | /* "neighbor timers" commands. */ | |
10476 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10477 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10478 | ||
10479 | /* "neighbor timers connect" commands. */ | |
10480 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10481 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10482 | |
10483 | /* "neighbor advertisement-interval" commands. */ | |
10484 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10485 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10486 | |
718e3744 | 10487 | /* "neighbor interface" commands. */ |
10488 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10489 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10490 | ||
10491 | /* "neighbor distribute" commands. */ | |
10492 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10493 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10494 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10495 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10496 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10497 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10498 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10499 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10500 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10501 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10502 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10503 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10504 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10505 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10506 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10507 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10508 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10509 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10510 | |
10511 | /* "neighbor prefix-list" commands. */ | |
10512 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10513 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10514 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10515 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10516 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10517 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10518 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10519 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10520 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10521 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10522 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10523 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10524 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10525 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10526 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10527 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10528 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10529 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10530 | |
10531 | /* "neighbor filter-list" commands. */ | |
10532 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10533 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10534 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10535 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10536 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10537 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10538 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10539 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10540 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10541 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10542 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10543 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10544 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10545 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10546 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10547 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10548 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10549 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10550 | |
10551 | /* "neighbor route-map" commands. */ | |
10552 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10553 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10554 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10555 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10556 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10557 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10558 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10559 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10560 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10561 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10562 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10563 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10564 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10565 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10566 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10567 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10568 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10569 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10570 | |
10571 | /* "neighbor unsuppress-map" commands. */ | |
10572 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10573 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10574 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10575 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10576 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10577 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10578 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10579 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10580 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10581 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10582 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10583 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10584 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10585 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10586 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10587 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10588 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10589 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10590 | |
10591 | /* "neighbor maximum-prefix" commands. */ | |
10592 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10593 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10594 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10595 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10596 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10597 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10598 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10599 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10600 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10601 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10602 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10603 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10604 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10605 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10606 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10607 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10608 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10609 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10610 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10611 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10612 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10613 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10614 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10615 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10616 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10617 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10618 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10619 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10620 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10621 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10622 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10623 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10624 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10625 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10626 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10627 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10628 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10629 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10630 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10631 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10632 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10633 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10634 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10635 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10636 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10637 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10638 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10639 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10640 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10641 | |
8b1fb8be LB |
10642 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10643 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10644 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10645 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10646 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10647 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10648 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10649 | |
10650 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10651 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10652 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10653 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10654 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10655 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10656 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10657 | |
718e3744 | 10658 | /* "neighbor allowas-in" */ |
10659 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10660 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10661 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10662 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10663 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10664 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10665 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10666 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10667 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10668 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10669 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10670 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10671 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10672 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10673 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10674 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10675 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10676 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10677 | |
10678 | /* address-family commands. */ | |
10679 | install_element (BGP_NODE, &address_family_ipv4_cmd); | |
10680 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); | |
10681 | #ifdef HAVE_IPV6 | |
10682 | install_element (BGP_NODE, &address_family_ipv6_cmd); | |
25ffbdc1 | 10683 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
718e3744 | 10684 | #endif /* HAVE_IPV6 */ |
10685 | install_element (BGP_NODE, &address_family_vpnv4_cmd); | |
718e3744 | 10686 | |
8b1fb8be | 10687 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
8b1fb8be LB |
10688 | |
10689 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be LB |
10690 | #ifdef HAVE_IPV6 |
10691 | install_element (BGP_NODE, &address_family_encapv6_cmd); | |
10692 | #endif | |
10693 | ||
718e3744 | 10694 | /* "exit-address-family" command. */ |
10695 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10696 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10697 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10698 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10699 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10700 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10701 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10702 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
718e3744 | 10703 | |
10704 | /* "clear ip bgp commands" */ | |
10705 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 10706 | |
8ad7271d DS |
10707 | /* clear ip bgp prefix */ |
10708 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
10709 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 10710 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 10711 | |
718e3744 | 10712 | /* "show ip bgp summary" commands. */ |
10713 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
3f9c7369 | 10714 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
f186de26 | 10715 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
3f9c7369 | 10716 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); |
8386ac43 | 10717 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
3f9c7369 | 10718 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
8386ac43 | 10719 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
3f9c7369 | 10720 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
8fe8a7f6 | 10721 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); |
8386ac43 | 10722 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
8fe8a7f6 | 10723 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
8386ac43 | 10724 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
8fe8a7f6 | 10725 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
e52702f2 QY |
10726 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
10727 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
10728 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
10729 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
10730 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
10731 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
10732 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
10733 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
10734 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
10735 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
10736 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
10737 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
8c3deaae QY |
10738 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
10739 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
e3e29b32 | 10740 | |
718e3744 | 10741 | /* "show ip bgp neighbors" commands. */ |
10742 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
718e3744 | 10743 | |
f14e6fdb DS |
10744 | /* "show ip bgp peer-group" commands. */ |
10745 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
f14e6fdb | 10746 | |
718e3744 | 10747 | /* "show ip bgp paths" commands. */ |
10748 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); | |
718e3744 | 10749 | |
10750 | /* "show ip bgp community" commands. */ | |
10751 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
718e3744 | 10752 | |
10753 | /* "show ip bgp attribute-info" commands. */ | |
10754 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
718e3744 | 10755 | |
10756 | /* "redistribute" commands. */ | |
10757 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
10758 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10759 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 10760 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 10761 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10762 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
10763 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10764 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10765 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 10766 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 10767 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 10768 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
10769 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
10770 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10771 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 10772 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
10773 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10774 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
10775 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10776 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10777 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 10778 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 10779 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 10780 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 10781 | #ifdef HAVE_IPV6 |
10782 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
10783 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
10784 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 10785 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 10786 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
10787 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 10788 | #endif /* HAVE_IPV6 */ |
10789 | ||
fa411a21 NH |
10790 | /* ttl_security commands */ |
10791 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
10792 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
10793 | ||
4bf6a362 PJ |
10794 | /* "show bgp memory" commands. */ |
10795 | install_element (VIEW_NODE, &show_bgp_memory_cmd); | |
e52702f2 | 10796 | |
e0081f70 ML |
10797 | /* "show bgp views" commands. */ |
10798 | install_element (VIEW_NODE, &show_bgp_views_cmd); | |
e52702f2 | 10799 | |
8386ac43 | 10800 | /* "show bgp vrfs" commands. */ |
10801 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); | |
e52702f2 | 10802 | |
718e3744 | 10803 | /* Community-list. */ |
10804 | community_list_vty (); | |
10805 | } | |
6b0655a2 | 10806 | |
718e3744 | 10807 | #include "memory.h" |
10808 | #include "bgp_regex.h" | |
10809 | #include "bgp_clist.h" | |
10810 | #include "bgp_ecommunity.h" | |
10811 | ||
10812 | /* VTY functions. */ | |
10813 | ||
10814 | /* Direction value to string conversion. */ | |
94f2b392 | 10815 | static const char * |
718e3744 | 10816 | community_direct_str (int direct) |
10817 | { | |
10818 | switch (direct) | |
10819 | { | |
10820 | case COMMUNITY_DENY: | |
10821 | return "deny"; | |
718e3744 | 10822 | case COMMUNITY_PERMIT: |
10823 | return "permit"; | |
718e3744 | 10824 | default: |
10825 | return "unknown"; | |
718e3744 | 10826 | } |
10827 | } | |
10828 | ||
10829 | /* Display error string. */ | |
94f2b392 | 10830 | static void |
718e3744 | 10831 | community_list_perror (struct vty *vty, int ret) |
10832 | { | |
10833 | switch (ret) | |
10834 | { | |
10835 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 10836 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 10837 | break; |
10838 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
10839 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
10840 | break; | |
10841 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
10842 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
10843 | break; | |
10844 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
10845 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
10846 | break; | |
10847 | } | |
10848 | } | |
10849 | ||
5bf15956 DW |
10850 | /* "community-list" keyword help string. */ |
10851 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
10852 | ||
718e3744 | 10853 | |
5bf15956 | 10854 | /* ip community-list standard */ |
718e3744 | 10855 | DEFUN (ip_community_list_standard, |
10856 | ip_community_list_standard_cmd, | |
e961923c | 10857 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10858 | IP_STR |
10859 | COMMUNITY_LIST_STR | |
10860 | "Community list number (standard)\n" | |
5bf15956 | 10861 | "Add an standard community-list entry\n" |
718e3744 | 10862 | "Community list name\n" |
10863 | "Specify community to reject\n" | |
10864 | "Specify community to accept\n" | |
10865 | COMMUNITY_VAL_STR) | |
10866 | { | |
42f914d4 QY |
10867 | char *cl_name_or_number = NULL; |
10868 | int direct = 0; | |
10869 | int style = COMMUNITY_LIST_STANDARD; | |
10870 | ||
10871 | int idx = 0; | |
10872 | argv_find (argv, argc, "(1-99)", &idx); | |
10873 | argv_find (argv, argc, "WORD", &idx); | |
10874 | cl_name_or_number = argv[idx]->arg; | |
10875 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10876 | argv_find (argv, argc, "AA:NN", &idx); | |
10877 | char *str = argv_concat (argv, argc, idx); | |
10878 | ||
10879 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10880 | ||
10881 | XFREE (MTYPE_TMP, str); | |
10882 | ||
10883 | if (ret < 0) | |
10884 | { | |
10885 | /* Display error string. */ | |
10886 | community_list_perror (vty, ret); | |
10887 | return CMD_WARNING; | |
10888 | } | |
10889 | ||
10890 | return CMD_SUCCESS; | |
718e3744 | 10891 | } |
10892 | ||
fee6e4e4 | 10893 | DEFUN (no_ip_community_list_standard_all, |
10894 | no_ip_community_list_standard_all_cmd, | |
e961923c | 10895 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10896 | NO_STR |
10897 | IP_STR | |
10898 | COMMUNITY_LIST_STR | |
10899 | "Community list number (standard)\n" | |
5bf15956 DW |
10900 | "Add an standard community-list entry\n" |
10901 | "Community list name\n" | |
718e3744 | 10902 | "Specify community to reject\n" |
10903 | "Specify community to accept\n" | |
10904 | COMMUNITY_VAL_STR) | |
10905 | { | |
42f914d4 QY |
10906 | int delete_all = 0; |
10907 | ||
10908 | char *cl_name_or_number = NULL; | |
10909 | int direct = 0; | |
10910 | int style = COMMUNITY_LIST_STANDARD; | |
10911 | ||
10912 | int idx = 0; | |
10913 | argv_find (argv, argc, "(1-99)", &idx); | |
10914 | argv_find (argv, argc, "WORD", &idx); | |
10915 | cl_name_or_number = argv[idx]->arg; | |
10916 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10917 | argv_find (argv, argc, "AA:NN", &idx); | |
10918 | char *str = argv_concat (argv, argc, idx); | |
10919 | ||
10920 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10921 | ||
10922 | if (ret < 0) | |
10923 | { | |
10924 | community_list_perror (vty, ret); | |
10925 | return CMD_WARNING; | |
10926 | } | |
10927 | ||
10928 | return CMD_SUCCESS; | |
718e3744 | 10929 | } |
10930 | ||
5bf15956 DW |
10931 | /* ip community-list expanded */ |
10932 | DEFUN (ip_community_list_expanded_all, | |
10933 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 10934 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10935 | IP_STR |
10936 | COMMUNITY_LIST_STR | |
10937 | "Community list number (expanded)\n" | |
5bf15956 | 10938 | "Add an expanded community-list entry\n" |
718e3744 | 10939 | "Community list name\n" |
10940 | "Specify community to reject\n" | |
10941 | "Specify community to accept\n" | |
10942 | COMMUNITY_VAL_STR) | |
10943 | { | |
42f914d4 QY |
10944 | char *cl_name_or_number = NULL; |
10945 | int direct = 0; | |
10946 | int style = COMMUNITY_LIST_EXPANDED; | |
10947 | ||
10948 | int idx = 0; | |
10949 | argv_find (argv, argc, "(100-500)", &idx); | |
10950 | argv_find (argv, argc, "WORD", &idx); | |
10951 | cl_name_or_number = argv[idx]->arg; | |
10952 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10953 | argv_find (argv, argc, "AA:NN", &idx); | |
10954 | char *str = argv_concat (argv, argc, idx); | |
10955 | ||
10956 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10957 | ||
10958 | XFREE (MTYPE_TMP, str); | |
10959 | ||
10960 | if (ret < 0) | |
10961 | { | |
10962 | /* Display error string. */ | |
10963 | community_list_perror (vty, ret); | |
10964 | return CMD_WARNING; | |
10965 | } | |
10966 | ||
10967 | return CMD_SUCCESS; | |
718e3744 | 10968 | } |
10969 | ||
5bf15956 DW |
10970 | DEFUN (no_ip_community_list_expanded_all, |
10971 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 10972 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10973 | NO_STR |
10974 | IP_STR | |
10975 | COMMUNITY_LIST_STR | |
5bf15956 DW |
10976 | "Community list number (expanded)\n" |
10977 | "Add an expanded community-list entry\n" | |
718e3744 | 10978 | "Community list name\n" |
10979 | "Specify community to reject\n" | |
10980 | "Specify community to accept\n" | |
5bf15956 | 10981 | COMMUNITY_VAL_STR) |
718e3744 | 10982 | { |
42f914d4 QY |
10983 | int delete_all = 0; |
10984 | ||
10985 | char *cl_name_or_number = NULL; | |
10986 | int direct = 0; | |
10987 | int style = COMMUNITY_LIST_EXPANDED; | |
10988 | ||
10989 | int idx = 0; | |
10990 | argv_find (argv, argc, "(100-500)", &idx); | |
10991 | argv_find (argv, argc, "WORD", &idx); | |
10992 | cl_name_or_number = argv[idx]->arg; | |
10993 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10994 | argv_find (argv, argc, "AA:NN", &idx); | |
10995 | char *str = argv_concat (argv, argc, idx); | |
10996 | ||
10997 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10998 | ||
10999 | if (ret < 0) | |
11000 | { | |
11001 | community_list_perror (vty, ret); | |
11002 | return CMD_WARNING; | |
11003 | } | |
11004 | ||
11005 | return CMD_SUCCESS; | |
718e3744 | 11006 | } |
11007 | ||
94f2b392 | 11008 | static void |
718e3744 | 11009 | community_list_show (struct vty *vty, struct community_list *list) |
11010 | { | |
11011 | struct community_entry *entry; | |
11012 | ||
11013 | for (entry = list->head; entry; entry = entry->next) | |
11014 | { | |
11015 | if (entry == list->head) | |
11016 | { | |
11017 | if (all_digit (list->name)) | |
11018 | vty_out (vty, "Community %s list %s%s", | |
11019 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11020 | "standard" : "(expanded) access", | |
11021 | list->name, VTY_NEWLINE); | |
11022 | else | |
11023 | vty_out (vty, "Named Community %s list %s%s", | |
11024 | entry->style == COMMUNITY_LIST_STANDARD ? | |
11025 | "standard" : "expanded", | |
11026 | list->name, VTY_NEWLINE); | |
11027 | } | |
11028 | if (entry->any) | |
11029 | vty_out (vty, " %s%s", | |
11030 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11031 | else | |
11032 | vty_out (vty, " %s %s%s", | |
11033 | community_direct_str (entry->direct), | |
11034 | entry->style == COMMUNITY_LIST_STANDARD | |
11035 | ? community_str (entry->u.com) : entry->config, | |
11036 | VTY_NEWLINE); | |
11037 | } | |
11038 | } | |
11039 | ||
11040 | DEFUN (show_ip_community_list, | |
11041 | show_ip_community_list_cmd, | |
11042 | "show ip community-list", | |
11043 | SHOW_STR | |
11044 | IP_STR | |
11045 | "List community-list\n") | |
11046 | { | |
11047 | struct community_list *list; | |
11048 | struct community_list_master *cm; | |
11049 | ||
fee6e4e4 | 11050 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11051 | if (! cm) |
11052 | return CMD_SUCCESS; | |
11053 | ||
11054 | for (list = cm->num.head; list; list = list->next) | |
11055 | community_list_show (vty, list); | |
11056 | ||
11057 | for (list = cm->str.head; list; list = list->next) | |
11058 | community_list_show (vty, list); | |
11059 | ||
11060 | return CMD_SUCCESS; | |
11061 | } | |
11062 | ||
11063 | DEFUN (show_ip_community_list_arg, | |
11064 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11065 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11066 | SHOW_STR |
11067 | IP_STR | |
11068 | "List community-list\n" | |
11069 | "Community-list number\n" | |
11070 | "Community-list name\n") | |
11071 | { | |
c500ae40 | 11072 | int idx_comm_list = 3; |
718e3744 | 11073 | struct community_list *list; |
11074 | ||
c500ae40 | 11075 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11076 | if (! list) |
11077 | { | |
b729294c | 11078 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11079 | return CMD_WARNING; |
11080 | } | |
11081 | ||
11082 | community_list_show (vty, list); | |
11083 | ||
11084 | return CMD_SUCCESS; | |
11085 | } | |
6b0655a2 | 11086 | |
718e3744 | 11087 | /* "extcommunity-list" keyword help string. */ |
11088 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11089 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11090 | ||
11091 | DEFUN (ip_extcommunity_list_standard, | |
11092 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11093 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11094 | IP_STR |
11095 | EXTCOMMUNITY_LIST_STR | |
11096 | "Extended Community list number (standard)\n" | |
718e3744 | 11097 | "Specify standard extcommunity-list\n" |
5bf15956 | 11098 | "Community list name\n" |
718e3744 | 11099 | "Specify community to reject\n" |
11100 | "Specify community to accept\n" | |
11101 | EXTCOMMUNITY_VAL_STR) | |
11102 | { | |
42f914d4 QY |
11103 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11104 | int direct = 0; | |
11105 | char *cl_number_or_name = NULL; | |
11106 | ||
11107 | int idx = 0; | |
11108 | argv_find (argv, argc, "(1-99)", &idx); | |
11109 | argv_find (argv, argc, "WORD", &idx); | |
11110 | cl_number_or_name = argv[idx]->arg; | |
11111 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11112 | argv_find (argv, argc, "AA:NN", &idx); | |
11113 | char *str = argv_concat (argv, argc, idx); | |
11114 | ||
11115 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11116 | ||
11117 | XFREE (MTYPE_TMP, str); | |
11118 | ||
11119 | if (ret < 0) | |
11120 | { | |
11121 | community_list_perror (vty, ret); | |
11122 | return CMD_WARNING; | |
11123 | } | |
11124 | ||
11125 | return CMD_SUCCESS; | |
718e3744 | 11126 | } |
11127 | ||
718e3744 | 11128 | DEFUN (ip_extcommunity_list_name_expanded, |
11129 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11130 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11131 | IP_STR |
11132 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11133 | "Extended Community list number (expanded)\n" |
718e3744 | 11134 | "Specify expanded extcommunity-list\n" |
11135 | "Extended Community list name\n" | |
11136 | "Specify community to reject\n" | |
11137 | "Specify community to accept\n" | |
11138 | "An ordered list as a regular-expression\n") | |
11139 | { | |
42f914d4 QY |
11140 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11141 | int direct = 0; | |
11142 | char *cl_number_or_name = NULL; | |
11143 | ||
11144 | int idx = 0; | |
11145 | argv_find (argv, argc, "(100-500)", &idx); | |
11146 | argv_find (argv, argc, "WORD", &idx); | |
11147 | cl_number_or_name = argv[idx]->arg; | |
11148 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11149 | argv_find (argv, argc, "LINE", &idx); | |
11150 | char *str = argv_concat (argv, argc, idx); | |
11151 | ||
11152 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11153 | ||
11154 | XFREE (MTYPE_TMP, str); | |
11155 | ||
11156 | if (ret < 0) | |
11157 | { | |
11158 | community_list_perror (vty, ret); | |
11159 | return CMD_WARNING; | |
11160 | } | |
11161 | ||
11162 | return CMD_SUCCESS; | |
718e3744 | 11163 | } |
11164 | ||
fee6e4e4 | 11165 | DEFUN (no_ip_extcommunity_list_standard_all, |
11166 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11167 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11168 | NO_STR |
11169 | IP_STR | |
11170 | EXTCOMMUNITY_LIST_STR | |
11171 | "Extended Community list number (standard)\n" | |
718e3744 | 11172 | "Specify standard extcommunity-list\n" |
5bf15956 | 11173 | "Community list name\n" |
718e3744 | 11174 | "Specify community to reject\n" |
11175 | "Specify community to accept\n" | |
11176 | EXTCOMMUNITY_VAL_STR) | |
11177 | { | |
42f914d4 QY |
11178 | int deleteall = 0; |
11179 | ||
11180 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11181 | int direct = 0; | |
11182 | char *cl_number_or_name = NULL; | |
11183 | ||
11184 | int idx = 0; | |
11185 | argv_find (argv, argc, "(1-99)", &idx); | |
11186 | argv_find (argv, argc, "WORD", &idx); | |
11187 | cl_number_or_name = argv[idx]->arg; | |
11188 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11189 | argv_find (argv, argc, "AA:NN", &idx); | |
11190 | char *str = argv_concat (argv, argc, idx); | |
11191 | ||
11192 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11193 | ||
11194 | XFREE (MTYPE_TMP, str); | |
11195 | ||
11196 | if (ret < 0) | |
11197 | { | |
11198 | community_list_perror (vty, ret); | |
11199 | return CMD_WARNING; | |
11200 | } | |
11201 | ||
11202 | return CMD_SUCCESS; | |
718e3744 | 11203 | } |
11204 | ||
5bf15956 DW |
11205 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11206 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11207 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11208 | NO_STR |
11209 | IP_STR | |
11210 | EXTCOMMUNITY_LIST_STR | |
11211 | "Extended Community list number (expanded)\n" | |
718e3744 | 11212 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11213 | "Extended Community list name\n" |
718e3744 | 11214 | "Specify community to reject\n" |
11215 | "Specify community to accept\n" | |
11216 | "An ordered list as a regular-expression\n") | |
11217 | { | |
42f914d4 QY |
11218 | int deleteall = 0; |
11219 | ||
11220 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11221 | int direct = 0; | |
11222 | char *cl_number_or_name = NULL; | |
11223 | ||
11224 | int idx = 0; | |
11225 | argv_find (argv, argc, "(100-500)", &idx); | |
11226 | argv_find (argv, argc, "WORD", &idx); | |
11227 | cl_number_or_name = argv[idx]->arg; | |
11228 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11229 | argv_find (argv, argc, "LINE", &idx); | |
11230 | char *str = argv_concat (argv, argc, idx); | |
11231 | ||
11232 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11233 | ||
11234 | XFREE (MTYPE_TMP, str); | |
11235 | ||
11236 | if (ret < 0) | |
11237 | { | |
11238 | community_list_perror (vty, ret); | |
11239 | return CMD_WARNING; | |
11240 | } | |
11241 | ||
11242 | return CMD_SUCCESS; | |
718e3744 | 11243 | } |
11244 | ||
94f2b392 | 11245 | static void |
718e3744 | 11246 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11247 | { | |
11248 | struct community_entry *entry; | |
11249 | ||
11250 | for (entry = list->head; entry; entry = entry->next) | |
11251 | { | |
11252 | if (entry == list->head) | |
11253 | { | |
11254 | if (all_digit (list->name)) | |
11255 | vty_out (vty, "Extended community %s list %s%s", | |
11256 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11257 | "standard" : "(expanded) access", | |
11258 | list->name, VTY_NEWLINE); | |
11259 | else | |
11260 | vty_out (vty, "Named extended community %s list %s%s", | |
11261 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11262 | "standard" : "expanded", | |
11263 | list->name, VTY_NEWLINE); | |
11264 | } | |
11265 | if (entry->any) | |
11266 | vty_out (vty, " %s%s", | |
11267 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11268 | else | |
11269 | vty_out (vty, " %s %s%s", | |
11270 | community_direct_str (entry->direct), | |
11271 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11272 | entry->u.ecom->str : entry->config, | |
11273 | VTY_NEWLINE); | |
11274 | } | |
11275 | } | |
11276 | ||
11277 | DEFUN (show_ip_extcommunity_list, | |
11278 | show_ip_extcommunity_list_cmd, | |
11279 | "show ip extcommunity-list", | |
11280 | SHOW_STR | |
11281 | IP_STR | |
11282 | "List extended-community list\n") | |
11283 | { | |
11284 | struct community_list *list; | |
11285 | struct community_list_master *cm; | |
11286 | ||
fee6e4e4 | 11287 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11288 | if (! cm) |
11289 | return CMD_SUCCESS; | |
11290 | ||
11291 | for (list = cm->num.head; list; list = list->next) | |
11292 | extcommunity_list_show (vty, list); | |
11293 | ||
11294 | for (list = cm->str.head; list; list = list->next) | |
11295 | extcommunity_list_show (vty, list); | |
11296 | ||
11297 | return CMD_SUCCESS; | |
11298 | } | |
11299 | ||
11300 | DEFUN (show_ip_extcommunity_list_arg, | |
11301 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11302 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11303 | SHOW_STR |
11304 | IP_STR | |
11305 | "List extended-community list\n" | |
11306 | "Extcommunity-list number\n" | |
11307 | "Extcommunity-list name\n") | |
11308 | { | |
c500ae40 | 11309 | int idx_comm_list = 3; |
718e3744 | 11310 | struct community_list *list; |
11311 | ||
c500ae40 | 11312 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11313 | if (! list) |
11314 | { | |
b729294c | 11315 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11316 | return CMD_WARNING; |
11317 | } | |
11318 | ||
11319 | extcommunity_list_show (vty, list); | |
11320 | ||
11321 | return CMD_SUCCESS; | |
11322 | } | |
6b0655a2 | 11323 | |
718e3744 | 11324 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11325 | static const char * |
718e3744 | 11326 | community_list_config_str (struct community_entry *entry) |
11327 | { | |
fd79ac91 | 11328 | const char *str; |
718e3744 | 11329 | |
11330 | if (entry->any) | |
11331 | str = ""; | |
11332 | else | |
11333 | { | |
11334 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11335 | str = community_str (entry->u.com); | |
11336 | else | |
11337 | str = entry->config; | |
11338 | } | |
11339 | return str; | |
11340 | } | |
11341 | ||
11342 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11343 | static int |
718e3744 | 11344 | community_list_config_write (struct vty *vty) |
11345 | { | |
11346 | struct community_list *list; | |
11347 | struct community_entry *entry; | |
11348 | struct community_list_master *cm; | |
11349 | int write = 0; | |
11350 | ||
11351 | /* Community-list. */ | |
fee6e4e4 | 11352 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11353 | |
11354 | for (list = cm->num.head; list; list = list->next) | |
11355 | for (entry = list->head; entry; entry = entry->next) | |
11356 | { | |
fee6e4e4 | 11357 | vty_out (vty, "ip community-list %s %s %s%s", |
11358 | list->name, community_direct_str (entry->direct), | |
11359 | community_list_config_str (entry), | |
11360 | VTY_NEWLINE); | |
718e3744 | 11361 | write++; |
11362 | } | |
11363 | for (list = cm->str.head; list; list = list->next) | |
11364 | for (entry = list->head; entry; entry = entry->next) | |
11365 | { | |
11366 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11367 | entry->style == COMMUNITY_LIST_STANDARD | |
11368 | ? "standard" : "expanded", | |
11369 | list->name, community_direct_str (entry->direct), | |
11370 | community_list_config_str (entry), | |
11371 | VTY_NEWLINE); | |
11372 | write++; | |
11373 | } | |
11374 | ||
11375 | /* Extcommunity-list. */ | |
fee6e4e4 | 11376 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11377 | |
11378 | for (list = cm->num.head; list; list = list->next) | |
11379 | for (entry = list->head; entry; entry = entry->next) | |
11380 | { | |
fee6e4e4 | 11381 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
11382 | list->name, community_direct_str (entry->direct), | |
11383 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 11384 | write++; |
11385 | } | |
11386 | for (list = cm->str.head; list; list = list->next) | |
11387 | for (entry = list->head; entry; entry = entry->next) | |
11388 | { | |
11389 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
11390 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
11391 | ? "standard" : "expanded", | |
11392 | list->name, community_direct_str (entry->direct), | |
11393 | community_list_config_str (entry), VTY_NEWLINE); | |
11394 | write++; | |
11395 | } | |
11396 | return write; | |
11397 | } | |
11398 | ||
7fc626de | 11399 | static struct cmd_node community_list_node = |
718e3744 | 11400 | { |
11401 | COMMUNITY_LIST_NODE, | |
11402 | "", | |
11403 | 1 /* Export to vtysh. */ | |
11404 | }; | |
11405 | ||
94f2b392 | 11406 | static void |
11407 | community_list_vty (void) | |
718e3744 | 11408 | { |
11409 | install_node (&community_list_node, community_list_config_write); | |
11410 | ||
11411 | /* Community-list. */ | |
718e3744 | 11412 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
fee6e4e4 | 11413 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
11414 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 11415 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
11416 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 11417 | |
11418 | /* Extcommunity-list. */ | |
11419 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 11420 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 11421 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
11422 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 11423 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
11424 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
5bf15956 | 11425 | } |