]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_vty.c
Merge branch 'frr/pull/157' ("Fixinator")
[mirror_frr.git] / bgpd / bgp_vty.c
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 "lib/json.h"
24 #include "command.h"
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"
32 #include "memory.h"
33 #include "memory_vty.h"
34 #include "hash.h"
35 #include "queue.h"
36 #include "filter.h"
37
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_advertise.h"
40 #include "bgpd/bgp_attr.h"
41 #include "bgpd/bgp_aspath.h"
42 #include "bgpd/bgp_community.h"
43 #include "bgpd/bgp_ecommunity.h"
44 #include "bgpd/bgp_damp.h"
45 #include "bgpd/bgp_debug.h"
46 #include "bgpd/bgp_fsm.h"
47 #include "bgpd/bgp_mplsvpn.h"
48 #include "bgpd/bgp_nexthop.h"
49 #include "bgpd/bgp_open.h"
50 #include "bgpd/bgp_regex.h"
51 #include "bgpd/bgp_route.h"
52 #include "bgpd/bgp_zebra.h"
53 #include "bgpd/bgp_table.h"
54 #include "bgpd/bgp_vty.h"
55 #include "bgpd/bgp_mpath.h"
56 #include "bgpd/bgp_packet.h"
57 #include "bgpd/bgp_updgrp.h"
58 #include "bgpd/bgp_bfd.h"
59
60 static struct peer_group *
61 listen_range_exists (struct bgp *bgp, struct prefix *range, int exact);
62
63 /* Utility function to get address family from current node. */
64 afi_t
65 bgp_node_afi (struct vty *vty)
66 {
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;
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 {
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;
108 }
109
110 /* supports (ipv4|ipv6) */
111 afi_t
112 bgp_vty_afi_from_arg(const char *afi_str)
113 {
114 afi_t afi = AFI_MAX; /* unknown */
115 if (!strcmp(afi_str, "ipv4")) {
116 afi = AFI_IP;
117 }
118 else if (!strcmp(afi_str, "ipv6")) {
119 afi = AFI_IP6;
120 }
121 return afi;
122 }
123
124 int
125 bgp_parse_afi(const char *str, afi_t *afi)
126 {
127 *afi = bgp_vty_afi_from_arg(str);
128 if (*afi != AFI_MAX)
129 return 0;
130 else
131 return -1;
132 }
133
134
135 /* supports (unicast|multicast|vpn|encap) */
136 safi_t
137 bgp_vty_safi_from_arg(const char *safi_str)
138 {
139 safi_t safi = SAFI_MAX; /* unknown */
140 if (strncmp (safi_str, "m", 1) == 0)
141 safi = SAFI_MULTICAST;
142 else if (strncmp (safi_str, "u", 1) == 0)
143 safi = SAFI_UNICAST;
144 else if (strncmp (safi_str, "e", 1) == 0)
145 safi = SAFI_ENCAP;
146 else if (strncmp (safi_str, "v", 1) == 0)
147 safi = SAFI_MPLS_VPN;
148 return safi;
149 }
150
151 int
152 bgp_parse_safi(const char *str, safi_t *safi)
153 {
154 *safi = bgp_vty_safi_from_arg(str);
155 if (*safi != SAFI_MAX)
156 return 0;
157 else
158 return -1;
159 }
160
161 static int
162 peer_address_self_check (struct bgp *bgp, union sockunion *su)
163 {
164 struct interface *ifp = NULL;
165
166 if (su->sa.sa_family == AF_INET)
167 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id);
168 else if (su->sa.sa_family == AF_INET6)
169 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
170 su->sin6.sin6_scope_id, bgp->vrf_id);
171
172 if (ifp)
173 return 1;
174
175 return 0;
176 }
177
178 /* Utility function for looking up peer from VTY. */
179 /* This is used only for configuration, so disallow if attempted on
180 * a dynamic neighbor.
181 */
182 static struct peer *
183 peer_lookup_vty (struct vty *vty, const char *ip_str)
184 {
185 int ret;
186 struct bgp *bgp;
187 union sockunion su;
188 struct peer *peer;
189
190 bgp = vty->index;
191
192 ret = str2sockunion (ip_str, &su);
193 if (ret < 0)
194 {
195 peer = peer_lookup_by_conf_if (bgp, ip_str);
196 if (!peer)
197 {
198 if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL)
199 {
200 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
201 return NULL;
202 }
203 }
204 }
205 else
206 {
207 peer = peer_lookup (bgp, &su);
208 if (! peer)
209 {
210 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
211 VTY_NEWLINE);
212 return NULL;
213 }
214 if (peer_dynamic_neighbor (peer))
215 {
216 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
217 VTY_NEWLINE);
218 return NULL;
219 }
220
221 }
222 return peer;
223 }
224
225 /* Utility function for looking up peer or peer group. */
226 /* This is used only for configuration, so disallow if attempted on
227 * a dynamic neighbor.
228 */
229 struct peer *
230 peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
231 {
232 int ret;
233 struct bgp *bgp;
234 union sockunion su;
235 struct peer *peer = NULL;
236 struct peer_group *group = NULL;
237
238 bgp = vty->index;
239
240 ret = str2sockunion (peer_str, &su);
241 if (ret == 0)
242 {
243 /* IP address, locate peer. */
244 peer = peer_lookup (bgp, &su);
245 }
246 else
247 {
248 /* Not IP, could match either peer configured on interface or a group. */
249 peer = peer_lookup_by_conf_if (bgp, peer_str);
250 if (!peer)
251 group = peer_group_lookup (bgp, peer_str);
252 }
253
254 if (peer)
255 {
256 if (peer_dynamic_neighbor (peer))
257 {
258 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
259 VTY_NEWLINE);
260 return NULL;
261 }
262
263 return peer;
264 }
265
266 if (group)
267 return group->conf;
268
269 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
270 VTY_NEWLINE);
271
272 return NULL;
273 }
274
275 int
276 bgp_vty_return (struct vty *vty, int ret)
277 {
278 const char *str = NULL;
279
280 switch (ret)
281 {
282 case BGP_ERR_INVALID_VALUE:
283 str = "Invalid value";
284 break;
285 case BGP_ERR_INVALID_FLAG:
286 str = "Invalid flag";
287 break;
288 case BGP_ERR_PEER_GROUP_SHUTDOWN:
289 str = "Peer-group has been shutdown. Activate the peer-group first";
290 break;
291 case BGP_ERR_PEER_FLAG_CONFLICT:
292 str = "Can't set override-capability and strict-capability-match at the same time";
293 break;
294 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
295 str = "Specify remote-as or peer-group remote AS first";
296 break;
297 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
298 str = "Cannot change the peer-group. Deconfigure first";
299 break;
300 case BGP_ERR_PEER_GROUP_MISMATCH:
301 str = "Peer is not a member of this peer-group";
302 break;
303 case BGP_ERR_PEER_FILTER_CONFLICT:
304 str = "Prefix/distribute list can not co-exist";
305 break;
306 case BGP_ERR_NOT_INTERNAL_PEER:
307 str = "Invalid command. Not an internal neighbor";
308 break;
309 case BGP_ERR_REMOVE_PRIVATE_AS:
310 str = "remove-private-AS cannot be configured for IBGP peers";
311 break;
312 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
313 str = "Local-AS allowed only for EBGP peers";
314 break;
315 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
316 str = "Cannot have local-as same as BGP AS number";
317 break;
318 case BGP_ERR_TCPSIG_FAILED:
319 str = "Error while applying TCP-Sig to session(s)";
320 break;
321 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
322 str = "ebgp-multihop and ttl-security cannot be configured together";
323 break;
324 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
325 str = "ttl-security only allowed for EBGP peers";
326 break;
327 case BGP_ERR_AS_OVERRIDE:
328 str = "as-override cannot be configured for IBGP peers";
329 break;
330 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
331 str = "Invalid limit for number of dynamic neighbors";
332 break;
333 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
334 str = "Dynamic neighbor listen range already exists";
335 break;
336 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
337 str = "Operation not allowed on a dynamic neighbor";
338 break;
339 case BGP_ERR_INVALID_FOR_DIRECT_PEER:
340 str = "Operation not allowed on a directly connected neighbor";
341 break;
342 }
343 if (str)
344 {
345 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
346 return CMD_WARNING;
347 }
348 return CMD_SUCCESS;
349 }
350
351 /* BGP clear sort. */
352 enum clear_sort
353 {
354 clear_all,
355 clear_peer,
356 clear_group,
357 clear_external,
358 clear_as
359 };
360
361 static void
362 bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
363 safi_t safi, int error)
364 {
365 switch (error)
366 {
367 case BGP_ERR_AF_UNCONFIGURED:
368 vty_out (vty,
369 "%%BGP: Enable %s address family for the neighbor %s%s",
370 afi_safi_print(afi, safi), peer->host, VTY_NEWLINE);
371 break;
372 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
373 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);
374 break;
375 default:
376 break;
377 }
378 }
379
380 /* `clear ip bgp' functions. */
381 static int
382 bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
383 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
384 {
385 int ret;
386 struct peer *peer;
387 struct listnode *node, *nnode;
388
389 /* Clear all neighbors. */
390 /*
391 * Pass along pointer to next node to peer_clear() when walking all nodes
392 * on the BGP instance as that may get freed if it is a doppelganger
393 */
394 if (sort == clear_all)
395 {
396 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
397 {
398 if (stype == BGP_CLEAR_SOFT_NONE)
399 ret = peer_clear (peer, &nnode);
400 else if (peer->afc[afi][safi])
401 ret = peer_clear_soft (peer, afi, safi, stype);
402 else
403 ret = 0;
404
405 if (ret < 0)
406 bgp_clear_vty_error (vty, peer, afi, safi, ret);
407 }
408
409 /* This is to apply read-only mode on this clear. */
410 if (stype == BGP_CLEAR_SOFT_NONE)
411 bgp->update_delay_over = 0;
412
413 return CMD_SUCCESS;
414 }
415
416 /* Clear specified neighbors. */
417 if (sort == clear_peer)
418 {
419 union sockunion su;
420 int ret;
421
422 /* Make sockunion for lookup. */
423 ret = str2sockunion (arg, &su);
424 if (ret < 0)
425 {
426 peer = peer_lookup_by_conf_if (bgp, arg);
427 if (!peer)
428 {
429 peer = peer_lookup_by_hostname(bgp, arg);
430 if (!peer)
431 {
432 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
433 return CMD_WARNING;
434 }
435 }
436 }
437 else
438 {
439 peer = peer_lookup (bgp, &su);
440 if (! peer)
441 {
442 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
443 return CMD_WARNING;
444 }
445 }
446
447 if (stype == BGP_CLEAR_SOFT_NONE)
448 ret = peer_clear (peer, NULL);
449 else
450 ret = peer_clear_soft (peer, afi, safi, stype);
451
452 if (ret < 0)
453 bgp_clear_vty_error (vty, peer, afi, safi, ret);
454
455 return CMD_SUCCESS;
456 }
457
458 /* Clear all peer-group members. */
459 if (sort == clear_group)
460 {
461 struct peer_group *group;
462
463 group = peer_group_lookup (bgp, arg);
464 if (! group)
465 {
466 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
467 return CMD_WARNING;
468 }
469
470 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
471 {
472 if (stype == BGP_CLEAR_SOFT_NONE)
473 {
474 peer_clear (peer, NULL);
475 continue;
476 }
477
478 if (! peer->afc[afi][safi])
479 continue;
480
481 ret = peer_clear_soft (peer, afi, safi, stype);
482
483 if (ret < 0)
484 bgp_clear_vty_error (vty, peer, afi, safi, ret);
485 }
486 return CMD_SUCCESS;
487 }
488
489 if (sort == clear_external)
490 {
491 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
492 {
493 if (peer->sort == BGP_PEER_IBGP)
494 continue;
495
496 if (stype == BGP_CLEAR_SOFT_NONE)
497 ret = peer_clear (peer, &nnode);
498 else
499 ret = peer_clear_soft (peer, afi, safi, stype);
500
501 if (ret < 0)
502 bgp_clear_vty_error (vty, peer, afi, safi, ret);
503 }
504 return CMD_SUCCESS;
505 }
506
507 if (sort == clear_as)
508 {
509 as_t as;
510 int find = 0;
511
512 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
513
514 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
515 {
516 if (peer->as != as)
517 continue;
518
519 find = 1;
520 if (stype == BGP_CLEAR_SOFT_NONE)
521 ret = peer_clear (peer, &nnode);
522 else
523 ret = peer_clear_soft (peer, afi, safi, stype);
524
525 if (ret < 0)
526 bgp_clear_vty_error (vty, peer, afi, safi, ret);
527 }
528 if (! find)
529 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
530 VTY_NEWLINE);
531 return CMD_SUCCESS;
532 }
533
534 return CMD_SUCCESS;
535 }
536
537 static int
538 bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
539 enum clear_sort sort, enum bgp_clear_type stype,
540 const char *arg)
541 {
542 struct bgp *bgp;
543
544 /* BGP structure lookup. */
545 if (name)
546 {
547 bgp = bgp_lookup_by_name (name);
548 if (bgp == NULL)
549 {
550 vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE);
551 return CMD_WARNING;
552 }
553 }
554 else
555 {
556 bgp = bgp_get_default ();
557 if (bgp == NULL)
558 {
559 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
560 return CMD_WARNING;
561 }
562 }
563
564 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
565 }
566
567 /* clear soft inbound */
568 static void
569 bgp_clear_star_soft_in (struct vty *vty, const char *name)
570 {
571 bgp_clear_vty (vty,name, AFI_IP, SAFI_UNICAST, clear_all,
572 BGP_CLEAR_SOFT_IN, NULL);
573 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
574 BGP_CLEAR_SOFT_IN, NULL);
575 }
576
577 /* clear soft outbound */
578 static void
579 bgp_clear_star_soft_out (struct vty *vty, const char *name)
580 {
581 bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all,
582 BGP_CLEAR_SOFT_OUT, NULL);
583 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
584 BGP_CLEAR_SOFT_OUT, NULL);
585 }
586
587
588 /* BGP global configuration. */
589
590 DEFUN (bgp_multiple_instance_func,
591 bgp_multiple_instance_cmd,
592 "bgp multiple-instance",
593 BGP_STR
594 "Enable bgp multiple instance\n")
595 {
596 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
597 return CMD_SUCCESS;
598 }
599
600 DEFUN (no_bgp_multiple_instance,
601 no_bgp_multiple_instance_cmd,
602 "no bgp multiple-instance",
603 NO_STR
604 BGP_STR
605 "BGP multiple instance\n")
606 {
607 int ret;
608
609 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
610 if (ret < 0)
611 {
612 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
613 return CMD_WARNING;
614 }
615 return CMD_SUCCESS;
616 }
617
618 DEFUN (bgp_config_type,
619 bgp_config_type_cmd,
620 "bgp config-type (cisco|zebra)",
621 BGP_STR
622 "Configuration type\n"
623 "cisco\n"
624 "zebra\n")
625 {
626 if (strncmp (argv[0], "c", 1) == 0)
627 bgp_option_set (BGP_OPT_CONFIG_CISCO);
628 else
629 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
630
631 return CMD_SUCCESS;
632 }
633
634 DEFUN (no_bgp_config_type,
635 no_bgp_config_type_cmd,
636 "no bgp config-type",
637 NO_STR
638 BGP_STR
639 "Display configuration type\n")
640 {
641 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
642 return CMD_SUCCESS;
643 }
644
645 ALIAS (no_bgp_config_type,
646 no_bgp_config_type_val_cmd,
647 "no bgp config-type (cisco|zebra)",
648 NO_STR
649 BGP_STR
650 "Configuration type\n"
651 "cisco\n"
652 "zebra\n")
653
654 DEFUN (no_synchronization,
655 no_synchronization_cmd,
656 "no synchronization",
657 NO_STR
658 "Perform IGP synchronization\n")
659 {
660 return CMD_SUCCESS;
661 }
662
663 DEFUN (no_auto_summary,
664 no_auto_summary_cmd,
665 "no auto-summary",
666 NO_STR
667 "Enable automatic network number summarization\n")
668 {
669 return CMD_SUCCESS;
670 }
671
672 /* "router bgp" commands. */
673 DEFUN (router_bgp,
674 router_bgp_cmd,
675 "router bgp " CMD_AS_RANGE,
676 ROUTER_STR
677 BGP_STR
678 AS_STR)
679 {
680 int ret;
681 as_t as;
682 struct bgp *bgp;
683 const char *name = NULL;
684 enum bgp_instance_type inst_type;
685
686 // "router bgp" without an ASN
687 if (argc < 1)
688 {
689 //Pending: Make VRF option available for ASN less config
690 bgp = bgp_get_default();
691
692 if (bgp == NULL)
693 {
694 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
695 return CMD_WARNING;
696 }
697
698 if (listcount(bm->bgp) > 1)
699 {
700 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
701 return CMD_WARNING;
702 }
703 }
704
705 // "router bgp X"
706 else
707 {
708 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
709
710 inst_type = BGP_INSTANCE_TYPE_DEFAULT;
711 if (argc == 3)
712 {
713 name = argv[2];
714 if (!strcmp(argv[1], "vrf"))
715 inst_type = BGP_INSTANCE_TYPE_VRF;
716 else if (!strcmp(argv[1], "view"))
717 inst_type = BGP_INSTANCE_TYPE_VIEW;
718 }
719
720 ret = bgp_get (&bgp, &as, name, inst_type);
721 switch (ret)
722 {
723 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
724 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
725 VTY_NEWLINE);
726 return CMD_WARNING;
727 case BGP_ERR_AS_MISMATCH:
728 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
729 return CMD_WARNING;
730 case BGP_ERR_INSTANCE_MISMATCH:
731 vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE);
732 vty_out (vty, "BGP instance is already running; AS is %u%s",
733 as, VTY_NEWLINE);
734 return CMD_WARNING;
735 }
736
737 /* Pending: handle when user tries to change a view to vrf n vv. */
738 }
739
740 vty->node = BGP_NODE;
741 vty->index = bgp;
742
743 return CMD_SUCCESS;
744 }
745
746 ALIAS (router_bgp,
747 router_bgp_instance_cmd,
748 "router bgp " CMD_AS_RANGE " (view|vrf) WORD",
749 ROUTER_STR
750 BGP_STR
751 AS_STR
752 "BGP view\nBGP VRF\n"
753 "View/VRF name\n")
754
755 ALIAS (router_bgp,
756 router_bgp_noasn_cmd,
757 "router bgp",
758 ROUTER_STR
759 BGP_STR)
760
761 /* "no router bgp" commands. */
762 DEFUN (no_router_bgp,
763 no_router_bgp_cmd,
764 "no router bgp " CMD_AS_RANGE,
765 NO_STR
766 ROUTER_STR
767 BGP_STR
768 AS_STR)
769 {
770 as_t as;
771 struct bgp *bgp;
772 const char *name = NULL;
773
774
775 // "no router bgp" without an ASN
776 if (argc < 1)
777 {
778 //Pending: Make VRF option available for ASN less config
779 bgp = bgp_get_default();
780
781 if (bgp == NULL)
782 {
783 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
784 return CMD_WARNING;
785 }
786
787 if (listcount(bm->bgp) > 1)
788 {
789 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
790 return CMD_WARNING;
791 }
792 }
793 else
794 {
795 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
796
797 if (argc == 3)
798 name = argv[2];
799
800 /* Lookup bgp structure. */
801 bgp = bgp_lookup (as, name);
802 if (! bgp)
803 {
804 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
805 return CMD_WARNING;
806 }
807 }
808
809 bgp_delete (bgp);
810
811 return CMD_SUCCESS;
812 }
813
814 ALIAS (no_router_bgp,
815 no_router_bgp_instance_cmd,
816 "no router bgp " CMD_AS_RANGE " (view|vrf) WORD",
817 NO_STR
818 ROUTER_STR
819 BGP_STR
820 AS_STR
821 "BGP view\nBGP VRF\n"
822 "View/VRF name\n")
823
824 ALIAS (no_router_bgp,
825 no_router_bgp_noasn_cmd,
826 "no router bgp",
827 NO_STR
828 ROUTER_STR
829 BGP_STR)
830
831 /* BGP router-id. */
832
833 DEFUN (bgp_router_id,
834 bgp_router_id_cmd,
835 "bgp router-id A.B.C.D",
836 BGP_STR
837 "Override configured router identifier\n"
838 "Manually configured router identifier\n")
839 {
840 int ret;
841 struct in_addr id;
842 struct bgp *bgp;
843
844 bgp = vty->index;
845
846 ret = inet_aton (argv[0], &id);
847 if (! ret)
848 {
849 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
850 return CMD_WARNING;
851 }
852
853 bgp_router_id_static_set (bgp, id);
854
855 return CMD_SUCCESS;
856 }
857
858 DEFUN (no_bgp_router_id,
859 no_bgp_router_id_cmd,
860 "no bgp router-id",
861 NO_STR
862 BGP_STR
863 "Override configured router identifier\n")
864 {
865 int ret;
866 struct in_addr id;
867 struct bgp *bgp;
868
869 bgp = vty->index;
870
871 if (argc == 1)
872 {
873 ret = inet_aton (argv[0], &id);
874 if (! ret)
875 {
876 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
877 return CMD_WARNING;
878 }
879
880 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
881 {
882 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
883 return CMD_WARNING;
884 }
885 }
886
887 id.s_addr = 0;
888 bgp_router_id_static_set (bgp, id);
889
890 return CMD_SUCCESS;
891 }
892
893 ALIAS (no_bgp_router_id,
894 no_bgp_router_id_val_cmd,
895 "no bgp router-id A.B.C.D",
896 NO_STR
897 BGP_STR
898 "Override configured router identifier\n"
899 "Manually configured router identifier\n")
900
901 /* BGP Cluster ID. */
902
903 DEFUN (bgp_cluster_id,
904 bgp_cluster_id_cmd,
905 "bgp cluster-id A.B.C.D",
906 BGP_STR
907 "Configure Route-Reflector Cluster-id\n"
908 "Route-Reflector Cluster-id in IP address format\n")
909 {
910 int ret;
911 struct bgp *bgp;
912 struct in_addr cluster;
913
914 bgp = vty->index;
915
916 ret = inet_aton (argv[0], &cluster);
917 if (! ret)
918 {
919 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
920 return CMD_WARNING;
921 }
922
923 bgp_cluster_id_set (bgp, &cluster);
924 bgp_clear_star_soft_out (vty, bgp->name);
925
926 return CMD_SUCCESS;
927 }
928
929 ALIAS (bgp_cluster_id,
930 bgp_cluster_id32_cmd,
931 "bgp cluster-id <1-4294967295>",
932 BGP_STR
933 "Configure Route-Reflector Cluster-id\n"
934 "Route-Reflector Cluster-id as 32 bit quantity\n")
935
936 DEFUN (no_bgp_cluster_id,
937 no_bgp_cluster_id_cmd,
938 "no bgp cluster-id",
939 NO_STR
940 BGP_STR
941 "Configure Route-Reflector Cluster-id\n")
942 {
943 int ret;
944 struct bgp *bgp;
945 struct in_addr cluster;
946
947 bgp = vty->index;
948
949 if (argc == 1)
950 {
951 ret = inet_aton (argv[0], &cluster);
952 if (! ret)
953 {
954 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
955 return CMD_WARNING;
956 }
957 }
958
959 bgp_cluster_id_unset (bgp);
960 bgp_clear_star_soft_out (vty, bgp->name);
961
962 return CMD_SUCCESS;
963 }
964
965 ALIAS (no_bgp_cluster_id,
966 no_bgp_cluster_id_ip_cmd,
967 "no bgp cluster-id A.B.C.D",
968 NO_STR
969 BGP_STR
970 "Configure Route-Reflector Cluster-id\n"
971 "Route-Reflector Cluster-id in IP address format\n")
972
973 ALIAS (no_bgp_cluster_id,
974 no_bgp_cluster_id_decimal_cmd,
975 "no bgp cluster-id <1-4294967295>",
976 NO_STR
977 BGP_STR
978 "Configure Route-Reflector Cluster-id\n"
979 "Route-Reflector Cluster-id as 32 bit quantity\n")
980
981 DEFUN (bgp_confederation_identifier,
982 bgp_confederation_identifier_cmd,
983 "bgp confederation identifier " CMD_AS_RANGE,
984 "BGP specific commands\n"
985 "AS confederation parameters\n"
986 "AS number\n"
987 "Set routing domain confederation AS\n")
988 {
989 struct bgp *bgp;
990 as_t as;
991
992 bgp = vty->index;
993
994 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
995
996 bgp_confederation_id_set (bgp, as);
997
998 return CMD_SUCCESS;
999 }
1000
1001 DEFUN (no_bgp_confederation_identifier,
1002 no_bgp_confederation_identifier_cmd,
1003 "no bgp confederation identifier",
1004 NO_STR
1005 "BGP specific commands\n"
1006 "AS confederation parameters\n"
1007 "AS number\n")
1008 {
1009 struct bgp *bgp;
1010
1011 bgp = vty->index;
1012
1013 bgp_confederation_id_unset (bgp);
1014
1015 return CMD_SUCCESS;
1016 }
1017
1018 ALIAS (no_bgp_confederation_identifier,
1019 no_bgp_confederation_identifier_arg_cmd,
1020 "no bgp confederation identifier " CMD_AS_RANGE,
1021 NO_STR
1022 "BGP specific commands\n"
1023 "AS confederation parameters\n"
1024 "AS number\n"
1025 "Set routing domain confederation AS\n")
1026
1027 DEFUN (bgp_confederation_peers,
1028 bgp_confederation_peers_cmd,
1029 "bgp confederation peers ." CMD_AS_RANGE,
1030 "BGP specific commands\n"
1031 "AS confederation parameters\n"
1032 "Peer ASs in BGP confederation\n"
1033 AS_STR)
1034 {
1035 struct bgp *bgp;
1036 as_t as;
1037 int i;
1038
1039 bgp = vty->index;
1040
1041 for (i = 0; i < argc; i++)
1042 {
1043 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
1044
1045 if (bgp->as == as)
1046 {
1047 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
1048 VTY_NEWLINE);
1049 continue;
1050 }
1051
1052 bgp_confederation_peers_add (bgp, as);
1053 }
1054 return CMD_SUCCESS;
1055 }
1056
1057 DEFUN (no_bgp_confederation_peers,
1058 no_bgp_confederation_peers_cmd,
1059 "no bgp confederation peers ." CMD_AS_RANGE,
1060 NO_STR
1061 "BGP specific commands\n"
1062 "AS confederation parameters\n"
1063 "Peer ASs in BGP confederation\n"
1064 AS_STR)
1065 {
1066 struct bgp *bgp;
1067 as_t as;
1068 int i;
1069
1070 bgp = vty->index;
1071
1072 for (i = 0; i < argc; i++)
1073 {
1074 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
1075
1076 bgp_confederation_peers_remove (bgp, as);
1077 }
1078 return CMD_SUCCESS;
1079 }
1080
1081 /**
1082 * Central routine for maximum-paths configuration.
1083 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1084 * @set: 1 for setting values, 0 for removing the max-paths config.
1085 */
1086 static int
1087 bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
1088 u_int16_t options, int set)
1089 {
1090 struct bgp *bgp;
1091 u_int16_t maxpaths = 0;
1092 int ret;
1093 afi_t afi;
1094 safi_t safi;
1095
1096 bgp = vty->index;
1097 afi = bgp_node_afi (vty);
1098 safi = bgp_node_safi (vty);
1099
1100 if (set)
1101 {
1102 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
1103 MULTIPATH_NUM);
1104 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
1105 options);
1106 }
1107 else
1108 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
1109
1110 if (ret < 0)
1111 {
1112 vty_out (vty,
1113 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
1114 (set == 1) ? "" : "un",
1115 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1116 maxpaths, afi, safi, VTY_NEWLINE);
1117 return CMD_WARNING;
1118 }
1119
1120 bgp_recalculate_all_bestpaths (bgp);
1121
1122 return CMD_SUCCESS;
1123 }
1124
1125 DEFUN (bgp_maxmed_admin,
1126 bgp_maxmed_admin_cmd,
1127 "bgp max-med administrative ",
1128 BGP_STR
1129 "Advertise routes with max-med\n"
1130 "Administratively applied, for an indefinite period\n")
1131 {
1132 struct bgp *bgp;
1133
1134 bgp = vty->index;
1135
1136 bgp->v_maxmed_admin = 1;
1137 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1138
1139 bgp_maxmed_update(bgp);
1140
1141 return CMD_SUCCESS;
1142 }
1143
1144 DEFUN (bgp_maxmed_admin_medv,
1145 bgp_maxmed_admin_medv_cmd,
1146 "bgp max-med administrative <0-4294967294>",
1147 BGP_STR
1148 "Advertise routes with max-med\n"
1149 "Administratively applied, for an indefinite period\n"
1150 "Max MED value to be used\n")
1151 {
1152 struct bgp *bgp;
1153
1154 bgp = vty->index;
1155
1156 bgp->v_maxmed_admin = 1;
1157 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]);
1158
1159 bgp_maxmed_update(bgp);
1160
1161 return CMD_SUCCESS;
1162 }
1163
1164 DEFUN (no_bgp_maxmed_admin,
1165 no_bgp_maxmed_admin_cmd,
1166 "no bgp max-med administrative",
1167 NO_STR
1168 BGP_STR
1169 "Advertise routes with max-med\n"
1170 "Administratively applied, for an indefinite period\n")
1171 {
1172 struct bgp *bgp;
1173
1174 bgp = vty->index;
1175
1176 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1177 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1178
1179 bgp_maxmed_update(bgp);
1180
1181 return CMD_SUCCESS;
1182 }
1183
1184 ALIAS (no_bgp_maxmed_admin,
1185 no_bgp_maxmed_admin_medv_cmd,
1186 "no bgp max-med administrative <0-4294967294>",
1187 NO_STR
1188 BGP_STR
1189 "Advertise routes with max-med\n"
1190 "Administratively applied, for an indefinite period\n"
1191 "Max MED value to be used\n")
1192
1193
1194 DEFUN (bgp_maxmed_onstartup,
1195 bgp_maxmed_onstartup_cmd,
1196 "bgp max-med on-startup <5-86400>",
1197 BGP_STR
1198 "Advertise routes with max-med\n"
1199 "Effective on a startup\n"
1200 "Time (seconds) period for max-med\n")
1201 {
1202 struct bgp *bgp;
1203
1204 bgp = vty->index;
1205
1206 if (argc != 1)
1207 {
1208 vty_out (vty, "%% Must supply max-med on-startup period");
1209 return CMD_WARNING;
1210 }
1211
1212 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1213 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1214
1215 bgp_maxmed_update(bgp);
1216
1217 return CMD_SUCCESS;
1218 }
1219
1220 DEFUN (bgp_maxmed_onstartup_medv,
1221 bgp_maxmed_onstartup_medv_cmd,
1222 "bgp max-med on-startup <5-86400> <0-4294967294>",
1223 BGP_STR
1224 "Advertise routes with max-med\n"
1225 "Effective on a startup\n"
1226 "Time (seconds) period for max-med\n"
1227 "Max MED value to be used\n")
1228 {
1229 struct bgp *bgp;
1230
1231 bgp = vty->index;
1232
1233 if (argc != 2)
1234 {
1235 vty_out (vty, "%% Must supply max-med on-startup period and med value");
1236 return CMD_WARNING;
1237 }
1238
1239 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1240 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]);
1241
1242 bgp_maxmed_update(bgp);
1243
1244 return CMD_SUCCESS;
1245 }
1246
1247 DEFUN (no_bgp_maxmed_onstartup,
1248 no_bgp_maxmed_onstartup_cmd,
1249 "no bgp max-med on-startup",
1250 NO_STR
1251 BGP_STR
1252 "Advertise routes with max-med\n"
1253 "Effective on a startup\n")
1254 {
1255 struct bgp *bgp;
1256
1257 bgp = vty->index;
1258
1259 /* Cancel max-med onstartup if its on */
1260 if (bgp->t_maxmed_onstartup)
1261 {
1262 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1263 bgp->maxmed_onstartup_over = 1;
1264 }
1265
1266 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1267 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1268
1269 bgp_maxmed_update(bgp);
1270
1271 return CMD_SUCCESS;
1272 }
1273
1274 ALIAS (no_bgp_maxmed_onstartup,
1275 no_bgp_maxmed_onstartup_period_cmd,
1276 "no bgp max-med on-startup <5-86400>",
1277 NO_STR
1278 BGP_STR
1279 "Advertise routes with max-med\n"
1280 "Effective on a startup\n"
1281 "Time (seconds) period for max-med\n")
1282
1283 ALIAS (no_bgp_maxmed_onstartup,
1284 no_bgp_maxmed_onstartup_period_medv_cmd,
1285 "no bgp max-med on-startup <5-86400> <0-4294967294>",
1286 NO_STR
1287 BGP_STR
1288 "Advertise routes with max-med\n"
1289 "Effective on a startup\n"
1290 "Time (seconds) period for max-med\n"
1291 "Max MED value to be used\n")
1292
1293 static int
1294 bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1295 const char *wait)
1296 {
1297 struct bgp *bgp;
1298 u_int16_t update_delay;
1299 u_int16_t establish_wait;
1300
1301
1302 bgp = vty->index;
1303
1304 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1305 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1306
1307 if (!wait) /* update-delay <delay> */
1308 {
1309 bgp->v_update_delay = update_delay;
1310 bgp->v_establish_wait = bgp->v_update_delay;
1311 return CMD_SUCCESS;
1312 }
1313
1314 /* update-delay <delay> <establish-wait> */
1315 establish_wait = atoi (wait);
1316 if (update_delay < establish_wait)
1317 {
1318 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1319 VTY_NEWLINE);
1320 return CMD_WARNING;
1321 }
1322
1323 bgp->v_update_delay = update_delay;
1324 bgp->v_establish_wait = establish_wait;
1325
1326 return CMD_SUCCESS;
1327 }
1328
1329 static int
1330 bgp_update_delay_deconfig_vty (struct vty *vty)
1331 {
1332 struct bgp *bgp;
1333
1334 bgp = vty->index;
1335
1336 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1337 bgp->v_establish_wait = bgp->v_update_delay;
1338
1339 return CMD_SUCCESS;
1340 }
1341
1342 int
1343 bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1344 {
1345 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1346 {
1347 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1348 if (bgp->v_update_delay != bgp->v_establish_wait)
1349 vty_out (vty, " %d", bgp->v_establish_wait);
1350 vty_out (vty, "%s", VTY_NEWLINE);
1351 }
1352
1353 return 0;
1354 }
1355
1356
1357 /* Update-delay configuration */
1358 DEFUN (bgp_update_delay,
1359 bgp_update_delay_cmd,
1360 "update-delay <0-3600>",
1361 "Force initial delay for best-path and updates\n"
1362 "Seconds\n")
1363 {
1364 return bgp_update_delay_config_vty(vty, argv[0], NULL);
1365 }
1366
1367 DEFUN (bgp_update_delay_establish_wait,
1368 bgp_update_delay_establish_wait_cmd,
1369 "update-delay <0-3600> <1-3600>",
1370 "Force initial delay for best-path and updates\n"
1371 "Seconds\n"
1372 "Wait for peers to be established\n"
1373 "Seconds\n")
1374 {
1375 return bgp_update_delay_config_vty(vty, argv[0], argv[1]);
1376 }
1377
1378 /* Update-delay deconfiguration */
1379 DEFUN (no_bgp_update_delay,
1380 no_bgp_update_delay_cmd,
1381 "no update-delay <0-3600>",
1382 "Force initial delay for best-path and updates\n"
1383 "Seconds\n")
1384 {
1385 return bgp_update_delay_deconfig_vty(vty);
1386 }
1387
1388 ALIAS (no_bgp_update_delay,
1389 no_bgp_update_delay_establish_wait_cmd,
1390 "no update-delay <0-3600> <1-3600>",
1391 "Force initial delay for best-path and updates\n"
1392 "Seconds\n"
1393 "Wait for peers to be established\n"
1394 "Seconds\n")
1395
1396 static int
1397 bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
1398 {
1399 struct bgp *bgp;
1400
1401 bgp = vty->index;
1402
1403 if (set)
1404 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
1405 1, 10000);
1406 else
1407 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1408
1409 return CMD_SUCCESS;
1410 }
1411
1412 int
1413 bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1414 {
1415 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1416 vty_out (vty, " write-quanta %d%s",
1417 bgp->wpkt_quanta, VTY_NEWLINE);
1418
1419 return 0;
1420 }
1421
1422
1423 /* Update-delay configuration */
1424 DEFUN (bgp_wpkt_quanta,
1425 bgp_wpkt_quanta_cmd,
1426 "write-quanta <1-10000>",
1427 "How many packets to write to peer socket per run\n"
1428 "Number of packets\n")
1429 {
1430 return bgp_wpkt_quanta_config_vty(vty, argv[0], 1);
1431 }
1432
1433 /* Update-delay deconfiguration */
1434 DEFUN (no_bgp_wpkt_quanta,
1435 no_bgp_wpkt_quanta_cmd,
1436 "no write-quanta <1-10000>",
1437 "How many packets to write to peer socket per run\n"
1438 "Number of packets\n")
1439 {
1440 return bgp_wpkt_quanta_config_vty(vty, argv[0], 0);
1441 }
1442
1443 static int
1444 bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1445 {
1446 struct bgp *bgp;
1447
1448 bgp = vty->index;
1449
1450 if (set)
1451 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1452 0, 4294967295);
1453 else
1454 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1455
1456 return CMD_SUCCESS;
1457 }
1458
1459 int
1460 bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1461 {
1462 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1463 vty_out (vty, " coalesce-time %d%s",
1464 bgp->coalesce_time, VTY_NEWLINE);
1465
1466 return 0;
1467 }
1468
1469
1470 DEFUN (bgp_coalesce_time,
1471 bgp_coalesce_time_cmd,
1472 "coalesce-time <0-4294967295>",
1473 "Subgroup coalesce timer\n"
1474 "Subgroup coalesce timer value (in ms)\n")
1475 {
1476 return bgp_coalesce_config_vty(vty, argv[0], 1);
1477 }
1478
1479 DEFUN (no_bgp_coalesce_time,
1480 no_bgp_coalesce_time_cmd,
1481 "no coalesce-time <0-4294967295>",
1482 "Subgroup coalesce timer\n"
1483 "Subgroup coalesce timer value (in ms)\n")
1484 {
1485 return bgp_coalesce_config_vty(vty, argv[0], 0);
1486 }
1487
1488 /* Maximum-paths configuration */
1489 DEFUN (bgp_maxpaths,
1490 bgp_maxpaths_cmd,
1491 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
1492 "Forward packets over multiple paths\n"
1493 "Number of paths\n")
1494 {
1495 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1);
1496 }
1497
1498 DEFUN (bgp_maxpaths_ibgp,
1499 bgp_maxpaths_ibgp_cmd,
1500 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
1501 "Forward packets over multiple paths\n"
1502 "iBGP-multipath\n"
1503 "Number of paths\n")
1504 {
1505 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1);
1506 }
1507
1508 DEFUN (bgp_maxpaths_ibgp_cluster,
1509 bgp_maxpaths_ibgp_cluster_cmd,
1510 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
1511 "Forward packets over multiple paths\n"
1512 "iBGP-multipath\n"
1513 "Number of paths\n"
1514 "Match the cluster length\n")
1515 {
1516 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0],
1517 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
1518 }
1519
1520 DEFUN (no_bgp_maxpaths,
1521 no_bgp_maxpaths_cmd,
1522 "no maximum-paths",
1523 NO_STR
1524 "Forward packets over multiple paths\n"
1525 "Number of paths\n")
1526 {
1527 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
1528 }
1529
1530 ALIAS (no_bgp_maxpaths,
1531 no_bgp_maxpaths_arg_cmd,
1532 "no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
1533 NO_STR
1534 "Forward packets over multiple paths\n"
1535 "Number of paths\n")
1536
1537 DEFUN (no_bgp_maxpaths_ibgp,
1538 no_bgp_maxpaths_ibgp_cmd,
1539 "no maximum-paths ibgp",
1540 NO_STR
1541 "Forward packets over multiple paths\n"
1542 "iBGP-multipath\n"
1543 "Number of paths\n")
1544 {
1545 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
1546 }
1547
1548 ALIAS (no_bgp_maxpaths_ibgp,
1549 no_bgp_maxpaths_ibgp_arg_cmd,
1550 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
1551 NO_STR
1552 "Forward packets over multiple paths\n"
1553 "iBGP-multipath\n"
1554 "Number of paths\n")
1555
1556 ALIAS (no_bgp_maxpaths_ibgp,
1557 no_bgp_maxpaths_ibgp_cluster_cmd,
1558 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
1559 NO_STR
1560 "Forward packets over multiple paths\n"
1561 "iBGP-multipath\n"
1562 "Number of paths\n"
1563 "Match the cluster length\n")
1564
1565 int
1566 bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1567 safi_t safi, int *write)
1568 {
1569 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
1570 {
1571 bgp_config_write_family_header (vty, afi, safi, write);
1572 vty_out (vty, " maximum-paths %d%s",
1573 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1574 }
1575
1576 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
1577 {
1578 bgp_config_write_family_header (vty, afi, safi, write);
1579 vty_out (vty, " maximum-paths ibgp %d",
1580 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1581 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1582 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1583 vty_out (vty, " equal-cluster-length");
1584 vty_out (vty, "%s", VTY_NEWLINE);
1585 }
1586
1587 return 0;
1588 }
1589
1590 /* BGP timers. */
1591
1592 DEFUN (bgp_timers,
1593 bgp_timers_cmd,
1594 "timers bgp <0-65535> <0-65535>",
1595 "Adjust routing timers\n"
1596 "BGP timers\n"
1597 "Keepalive interval\n"
1598 "Holdtime\n")
1599 {
1600 struct bgp *bgp;
1601 unsigned long keepalive = 0;
1602 unsigned long holdtime = 0;
1603
1604 bgp = vty->index;
1605
1606 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
1607 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
1608
1609 /* Holdtime value check. */
1610 if (holdtime < 3 && holdtime != 0)
1611 {
1612 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1613 VTY_NEWLINE);
1614 return CMD_WARNING;
1615 }
1616
1617 bgp_timers_set (bgp, keepalive, holdtime);
1618
1619 return CMD_SUCCESS;
1620 }
1621
1622 DEFUN (no_bgp_timers,
1623 no_bgp_timers_cmd,
1624 "no timers bgp",
1625 NO_STR
1626 "Adjust routing timers\n"
1627 "BGP timers\n")
1628 {
1629 struct bgp *bgp;
1630
1631 bgp = vty->index;
1632 bgp_timers_unset (bgp);
1633
1634 return CMD_SUCCESS;
1635 }
1636
1637 ALIAS (no_bgp_timers,
1638 no_bgp_timers_arg_cmd,
1639 "no timers bgp <0-65535> <0-65535>",
1640 NO_STR
1641 "Adjust routing timers\n"
1642 "BGP timers\n"
1643 "Keepalive interval\n"
1644 "Holdtime\n")
1645
1646 DEFUN (bgp_client_to_client_reflection,
1647 bgp_client_to_client_reflection_cmd,
1648 "bgp client-to-client reflection",
1649 "BGP specific commands\n"
1650 "Configure client to client route reflection\n"
1651 "reflection of routes allowed\n")
1652 {
1653 struct bgp *bgp;
1654
1655 bgp = vty->index;
1656 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1657 bgp_clear_star_soft_out (vty, bgp->name);
1658
1659 return CMD_SUCCESS;
1660 }
1661
1662 DEFUN (no_bgp_client_to_client_reflection,
1663 no_bgp_client_to_client_reflection_cmd,
1664 "no bgp client-to-client reflection",
1665 NO_STR
1666 "BGP specific commands\n"
1667 "Configure client to client route reflection\n"
1668 "reflection of routes allowed\n")
1669 {
1670 struct bgp *bgp;
1671
1672 bgp = vty->index;
1673 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1674 bgp_clear_star_soft_out (vty, bgp->name);
1675
1676 return CMD_SUCCESS;
1677 }
1678
1679 /* "bgp always-compare-med" configuration. */
1680 DEFUN (bgp_always_compare_med,
1681 bgp_always_compare_med_cmd,
1682 "bgp always-compare-med",
1683 "BGP specific commands\n"
1684 "Allow comparing MED from different neighbors\n")
1685 {
1686 struct bgp *bgp;
1687
1688 bgp = vty->index;
1689 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1690 bgp_recalculate_all_bestpaths (bgp);
1691
1692 return CMD_SUCCESS;
1693 }
1694
1695 DEFUN (no_bgp_always_compare_med,
1696 no_bgp_always_compare_med_cmd,
1697 "no bgp always-compare-med",
1698 NO_STR
1699 "BGP specific commands\n"
1700 "Allow comparing MED from different neighbors\n")
1701 {
1702 struct bgp *bgp;
1703
1704 bgp = vty->index;
1705 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1706 bgp_recalculate_all_bestpaths (bgp);
1707
1708 return CMD_SUCCESS;
1709 }
1710
1711 /* "bgp deterministic-med" configuration. */
1712 DEFUN (bgp_deterministic_med,
1713 bgp_deterministic_med_cmd,
1714 "bgp deterministic-med",
1715 "BGP specific commands\n"
1716 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1717 {
1718 struct bgp *bgp;
1719
1720 bgp = vty->index;
1721
1722 if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1723 {
1724 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1725 bgp_recalculate_all_bestpaths (bgp);
1726 }
1727
1728 return CMD_SUCCESS;
1729 }
1730
1731 DEFUN (no_bgp_deterministic_med,
1732 no_bgp_deterministic_med_cmd,
1733 "no bgp deterministic-med",
1734 NO_STR
1735 "BGP specific commands\n"
1736 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1737 {
1738 struct bgp *bgp;
1739 int bestpath_per_as_used;
1740 afi_t afi;
1741 safi_t safi;
1742 struct peer *peer;
1743 struct listnode *node, *nnode;
1744
1745 bgp = vty->index;
1746
1747 if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1748 {
1749 bestpath_per_as_used = 0;
1750
1751 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1752 {
1753 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1754 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1755 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
1756 {
1757 bestpath_per_as_used = 1;
1758 break;
1759 }
1760
1761 if (bestpath_per_as_used)
1762 break;
1763 }
1764
1765 if (bestpath_per_as_used)
1766 {
1767 vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s",
1768 VTY_NEWLINE);
1769 return CMD_WARNING;
1770 }
1771 else
1772 {
1773 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1774 bgp_recalculate_all_bestpaths (bgp);
1775 }
1776 }
1777
1778 return CMD_SUCCESS;
1779 }
1780
1781 /* "bgp graceful-restart" configuration. */
1782 DEFUN (bgp_graceful_restart,
1783 bgp_graceful_restart_cmd,
1784 "bgp graceful-restart",
1785 "BGP specific commands\n"
1786 "Graceful restart capability parameters\n")
1787 {
1788 struct bgp *bgp;
1789
1790 bgp = vty->index;
1791 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1792 return CMD_SUCCESS;
1793 }
1794
1795 DEFUN (no_bgp_graceful_restart,
1796 no_bgp_graceful_restart_cmd,
1797 "no bgp graceful-restart",
1798 NO_STR
1799 "BGP specific commands\n"
1800 "Graceful restart capability parameters\n")
1801 {
1802 struct bgp *bgp;
1803
1804 bgp = vty->index;
1805 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1806 return CMD_SUCCESS;
1807 }
1808
1809 DEFUN (bgp_graceful_restart_stalepath_time,
1810 bgp_graceful_restart_stalepath_time_cmd,
1811 "bgp graceful-restart stalepath-time <1-3600>",
1812 "BGP specific commands\n"
1813 "Graceful restart capability parameters\n"
1814 "Set the max time to hold onto restarting peer's stale paths\n"
1815 "Delay value (seconds)\n")
1816 {
1817 struct bgp *bgp;
1818 u_int32_t stalepath;
1819
1820 bgp = vty->index;
1821 if (! bgp)
1822 return CMD_WARNING;
1823
1824 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1825 bgp->stalepath_time = stalepath;
1826 return CMD_SUCCESS;
1827 }
1828
1829 DEFUN (bgp_graceful_restart_restart_time,
1830 bgp_graceful_restart_restart_time_cmd,
1831 "bgp graceful-restart restart-time <1-3600>",
1832 "BGP specific commands\n"
1833 "Graceful restart capability parameters\n"
1834 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1835 "Delay value (seconds)\n")
1836 {
1837 struct bgp *bgp;
1838 u_int32_t restart;
1839
1840 bgp = vty->index;
1841 if (! bgp)
1842 return CMD_WARNING;
1843
1844 VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[0], 1, 3600);
1845 bgp->restart_time = restart;
1846 return CMD_SUCCESS;
1847 }
1848
1849 DEFUN (no_bgp_graceful_restart_stalepath_time,
1850 no_bgp_graceful_restart_stalepath_time_cmd,
1851 "no bgp graceful-restart stalepath-time",
1852 NO_STR
1853 "BGP specific commands\n"
1854 "Graceful restart capability parameters\n"
1855 "Set the max time to hold onto restarting peer's stale paths\n")
1856 {
1857 struct bgp *bgp;
1858
1859 bgp = vty->index;
1860 if (! bgp)
1861 return CMD_WARNING;
1862
1863 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1864 return CMD_SUCCESS;
1865 }
1866
1867 DEFUN (no_bgp_graceful_restart_restart_time,
1868 no_bgp_graceful_restart_restart_time_cmd,
1869 "no bgp graceful-restart restart-time",
1870 NO_STR
1871 "BGP specific commands\n"
1872 "Graceful restart capability parameters\n"
1873 "Set the time to wait to delete stale routes before a BGP open message is received\n")
1874 {
1875 struct bgp *bgp;
1876
1877 bgp = vty->index;
1878 if (! bgp)
1879 return CMD_WARNING;
1880
1881 bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
1882 return CMD_SUCCESS;
1883 }
1884
1885 ALIAS (no_bgp_graceful_restart_stalepath_time,
1886 no_bgp_graceful_restart_stalepath_time_val_cmd,
1887 "no bgp graceful-restart stalepath-time <1-3600>",
1888 NO_STR
1889 "BGP specific commands\n"
1890 "Graceful restart capability parameters\n"
1891 "Set the max time to hold onto restarting peer's stale paths\n"
1892 "Delay value (seconds)\n")
1893
1894 ALIAS (no_bgp_graceful_restart_restart_time,
1895 no_bgp_graceful_restart_restart_time_val_cmd,
1896 "no bgp graceful-restart restart-time <1-3600>",
1897 NO_STR
1898 "BGP specific commands\n"
1899 "Graceful restart capability parameters\n"
1900 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1901 "Delay value (seconds)\n")
1902
1903 /* "bgp fast-external-failover" configuration. */
1904 DEFUN (bgp_fast_external_failover,
1905 bgp_fast_external_failover_cmd,
1906 "bgp fast-external-failover",
1907 BGP_STR
1908 "Immediately reset session if a link to a directly connected external peer goes down\n")
1909 {
1910 struct bgp *bgp;
1911
1912 bgp = vty->index;
1913 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1914 return CMD_SUCCESS;
1915 }
1916
1917 DEFUN (no_bgp_fast_external_failover,
1918 no_bgp_fast_external_failover_cmd,
1919 "no bgp fast-external-failover",
1920 NO_STR
1921 BGP_STR
1922 "Immediately reset session if a link to a directly connected external peer goes down\n")
1923 {
1924 struct bgp *bgp;
1925
1926 bgp = vty->index;
1927 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1928 return CMD_SUCCESS;
1929 }
1930
1931 /* "bgp enforce-first-as" configuration. */
1932 DEFUN (bgp_enforce_first_as,
1933 bgp_enforce_first_as_cmd,
1934 "bgp enforce-first-as",
1935 BGP_STR
1936 "Enforce the first AS for EBGP routes\n")
1937 {
1938 struct bgp *bgp;
1939
1940 bgp = vty->index;
1941 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1942 bgp_clear_star_soft_in (vty, bgp->name);
1943
1944 return CMD_SUCCESS;
1945 }
1946
1947 DEFUN (no_bgp_enforce_first_as,
1948 no_bgp_enforce_first_as_cmd,
1949 "no bgp enforce-first-as",
1950 NO_STR
1951 BGP_STR
1952 "Enforce the first AS for EBGP routes\n")
1953 {
1954 struct bgp *bgp;
1955
1956 bgp = vty->index;
1957 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1958 bgp_clear_star_soft_in (vty, bgp->name);
1959
1960 return CMD_SUCCESS;
1961 }
1962
1963 /* "bgp bestpath compare-routerid" configuration. */
1964 DEFUN (bgp_bestpath_compare_router_id,
1965 bgp_bestpath_compare_router_id_cmd,
1966 "bgp bestpath compare-routerid",
1967 "BGP specific commands\n"
1968 "Change the default bestpath selection\n"
1969 "Compare router-id for identical EBGP paths\n")
1970 {
1971 struct bgp *bgp;
1972
1973 bgp = vty->index;
1974 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1975 bgp_recalculate_all_bestpaths (bgp);
1976
1977 return CMD_SUCCESS;
1978 }
1979
1980 DEFUN (no_bgp_bestpath_compare_router_id,
1981 no_bgp_bestpath_compare_router_id_cmd,
1982 "no bgp bestpath compare-routerid",
1983 NO_STR
1984 "BGP specific commands\n"
1985 "Change the default bestpath selection\n"
1986 "Compare router-id for identical EBGP paths\n")
1987 {
1988 struct bgp *bgp;
1989
1990 bgp = vty->index;
1991 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1992 bgp_recalculate_all_bestpaths (bgp);
1993
1994 return CMD_SUCCESS;
1995 }
1996
1997 /* "bgp bestpath as-path ignore" configuration. */
1998 DEFUN (bgp_bestpath_aspath_ignore,
1999 bgp_bestpath_aspath_ignore_cmd,
2000 "bgp bestpath as-path ignore",
2001 "BGP specific commands\n"
2002 "Change the default bestpath selection\n"
2003 "AS-path attribute\n"
2004 "Ignore as-path length in selecting a route\n")
2005 {
2006 struct bgp *bgp;
2007
2008 bgp = vty->index;
2009 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
2010 bgp_recalculate_all_bestpaths (bgp);
2011
2012 return CMD_SUCCESS;
2013 }
2014
2015 DEFUN (no_bgp_bestpath_aspath_ignore,
2016 no_bgp_bestpath_aspath_ignore_cmd,
2017 "no bgp bestpath as-path ignore",
2018 NO_STR
2019 "BGP specific commands\n"
2020 "Change the default bestpath selection\n"
2021 "AS-path attribute\n"
2022 "Ignore as-path length in selecting a route\n")
2023 {
2024 struct bgp *bgp;
2025
2026 bgp = vty->index;
2027 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
2028 bgp_recalculate_all_bestpaths (bgp);
2029
2030 return CMD_SUCCESS;
2031 }
2032
2033 /* "bgp bestpath as-path confed" configuration. */
2034 DEFUN (bgp_bestpath_aspath_confed,
2035 bgp_bestpath_aspath_confed_cmd,
2036 "bgp bestpath as-path confed",
2037 "BGP specific commands\n"
2038 "Change the default bestpath selection\n"
2039 "AS-path attribute\n"
2040 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2041 {
2042 struct bgp *bgp;
2043
2044 bgp = vty->index;
2045 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
2046 bgp_recalculate_all_bestpaths (bgp);
2047
2048 return CMD_SUCCESS;
2049 }
2050
2051 DEFUN (no_bgp_bestpath_aspath_confed,
2052 no_bgp_bestpath_aspath_confed_cmd,
2053 "no bgp bestpath as-path confed",
2054 NO_STR
2055 "BGP specific commands\n"
2056 "Change the default bestpath selection\n"
2057 "AS-path attribute\n"
2058 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2059 {
2060 struct bgp *bgp;
2061
2062 bgp = vty->index;
2063 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
2064 bgp_recalculate_all_bestpaths (bgp);
2065
2066 return CMD_SUCCESS;
2067 }
2068
2069 /* "bgp bestpath as-path multipath-relax" configuration. */
2070 DEFUN (bgp_bestpath_aspath_multipath_relax,
2071 bgp_bestpath_aspath_multipath_relax_cmd,
2072 "bgp bestpath as-path multipath-relax {as-set|no-as-set}",
2073 "BGP specific commands\n"
2074 "Change the default bestpath selection\n"
2075 "AS-path attribute\n"
2076 "Allow load sharing across routes that have different AS paths (but same length)\n"
2077 "Generate an AS_SET\n"
2078 "Do not generate an AS_SET\n")
2079 {
2080 struct bgp *bgp;
2081
2082 bgp = vty->index;
2083 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
2084
2085 /* no-as-set is now the default behavior so we can silently
2086 * ignore it */
2087 if (argv[0] != NULL && strncmp (argv[0], "a", 1) == 0)
2088 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
2089 else
2090 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ;
2091
2092 bgp_recalculate_all_bestpaths (bgp);
2093
2094 return CMD_SUCCESS;
2095 }
2096
2097 DEFUN (no_bgp_bestpath_aspath_multipath_relax,
2098 no_bgp_bestpath_aspath_multipath_relax_cmd,
2099 "no bgp bestpath as-path multipath-relax {as-set|no-as-set}",
2100 NO_STR
2101 "BGP specific commands\n"
2102 "Change the default bestpath selection\n"
2103 "AS-path attribute\n"
2104 "Allow load sharing across routes that have different AS paths (but same length)\n"
2105 "Generate an AS_SET\n"
2106 "Do not generate an AS_SET\n")
2107 {
2108 struct bgp *bgp;
2109
2110 bgp = vty->index;
2111 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
2112 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
2113 bgp_recalculate_all_bestpaths (bgp);
2114
2115 return CMD_SUCCESS;
2116 }
2117
2118 /* "bgp log-neighbor-changes" configuration. */
2119 DEFUN (bgp_log_neighbor_changes,
2120 bgp_log_neighbor_changes_cmd,
2121 "bgp log-neighbor-changes",
2122 "BGP specific commands\n"
2123 "Log neighbor up/down and reset reason\n")
2124 {
2125 struct bgp *bgp;
2126
2127 bgp = vty->index;
2128 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2129 return CMD_SUCCESS;
2130 }
2131
2132 DEFUN (no_bgp_log_neighbor_changes,
2133 no_bgp_log_neighbor_changes_cmd,
2134 "no bgp log-neighbor-changes",
2135 NO_STR
2136 "BGP specific commands\n"
2137 "Log neighbor up/down and reset reason\n")
2138 {
2139 struct bgp *bgp;
2140
2141 bgp = vty->index;
2142 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2143 return CMD_SUCCESS;
2144 }
2145
2146 /* "bgp bestpath med" configuration. */
2147 DEFUN (bgp_bestpath_med,
2148 bgp_bestpath_med_cmd,
2149 "bgp bestpath med (confed|missing-as-worst)",
2150 "BGP specific commands\n"
2151 "Change the default bestpath selection\n"
2152 "MED attribute\n"
2153 "Compare MED among confederation paths\n"
2154 "Treat missing MED as the least preferred one\n")
2155 {
2156 struct bgp *bgp;
2157
2158 bgp = vty->index;
2159
2160 if (strncmp (argv[0], "confed", 1) == 0)
2161 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2162 else
2163 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2164
2165 bgp_recalculate_all_bestpaths (bgp);
2166
2167 return CMD_SUCCESS;
2168 }
2169
2170 DEFUN (bgp_bestpath_med2,
2171 bgp_bestpath_med2_cmd,
2172 "bgp bestpath med confed missing-as-worst",
2173 "BGP specific commands\n"
2174 "Change the default bestpath selection\n"
2175 "MED attribute\n"
2176 "Compare MED among confederation paths\n"
2177 "Treat missing MED as the least preferred one\n")
2178 {
2179 struct bgp *bgp;
2180
2181 bgp = vty->index;
2182 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2183 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2184 bgp_recalculate_all_bestpaths (bgp);
2185
2186 return CMD_SUCCESS;
2187 }
2188
2189 ALIAS (bgp_bestpath_med2,
2190 bgp_bestpath_med3_cmd,
2191 "bgp bestpath med missing-as-worst confed",
2192 "BGP specific commands\n"
2193 "Change the default bestpath selection\n"
2194 "MED attribute\n"
2195 "Treat missing MED as the least preferred one\n"
2196 "Compare MED among confederation paths\n")
2197
2198 DEFUN (no_bgp_bestpath_med,
2199 no_bgp_bestpath_med_cmd,
2200 "no bgp bestpath med (confed|missing-as-worst)",
2201 NO_STR
2202 "BGP specific commands\n"
2203 "Change the default bestpath selection\n"
2204 "MED attribute\n"
2205 "Compare MED among confederation paths\n"
2206 "Treat missing MED as the least preferred one\n")
2207 {
2208 struct bgp *bgp;
2209
2210 bgp = vty->index;
2211
2212 if (strncmp (argv[0], "confed", 1) == 0)
2213 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2214 else
2215 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2216
2217 bgp_recalculate_all_bestpaths (bgp);
2218
2219 return CMD_SUCCESS;
2220 }
2221
2222 DEFUN (no_bgp_bestpath_med2,
2223 no_bgp_bestpath_med2_cmd,
2224 "no bgp bestpath med confed missing-as-worst",
2225 NO_STR
2226 "BGP specific commands\n"
2227 "Change the default bestpath selection\n"
2228 "MED attribute\n"
2229 "Compare MED among confederation paths\n"
2230 "Treat missing MED as the least preferred one\n")
2231 {
2232 struct bgp *bgp;
2233
2234 bgp = vty->index;
2235 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2236 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2237 bgp_recalculate_all_bestpaths (bgp);
2238
2239 return CMD_SUCCESS;
2240 }
2241
2242 ALIAS (no_bgp_bestpath_med2,
2243 no_bgp_bestpath_med3_cmd,
2244 "no bgp bestpath med missing-as-worst confed",
2245 NO_STR
2246 "BGP specific commands\n"
2247 "Change the default bestpath selection\n"
2248 "MED attribute\n"
2249 "Treat missing MED as the least preferred one\n"
2250 "Compare MED among confederation paths\n")
2251
2252 /* "no bgp default ipv4-unicast". */
2253 DEFUN (no_bgp_default_ipv4_unicast,
2254 no_bgp_default_ipv4_unicast_cmd,
2255 "no bgp default ipv4-unicast",
2256 NO_STR
2257 "BGP specific commands\n"
2258 "Configure BGP defaults\n"
2259 "Activate ipv4-unicast for a peer by default\n")
2260 {
2261 struct bgp *bgp;
2262
2263 bgp = vty->index;
2264 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2265 return CMD_SUCCESS;
2266 }
2267
2268 DEFUN (bgp_default_ipv4_unicast,
2269 bgp_default_ipv4_unicast_cmd,
2270 "bgp default ipv4-unicast",
2271 "BGP specific commands\n"
2272 "Configure BGP defaults\n"
2273 "Activate ipv4-unicast for a peer by default\n")
2274 {
2275 struct bgp *bgp;
2276
2277 bgp = vty->index;
2278 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2279 return CMD_SUCCESS;
2280 }
2281
2282 /* Display hostname in certain command outputs */
2283 DEFUN (bgp_default_show_hostname,
2284 bgp_default_show_hostname_cmd,
2285 "bgp default show-hostname",
2286 "BGP specific commands\n"
2287 "Configure BGP defaults\n"
2288 "Show hostname in certain command ouputs\n")
2289 {
2290 struct bgp *bgp;
2291
2292 bgp = vty->index;
2293 bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
2294 return CMD_SUCCESS;
2295 }
2296
2297 DEFUN (no_bgp_default_show_hostname,
2298 no_bgp_default_show_hostname_cmd,
2299 "no bgp default show-hostname",
2300 NO_STR
2301 "BGP specific commands\n"
2302 "Configure BGP defaults\n"
2303 "Show hostname in certain command ouputs\n")
2304 {
2305 struct bgp *bgp;
2306
2307 bgp = vty->index;
2308 bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
2309 return CMD_SUCCESS;
2310 }
2311
2312 /* "bgp network import-check" configuration. */
2313 DEFUN (bgp_network_import_check,
2314 bgp_network_import_check_cmd,
2315 "bgp network import-check",
2316 "BGP specific commands\n"
2317 "BGP network command\n"
2318 "Check BGP network route exists in IGP\n")
2319 {
2320 struct bgp *bgp;
2321
2322 bgp = vty->index;
2323 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2324 {
2325 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
2326 bgp_static_redo_import_check(bgp);
2327 }
2328
2329 return CMD_SUCCESS;
2330 }
2331
2332 ALIAS_HIDDEN (bgp_network_import_check,
2333 bgp_network_import_check_exact_cmd,
2334 "bgp network import-check exact",
2335 "BGP specific commands\n"
2336 "BGP network command\n"
2337 "Check BGP network route exists in IGP\n"
2338 "Match route precisely\n")
2339
2340 DEFUN (no_bgp_network_import_check,
2341 no_bgp_network_import_check_cmd,
2342 "no bgp network import-check",
2343 NO_STR
2344 "BGP specific commands\n"
2345 "BGP network command\n"
2346 "Check BGP network route exists in IGP\n")
2347 {
2348 struct bgp *bgp;
2349
2350 bgp = vty->index;
2351 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2352 {
2353 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
2354 bgp_static_redo_import_check(bgp);
2355 }
2356
2357 return CMD_SUCCESS;
2358 }
2359
2360 DEFUN (bgp_default_local_preference,
2361 bgp_default_local_preference_cmd,
2362 "bgp default local-preference <0-4294967295>",
2363 "BGP specific commands\n"
2364 "Configure BGP defaults\n"
2365 "local preference (higher=more preferred)\n"
2366 "Configure default local preference value\n")
2367 {
2368 struct bgp *bgp;
2369 u_int32_t local_pref;
2370
2371 bgp = vty->index;
2372
2373 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
2374
2375 bgp_default_local_preference_set (bgp, local_pref);
2376 bgp_clear_star_soft_in (vty, bgp->name);
2377
2378 return CMD_SUCCESS;
2379 }
2380
2381 DEFUN (no_bgp_default_local_preference,
2382 no_bgp_default_local_preference_cmd,
2383 "no bgp default local-preference",
2384 NO_STR
2385 "BGP specific commands\n"
2386 "Configure BGP defaults\n"
2387 "local preference (higher=more preferred)\n")
2388 {
2389 struct bgp *bgp;
2390
2391 bgp = vty->index;
2392 bgp_default_local_preference_unset (bgp);
2393 bgp_clear_star_soft_in (vty, bgp->name);
2394
2395 return CMD_SUCCESS;
2396 }
2397
2398 ALIAS (no_bgp_default_local_preference,
2399 no_bgp_default_local_preference_val_cmd,
2400 "no bgp default local-preference <0-4294967295>",
2401 NO_STR
2402 "BGP specific commands\n"
2403 "Configure BGP defaults\n"
2404 "local preference (higher=more preferred)\n"
2405 "Configure default local preference value\n")
2406
2407 DEFUN (bgp_default_subgroup_pkt_queue_max,
2408 bgp_default_subgroup_pkt_queue_max_cmd,
2409 "bgp default subgroup-pkt-queue-max <20-100>",
2410 "BGP specific commands\n"
2411 "Configure BGP defaults\n"
2412 "subgroup-pkt-queue-max\n"
2413 "Configure subgroup packet queue max\n")
2414 {
2415 struct bgp *bgp;
2416 u_int32_t max_size;
2417
2418 bgp = vty->index;
2419
2420 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]);
2421
2422 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2423
2424 return CMD_SUCCESS;
2425 }
2426
2427 DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2428 no_bgp_default_subgroup_pkt_queue_max_cmd,
2429 "no bgp default subgroup-pkt-queue-max",
2430 NO_STR
2431 "BGP specific commands\n"
2432 "Configure BGP defaults\n"
2433 "subgroup-pkt-queue-max\n")
2434 {
2435 struct bgp *bgp;
2436
2437 bgp = vty->index;
2438 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2439 return CMD_SUCCESS;
2440 }
2441
2442 ALIAS (no_bgp_default_subgroup_pkt_queue_max,
2443 no_bgp_default_subgroup_pkt_queue_max_val_cmd,
2444 "no bgp default subgroup-pkt-queue-max <20-100>",
2445 NO_STR
2446 "BGP specific commands\n"
2447 "Configure BGP defaults\n"
2448 "subgroup-pkt-queue-max\n"
2449 "Configure subgroup packet queue max\n")
2450
2451 DEFUN (bgp_rr_allow_outbound_policy,
2452 bgp_rr_allow_outbound_policy_cmd,
2453 "bgp route-reflector allow-outbound-policy",
2454 "BGP specific commands\n"
2455 "Allow modifications made by out route-map\n"
2456 "on ibgp neighbors\n")
2457 {
2458 struct bgp *bgp;
2459
2460 bgp = vty->index;
2461
2462 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2463 {
2464 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
2465 update_group_announce_rrclients(bgp);
2466 bgp_clear_star_soft_out (vty, bgp->name);
2467 }
2468
2469 return CMD_SUCCESS;
2470 }
2471
2472 DEFUN (no_bgp_rr_allow_outbound_policy,
2473 no_bgp_rr_allow_outbound_policy_cmd,
2474 "no bgp route-reflector allow-outbound-policy",
2475 NO_STR
2476 "BGP specific commands\n"
2477 "Allow modifications made by out route-map\n"
2478 "on ibgp neighbors\n")
2479 {
2480 struct bgp *bgp;
2481
2482 bgp = vty->index;
2483
2484 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2485 {
2486 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
2487 update_group_announce_rrclients(bgp);
2488 bgp_clear_star_soft_out (vty, bgp->name);
2489 }
2490
2491 return CMD_SUCCESS;
2492 }
2493
2494 DEFUN (bgp_listen_limit,
2495 bgp_listen_limit_cmd,
2496 "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2497 "BGP specific commands\n"
2498 "Configure BGP defaults\n"
2499 "maximum number of BGP Dynamic Neighbors that can be created\n"
2500 "Configure Dynamic Neighbors listen limit value\n")
2501 {
2502 struct bgp *bgp;
2503 int listen_limit;
2504
2505 bgp = vty->index;
2506
2507 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0],
2508 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2509 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2510
2511 bgp_listen_limit_set (bgp, listen_limit);
2512
2513 return CMD_SUCCESS;
2514 }
2515
2516 DEFUN (no_bgp_listen_limit,
2517 no_bgp_listen_limit_cmd,
2518 "no bgp listen limit",
2519 "BGP specific commands\n"
2520 "Configure BGP defaults\n"
2521 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2522 "Configure Dynamic Neighbors listen limit value to default\n")
2523 {
2524 struct bgp *bgp;
2525
2526 bgp = vty->index;
2527 bgp_listen_limit_unset (bgp);
2528 return CMD_SUCCESS;
2529 }
2530
2531 ALIAS (no_bgp_listen_limit,
2532 no_bgp_listen_limit_val_cmd,
2533 "no bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2534 NO_STR
2535 "BGP specific commands\n"
2536 "Configure BGP defaults\n"
2537 "maximum number of BGP Dynamic Neighbors that can be created\n"
2538 "Configure Dynamic Neighbors listen limit value\n")
2539
2540 /*
2541 * Check if this listen range is already configured. Check for exact
2542 * match or overlap based on input.
2543 */
2544 static struct peer_group *
2545 listen_range_exists (struct bgp *bgp, struct prefix *range, int exact)
2546 {
2547 struct listnode *node, *nnode;
2548 struct listnode *node1, *nnode1;
2549 struct peer_group *group;
2550 struct prefix *lr;
2551 afi_t afi;
2552 int match;
2553
2554 afi = family2afi(range->family);
2555 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2556 {
2557 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1,
2558 nnode1, lr))
2559 {
2560 if (exact)
2561 match = prefix_same (range, lr);
2562 else
2563 match = (prefix_match (range, lr) || prefix_match (lr, range));
2564 if (match)
2565 return group;
2566 }
2567 }
2568
2569 return NULL;
2570 }
2571
2572 DEFUN (bgp_listen_range,
2573 bgp_listen_range_cmd,
2574 LISTEN_RANGE_CMD "peer-group WORD" ,
2575 "BGP specific commands\n"
2576 "Configure BGP Dynamic Neighbors\n"
2577 "add a listening range for Dynamic Neighbors\n"
2578 LISTEN_RANGE_ADDR_STR)
2579 {
2580 struct bgp *bgp;
2581 struct prefix range;
2582 struct peer_group *group, *existing_group;
2583 afi_t afi;
2584 int ret;
2585
2586 bgp = vty->index;
2587
2588 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2589
2590 /* Convert IP prefix string to struct prefix. */
2591 ret = str2prefix (argv[0], &range);
2592 if (! ret)
2593 {
2594 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2595 return CMD_WARNING;
2596 }
2597
2598 afi = family2afi(range.family);
2599
2600 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2601 {
2602 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2603 VTY_NEWLINE);
2604 return CMD_WARNING;
2605 }
2606
2607 apply_mask (&range);
2608
2609 /* Check if same listen range is already configured. */
2610 existing_group = listen_range_exists (bgp, &range, 1);
2611 if (existing_group)
2612 {
2613 if (strcmp (existing_group->name, argv[1]) == 0)
2614 return CMD_SUCCESS;
2615 else
2616 {
2617 vty_out (vty, "%% Same listen range is attached to peer-group %s%s",
2618 existing_group->name, VTY_NEWLINE);
2619 return CMD_WARNING;
2620 }
2621 }
2622
2623 /* Check if an overlapping listen range exists. */
2624 if (listen_range_exists (bgp, &range, 0))
2625 {
2626 vty_out (vty, "%% Listen range overlaps with existing listen range%s",
2627 VTY_NEWLINE);
2628 return CMD_WARNING;
2629 }
2630
2631 group = peer_group_lookup (bgp, argv[1]);
2632 if (! group)
2633 {
2634 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2635 return CMD_WARNING;
2636 }
2637
2638 ret = peer_group_listen_range_add(group, &range);
2639 return bgp_vty_return (vty, ret);
2640 }
2641
2642 DEFUN (no_bgp_listen_range,
2643 no_bgp_listen_range_cmd,
2644 "no bgp listen range A.B.C.D/M peer-group WORD" ,
2645 "BGP specific commands\n"
2646 "Configure BGP defaults\n"
2647 "delete a listening range for Dynamic Neighbors\n"
2648 "Remove Dynamic Neighbors listening range\n")
2649 {
2650 struct bgp *bgp;
2651 struct prefix range;
2652 struct peer_group *group;
2653 afi_t afi;
2654 int ret;
2655
2656 bgp = vty->index;
2657
2658 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2659
2660 /* Convert IP prefix string to struct prefix. */
2661 ret = str2prefix (argv[0], &range);
2662 if (! ret)
2663 {
2664 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2665 return CMD_WARNING;
2666 }
2667
2668 afi = family2afi(range.family);
2669
2670 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2671 {
2672 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2673 VTY_NEWLINE);
2674 return CMD_WARNING;
2675 }
2676
2677 apply_mask (&range);
2678
2679
2680 group = peer_group_lookup (bgp, argv[1]);
2681 if (! group)
2682 {
2683 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2684 return CMD_WARNING;
2685 }
2686
2687 ret = peer_group_listen_range_del(group, &range);
2688 return bgp_vty_return (vty, ret);
2689 }
2690
2691 int
2692 bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2693 {
2694 struct peer_group *group;
2695 struct listnode *node, *nnode, *rnode, *nrnode;
2696 struct prefix *range;
2697 afi_t afi;
2698 char buf[PREFIX2STR_BUFFER];
2699
2700 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2701 vty_out (vty, " bgp listen limit %d%s",
2702 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2703
2704 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2705 {
2706 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2707 {
2708 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2709 {
2710 prefix2str(range, buf, sizeof(buf));
2711 vty_out(vty, " bgp listen range %s peer-group %s%s",
2712 buf, group->name, VTY_NEWLINE);
2713 }
2714 }
2715 }
2716
2717 return 0;
2718 }
2719
2720
2721 DEFUN (bgp_disable_connected_route_check,
2722 bgp_disable_connected_route_check_cmd,
2723 "bgp disable-ebgp-connected-route-check",
2724 "BGP specific commands\n"
2725 "Disable checking if nexthop is connected on ebgp sessions\n")
2726 {
2727 struct bgp *bgp;
2728
2729 bgp = vty->index;
2730 bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
2731 bgp_clear_star_soft_in (vty, bgp->name);
2732
2733 return CMD_SUCCESS;
2734 }
2735
2736 DEFUN (no_bgp_disable_connected_route_check,
2737 no_bgp_disable_connected_route_check_cmd,
2738 "no bgp disable-ebgp-connected-route-check",
2739 NO_STR
2740 "BGP specific commands\n"
2741 "Disable checking if nexthop is connected on ebgp sessions\n")
2742 {
2743 struct bgp *bgp;
2744
2745 bgp = vty->index;
2746 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
2747 bgp_clear_star_soft_in (vty, bgp->name);
2748
2749 return CMD_SUCCESS;
2750 }
2751
2752
2753 static int
2754 peer_remote_as_vty (struct vty *vty, const char *peer_str,
2755 const char *as_str, afi_t afi, safi_t safi)
2756 {
2757 int ret;
2758 struct bgp *bgp;
2759 as_t as;
2760 int as_type = AS_SPECIFIED;
2761 union sockunion su;
2762
2763 bgp = vty->index;
2764
2765 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2766 {
2767 as = 0;
2768 as_type = AS_INTERNAL;
2769 }
2770 else if (strncmp(as_str, "external", strlen("external")) == 0)
2771 {
2772 as = 0;
2773 as_type = AS_EXTERNAL;
2774 }
2775 else
2776 {
2777 /* Get AS number. */
2778 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2779 }
2780
2781 /* If peer is peer group, call proper function. */
2782 ret = str2sockunion (peer_str, &su);
2783 if (ret < 0)
2784 {
2785 /* Check for peer by interface */
2786 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
2787 if (ret < 0)
2788 {
2789 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
2790 if (ret < 0)
2791 {
2792 vty_out (vty, "%% Create the peer-group or interface first%s",
2793 VTY_NEWLINE);
2794 return CMD_WARNING;
2795 }
2796 return CMD_SUCCESS;
2797 }
2798 }
2799 else
2800 {
2801 if (peer_address_self_check (bgp, &su))
2802 {
2803 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2804 VTY_NEWLINE);
2805 return CMD_WARNING;
2806 }
2807 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
2808 }
2809
2810 /* This peer belongs to peer group. */
2811 switch (ret)
2812 {
2813 case BGP_ERR_PEER_GROUP_MEMBER:
2814 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
2815 return CMD_WARNING;
2816 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
2817 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);
2818 return CMD_WARNING;
2819 }
2820 return bgp_vty_return (vty, ret);
2821 }
2822
2823 DEFUN (neighbor_remote_as,
2824 neighbor_remote_as_cmd,
2825 NEIGHBOR_CMD2 "remote-as (" CMD_AS_RANGE "|external|internal)",
2826 NEIGHBOR_STR
2827 NEIGHBOR_ADDR_STR2
2828 "Specify a BGP neighbor\n"
2829 AS_STR)
2830 {
2831 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
2832 }
2833
2834 static int
2835 peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
2836 safi_t safi, int v6only, const char *peer_group_name,
2837 const char *as_str)
2838 {
2839 as_t as = 0;
2840 int as_type = AS_UNSPECIFIED;
2841 struct bgp *bgp;
2842 struct peer *peer;
2843 struct peer_group *group;
2844 int ret = 0;
2845 union sockunion su;
2846
2847 bgp = vty->index;
2848 group = peer_group_lookup (bgp, conf_if);
2849
2850 if (group)
2851 {
2852 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2853 return CMD_WARNING;
2854 }
2855
2856 if (as_str)
2857 {
2858 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2859 {
2860 as_type = AS_INTERNAL;
2861 }
2862 else if (strncmp(as_str, "external", strlen("external")) == 0)
2863 {
2864 as_type = AS_EXTERNAL;
2865 }
2866 else
2867 {
2868 /* Get AS number. */
2869 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2870 as_type = AS_SPECIFIED;
2871 }
2872 }
2873
2874 peer = peer_lookup_by_conf_if (bgp, conf_if);
2875 if (!peer)
2876 {
2877 if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
2878 && afi == AFI_IP && safi == SAFI_UNICAST)
2879 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0,
2880 NULL);
2881 else
2882 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi,
2883 NULL);
2884
2885 if (peer && v6only)
2886 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2887
2888 /* Request zebra to initiate IPv6 RAs on this interface. We do this
2889 * any unnumbered peer in order to not worry about run-time transitions
2890 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address
2891 * gets deleted later etc.)
2892 */
2893 if (peer->ifp)
2894 {
2895 bgp_zebra_initiate_radv (bgp, peer);
2896 }
2897 peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE);
2898 }
2899 else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) ||
2900 (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)))
2901 {
2902 if (v6only)
2903 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2904 else
2905 UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2906
2907 /* v6only flag changed. Reset bgp seesion */
2908 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
2909 {
2910 peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
2911 bgp_notify_send (peer, BGP_NOTIFY_CEASE,
2912 BGP_NOTIFY_CEASE_CONFIG_CHANGE);
2913 }
2914 else
2915 bgp_session_reset(peer);
2916 }
2917
2918 if (!peer)
2919 return CMD_WARNING;
2920
2921 if (peer_group_name)
2922 {
2923 group = peer_group_lookup (bgp, peer_group_name);
2924 if (! group)
2925 {
2926 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2927 return CMD_WARNING;
2928 }
2929
2930 ret = peer_group_bind (bgp, &su, peer, group, &as);
2931 }
2932
2933 return bgp_vty_return (vty, ret);
2934 }
2935
2936 DEFUN (neighbor_interface_config,
2937 neighbor_interface_config_cmd,
2938 "neighbor WORD interface",
2939 NEIGHBOR_STR
2940 "Interface name or neighbor tag\n"
2941 "Enable BGP on interface\n")
2942 {
2943 if (argc == 2)
2944 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0,
2945 argv[1], NULL);
2946 else
2947 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0,
2948 NULL, NULL);
2949 }
2950
2951 ALIAS (neighbor_interface_config,
2952 neighbor_interface_config_peergroup_cmd,
2953 "neighbor WORD interface peer-group WORD",
2954 NEIGHBOR_STR
2955 "Interface name or neighbor tag\n"
2956 "Enable BGP on interface\n"
2957 "Member of the peer-group\n"
2958 "peer-group name\n")
2959
2960 DEFUN (neighbor_interface_config_v6only,
2961 neighbor_interface_config_v6only_cmd,
2962 "neighbor WORD interface v6only",
2963 NEIGHBOR_STR
2964 "Interface name or neighbor tag\n"
2965 "Enable BGP on interface\n"
2966 "Enable BGP with v6 link-local only\n")
2967 {
2968 if (argc == 2)
2969 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1,
2970 argv[1], NULL);
2971 else
2972 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1,
2973 NULL, NULL);
2974 }
2975
2976 ALIAS (neighbor_interface_config_v6only,
2977 neighbor_interface_config_v6only_peergroup_cmd,
2978 "neighbor WORD interface v6only peer-group WORD",
2979 NEIGHBOR_STR
2980 "Interface name or neighbor tag\n"
2981 "Enable BGP on interface\n"
2982 "Enable BGP with v6 link-local only\n"
2983 "Member of the peer-group\n"
2984 "peer-group name\n")
2985
2986 DEFUN (neighbor_interface_config_remote_as,
2987 neighbor_interface_config_remote_as_cmd,
2988 "neighbor WORD interface remote-as (" CMD_AS_RANGE "|external|internal)",
2989 NEIGHBOR_STR
2990 "Interface name or neighbor tag\n"
2991 "Enable BGP on interface\n"
2992 AS_STR)
2993 {
2994 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0,
2995 NULL, argv[1]);
2996 }
2997
2998 DEFUN (neighbor_interface_v6only_config_remote_as,
2999 neighbor_interface_v6only_config_remote_as_cmd,
3000 "neighbor WORD interface v6only remote-as (" CMD_AS_RANGE "|external|internal)",
3001 NEIGHBOR_STR
3002 "Interface name or neighbor tag\n"
3003 "Enable BGP on interface\n"
3004 AS_STR)
3005 {
3006 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1,
3007 NULL, argv[1]);
3008 }
3009
3010 DEFUN (neighbor_peer_group,
3011 neighbor_peer_group_cmd,
3012 "neighbor WORD peer-group",
3013 NEIGHBOR_STR
3014 "Interface name or neighbor tag\n"
3015 "Configure peer-group\n")
3016 {
3017 struct bgp *bgp;
3018 struct peer *peer;
3019 struct peer_group *group;
3020
3021 bgp = vty->index;
3022 peer = peer_lookup_by_conf_if (bgp, argv[0]);
3023 if (peer)
3024 {
3025 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
3026 return CMD_WARNING;
3027 }
3028
3029 group = peer_group_get (bgp, argv[0]);
3030 if (! group)
3031 return CMD_WARNING;
3032
3033 return CMD_SUCCESS;
3034 }
3035
3036 DEFUN (no_neighbor,
3037 no_neighbor_cmd,
3038 NO_NEIGHBOR_CMD2,
3039 NO_STR
3040 NEIGHBOR_STR
3041 NEIGHBOR_ADDR_STR2)
3042 {
3043 int ret;
3044 union sockunion su;
3045 struct peer_group *group;
3046 struct peer *peer;
3047 struct peer *other;
3048
3049 ret = str2sockunion (argv[0], &su);
3050 if (ret < 0)
3051 {
3052 /* look up for neighbor by interface name config. */
3053 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
3054 if (peer)
3055 {
3056 /* Request zebra to terminate IPv6 RAs on this interface. */
3057 if (peer->ifp)
3058 bgp_zebra_terminate_radv (peer->bgp, peer);
3059 peer_delete (peer);
3060 return CMD_SUCCESS;
3061 }
3062
3063 group = peer_group_lookup (vty->index, argv[0]);
3064 if (group)
3065 peer_group_delete (group);
3066 else
3067 {
3068 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
3069 return CMD_WARNING;
3070 }
3071 }
3072 else
3073 {
3074 peer = peer_lookup (vty->index, &su);
3075 if (peer)
3076 {
3077 if (peer_dynamic_neighbor (peer))
3078 {
3079 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3080 VTY_NEWLINE);
3081 return CMD_WARNING;
3082 }
3083
3084 other = peer->doppelganger;
3085 peer_delete (peer);
3086 if (other && other->status != Deleted)
3087 peer_delete(other);
3088 }
3089 }
3090
3091 return CMD_SUCCESS;
3092 }
3093
3094 ALIAS (no_neighbor,
3095 no_neighbor_remote_as_cmd,
3096 NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)",
3097 NO_STR
3098 NEIGHBOR_STR
3099 NEIGHBOR_ADDR_STR
3100 "Specify a BGP neighbor\n"
3101 AS_STR)
3102
3103 DEFUN (no_neighbor_interface_config,
3104 no_neighbor_interface_config_cmd,
3105 "no neighbor WORD interface",
3106 NO_STR
3107 NEIGHBOR_STR
3108 "Interface name\n"
3109 "Configure BGP on interface\n")
3110 {
3111 struct peer *peer;
3112
3113 /* look up for neighbor by interface name config. */
3114 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
3115 if (peer)
3116 {
3117 /* Request zebra to terminate IPv6 RAs on this interface. */
3118 if (peer->ifp)
3119 bgp_zebra_terminate_radv (peer->bgp, peer);
3120 peer_delete (peer);
3121 }
3122 else
3123 {
3124 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
3125 return CMD_WARNING;
3126 }
3127 return CMD_SUCCESS;
3128 }
3129
3130 ALIAS (no_neighbor_interface_config,
3131 no_neighbor_interface_config_peergroup_cmd,
3132 "no neighbor WORD interface peer-group WORD",
3133 NO_STR
3134 NEIGHBOR_STR
3135 "Interface name\n"
3136 "Configure BGP on interface\n"
3137 "Member of the peer-group\n"
3138 "peer-group name\n")
3139
3140 ALIAS (no_neighbor_interface_config,
3141 no_neighbor_interface_config_v6only_cmd,
3142 "no neighbor WORD interface v6only",
3143 NO_STR
3144 NEIGHBOR_STR
3145 "Interface name\n"
3146 "Configure BGP on interface\n"
3147 "Enable BGP with v6 link-local only\n")
3148
3149 ALIAS (no_neighbor_interface_config,
3150 no_neighbor_interface_config_v6only_peergroup_cmd,
3151 "no neighbor WORD interface v6only peer-group WORD",
3152 NO_STR
3153 NEIGHBOR_STR
3154 "Interface name\n"
3155 "Configure BGP on interface\n"
3156 "Enable BGP with v6 link-local only\n"
3157 "Member of the peer-group\n"
3158 "peer-group name\n")
3159
3160 ALIAS (no_neighbor_interface_config,
3161 no_neighbor_interface_config_remote_as_cmd,
3162 "no neighbor WORD interface remote-as (" CMD_AS_RANGE "|internal|external)",
3163 NO_STR
3164 NEIGHBOR_STR
3165 "Interface name\n"
3166 "Configure BGP on interface\n"
3167 AS_STR)
3168
3169 ALIAS (no_neighbor_interface_config,
3170 no_neighbor_interface_config_v6only_remote_as_cmd,
3171 "no neighbor WORD interface v6only remote-as (" CMD_AS_RANGE "|internal|external)",
3172 NO_STR
3173 NEIGHBOR_STR
3174 "Interface name\n"
3175 "Configure BGP on interface\n"
3176 "Enable BGP with v6 link-local only\n"
3177 AS_STR)
3178
3179 DEFUN (no_neighbor_peer_group,
3180 no_neighbor_peer_group_cmd,
3181 "no neighbor WORD peer-group",
3182 NO_STR
3183 NEIGHBOR_STR
3184 "Neighbor tag\n"
3185 "Configure peer-group\n")
3186 {
3187 struct peer_group *group;
3188
3189 group = peer_group_lookup (vty->index, argv[0]);
3190 if (group)
3191 peer_group_delete (group);
3192 else
3193 {
3194 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
3195 return CMD_WARNING;
3196 }
3197 return CMD_SUCCESS;
3198 }
3199
3200 DEFUN (no_neighbor_interface_peer_group_remote_as,
3201 no_neighbor_interface_peer_group_remote_as_cmd,
3202 "no neighbor WORD remote-as (" CMD_AS_RANGE "|internal|external)",
3203 NO_STR
3204 NEIGHBOR_STR
3205 "Interface name or neighbor tag\n"
3206 "Specify a BGP neighbor\n"
3207 AS_STR)
3208 {
3209 struct peer_group *group;
3210 struct peer *peer;
3211
3212 /* look up for neighbor by interface name config. */
3213 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
3214 if (peer)
3215 {
3216 peer_as_change (peer, 0, AS_SPECIFIED);
3217 return CMD_SUCCESS;
3218 }
3219
3220 group = peer_group_lookup (vty->index, argv[0]);
3221 if (group)
3222 peer_group_remote_as_delete (group);
3223 else
3224 {
3225 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
3226 return CMD_WARNING;
3227 }
3228 return CMD_SUCCESS;
3229 }
3230
3231 DEFUN (neighbor_local_as,
3232 neighbor_local_as_cmd,
3233 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
3234 NEIGHBOR_STR
3235 NEIGHBOR_ADDR_STR2
3236 "Specify a local-as number\n"
3237 "AS number used as local AS\n")
3238 {
3239 struct peer *peer;
3240 int ret;
3241 as_t as;
3242 peer = peer_and_group_lookup_vty (vty, argv[0]);
3243 if (! peer)
3244 return CMD_WARNING;
3245
3246 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX);
3247 ret = peer_local_as_set (peer, as, 0, 0);
3248 return bgp_vty_return (vty, ret);
3249 }
3250
3251 DEFUN (neighbor_local_as_no_prepend,
3252 neighbor_local_as_no_prepend_cmd,
3253 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
3254 NEIGHBOR_STR
3255 NEIGHBOR_ADDR_STR2
3256 "Specify a local-as number\n"
3257 "AS number used as local AS\n"
3258 "Do not prepend local-as to updates from ebgp peers\n")
3259 {
3260 struct peer *peer;
3261 int ret;
3262 as_t as;
3263
3264 peer = peer_and_group_lookup_vty (vty, argv[0]);
3265 if (! peer)
3266 return CMD_WARNING;
3267
3268 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX);
3269 ret = peer_local_as_set (peer, as, 1, 0);
3270 return bgp_vty_return (vty, ret);
3271 }
3272
3273 DEFUN (neighbor_local_as_no_prepend_replace_as,
3274 neighbor_local_as_no_prepend_replace_as_cmd,
3275 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3276 NEIGHBOR_STR
3277 NEIGHBOR_ADDR_STR2
3278 "Specify a local-as number\n"
3279 "AS number used as local AS\n"
3280 "Do not prepend local-as to updates from ebgp peers\n"
3281 "Do not prepend local-as to updates from ibgp peers\n")
3282 {
3283 struct peer *peer;
3284 int ret;
3285 as_t as;
3286
3287 peer = peer_and_group_lookup_vty (vty, argv[0]);
3288 if (! peer)
3289 return CMD_WARNING;
3290
3291 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX);
3292 ret = peer_local_as_set (peer, as, 1, 1);
3293 return bgp_vty_return (vty, ret);
3294 }
3295
3296
3297 DEFUN (no_neighbor_local_as,
3298 no_neighbor_local_as_cmd,
3299 NO_NEIGHBOR_CMD2 "local-as",
3300 NO_STR
3301 NEIGHBOR_STR
3302 NEIGHBOR_ADDR_STR2
3303 "Specify a local-as number\n")
3304 {
3305 struct peer *peer;
3306 int ret;
3307
3308 peer = peer_and_group_lookup_vty (vty, argv[0]);
3309 if (! peer)
3310 return CMD_WARNING;
3311
3312 ret = peer_local_as_unset (peer);
3313 return bgp_vty_return (vty, ret);
3314 }
3315
3316 ALIAS (no_neighbor_local_as,
3317 no_neighbor_local_as_val_cmd,
3318 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
3319 NO_STR
3320 NEIGHBOR_STR
3321 NEIGHBOR_ADDR_STR2
3322 "Specify a local-as number\n"
3323 "AS number used as local AS\n")
3324
3325 ALIAS (no_neighbor_local_as,
3326 no_neighbor_local_as_val2_cmd,
3327 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
3328 NO_STR
3329 NEIGHBOR_STR
3330 NEIGHBOR_ADDR_STR2
3331 "Specify a local-as number\n"
3332 "AS number used as local AS\n"
3333 "Do not prepend local-as to updates from ebgp peers\n")
3334
3335 ALIAS (no_neighbor_local_as,
3336 no_neighbor_local_as_val3_cmd,
3337 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3338 NO_STR
3339 NEIGHBOR_STR
3340 NEIGHBOR_ADDR_STR2
3341 "Specify a local-as number\n"
3342 "AS number used as local AS\n"
3343 "Do not prepend local-as to updates from ebgp peers\n"
3344 "Do not prepend local-as to updates from ibgp peers\n")
3345
3346 DEFUN (neighbor_solo,
3347 neighbor_solo_cmd,
3348 NEIGHBOR_CMD2 "solo",
3349 NEIGHBOR_STR
3350 NEIGHBOR_ADDR_STR2
3351 "Solo peer - part of its own update group\n")
3352 {
3353 struct peer *peer;
3354 int ret;
3355
3356 peer = peer_and_group_lookup_vty (vty, argv[0]);
3357 if (! peer)
3358 return CMD_WARNING;
3359
3360 ret = update_group_adjust_soloness(peer, 1);
3361 return bgp_vty_return (vty, ret);
3362 }
3363
3364 DEFUN (no_neighbor_solo,
3365 no_neighbor_solo_cmd,
3366 NO_NEIGHBOR_CMD2 "solo",
3367 NO_STR
3368 NEIGHBOR_STR
3369 NEIGHBOR_ADDR_STR2
3370 "Solo peer - part of its own update group\n")
3371 {
3372 struct peer *peer;
3373 int ret;
3374
3375 peer = peer_and_group_lookup_vty (vty, argv[0]);
3376 if (! peer)
3377 return CMD_WARNING;
3378
3379 ret = update_group_adjust_soloness(peer, 0);
3380 return bgp_vty_return (vty, ret);
3381 }
3382
3383 DEFUN (neighbor_password,
3384 neighbor_password_cmd,
3385 NEIGHBOR_CMD2 "password LINE",
3386 NEIGHBOR_STR
3387 NEIGHBOR_ADDR_STR2
3388 "Set a password\n"
3389 "The password\n")
3390 {
3391 struct peer *peer;
3392 int ret;
3393
3394 peer = peer_and_group_lookup_vty (vty, argv[0]);
3395 if (! peer)
3396 return CMD_WARNING;
3397
3398 ret = peer_password_set (peer, argv[1]);
3399 return bgp_vty_return (vty, ret);
3400 }
3401
3402 DEFUN (no_neighbor_password,
3403 no_neighbor_password_cmd,
3404 NO_NEIGHBOR_CMD2 "password",
3405 NO_STR
3406 NEIGHBOR_STR
3407 NEIGHBOR_ADDR_STR2
3408 "Set a password\n")
3409 {
3410 struct peer *peer;
3411 int ret;
3412
3413 peer = peer_and_group_lookup_vty (vty, argv[0]);
3414 if (! peer)
3415 return CMD_WARNING;
3416
3417 ret = peer_password_unset (peer);
3418 return bgp_vty_return (vty, ret);
3419 }
3420
3421 ALIAS (no_neighbor_password,
3422 no_neighbor_password_val_cmd,
3423 NO_NEIGHBOR_CMD2 "password LINE",
3424 NO_STR
3425 NEIGHBOR_STR
3426 NEIGHBOR_ADDR_STR2
3427 "Set a password\n"
3428 "The password\n")
3429
3430 DEFUN (neighbor_activate,
3431 neighbor_activate_cmd,
3432 NEIGHBOR_CMD2 "activate",
3433 NEIGHBOR_STR
3434 NEIGHBOR_ADDR_STR2
3435 "Enable the Address Family for this Neighbor\n")
3436 {
3437 int ret;
3438 struct peer *peer;
3439
3440 peer = peer_and_group_lookup_vty (vty, argv[0]);
3441 if (! peer)
3442 return CMD_WARNING;
3443
3444 ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3445
3446 if (ret)
3447 return CMD_WARNING;
3448 return CMD_SUCCESS;
3449 }
3450
3451 DEFUN (no_neighbor_activate,
3452 no_neighbor_activate_cmd,
3453 NO_NEIGHBOR_CMD2 "activate",
3454 NO_STR
3455 NEIGHBOR_STR
3456 NEIGHBOR_ADDR_STR2
3457 "Enable the Address Family for this Neighbor\n")
3458 {
3459 int ret;
3460 struct peer *peer;
3461
3462 /* Lookup peer. */
3463 peer = peer_and_group_lookup_vty (vty, argv[0]);
3464 if (! peer)
3465 return CMD_WARNING;
3466
3467 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3468
3469 if (ret)
3470 return CMD_WARNING;
3471 return CMD_SUCCESS;
3472 }
3473
3474 DEFUN (neighbor_set_peer_group,
3475 neighbor_set_peer_group_cmd,
3476 NEIGHBOR_CMD2 "peer-group WORD",
3477 NEIGHBOR_STR
3478 NEIGHBOR_ADDR_STR2
3479 "Member of the peer-group\n"
3480 "peer-group name\n")
3481 {
3482 int ret;
3483 as_t as;
3484 union sockunion su;
3485 struct bgp *bgp;
3486 struct peer *peer;
3487 struct peer_group *group;
3488
3489 bgp = vty->index;
3490 peer = NULL;
3491
3492 ret = str2sockunion (argv[0], &su);
3493 if (ret < 0)
3494 {
3495 peer = peer_lookup_by_conf_if (bgp, argv[0]);
3496 if (!peer)
3497 {
3498 vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE);
3499 return CMD_WARNING;
3500 }
3501 }
3502 else
3503 {
3504 if (peer_address_self_check (bgp, &su))
3505 {
3506 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3507 VTY_NEWLINE);
3508 return CMD_WARNING;
3509 }
3510
3511 /* Disallow for dynamic neighbor. */
3512 peer = peer_lookup (bgp, &su);
3513 if (peer && peer_dynamic_neighbor (peer))
3514 {
3515 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3516 VTY_NEWLINE);
3517 return CMD_WARNING;
3518 }
3519 }
3520
3521 group = peer_group_lookup (bgp, argv[1]);
3522 if (! group)
3523 {
3524 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3525 return CMD_WARNING;
3526 }
3527
3528 ret = peer_group_bind (bgp, &su, peer, group, &as);
3529
3530 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3531 {
3532 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);
3533 return CMD_WARNING;
3534 }
3535
3536 return bgp_vty_return (vty, ret);
3537 }
3538
3539 DEFUN (no_neighbor_set_peer_group,
3540 no_neighbor_set_peer_group_cmd,
3541 NO_NEIGHBOR_CMD2 "peer-group WORD",
3542 NO_STR
3543 NEIGHBOR_STR
3544 NEIGHBOR_ADDR_STR2
3545 "Member of the peer-group\n"
3546 "peer-group name\n")
3547 {
3548 int ret;
3549 struct bgp *bgp;
3550 struct peer *peer;
3551 struct peer_group *group;
3552
3553 bgp = vty->index;
3554
3555 peer = peer_lookup_vty (vty, argv[0]);
3556 if (! peer)
3557 return CMD_WARNING;
3558
3559 group = peer_group_lookup (bgp, argv[1]);
3560 if (! group)
3561 {
3562 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3563 return CMD_WARNING;
3564 }
3565
3566 ret = peer_group_unbind (bgp, peer, group);
3567
3568 return bgp_vty_return (vty, ret);
3569 }
3570
3571 static int
3572 peer_flag_modify_vty (struct vty *vty, const char *ip_str,
3573 u_int16_t flag, int set)
3574 {
3575 int ret;
3576 struct peer *peer;
3577
3578 peer = peer_and_group_lookup_vty (vty, ip_str);
3579 if (! peer)
3580 return CMD_WARNING;
3581
3582 /*
3583 * If 'neighbor <interface>', then this is for directly connected peers,
3584 * we should not accept disable-connected-check.
3585 */
3586 if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) {
3587 vty_out (vty, "%s is directly connected peer, cannot accept disable-"
3588 "connected-check%s", ip_str, VTY_NEWLINE);
3589 return CMD_WARNING;
3590 }
3591
3592 if (set)
3593 ret = peer_flag_set (peer, flag);
3594 else
3595 ret = peer_flag_unset (peer, flag);
3596
3597 return bgp_vty_return (vty, ret);
3598 }
3599
3600 static int
3601 peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
3602 {
3603 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3604 }
3605
3606 static int
3607 peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
3608 {
3609 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3610 }
3611
3612 /* neighbor passive. */
3613 DEFUN (neighbor_passive,
3614 neighbor_passive_cmd,
3615 NEIGHBOR_CMD2 "passive",
3616 NEIGHBOR_STR
3617 NEIGHBOR_ADDR_STR2
3618 "Don't send open messages to this neighbor\n")
3619 {
3620 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3621 }
3622
3623 DEFUN (no_neighbor_passive,
3624 no_neighbor_passive_cmd,
3625 NO_NEIGHBOR_CMD2 "passive",
3626 NO_STR
3627 NEIGHBOR_STR
3628 NEIGHBOR_ADDR_STR2
3629 "Don't send open messages to this neighbor\n")
3630 {
3631 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3632 }
3633
3634 /* neighbor shutdown. */
3635 DEFUN (neighbor_shutdown,
3636 neighbor_shutdown_cmd,
3637 NEIGHBOR_CMD2 "shutdown",
3638 NEIGHBOR_STR
3639 NEIGHBOR_ADDR_STR2
3640 "Administratively shut down this neighbor\n")
3641 {
3642 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3643 }
3644
3645 DEFUN (no_neighbor_shutdown,
3646 no_neighbor_shutdown_cmd,
3647 NO_NEIGHBOR_CMD2 "shutdown",
3648 NO_STR
3649 NEIGHBOR_STR
3650 NEIGHBOR_ADDR_STR2
3651 "Administratively shut down this neighbor\n")
3652 {
3653 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3654 }
3655
3656 /* neighbor capability dynamic. */
3657 DEFUN (neighbor_capability_dynamic,
3658 neighbor_capability_dynamic_cmd,
3659 NEIGHBOR_CMD2 "capability dynamic",
3660 NEIGHBOR_STR
3661 NEIGHBOR_ADDR_STR2
3662 "Advertise capability to the peer\n"
3663 "Advertise dynamic capability to this neighbor\n")
3664 {
3665 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3666 }
3667
3668 DEFUN (no_neighbor_capability_dynamic,
3669 no_neighbor_capability_dynamic_cmd,
3670 NO_NEIGHBOR_CMD2 "capability dynamic",
3671 NO_STR
3672 NEIGHBOR_STR
3673 NEIGHBOR_ADDR_STR2
3674 "Advertise capability to the peer\n"
3675 "Advertise dynamic capability to this neighbor\n")
3676 {
3677 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3678 }
3679
3680 /* neighbor dont-capability-negotiate */
3681 DEFUN (neighbor_dont_capability_negotiate,
3682 neighbor_dont_capability_negotiate_cmd,
3683 NEIGHBOR_CMD2 "dont-capability-negotiate",
3684 NEIGHBOR_STR
3685 NEIGHBOR_ADDR_STR2
3686 "Do not perform capability negotiation\n")
3687 {
3688 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3689 }
3690
3691 DEFUN (no_neighbor_dont_capability_negotiate,
3692 no_neighbor_dont_capability_negotiate_cmd,
3693 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
3694 NO_STR
3695 NEIGHBOR_STR
3696 NEIGHBOR_ADDR_STR2
3697 "Do not perform capability negotiation\n")
3698 {
3699 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3700 }
3701
3702 /* neighbor capability extended next hop encoding */
3703 DEFUN (neighbor_capability_enhe,
3704 neighbor_capability_enhe_cmd,
3705 NEIGHBOR_CMD2 "capability extended-nexthop",
3706 NEIGHBOR_STR
3707 NEIGHBOR_ADDR_STR2
3708 "Advertise capability to the peer\n"
3709 "Advertise extended next-hop capability to the peer\n")
3710 {
3711 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3712 }
3713
3714 DEFUN (no_neighbor_capability_enhe,
3715 no_neighbor_capability_enhe_cmd,
3716 NO_NEIGHBOR_CMD2 "capability extended-nexthop",
3717 NO_STR
3718 NEIGHBOR_STR
3719 NEIGHBOR_ADDR_STR2
3720 "Advertise capability to the peer\n"
3721 "Advertise extended next-hop capability to the peer\n")
3722 {
3723 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3724 }
3725
3726 static int
3727 peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
3728 safi_t safi, u_int32_t flag, int set)
3729 {
3730 int ret;
3731 struct peer *peer;
3732
3733 peer = peer_and_group_lookup_vty (vty, peer_str);
3734 if (! peer)
3735 return CMD_WARNING;
3736
3737 if (set)
3738 ret = peer_af_flag_set (peer, afi, safi, flag);
3739 else
3740 ret = peer_af_flag_unset (peer, afi, safi, flag);
3741
3742 return bgp_vty_return (vty, ret);
3743 }
3744
3745 static int
3746 peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
3747 safi_t safi, u_int32_t flag)
3748 {
3749 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3750 }
3751
3752 static int
3753 peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
3754 safi_t safi, u_int32_t flag)
3755 {
3756 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3757 }
3758
3759 /* neighbor capability orf prefix-list. */
3760 DEFUN (neighbor_capability_orf_prefix,
3761 neighbor_capability_orf_prefix_cmd,
3762 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3763 NEIGHBOR_STR
3764 NEIGHBOR_ADDR_STR2
3765 "Advertise capability to the peer\n"
3766 "Advertise ORF capability to the peer\n"
3767 "Advertise prefixlist ORF capability to this neighbor\n"
3768 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3769 "Capability to RECEIVE the ORF from this neighbor\n"
3770 "Capability to SEND the ORF to this neighbor\n")
3771 {
3772 u_int16_t flag = 0;
3773
3774 if (strncmp (argv[1], "s", 1) == 0)
3775 flag = PEER_FLAG_ORF_PREFIX_SM;
3776 else if (strncmp (argv[1], "r", 1) == 0)
3777 flag = PEER_FLAG_ORF_PREFIX_RM;
3778 else if (strncmp (argv[1], "b", 1) == 0)
3779 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3780 else
3781 return CMD_WARNING;
3782
3783 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3784 bgp_node_safi (vty), flag);
3785 }
3786
3787 DEFUN (no_neighbor_capability_orf_prefix,
3788 no_neighbor_capability_orf_prefix_cmd,
3789 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3790 NO_STR
3791 NEIGHBOR_STR
3792 NEIGHBOR_ADDR_STR2
3793 "Advertise capability to the peer\n"
3794 "Advertise ORF capability to the peer\n"
3795 "Advertise prefixlist ORF capability to this neighbor\n"
3796 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3797 "Capability to RECEIVE the ORF from this neighbor\n"
3798 "Capability to SEND the ORF to this neighbor\n")
3799 {
3800 u_int16_t flag = 0;
3801
3802 if (strncmp (argv[1], "s", 1) == 0)
3803 flag = PEER_FLAG_ORF_PREFIX_SM;
3804 else if (strncmp (argv[1], "r", 1) == 0)
3805 flag = PEER_FLAG_ORF_PREFIX_RM;
3806 else if (strncmp (argv[1], "b", 1) == 0)
3807 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3808 else
3809 return CMD_WARNING;
3810
3811 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3812 bgp_node_safi (vty), flag);
3813 }
3814
3815 /* neighbor next-hop-self. */
3816 DEFUN (neighbor_nexthop_self,
3817 neighbor_nexthop_self_cmd,
3818 NEIGHBOR_CMD2 "next-hop-self",
3819 NEIGHBOR_STR
3820 NEIGHBOR_ADDR_STR2
3821 "Disable the next hop calculation for this neighbor\n")
3822 {
3823 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3824 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3825 }
3826
3827 /* neighbor next-hop-self. */
3828 DEFUN (neighbor_nexthop_self_force,
3829 neighbor_nexthop_self_force_cmd,
3830 NEIGHBOR_CMD2 "next-hop-self force",
3831 NEIGHBOR_STR
3832 NEIGHBOR_ADDR_STR2
3833 "Disable the next hop calculation for this neighbor\n"
3834 "Set the next hop to self for reflected routes\n")
3835 {
3836 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3837 bgp_node_safi (vty),
3838 PEER_FLAG_FORCE_NEXTHOP_SELF);
3839 }
3840
3841 DEFUN (no_neighbor_nexthop_self,
3842 no_neighbor_nexthop_self_cmd,
3843 NO_NEIGHBOR_CMD2 "next-hop-self",
3844 NO_STR
3845 NEIGHBOR_STR
3846 NEIGHBOR_ADDR_STR2
3847 "Disable the next hop calculation for this neighbor\n")
3848 {
3849 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3850 bgp_node_safi (vty),
3851 PEER_FLAG_NEXTHOP_SELF);
3852 }
3853
3854 DEFUN (no_neighbor_nexthop_self_force,
3855 no_neighbor_nexthop_self_force_cmd,
3856 NO_NEIGHBOR_CMD2 "next-hop-self force",
3857 NO_STR
3858 NEIGHBOR_STR
3859 NEIGHBOR_ADDR_STR2
3860 "Disable the next hop calculation for this neighbor\n"
3861 "Set the next hop to self for reflected routes\n")
3862 {
3863 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3864 bgp_node_safi (vty),
3865 PEER_FLAG_FORCE_NEXTHOP_SELF);
3866 }
3867
3868 /* neighbor as-override */
3869 DEFUN (neighbor_as_override,
3870 neighbor_as_override_cmd,
3871 NEIGHBOR_CMD2 "as-override",
3872 NEIGHBOR_STR
3873 NEIGHBOR_ADDR_STR2
3874 "Override ASNs in outbound updates if aspath equals remote-as\n")
3875 {
3876 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3877 bgp_node_safi (vty),
3878 PEER_FLAG_AS_OVERRIDE);
3879 }
3880
3881 DEFUN (no_neighbor_as_override,
3882 no_neighbor_as_override_cmd,
3883 NO_NEIGHBOR_CMD2 "as-override",
3884 NO_STR
3885 NEIGHBOR_STR
3886 NEIGHBOR_ADDR_STR2
3887 "Override ASNs in outbound updates if aspath equals remote-as\n")
3888 {
3889 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3890 bgp_node_safi (vty),
3891 PEER_FLAG_AS_OVERRIDE);
3892 }
3893
3894 /* neighbor remove-private-AS. */
3895 DEFUN (neighbor_remove_private_as,
3896 neighbor_remove_private_as_cmd,
3897 NEIGHBOR_CMD2 "remove-private-AS",
3898 NEIGHBOR_STR
3899 NEIGHBOR_ADDR_STR2
3900 "Remove private ASNs in outbound updates\n")
3901 {
3902 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3903 bgp_node_safi (vty),
3904 PEER_FLAG_REMOVE_PRIVATE_AS);
3905 }
3906
3907 DEFUN (neighbor_remove_private_as_all,
3908 neighbor_remove_private_as_all_cmd,
3909 NEIGHBOR_CMD2 "remove-private-AS all",
3910 NEIGHBOR_STR
3911 NEIGHBOR_ADDR_STR2
3912 "Remove private ASNs in outbound updates\n"
3913 "Apply to all AS numbers")
3914 {
3915 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3916 bgp_node_safi (vty),
3917 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3918 }
3919
3920 DEFUN (neighbor_remove_private_as_replace_as,
3921 neighbor_remove_private_as_replace_as_cmd,
3922 NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3923 NEIGHBOR_STR
3924 NEIGHBOR_ADDR_STR2
3925 "Remove private ASNs in outbound updates\n"
3926 "Replace private ASNs with our ASN in outbound updates\n")
3927 {
3928 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3929 bgp_node_safi (vty),
3930 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3931 }
3932
3933 DEFUN (neighbor_remove_private_as_all_replace_as,
3934 neighbor_remove_private_as_all_replace_as_cmd,
3935 NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3936 NEIGHBOR_STR
3937 NEIGHBOR_ADDR_STR2
3938 "Remove private ASNs in outbound updates\n"
3939 "Apply to all AS numbers"
3940 "Replace private ASNs with our ASN in outbound updates\n")
3941 {
3942 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3943 bgp_node_safi (vty),
3944 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
3945 }
3946
3947 DEFUN (no_neighbor_remove_private_as,
3948 no_neighbor_remove_private_as_cmd,
3949 NO_NEIGHBOR_CMD2 "remove-private-AS",
3950 NO_STR
3951 NEIGHBOR_STR
3952 NEIGHBOR_ADDR_STR2
3953 "Remove private ASNs in outbound updates\n")
3954 {
3955 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3956 bgp_node_safi (vty),
3957 PEER_FLAG_REMOVE_PRIVATE_AS);
3958 }
3959
3960 DEFUN (no_neighbor_remove_private_as_all,
3961 no_neighbor_remove_private_as_all_cmd,
3962 NO_NEIGHBOR_CMD2 "remove-private-AS all",
3963 NO_STR
3964 NEIGHBOR_STR
3965 NEIGHBOR_ADDR_STR2
3966 "Remove private ASNs in outbound updates\n"
3967 "Apply to all AS numbers")
3968 {
3969 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3970 bgp_node_safi (vty),
3971 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3972 }
3973
3974 DEFUN (no_neighbor_remove_private_as_replace_as,
3975 no_neighbor_remove_private_as_replace_as_cmd,
3976 NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3977 NO_STR
3978 NEIGHBOR_STR
3979 NEIGHBOR_ADDR_STR2
3980 "Remove private ASNs in outbound updates\n"
3981 "Replace private ASNs with our ASN in outbound updates\n")
3982 {
3983 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3984 bgp_node_safi (vty),
3985 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3986 }
3987
3988 DEFUN (no_neighbor_remove_private_as_all_replace_as,
3989 no_neighbor_remove_private_as_all_replace_as_cmd,
3990 NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3991 NO_STR
3992 NEIGHBOR_STR
3993 NEIGHBOR_ADDR_STR2
3994 "Remove private ASNs in outbound updates\n"
3995 "Apply to all AS numbers"
3996 "Replace private ASNs with our ASN in outbound updates\n")
3997 {
3998 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3999 bgp_node_safi (vty),
4000 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
4001 }
4002
4003
4004 /* neighbor send-community. */
4005 DEFUN (neighbor_send_community,
4006 neighbor_send_community_cmd,
4007 NEIGHBOR_CMD2 "send-community",
4008 NEIGHBOR_STR
4009 NEIGHBOR_ADDR_STR2
4010 "Send Community attribute to this neighbor\n")
4011 {
4012 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4013 bgp_node_safi (vty),
4014 PEER_FLAG_SEND_COMMUNITY);
4015 }
4016
4017 DEFUN (no_neighbor_send_community,
4018 no_neighbor_send_community_cmd,
4019 NO_NEIGHBOR_CMD2 "send-community",
4020 NO_STR
4021 NEIGHBOR_STR
4022 NEIGHBOR_ADDR_STR2
4023 "Send Community attribute to this neighbor\n")
4024 {
4025 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4026 bgp_node_safi (vty),
4027 PEER_FLAG_SEND_COMMUNITY);
4028 }
4029
4030 /* neighbor send-community extended. */
4031 DEFUN (neighbor_send_community_type,
4032 neighbor_send_community_type_cmd,
4033 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
4034 NEIGHBOR_STR
4035 NEIGHBOR_ADDR_STR2
4036 "Send Community attribute to this neighbor\n"
4037 "Send Standard and Extended Community attributes\n"
4038 "Send Extended Community attributes\n"
4039 "Send Standard Community attributes\n")
4040 {
4041 if (strncmp (argv[1], "s", 1) == 0)
4042 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4043 bgp_node_safi (vty),
4044 PEER_FLAG_SEND_COMMUNITY);
4045 if (strncmp (argv[1], "e", 1) == 0)
4046 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4047 bgp_node_safi (vty),
4048 PEER_FLAG_SEND_EXT_COMMUNITY);
4049
4050 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4051 bgp_node_safi (vty),
4052 (PEER_FLAG_SEND_COMMUNITY|
4053 PEER_FLAG_SEND_EXT_COMMUNITY));
4054 }
4055
4056 DEFUN (no_neighbor_send_community_type,
4057 no_neighbor_send_community_type_cmd,
4058 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
4059 NO_STR
4060 NEIGHBOR_STR
4061 NEIGHBOR_ADDR_STR2
4062 "Send Community attribute to this neighbor\n"
4063 "Send Standard and Extended Community attributes\n"
4064 "Send Extended Community attributes\n"
4065 "Send Standard Community attributes\n")
4066 {
4067 if (strncmp (argv[1], "s", 1) == 0)
4068 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4069 bgp_node_safi (vty),
4070 PEER_FLAG_SEND_COMMUNITY);
4071 if (strncmp (argv[1], "e", 1) == 0)
4072 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4073 bgp_node_safi (vty),
4074 PEER_FLAG_SEND_EXT_COMMUNITY);
4075
4076 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4077 bgp_node_safi (vty),
4078 (PEER_FLAG_SEND_COMMUNITY |
4079 PEER_FLAG_SEND_EXT_COMMUNITY));
4080 }
4081
4082 /* neighbor soft-reconfig. */
4083 DEFUN (neighbor_soft_reconfiguration,
4084 neighbor_soft_reconfiguration_cmd,
4085 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
4086 NEIGHBOR_STR
4087 NEIGHBOR_ADDR_STR2
4088 "Per neighbor soft reconfiguration\n"
4089 "Allow inbound soft reconfiguration for this neighbor\n")
4090 {
4091 return peer_af_flag_set_vty (vty, argv[0],
4092 bgp_node_afi (vty), bgp_node_safi (vty),
4093 PEER_FLAG_SOFT_RECONFIG);
4094 }
4095
4096 DEFUN (no_neighbor_soft_reconfiguration,
4097 no_neighbor_soft_reconfiguration_cmd,
4098 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
4099 NO_STR
4100 NEIGHBOR_STR
4101 NEIGHBOR_ADDR_STR2
4102 "Per neighbor soft reconfiguration\n"
4103 "Allow inbound soft reconfiguration for this neighbor\n")
4104 {
4105 return peer_af_flag_unset_vty (vty, argv[0],
4106 bgp_node_afi (vty), bgp_node_safi (vty),
4107 PEER_FLAG_SOFT_RECONFIG);
4108 }
4109
4110 DEFUN (neighbor_route_reflector_client,
4111 neighbor_route_reflector_client_cmd,
4112 NEIGHBOR_CMD2 "route-reflector-client",
4113 NEIGHBOR_STR
4114 NEIGHBOR_ADDR_STR2
4115 "Configure a neighbor as Route Reflector client\n")
4116 {
4117 struct peer *peer;
4118
4119
4120 peer = peer_and_group_lookup_vty (vty, argv[0]);
4121 if (! peer)
4122 return CMD_WARNING;
4123
4124 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4125 bgp_node_safi (vty),
4126 PEER_FLAG_REFLECTOR_CLIENT);
4127 }
4128
4129 DEFUN (no_neighbor_route_reflector_client,
4130 no_neighbor_route_reflector_client_cmd,
4131 NO_NEIGHBOR_CMD2 "route-reflector-client",
4132 NO_STR
4133 NEIGHBOR_STR
4134 NEIGHBOR_ADDR_STR2
4135 "Configure a neighbor as Route Reflector client\n")
4136 {
4137 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4138 bgp_node_safi (vty),
4139 PEER_FLAG_REFLECTOR_CLIENT);
4140 }
4141
4142 /* neighbor route-server-client. */
4143 DEFUN (neighbor_route_server_client,
4144 neighbor_route_server_client_cmd,
4145 NEIGHBOR_CMD2 "route-server-client",
4146 NEIGHBOR_STR
4147 NEIGHBOR_ADDR_STR2
4148 "Configure a neighbor as Route Server client\n")
4149 {
4150 struct peer *peer;
4151
4152 peer = peer_and_group_lookup_vty (vty, argv[0]);
4153 if (! peer)
4154 return CMD_WARNING;
4155 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4156 bgp_node_safi (vty),
4157 PEER_FLAG_RSERVER_CLIENT);
4158 }
4159
4160 DEFUN (no_neighbor_route_server_client,
4161 no_neighbor_route_server_client_cmd,
4162 NO_NEIGHBOR_CMD2 "route-server-client",
4163 NO_STR
4164 NEIGHBOR_STR
4165 NEIGHBOR_ADDR_STR2
4166 "Configure a neighbor as Route Server client\n")
4167 {
4168 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4169 bgp_node_safi (vty),
4170 PEER_FLAG_RSERVER_CLIENT);
4171 }
4172
4173 DEFUN (neighbor_nexthop_local_unchanged,
4174 neighbor_nexthop_local_unchanged_cmd,
4175 NEIGHBOR_CMD2 "nexthop-local unchanged",
4176 NEIGHBOR_STR
4177 NEIGHBOR_ADDR_STR2
4178 "Configure treatment of outgoing link-local nexthop attribute\n"
4179 "Leave link-local nexthop unchanged for this peer\n")
4180 {
4181 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4182 bgp_node_safi (vty),
4183 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
4184 }
4185
4186 DEFUN (no_neighbor_nexthop_local_unchanged,
4187 no_neighbor_nexthop_local_unchanged_cmd,
4188 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
4189 NO_STR
4190 NEIGHBOR_STR
4191 NEIGHBOR_ADDR_STR2
4192 "Configure treatment of outgoing link-local-nexthop attribute\n"
4193 "Leave link-local nexthop unchanged for this peer\n")
4194 {
4195 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4196 bgp_node_safi (vty),
4197 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
4198 }
4199
4200 DEFUN (neighbor_attr_unchanged,
4201 neighbor_attr_unchanged_cmd,
4202 NEIGHBOR_CMD2 "attribute-unchanged",
4203 NEIGHBOR_STR
4204 NEIGHBOR_ADDR_STR2
4205 "BGP attribute is propagated unchanged to this neighbor\n")
4206 {
4207 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4208 bgp_node_safi (vty),
4209 (PEER_FLAG_AS_PATH_UNCHANGED |
4210 PEER_FLAG_NEXTHOP_UNCHANGED |
4211 PEER_FLAG_MED_UNCHANGED));
4212 }
4213
4214 DEFUN (neighbor_attr_unchanged1,
4215 neighbor_attr_unchanged1_cmd,
4216 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
4217 NEIGHBOR_STR
4218 NEIGHBOR_ADDR_STR2
4219 "BGP attribute is propagated unchanged to this neighbor\n"
4220 "As-path attribute\n"
4221 "Nexthop attribute\n"
4222 "Med attribute\n")
4223 {
4224 u_int16_t flags = 0;
4225
4226 if (strncmp (argv[1], "as-path", 1) == 0)
4227 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4228 else if (strncmp (argv[1], "next-hop", 1) == 0)
4229 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4230 else if (strncmp (argv[1], "med", 1) == 0)
4231 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4232
4233 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4234 bgp_node_safi (vty), flags);
4235 }
4236
4237 DEFUN (neighbor_attr_unchanged2,
4238 neighbor_attr_unchanged2_cmd,
4239 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4240 NEIGHBOR_STR
4241 NEIGHBOR_ADDR_STR2
4242 "BGP attribute is propagated unchanged to this neighbor\n"
4243 "As-path attribute\n"
4244 "Nexthop attribute\n"
4245 "Med attribute\n")
4246 {
4247 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4248
4249 if (strncmp (argv[1], "next-hop", 1) == 0)
4250 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4251 else if (strncmp (argv[1], "med", 1) == 0)
4252 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4253
4254 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4255 bgp_node_safi (vty), flags);
4256
4257 }
4258
4259 DEFUN (neighbor_attr_unchanged3,
4260 neighbor_attr_unchanged3_cmd,
4261 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4262 NEIGHBOR_STR
4263 NEIGHBOR_ADDR_STR2
4264 "BGP attribute is propagated unchanged to this neighbor\n"
4265 "Nexthop attribute\n"
4266 "As-path attribute\n"
4267 "Med attribute\n")
4268 {
4269 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4270
4271 if (strncmp (argv[1], "as-path", 1) == 0)
4272 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4273 else if (strncmp (argv[1], "med", 1) == 0)
4274 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4275
4276 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4277 bgp_node_safi (vty), flags);
4278 }
4279
4280 DEFUN (neighbor_attr_unchanged4,
4281 neighbor_attr_unchanged4_cmd,
4282 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4283 NEIGHBOR_STR
4284 NEIGHBOR_ADDR_STR2
4285 "BGP attribute is propagated unchanged to this neighbor\n"
4286 "Med attribute\n"
4287 "As-path attribute\n"
4288 "Nexthop attribute\n")
4289 {
4290 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4291
4292 if (strncmp (argv[1], "as-path", 1) == 0)
4293 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4294 else if (strncmp (argv[1], "next-hop", 1) == 0)
4295 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4296
4297 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4298 bgp_node_safi (vty), flags);
4299 }
4300
4301 ALIAS (neighbor_attr_unchanged,
4302 neighbor_attr_unchanged5_cmd,
4303 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4304 NEIGHBOR_STR
4305 NEIGHBOR_ADDR_STR2
4306 "BGP attribute is propagated unchanged to this neighbor\n"
4307 "As-path attribute\n"
4308 "Nexthop attribute\n"
4309 "Med attribute\n")
4310
4311 ALIAS (neighbor_attr_unchanged,
4312 neighbor_attr_unchanged6_cmd,
4313 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4314 NEIGHBOR_STR
4315 NEIGHBOR_ADDR_STR2
4316 "BGP attribute is propagated unchanged to this neighbor\n"
4317 "As-path attribute\n"
4318 "Med attribute\n"
4319 "Nexthop attribute\n")
4320
4321 ALIAS (neighbor_attr_unchanged,
4322 neighbor_attr_unchanged7_cmd,
4323 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4324 NEIGHBOR_STR
4325 NEIGHBOR_ADDR_STR2
4326 "BGP attribute is propagated unchanged to this neighbor\n"
4327 "Nexthop attribute\n"
4328 "Med attribute\n"
4329 "As-path attribute\n")
4330
4331 ALIAS (neighbor_attr_unchanged,
4332 neighbor_attr_unchanged8_cmd,
4333 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4334 NEIGHBOR_STR
4335 NEIGHBOR_ADDR_STR2
4336 "BGP attribute is propagated unchanged to this neighbor\n"
4337 "Nexthop attribute\n"
4338 "As-path attribute\n"
4339 "Med attribute\n")
4340
4341 ALIAS (neighbor_attr_unchanged,
4342 neighbor_attr_unchanged9_cmd,
4343 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4344 NEIGHBOR_STR
4345 NEIGHBOR_ADDR_STR2
4346 "BGP attribute is propagated unchanged to this neighbor\n"
4347 "Med attribute\n"
4348 "Nexthop attribute\n"
4349 "As-path attribute\n")
4350
4351 ALIAS (neighbor_attr_unchanged,
4352 neighbor_attr_unchanged10_cmd,
4353 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4354 NEIGHBOR_STR
4355 NEIGHBOR_ADDR_STR2
4356 "BGP attribute is propagated unchanged to this neighbor\n"
4357 "Med attribute\n"
4358 "As-path attribute\n"
4359 "Nexthop attribute\n")
4360
4361 DEFUN (no_neighbor_attr_unchanged,
4362 no_neighbor_attr_unchanged_cmd,
4363 NO_NEIGHBOR_CMD2 "attribute-unchanged",
4364 NO_STR
4365 NEIGHBOR_STR
4366 NEIGHBOR_ADDR_STR2
4367 "BGP attribute is propagated unchanged to this neighbor\n")
4368 {
4369 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4370 bgp_node_safi (vty),
4371 (PEER_FLAG_AS_PATH_UNCHANGED |
4372 PEER_FLAG_NEXTHOP_UNCHANGED |
4373 PEER_FLAG_MED_UNCHANGED));
4374 }
4375
4376 DEFUN (no_neighbor_attr_unchanged1,
4377 no_neighbor_attr_unchanged1_cmd,
4378 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
4379 NO_STR
4380 NEIGHBOR_STR
4381 NEIGHBOR_ADDR_STR2
4382 "BGP attribute is propagated unchanged to this neighbor\n"
4383 "As-path attribute\n"
4384 "Nexthop attribute\n"
4385 "Med attribute\n")
4386 {
4387 u_int16_t flags = 0;
4388
4389 if (strncmp (argv[1], "as-path", 1) == 0)
4390 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4391 else if (strncmp (argv[1], "next-hop", 1) == 0)
4392 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4393 else if (strncmp (argv[1], "med", 1) == 0)
4394 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4395
4396 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4397 bgp_node_safi (vty), flags);
4398 }
4399
4400 DEFUN (no_neighbor_attr_unchanged2,
4401 no_neighbor_attr_unchanged2_cmd,
4402 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4403 NO_STR
4404 NEIGHBOR_STR
4405 NEIGHBOR_ADDR_STR2
4406 "BGP attribute is propagated unchanged to this neighbor\n"
4407 "As-path attribute\n"
4408 "Nexthop attribute\n"
4409 "Med attribute\n")
4410 {
4411 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4412
4413 if (strncmp (argv[1], "next-hop", 1) == 0)
4414 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4415 else if (strncmp (argv[1], "med", 1) == 0)
4416 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4417
4418 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4419 bgp_node_safi (vty), flags);
4420 }
4421
4422 DEFUN (no_neighbor_attr_unchanged3,
4423 no_neighbor_attr_unchanged3_cmd,
4424 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4425 NO_STR
4426 NEIGHBOR_STR
4427 NEIGHBOR_ADDR_STR2
4428 "BGP attribute is propagated unchanged to this neighbor\n"
4429 "Nexthop attribute\n"
4430 "As-path attribute\n"
4431 "Med attribute\n")
4432 {
4433 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4434
4435 if (strncmp (argv[1], "as-path", 1) == 0)
4436 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4437 else if (strncmp (argv[1], "med", 1) == 0)
4438 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4439
4440 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4441 bgp_node_safi (vty), flags);
4442 }
4443
4444 DEFUN (no_neighbor_attr_unchanged4,
4445 no_neighbor_attr_unchanged4_cmd,
4446 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4447 NO_STR
4448 NEIGHBOR_STR
4449 NEIGHBOR_ADDR_STR2
4450 "BGP attribute is propagated unchanged to this neighbor\n"
4451 "Med attribute\n"
4452 "As-path attribute\n"
4453 "Nexthop attribute\n")
4454 {
4455 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4456
4457 if (strncmp (argv[1], "as-path", 1) == 0)
4458 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4459 else if (strncmp (argv[1], "next-hop", 1) == 0)
4460 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4461
4462 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4463 bgp_node_safi (vty), flags);
4464 }
4465
4466 ALIAS (no_neighbor_attr_unchanged,
4467 no_neighbor_attr_unchanged5_cmd,
4468 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4469 NO_STR
4470 NEIGHBOR_STR
4471 NEIGHBOR_ADDR_STR2
4472 "BGP attribute is propagated unchanged to this neighbor\n"
4473 "As-path attribute\n"
4474 "Nexthop attribute\n"
4475 "Med attribute\n")
4476
4477 ALIAS (no_neighbor_attr_unchanged,
4478 no_neighbor_attr_unchanged6_cmd,
4479 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4480 NO_STR
4481 NEIGHBOR_STR
4482 NEIGHBOR_ADDR_STR2
4483 "BGP attribute is propagated unchanged to this neighbor\n"
4484 "As-path attribute\n"
4485 "Med attribute\n"
4486 "Nexthop attribute\n")
4487
4488 ALIAS (no_neighbor_attr_unchanged,
4489 no_neighbor_attr_unchanged7_cmd,
4490 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4491 NO_STR
4492 NEIGHBOR_STR
4493 NEIGHBOR_ADDR_STR2
4494 "BGP attribute is propagated unchanged to this neighbor\n"
4495 "Nexthop attribute\n"
4496 "Med attribute\n"
4497 "As-path attribute\n")
4498
4499 ALIAS (no_neighbor_attr_unchanged,
4500 no_neighbor_attr_unchanged8_cmd,
4501 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4502 NO_STR
4503 NEIGHBOR_STR
4504 NEIGHBOR_ADDR_STR2
4505 "BGP attribute is propagated unchanged to this neighbor\n"
4506 "Nexthop attribute\n"
4507 "As-path attribute\n"
4508 "Med attribute\n")
4509
4510 ALIAS (no_neighbor_attr_unchanged,
4511 no_neighbor_attr_unchanged9_cmd,
4512 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4513 NO_STR
4514 NEIGHBOR_STR
4515 NEIGHBOR_ADDR_STR2
4516 "BGP attribute is propagated unchanged to this neighbor\n"
4517 "Med attribute\n"
4518 "Nexthop attribute\n"
4519 "As-path attribute\n")
4520
4521 ALIAS (no_neighbor_attr_unchanged,
4522 no_neighbor_attr_unchanged10_cmd,
4523 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4524 NO_STR
4525 NEIGHBOR_STR
4526 NEIGHBOR_ADDR_STR2
4527 "BGP attribute is propagated unchanged to this neighbor\n"
4528 "Med attribute\n"
4529 "As-path attribute\n"
4530 "Nexthop attribute\n")
4531
4532 /* EBGP multihop configuration. */
4533 static int
4534 peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
4535 const char *ttl_str)
4536 {
4537 struct peer *peer;
4538 unsigned int ttl;
4539
4540 peer = peer_and_group_lookup_vty (vty, ip_str);
4541 if (! peer)
4542 return CMD_WARNING;
4543
4544 if (peer->conf_if)
4545 return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER);
4546
4547 if (! ttl_str)
4548 ttl = MAXTTL;
4549 else
4550 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
4551
4552 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
4553 }
4554
4555 static int
4556 peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
4557 {
4558 struct peer *peer;
4559
4560 peer = peer_and_group_lookup_vty (vty, ip_str);
4561 if (! peer)
4562 return CMD_WARNING;
4563
4564 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
4565 }
4566
4567 /* neighbor ebgp-multihop. */
4568 DEFUN (neighbor_ebgp_multihop,
4569 neighbor_ebgp_multihop_cmd,
4570 NEIGHBOR_CMD2 "ebgp-multihop",
4571 NEIGHBOR_STR
4572 NEIGHBOR_ADDR_STR2
4573 "Allow EBGP neighbors not on directly connected networks\n")
4574 {
4575 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
4576 }
4577
4578 DEFUN (neighbor_ebgp_multihop_ttl,
4579 neighbor_ebgp_multihop_ttl_cmd,
4580 NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
4581 NEIGHBOR_STR
4582 NEIGHBOR_ADDR_STR2
4583 "Allow EBGP neighbors not on directly connected networks\n"
4584 "maximum hop count\n")
4585 {
4586 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
4587 }
4588
4589 DEFUN (no_neighbor_ebgp_multihop,
4590 no_neighbor_ebgp_multihop_cmd,
4591 NO_NEIGHBOR_CMD2 "ebgp-multihop",
4592 NO_STR
4593 NEIGHBOR_STR
4594 NEIGHBOR_ADDR_STR2
4595 "Allow EBGP neighbors not on directly connected networks\n")
4596 {
4597 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
4598 }
4599
4600 ALIAS (no_neighbor_ebgp_multihop,
4601 no_neighbor_ebgp_multihop_ttl_cmd,
4602 NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
4603 NO_STR
4604 NEIGHBOR_STR
4605 NEIGHBOR_ADDR_STR2
4606 "Allow EBGP neighbors not on directly connected networks\n"
4607 "maximum hop count\n")
4608
4609 /* disable-connected-check */
4610 DEFUN (neighbor_disable_connected_check,
4611 neighbor_disable_connected_check_cmd,
4612 NEIGHBOR_CMD2 "disable-connected-check",
4613 NEIGHBOR_STR
4614 NEIGHBOR_ADDR_STR2
4615 "one-hop away EBGP peer using loopback address\n")
4616 {
4617 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4618 }
4619
4620 DEFUN (no_neighbor_disable_connected_check,
4621 no_neighbor_disable_connected_check_cmd,
4622 NO_NEIGHBOR_CMD2 "disable-connected-check",
4623 NO_STR
4624 NEIGHBOR_STR
4625 NEIGHBOR_ADDR_STR2
4626 "one-hop away EBGP peer using loopback address\n")
4627 {
4628 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4629 }
4630
4631 /* Enforce multihop. */
4632 ALIAS (neighbor_disable_connected_check,
4633 neighbor_enforce_multihop_cmd,
4634 NEIGHBOR_CMD2 "enforce-multihop",
4635 NEIGHBOR_STR
4636 NEIGHBOR_ADDR_STR2
4637 "Enforce EBGP neighbors perform multihop\n")
4638
4639 /* Enforce multihop. */
4640 ALIAS (no_neighbor_disable_connected_check,
4641 no_neighbor_enforce_multihop_cmd,
4642 NO_NEIGHBOR_CMD2 "enforce-multihop",
4643 NO_STR
4644 NEIGHBOR_STR
4645 NEIGHBOR_ADDR_STR2
4646 "Enforce EBGP neighbors perform multihop\n")
4647
4648 DEFUN (neighbor_description,
4649 neighbor_description_cmd,
4650 NEIGHBOR_CMD2 "description .LINE",
4651 NEIGHBOR_STR
4652 NEIGHBOR_ADDR_STR2
4653 "Neighbor specific description\n"
4654 "Up to 80 characters describing this neighbor\n")
4655 {
4656 struct peer *peer;
4657 char *str;
4658
4659 peer = peer_and_group_lookup_vty (vty, argv[0]);
4660 if (! peer)
4661 return CMD_WARNING;
4662
4663 if (argc == 1)
4664 return CMD_SUCCESS;
4665
4666 str = argv_concat(argv, argc, 1);
4667
4668 peer_description_set (peer, str);
4669
4670 XFREE (MTYPE_TMP, str);
4671
4672 return CMD_SUCCESS;
4673 }
4674
4675 DEFUN (no_neighbor_description,
4676 no_neighbor_description_cmd,
4677 NO_NEIGHBOR_CMD2 "description",
4678 NO_STR
4679 NEIGHBOR_STR
4680 NEIGHBOR_ADDR_STR2
4681 "Neighbor specific description\n")
4682 {
4683 struct peer *peer;
4684
4685 peer = peer_and_group_lookup_vty (vty, argv[0]);
4686 if (! peer)
4687 return CMD_WARNING;
4688
4689 peer_description_unset (peer);
4690
4691 return CMD_SUCCESS;
4692 }
4693
4694 ALIAS (no_neighbor_description,
4695 no_neighbor_description_val_cmd,
4696 NO_NEIGHBOR_CMD2 "description .LINE",
4697 NO_STR
4698 NEIGHBOR_STR
4699 NEIGHBOR_ADDR_STR2
4700 "Neighbor specific description\n"
4701 "Up to 80 characters describing this neighbor\n")
4702
4703 /* Neighbor update-source. */
4704 static int
4705 peer_update_source_vty (struct vty *vty, const char *peer_str,
4706 const char *source_str)
4707 {
4708 struct peer *peer;
4709 struct prefix p;
4710
4711 peer = peer_and_group_lookup_vty (vty, peer_str);
4712 if (! peer)
4713 return CMD_WARNING;
4714
4715 if (peer->conf_if)
4716 return CMD_WARNING;
4717
4718 if (source_str)
4719 {
4720 union sockunion su;
4721 int ret = str2sockunion (source_str, &su);
4722
4723 if (ret == 0)
4724 peer_update_source_addr_set (peer, &su);
4725 else
4726 {
4727 if (str2prefix (source_str, &p))
4728 {
4729 vty_out (vty, "%% Invalid update-source, remove prefix length %s",
4730 VTY_NEWLINE);
4731 return CMD_WARNING;
4732 }
4733 else
4734 peer_update_source_if_set (peer, source_str);
4735 }
4736 }
4737 else
4738 peer_update_source_unset (peer);
4739
4740 return CMD_SUCCESS;
4741 }
4742
4743 #define BGP_UPDATE_SOURCE_STR "A.B.C.D|X:X::X:X|WORD"
4744 #define BGP_UPDATE_SOURCE_REQ_STR "(" BGP_UPDATE_SOURCE_STR ")"
4745 #define BGP_UPDATE_SOURCE_OPT_STR "{" BGP_UPDATE_SOURCE_STR "}"
4746 #define BGP_UPDATE_SOURCE_HELP_STR \
4747 "IPv4 address\n" \
4748 "IPv6 address\n" \
4749 "Interface name (requires zebra to be running)\n"
4750
4751 DEFUN (neighbor_update_source,
4752 neighbor_update_source_cmd,
4753 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_REQ_STR,
4754 NEIGHBOR_STR
4755 NEIGHBOR_ADDR_STR2
4756 "Source of routing updates\n"
4757 BGP_UPDATE_SOURCE_HELP_STR)
4758 {
4759 return peer_update_source_vty (vty, argv[0], argv[1]);
4760 }
4761
4762 DEFUN (no_neighbor_update_source,
4763 no_neighbor_update_source_cmd,
4764 NO_NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_OPT_STR,
4765 NO_STR
4766 NEIGHBOR_STR
4767 NEIGHBOR_ADDR_STR2
4768 "Source of routing updates\n"
4769 BGP_UPDATE_SOURCE_HELP_STR)
4770 {
4771 return peer_update_source_vty (vty, argv[0], NULL);
4772 }
4773
4774 static int
4775 peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4776 afi_t afi, safi_t safi,
4777 const char *rmap, int set)
4778 {
4779 int ret;
4780 struct peer *peer;
4781
4782 peer = peer_and_group_lookup_vty (vty, peer_str);
4783 if (! peer)
4784 return CMD_WARNING;
4785
4786 if (set)
4787 ret = peer_default_originate_set (peer, afi, safi, rmap);
4788 else
4789 ret = peer_default_originate_unset (peer, afi, safi);
4790
4791 return bgp_vty_return (vty, ret);
4792 }
4793
4794 /* neighbor default-originate. */
4795 DEFUN (neighbor_default_originate,
4796 neighbor_default_originate_cmd,
4797 NEIGHBOR_CMD2 "default-originate",
4798 NEIGHBOR_STR
4799 NEIGHBOR_ADDR_STR2
4800 "Originate default route to this neighbor\n")
4801 {
4802 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4803 bgp_node_safi (vty), NULL, 1);
4804 }
4805
4806 DEFUN (neighbor_default_originate_rmap,
4807 neighbor_default_originate_rmap_cmd,
4808 NEIGHBOR_CMD2 "default-originate route-map WORD",
4809 NEIGHBOR_STR
4810 NEIGHBOR_ADDR_STR2
4811 "Originate default route to this neighbor\n"
4812 "Route-map to specify criteria to originate default\n"
4813 "route-map name\n")
4814 {
4815 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4816 bgp_node_safi (vty), argv[1], 1);
4817 }
4818
4819 DEFUN (no_neighbor_default_originate,
4820 no_neighbor_default_originate_cmd,
4821 NO_NEIGHBOR_CMD2 "default-originate",
4822 NO_STR
4823 NEIGHBOR_STR
4824 NEIGHBOR_ADDR_STR2
4825 "Originate default route to this neighbor\n")
4826 {
4827 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4828 bgp_node_safi (vty), NULL, 0);
4829 }
4830
4831 ALIAS (no_neighbor_default_originate,
4832 no_neighbor_default_originate_rmap_cmd,
4833 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
4834 NO_STR
4835 NEIGHBOR_STR
4836 NEIGHBOR_ADDR_STR2
4837 "Originate default route to this neighbor\n"
4838 "Route-map to specify criteria to originate default\n"
4839 "route-map name\n")
4840
4841 /* Set neighbor's BGP port. */
4842 static int
4843 peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4844 const char *port_str)
4845 {
4846 struct peer *peer;
4847 u_int16_t port;
4848 struct servent *sp;
4849
4850 peer = peer_lookup_vty (vty, ip_str);
4851 if (! peer)
4852 return CMD_WARNING;
4853
4854 if (! port_str)
4855 {
4856 sp = getservbyname ("bgp", "tcp");
4857 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4858 }
4859 else
4860 {
4861 VTY_GET_INTEGER("port", port, port_str);
4862 }
4863
4864 peer_port_set (peer, port);
4865
4866 return CMD_SUCCESS;
4867 }
4868
4869 /* Set specified peer's BGP port. */
4870 DEFUN (neighbor_port,
4871 neighbor_port_cmd,
4872 NEIGHBOR_CMD "port <0-65535>",
4873 NEIGHBOR_STR
4874 NEIGHBOR_ADDR_STR
4875 "Neighbor's BGP port\n"
4876 "TCP port number\n")
4877 {
4878 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
4879 }
4880
4881 DEFUN (no_neighbor_port,
4882 no_neighbor_port_cmd,
4883 NO_NEIGHBOR_CMD "port",
4884 NO_STR
4885 NEIGHBOR_STR
4886 NEIGHBOR_ADDR_STR
4887 "Neighbor's BGP port\n")
4888 {
4889 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
4890 }
4891
4892 ALIAS (no_neighbor_port,
4893 no_neighbor_port_val_cmd,
4894 NO_NEIGHBOR_CMD "port <0-65535>",
4895 NO_STR
4896 NEIGHBOR_STR
4897 NEIGHBOR_ADDR_STR
4898 "Neighbor's BGP port\n"
4899 "TCP port number\n")
4900
4901 /* neighbor weight. */
4902 static int
4903 peer_weight_set_vty (struct vty *vty, const char *ip_str,
4904 afi_t afi, safi_t safi,
4905 const char *weight_str)
4906 {
4907 int ret;
4908 struct peer *peer;
4909 unsigned long weight;
4910
4911 peer = peer_and_group_lookup_vty (vty, ip_str);
4912 if (! peer)
4913 return CMD_WARNING;
4914
4915 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4916
4917 ret = peer_weight_set (peer, afi, safi, weight);
4918 return bgp_vty_return (vty, ret);
4919 }
4920
4921 static int
4922 peer_weight_unset_vty (struct vty *vty, const char *ip_str,
4923 afi_t afi, safi_t safi)
4924 {
4925 int ret;
4926 struct peer *peer;
4927
4928 peer = peer_and_group_lookup_vty (vty, ip_str);
4929 if (! peer)
4930 return CMD_WARNING;
4931
4932 ret = peer_weight_unset (peer, afi, safi);
4933 return bgp_vty_return (vty, ret);
4934 }
4935
4936 DEFUN (neighbor_weight,
4937 neighbor_weight_cmd,
4938 NEIGHBOR_CMD2 "weight <0-65535>",
4939 NEIGHBOR_STR
4940 NEIGHBOR_ADDR_STR2
4941 "Set default weight for routes from this neighbor\n"
4942 "default weight\n")
4943 {
4944 return peer_weight_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), argv[1]);
4945 }
4946
4947 DEFUN (no_neighbor_weight,
4948 no_neighbor_weight_cmd,
4949 NO_NEIGHBOR_CMD2 "weight",
4950 NO_STR
4951 NEIGHBOR_STR
4952 NEIGHBOR_ADDR_STR2
4953 "Set default weight for routes from this neighbor\n")
4954 {
4955 return peer_weight_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty));
4956 }
4957
4958 ALIAS (no_neighbor_weight,
4959 no_neighbor_weight_val_cmd,
4960 NO_NEIGHBOR_CMD2 "weight <0-65535>",
4961 NO_STR
4962 NEIGHBOR_STR
4963 NEIGHBOR_ADDR_STR2
4964 "Set default weight for routes from this neighbor\n"
4965 "default weight\n")
4966
4967 /* Override capability negotiation. */
4968 DEFUN (neighbor_override_capability,
4969 neighbor_override_capability_cmd,
4970 NEIGHBOR_CMD2 "override-capability",
4971 NEIGHBOR_STR
4972 NEIGHBOR_ADDR_STR2
4973 "Override capability negotiation result\n")
4974 {
4975 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4976 }
4977
4978 DEFUN (no_neighbor_override_capability,
4979 no_neighbor_override_capability_cmd,
4980 NO_NEIGHBOR_CMD2 "override-capability",
4981 NO_STR
4982 NEIGHBOR_STR
4983 NEIGHBOR_ADDR_STR2
4984 "Override capability negotiation result\n")
4985 {
4986 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4987 }
4988
4989 DEFUN (neighbor_strict_capability,
4990 neighbor_strict_capability_cmd,
4991 NEIGHBOR_CMD "strict-capability-match",
4992 NEIGHBOR_STR
4993 NEIGHBOR_ADDR_STR
4994 "Strict capability negotiation match\n")
4995 {
4996 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4997 }
4998
4999 DEFUN (no_neighbor_strict_capability,
5000 no_neighbor_strict_capability_cmd,
5001 NO_NEIGHBOR_CMD "strict-capability-match",
5002 NO_STR
5003 NEIGHBOR_STR
5004 NEIGHBOR_ADDR_STR
5005 "Strict capability negotiation match\n")
5006 {
5007 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
5008 }
5009
5010 static int
5011 peer_timers_set_vty (struct vty *vty, const char *ip_str,
5012 const char *keep_str, const char *hold_str)
5013 {
5014 int ret;
5015 struct peer *peer;
5016 u_int32_t keepalive;
5017 u_int32_t holdtime;
5018
5019 peer = peer_and_group_lookup_vty (vty, ip_str);
5020 if (! peer)
5021 return CMD_WARNING;
5022
5023 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
5024 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
5025
5026 ret = peer_timers_set (peer, keepalive, holdtime);
5027
5028 return bgp_vty_return (vty, ret);
5029 }
5030
5031 static int
5032 peer_timers_unset_vty (struct vty *vty, const char *ip_str)
5033 {
5034 int ret;
5035 struct peer *peer;
5036
5037 peer = peer_and_group_lookup_vty (vty, ip_str);
5038 if (! peer)
5039 return CMD_WARNING;
5040
5041 ret = peer_timers_unset (peer);
5042
5043 return bgp_vty_return (vty, ret);
5044 }
5045
5046 DEFUN (neighbor_timers,
5047 neighbor_timers_cmd,
5048 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
5049 NEIGHBOR_STR
5050 NEIGHBOR_ADDR_STR2
5051 "BGP per neighbor timers\n"
5052 "Keepalive interval\n"
5053 "Holdtime\n")
5054 {
5055 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
5056 }
5057
5058 DEFUN (no_neighbor_timers,
5059 no_neighbor_timers_cmd,
5060 NO_NEIGHBOR_CMD2 "timers",
5061 NO_STR
5062 NEIGHBOR_STR
5063 NEIGHBOR_ADDR_STR2
5064 "BGP per neighbor timers\n")
5065 {
5066 return peer_timers_unset_vty (vty, argv[0]);
5067 }
5068
5069 ALIAS (no_neighbor_timers,
5070 no_neighbor_timers_val_cmd,
5071 NO_NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
5072 NO_STR
5073 NEIGHBOR_STR
5074 NEIGHBOR_ADDR_STR2
5075 "BGP per neighbor timers\n"
5076 "Keepalive interval\n"
5077 "Holdtime\n")
5078
5079 static int
5080 peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
5081 const char *time_str)
5082 {
5083 int ret;
5084 struct peer *peer;
5085 u_int32_t connect;
5086
5087 peer = peer_and_group_lookup_vty (vty, ip_str);
5088 if (! peer)
5089 return CMD_WARNING;
5090
5091 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
5092
5093 ret = peer_timers_connect_set (peer, connect);
5094
5095 return bgp_vty_return (vty, ret);
5096 }
5097
5098 static int
5099 peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
5100 {
5101 int ret;
5102 struct peer *peer;
5103
5104 peer = peer_and_group_lookup_vty (vty, ip_str);
5105 if (! peer)
5106 return CMD_WARNING;
5107
5108 ret = peer_timers_connect_unset (peer);
5109
5110 return bgp_vty_return (vty, ret);
5111 }
5112
5113 DEFUN (neighbor_timers_connect,
5114 neighbor_timers_connect_cmd,
5115 NEIGHBOR_CMD2 "timers connect <1-65535>",
5116 NEIGHBOR_STR
5117 NEIGHBOR_ADDR_STR2
5118 "BGP per neighbor timers\n"
5119 "BGP connect timer\n"
5120 "Connect timer\n")
5121 {
5122 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
5123 }
5124
5125 DEFUN (no_neighbor_timers_connect,
5126 no_neighbor_timers_connect_cmd,
5127 NO_NEIGHBOR_CMD2 "timers connect",
5128 NO_STR
5129 NEIGHBOR_STR
5130 NEIGHBOR_ADDR_STR2
5131 "BGP per neighbor timers\n"
5132 "BGP connect timer\n")
5133 {
5134 return peer_timers_connect_unset_vty (vty, argv[0]);
5135 }
5136
5137 ALIAS (no_neighbor_timers_connect,
5138 no_neighbor_timers_connect_val_cmd,
5139 NO_NEIGHBOR_CMD2 "timers connect <1-65535>",
5140 NO_STR
5141 NEIGHBOR_STR
5142 NEIGHBOR_ADDR_STR2
5143 "BGP per neighbor timers\n"
5144 "BGP connect timer\n"
5145 "Connect timer\n")
5146
5147 static int
5148 peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
5149 const char *time_str, int set)
5150 {
5151 int ret;
5152 struct peer *peer;
5153 u_int32_t routeadv = 0;
5154
5155 peer = peer_and_group_lookup_vty (vty, ip_str);
5156 if (! peer)
5157 return CMD_WARNING;
5158
5159 if (time_str)
5160 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
5161
5162 if (set)
5163 ret = peer_advertise_interval_set (peer, routeadv);
5164 else
5165 ret = peer_advertise_interval_unset (peer);
5166
5167 return bgp_vty_return (vty, ret);
5168 }
5169
5170 DEFUN (neighbor_advertise_interval,
5171 neighbor_advertise_interval_cmd,
5172 NEIGHBOR_CMD2 "advertisement-interval <0-600>",
5173 NEIGHBOR_STR
5174 NEIGHBOR_ADDR_STR2
5175 "Minimum interval between sending BGP routing updates\n"
5176 "time in seconds\n")
5177 {
5178 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
5179 }
5180
5181 DEFUN (no_neighbor_advertise_interval,
5182 no_neighbor_advertise_interval_cmd,
5183 NO_NEIGHBOR_CMD2 "advertisement-interval",
5184 NO_STR
5185 NEIGHBOR_STR
5186 NEIGHBOR_ADDR_STR2
5187 "Minimum interval between sending BGP routing updates\n")
5188 {
5189 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
5190 }
5191
5192 ALIAS (no_neighbor_advertise_interval,
5193 no_neighbor_advertise_interval_val_cmd,
5194 NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
5195 NO_STR
5196 NEIGHBOR_STR
5197 NEIGHBOR_ADDR_STR2
5198 "Minimum interval between sending BGP routing updates\n"
5199 "time in seconds\n")
5200
5201 /* Time to wait before processing route-map updates */
5202 DEFUN (bgp_set_route_map_delay_timer,
5203 bgp_set_route_map_delay_timer_cmd,
5204 "bgp route-map delay-timer <0-600>",
5205 SET_STR
5206 "BGP route-map delay timer\n"
5207 "Time in secs to wait before processing route-map changes\n"
5208 "0 disables the timer, no route updates happen when route-maps change\n")
5209 {
5210 u_int32_t rmap_delay_timer;
5211
5212 if (argv[0])
5213 {
5214 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
5215 bm->rmap_update_timer = rmap_delay_timer;
5216
5217 /* if the dynamic update handling is being disabled, and a timer is
5218 * running, stop the timer and act as if the timer has already fired.
5219 */
5220 if (!rmap_delay_timer && bm->t_rmap_update )
5221 {
5222 BGP_TIMER_OFF(bm->t_rmap_update);
5223 thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0);
5224 }
5225 return CMD_SUCCESS;
5226 }
5227 else
5228 return CMD_WARNING;
5229 }
5230
5231 DEFUN (no_bgp_set_route_map_delay_timer,
5232 no_bgp_set_route_map_delay_timer_cmd,
5233 "no bgp route-map delay-timer",
5234 NO_STR
5235 "Default BGP route-map delay timer\n"
5236 "Reset to default time to wait for processing route-map changes\n")
5237 {
5238
5239 bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
5240
5241 return CMD_SUCCESS;
5242 }
5243
5244 ALIAS (no_bgp_set_route_map_delay_timer,
5245 no_bgp_set_route_map_delay_timer_val_cmd,
5246 "no bgp route-map delay-timer <0-600>",
5247 NO_STR
5248 "Default BGP route-map delay timer\n"
5249 "Reset to default time to wait for processing route-map changes\n"
5250 "0 disables the timer, no route updates happen when route-maps change\n")
5251
5252 /* neighbor interface */
5253 static int
5254 peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
5255 {
5256 struct peer *peer;
5257
5258 peer = peer_lookup_vty (vty, ip_str);
5259 if (! peer || peer->conf_if)
5260 return CMD_WARNING;
5261
5262 if (str)
5263 peer_interface_set (peer, str);
5264 else
5265 peer_interface_unset (peer);
5266
5267 return CMD_SUCCESS;
5268 }
5269
5270 DEFUN (neighbor_interface,
5271 neighbor_interface_cmd,
5272 NEIGHBOR_CMD "interface WORD",
5273 NEIGHBOR_STR
5274 NEIGHBOR_ADDR_STR
5275 "Interface\n"
5276 "Interface name\n")
5277 {
5278 if (argc == 3)
5279 return peer_interface_vty (vty, argv[0], argv[1]);
5280 else
5281 return peer_interface_vty (vty, argv[0], argv[1]);
5282 }
5283
5284 DEFUN (no_neighbor_interface,
5285 no_neighbor_interface_cmd,
5286 NO_NEIGHBOR_CMD2 "interface WORD",
5287 NO_STR
5288 NEIGHBOR_STR
5289 NEIGHBOR_ADDR_STR
5290 "Interface\n"
5291 "Interface name\n")
5292 {
5293 return peer_interface_vty (vty, argv[0], NULL);
5294 }
5295
5296 /* Set distribute list to the peer. */
5297 static int
5298 peer_distribute_set_vty (struct vty *vty, const char *ip_str,
5299 afi_t afi, safi_t safi,
5300 const char *name_str, const char *direct_str)
5301 {
5302 int ret;
5303 struct peer *peer;
5304 int direct = FILTER_IN;
5305
5306 peer = peer_and_group_lookup_vty (vty, ip_str);
5307 if (! peer)
5308 return CMD_WARNING;
5309
5310 /* Check filter direction. */
5311 if (strncmp (direct_str, "i", 1) == 0)
5312 direct = FILTER_IN;
5313 else if (strncmp (direct_str, "o", 1) == 0)
5314 direct = FILTER_OUT;
5315
5316 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5317
5318 return bgp_vty_return (vty, ret);
5319 }
5320
5321 static int
5322 peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5323 safi_t safi, const char *direct_str)
5324 {
5325 int ret;
5326 struct peer *peer;
5327 int direct = FILTER_IN;
5328
5329 peer = peer_and_group_lookup_vty (vty, ip_str);
5330 if (! peer)
5331 return CMD_WARNING;
5332
5333 /* Check filter direction. */
5334 if (strncmp (direct_str, "i", 1) == 0)
5335 direct = FILTER_IN;
5336 else if (strncmp (direct_str, "o", 1) == 0)
5337 direct = FILTER_OUT;
5338
5339 ret = peer_distribute_unset (peer, afi, safi, direct);
5340
5341 return bgp_vty_return (vty, ret);
5342 }
5343
5344 DEFUN (neighbor_distribute_list,
5345 neighbor_distribute_list_cmd,
5346 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5347 NEIGHBOR_STR
5348 NEIGHBOR_ADDR_STR2
5349 "Filter updates to/from this neighbor\n"
5350 "IP access-list number\n"
5351 "IP access-list number (expanded range)\n"
5352 "IP Access-list name\n"
5353 "Filter incoming updates\n"
5354 "Filter outgoing updates\n")
5355 {
5356 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
5357 bgp_node_safi (vty), argv[1], argv[2]);
5358 }
5359
5360 DEFUN (no_neighbor_distribute_list,
5361 no_neighbor_distribute_list_cmd,
5362 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5363 NO_STR
5364 NEIGHBOR_STR
5365 NEIGHBOR_ADDR_STR2
5366 "Filter updates to/from this neighbor\n"
5367 "IP access-list number\n"
5368 "IP access-list number (expanded range)\n"
5369 "IP Access-list name\n"
5370 "Filter incoming updates\n"
5371 "Filter outgoing updates\n")
5372 {
5373 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
5374 bgp_node_safi (vty), argv[2]);
5375 }
5376
5377 /* Set prefix list to the peer. */
5378 static int
5379 peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5380 safi_t safi, const char *name_str,
5381 const char *direct_str)
5382 {
5383 int ret;
5384 struct peer *peer;
5385 int direct = FILTER_IN;
5386
5387 peer = peer_and_group_lookup_vty (vty, ip_str);
5388 if (! peer)
5389 return CMD_WARNING;
5390
5391 /* Check filter direction. */
5392 if (strncmp (direct_str, "i", 1) == 0)
5393 direct = FILTER_IN;
5394 else if (strncmp (direct_str, "o", 1) == 0)
5395 direct = FILTER_OUT;
5396
5397 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5398
5399 return bgp_vty_return (vty, ret);
5400 }
5401
5402 static int
5403 peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5404 safi_t safi, const char *direct_str)
5405 {
5406 int ret;
5407 struct peer *peer;
5408 int direct = FILTER_IN;
5409
5410 peer = peer_and_group_lookup_vty (vty, ip_str);
5411 if (! peer)
5412 return CMD_WARNING;
5413
5414 /* Check filter direction. */
5415 if (strncmp (direct_str, "i", 1) == 0)
5416 direct = FILTER_IN;
5417 else if (strncmp (direct_str, "o", 1) == 0)
5418 direct = FILTER_OUT;
5419
5420 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5421
5422 return bgp_vty_return (vty, ret);
5423 }
5424
5425 DEFUN (neighbor_prefix_list,
5426 neighbor_prefix_list_cmd,
5427 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5428 NEIGHBOR_STR
5429 NEIGHBOR_ADDR_STR2
5430 "Filter updates to/from this neighbor\n"
5431 "Name of a prefix list\n"
5432 "Filter incoming updates\n"
5433 "Filter outgoing updates\n")
5434 {
5435 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
5436 bgp_node_safi (vty), argv[1], argv[2]);
5437 }
5438
5439 DEFUN (no_neighbor_prefix_list,
5440 no_neighbor_prefix_list_cmd,
5441 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5442 NO_STR
5443 NEIGHBOR_STR
5444 NEIGHBOR_ADDR_STR2
5445 "Filter updates to/from this neighbor\n"
5446 "Name of a prefix list\n"
5447 "Filter incoming updates\n"
5448 "Filter outgoing updates\n")
5449 {
5450 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
5451 bgp_node_safi (vty), argv[2]);
5452 }
5453
5454 static int
5455 peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5456 afi_t afi, safi_t safi,
5457 const char *name_str, const char *direct_str)
5458 {
5459 int ret;
5460 struct peer *peer;
5461 int direct = FILTER_IN;
5462
5463 peer = peer_and_group_lookup_vty (vty, ip_str);
5464 if (! peer)
5465 return CMD_WARNING;
5466
5467 /* Check filter direction. */
5468 if (strncmp (direct_str, "i", 1) == 0)
5469 direct = FILTER_IN;
5470 else if (strncmp (direct_str, "o", 1) == 0)
5471 direct = FILTER_OUT;
5472
5473 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5474
5475 return bgp_vty_return (vty, ret);
5476 }
5477
5478 static int
5479 peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5480 afi_t afi, safi_t safi,
5481 const char *direct_str)
5482 {
5483 int ret;
5484 struct peer *peer;
5485 int direct = FILTER_IN;
5486
5487 peer = peer_and_group_lookup_vty (vty, ip_str);
5488 if (! peer)
5489 return CMD_WARNING;
5490
5491 /* Check filter direction. */
5492 if (strncmp (direct_str, "i", 1) == 0)
5493 direct = FILTER_IN;
5494 else if (strncmp (direct_str, "o", 1) == 0)
5495 direct = FILTER_OUT;
5496
5497 ret = peer_aslist_unset (peer, afi, safi, direct);
5498
5499 return bgp_vty_return (vty, ret);
5500 }
5501
5502 DEFUN (neighbor_filter_list,
5503 neighbor_filter_list_cmd,
5504 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5505 NEIGHBOR_STR
5506 NEIGHBOR_ADDR_STR2
5507 "Establish BGP filters\n"
5508 "AS path access-list name\n"
5509 "Filter incoming routes\n"
5510 "Filter outgoing routes\n")
5511 {
5512 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
5513 bgp_node_safi (vty), argv[1], argv[2]);
5514 }
5515
5516 DEFUN (no_neighbor_filter_list,
5517 no_neighbor_filter_list_cmd,
5518 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5519 NO_STR
5520 NEIGHBOR_STR
5521 NEIGHBOR_ADDR_STR2
5522 "Establish BGP filters\n"
5523 "AS path access-list name\n"
5524 "Filter incoming routes\n"
5525 "Filter outgoing routes\n")
5526 {
5527 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
5528 bgp_node_safi (vty), argv[2]);
5529 }
5530
5531 /* Set route-map to the peer. */
5532 static int
5533 peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5534 afi_t afi, safi_t safi,
5535 const char *name_str, const char *direct_str)
5536 {
5537 int ret;
5538 struct peer *peer;
5539 int direct = RMAP_IN;
5540
5541 peer = peer_and_group_lookup_vty (vty, ip_str);
5542 if (! peer)
5543 return CMD_WARNING;
5544
5545 /* Check filter direction. */
5546 if (strncmp (direct_str, "in", 2) == 0)
5547 direct = RMAP_IN;
5548 else if (strncmp (direct_str, "o", 1) == 0)
5549 direct = RMAP_OUT;
5550
5551 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5552
5553 return bgp_vty_return (vty, ret);
5554 }
5555
5556 static int
5557 peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5558 safi_t safi, const char *direct_str)
5559 {
5560 int ret;
5561 struct peer *peer;
5562 int direct = RMAP_IN;
5563
5564 peer = peer_and_group_lookup_vty (vty, ip_str);
5565 if (! peer)
5566 return CMD_WARNING;
5567
5568 /* Check filter direction. */
5569 if (strncmp (direct_str, "in", 2) == 0)
5570 direct = RMAP_IN;
5571 else if (strncmp (direct_str, "o", 1) == 0)
5572 direct = RMAP_OUT;
5573
5574 ret = peer_route_map_unset (peer, afi, safi, direct);
5575
5576 return bgp_vty_return (vty, ret);
5577 }
5578
5579 DEFUN (neighbor_route_map,
5580 neighbor_route_map_cmd,
5581 NEIGHBOR_CMD2 "route-map WORD (in|out)",
5582 NEIGHBOR_STR
5583 NEIGHBOR_ADDR_STR2
5584 "Apply route map to neighbor\n"
5585 "Name of route map\n"
5586 "Apply map to incoming routes\n"
5587 "Apply map to outbound routes\n")
5588 {
5589 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5590 bgp_node_safi (vty), argv[1], argv[2]);
5591 }
5592
5593 DEFUN (no_neighbor_route_map,
5594 no_neighbor_route_map_cmd,
5595 NO_NEIGHBOR_CMD2 "route-map WORD (in|out)",
5596 NO_STR
5597 NEIGHBOR_STR
5598 NEIGHBOR_ADDR_STR2
5599 "Apply route map to neighbor\n"
5600 "Name of route map\n"
5601 "Apply map to incoming routes\n"
5602 "Apply map to outbound routes\n")
5603 {
5604 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5605 bgp_node_safi (vty), argv[2]);
5606 }
5607
5608 /* Set unsuppress-map to the peer. */
5609 static int
5610 peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5611 safi_t safi, const char *name_str)
5612 {
5613 int ret;
5614 struct peer *peer;
5615
5616 peer = peer_and_group_lookup_vty (vty, ip_str);
5617 if (! peer)
5618 return CMD_WARNING;
5619
5620 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5621
5622 return bgp_vty_return (vty, ret);
5623 }
5624
5625 /* Unset route-map from the peer. */
5626 static int
5627 peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5628 safi_t safi)
5629 {
5630 int ret;
5631 struct peer *peer;
5632
5633 peer = peer_and_group_lookup_vty (vty, ip_str);
5634 if (! peer)
5635 return CMD_WARNING;
5636
5637 ret = peer_unsuppress_map_unset (peer, afi, safi);
5638
5639 return bgp_vty_return (vty, ret);
5640 }
5641
5642 DEFUN (neighbor_unsuppress_map,
5643 neighbor_unsuppress_map_cmd,
5644 NEIGHBOR_CMD2 "unsuppress-map WORD",
5645 NEIGHBOR_STR
5646 NEIGHBOR_ADDR_STR2
5647 "Route-map to selectively unsuppress suppressed routes\n"
5648 "Name of route map\n")
5649 {
5650 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5651 bgp_node_safi (vty), argv[1]);
5652 }
5653
5654 DEFUN (no_neighbor_unsuppress_map,
5655 no_neighbor_unsuppress_map_cmd,
5656 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
5657 NO_STR
5658 NEIGHBOR_STR
5659 NEIGHBOR_ADDR_STR2
5660 "Route-map to selectively unsuppress suppressed routes\n"
5661 "Name of route map\n")
5662 {
5663 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5664 bgp_node_safi (vty));
5665 }
5666
5667 static int
5668 peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5669 safi_t safi, const char *num_str,
5670 const char *threshold_str, int warning,
5671 const char *restart_str)
5672 {
5673 int ret;
5674 struct peer *peer;
5675 u_int32_t max;
5676 u_char threshold;
5677 u_int16_t restart;
5678
5679 peer = peer_and_group_lookup_vty (vty, ip_str);
5680 if (! peer)
5681 return CMD_WARNING;
5682
5683 VTY_GET_INTEGER ("maximum number", max, num_str);
5684 if (threshold_str)
5685 threshold = atoi (threshold_str);
5686 else
5687 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
5688
5689 if (restart_str)
5690 restart = atoi (restart_str);
5691 else
5692 restart = 0;
5693
5694 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
5695
5696 return bgp_vty_return (vty, ret);
5697 }
5698
5699 static int
5700 peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5701 safi_t safi)
5702 {
5703 int ret;
5704 struct peer *peer;
5705
5706 peer = peer_and_group_lookup_vty (vty, ip_str);
5707 if (! peer)
5708 return CMD_WARNING;
5709
5710 ret = peer_maximum_prefix_unset (peer, afi, safi);
5711
5712 return bgp_vty_return (vty, ret);
5713 }
5714
5715 /* Maximum number of prefix configuration. prefix count is different
5716 for each peer configuration. So this configuration can be set for
5717 each peer configuration. */
5718 DEFUN (neighbor_maximum_prefix,
5719 neighbor_maximum_prefix_cmd,
5720 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5721 NEIGHBOR_STR
5722 NEIGHBOR_ADDR_STR2
5723 "Maximum number of prefix accept from this peer\n"
5724 "maximum no. of prefix limit\n")
5725 {
5726 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5727 bgp_node_safi (vty), argv[1], NULL, 0,
5728 NULL);
5729 }
5730
5731 DEFUN (neighbor_maximum_prefix_threshold,
5732 neighbor_maximum_prefix_threshold_cmd,
5733 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5734 NEIGHBOR_STR
5735 NEIGHBOR_ADDR_STR2
5736 "Maximum number of prefix accept from this peer\n"
5737 "maximum no. of prefix limit\n"
5738 "Threshold value (%) at which to generate a warning msg\n")
5739 {
5740 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5741 bgp_node_safi (vty), argv[1], argv[2], 0,
5742 NULL);
5743 }
5744
5745 DEFUN (neighbor_maximum_prefix_warning,
5746 neighbor_maximum_prefix_warning_cmd,
5747 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5748 NEIGHBOR_STR
5749 NEIGHBOR_ADDR_STR2
5750 "Maximum number of prefix accept from this peer\n"
5751 "maximum no. of prefix limit\n"
5752 "Only give warning message when limit is exceeded\n")
5753 {
5754 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5755 bgp_node_safi (vty), argv[1], NULL, 1,
5756 NULL);
5757 }
5758
5759 DEFUN (neighbor_maximum_prefix_threshold_warning,
5760 neighbor_maximum_prefix_threshold_warning_cmd,
5761 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5762 NEIGHBOR_STR
5763 NEIGHBOR_ADDR_STR2
5764 "Maximum number of prefix accept from this peer\n"
5765 "maximum no. of prefix limit\n"
5766 "Threshold value (%) at which to generate a warning msg\n"
5767 "Only give warning message when limit is exceeded\n")
5768 {
5769 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5770 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5771 }
5772
5773 DEFUN (neighbor_maximum_prefix_restart,
5774 neighbor_maximum_prefix_restart_cmd,
5775 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5776 NEIGHBOR_STR
5777 NEIGHBOR_ADDR_STR2
5778 "Maximum number of prefix accept from this peer\n"
5779 "maximum no. of prefix limit\n"
5780 "Restart bgp connection after limit is exceeded\n"
5781 "Restart interval in minutes")
5782 {
5783 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5784 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5785 }
5786
5787 DEFUN (neighbor_maximum_prefix_threshold_restart,
5788 neighbor_maximum_prefix_threshold_restart_cmd,
5789 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5790 NEIGHBOR_STR
5791 NEIGHBOR_ADDR_STR2
5792 "Maximum number of prefix accept from this peer\n"
5793 "maximum no. of prefix limit\n"
5794 "Threshold value (%) at which to generate a warning msg\n"
5795 "Restart bgp connection after limit is exceeded\n"
5796 "Restart interval in minutes")
5797 {
5798 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5799 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5800 }
5801
5802 DEFUN (no_neighbor_maximum_prefix,
5803 no_neighbor_maximum_prefix_cmd,
5804 NO_NEIGHBOR_CMD2 "maximum-prefix",
5805 NO_STR
5806 NEIGHBOR_STR
5807 NEIGHBOR_ADDR_STR2
5808 "Maximum number of prefix accept from this peer\n")
5809 {
5810 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5811 bgp_node_safi (vty));
5812 }
5813
5814 ALIAS (no_neighbor_maximum_prefix,
5815 no_neighbor_maximum_prefix_val_cmd,
5816 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5817 NO_STR
5818 NEIGHBOR_STR
5819 NEIGHBOR_ADDR_STR2
5820 "Maximum number of prefix accept from this peer\n"
5821 "maximum no. of prefix limit\n")
5822
5823 ALIAS (no_neighbor_maximum_prefix,
5824 no_neighbor_maximum_prefix_threshold_cmd,
5825 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5826 NO_STR
5827 NEIGHBOR_STR
5828 NEIGHBOR_ADDR_STR2
5829 "Maximum number of prefix accept from this peer\n"
5830 "maximum no. of prefix limit\n"
5831 "Threshold value (%) at which to generate a warning msg\n")
5832
5833 ALIAS (no_neighbor_maximum_prefix,
5834 no_neighbor_maximum_prefix_warning_cmd,
5835 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5836 NO_STR
5837 NEIGHBOR_STR
5838 NEIGHBOR_ADDR_STR2
5839 "Maximum number of prefix accept from this peer\n"
5840 "maximum no. of prefix limit\n"
5841 "Only give warning message when limit is exceeded\n")
5842
5843 ALIAS (no_neighbor_maximum_prefix,
5844 no_neighbor_maximum_prefix_threshold_warning_cmd,
5845 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5846 NO_STR
5847 NEIGHBOR_STR
5848 NEIGHBOR_ADDR_STR2
5849 "Maximum number of prefix accept from this peer\n"
5850 "maximum no. of prefix limit\n"
5851 "Threshold value (%) at which to generate a warning msg\n"
5852 "Only give warning message when limit is exceeded\n")
5853
5854 ALIAS (no_neighbor_maximum_prefix,
5855 no_neighbor_maximum_prefix_restart_cmd,
5856 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5857 NO_STR
5858 NEIGHBOR_STR
5859 NEIGHBOR_ADDR_STR2
5860 "Maximum number of prefix accept from this peer\n"
5861 "maximum no. of prefix limit\n"
5862 "Restart bgp connection after limit is exceeded\n"
5863 "Restart interval in minutes")
5864
5865 ALIAS (no_neighbor_maximum_prefix,
5866 no_neighbor_maximum_prefix_threshold_restart_cmd,
5867 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5868 NO_STR
5869 NEIGHBOR_STR
5870 NEIGHBOR_ADDR_STR2
5871 "Maximum number of prefix accept from this peer\n"
5872 "maximum no. of prefix limit\n"
5873 "Threshold value (%) at which to generate a warning msg\n"
5874 "Restart bgp connection after limit is exceeded\n"
5875 "Restart interval in minutes")
5876
5877 /* "neighbor allowas-in" */
5878 DEFUN (neighbor_allowas_in,
5879 neighbor_allowas_in_cmd,
5880 NEIGHBOR_CMD2 "allowas-in",
5881 NEIGHBOR_STR
5882 NEIGHBOR_ADDR_STR2
5883 "Accept as-path with my AS present in it\n")
5884 {
5885 int ret;
5886 int origin = 0;
5887 struct peer *peer;
5888 int allow_num = 0;
5889
5890 peer = peer_and_group_lookup_vty (vty, argv[0]);
5891 if (! peer)
5892 return CMD_WARNING;
5893
5894 if (argc == 1)
5895 allow_num = 3;
5896 else
5897 {
5898 if (strncmp (argv[1], "o", 1) == 0)
5899 origin = 1;
5900 else
5901 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5902 }
5903
5904 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5905 allow_num, origin);
5906
5907 return bgp_vty_return (vty, ret);
5908 }
5909
5910 ALIAS (neighbor_allowas_in,
5911 neighbor_allowas_in_arg_cmd,
5912 NEIGHBOR_CMD2 "allowas-in (<1-10>|origin)",
5913 NEIGHBOR_STR
5914 NEIGHBOR_ADDR_STR2
5915 "Accept as-path with my AS present in it\n"
5916 "Number of occurances of AS number\n"
5917 "Only accept my AS in the as-path if the route was originated in my AS\n")
5918
5919 DEFUN (no_neighbor_allowas_in,
5920 no_neighbor_allowas_in_cmd,
5921 NO_NEIGHBOR_CMD2 "allowas-in",
5922 NO_STR
5923 NEIGHBOR_STR
5924 NEIGHBOR_ADDR_STR2
5925 "allow local ASN appears in aspath attribute\n")
5926 {
5927 int ret;
5928 struct peer *peer;
5929
5930 peer = peer_and_group_lookup_vty (vty, argv[0]);
5931 if (! peer)
5932 return CMD_WARNING;
5933
5934 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5935
5936 return bgp_vty_return (vty, ret);
5937 }
5938
5939 ALIAS (no_neighbor_allowas_in,
5940 no_neighbor_allowas_in_val_cmd,
5941 NO_NEIGHBOR_CMD2 "allowas-in (<1-10>|origin)",
5942 NO_STR
5943 NEIGHBOR_STR
5944 NEIGHBOR_ADDR_STR2
5945 "allow local ASN appears in aspath attribute\n"
5946 "Number of occurances of AS number\n"
5947 "Only accept my AS in the as-path if the route was originated in my AS\n")
5948
5949 DEFUN (neighbor_ttl_security,
5950 neighbor_ttl_security_cmd,
5951 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5952 NEIGHBOR_STR
5953 NEIGHBOR_ADDR_STR2
5954 "Specify the maximum number of hops to the BGP peer\n")
5955 {
5956 struct peer *peer;
5957 int gtsm_hops;
5958
5959 peer = peer_and_group_lookup_vty (vty, argv[0]);
5960 if (! peer)
5961 return CMD_WARNING;
5962
5963 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5964
5965 /*
5966 * If 'neighbor swpX', then this is for directly connected peers,
5967 * we should not accept a ttl-security hops value greater than 1.
5968 */
5969 if (peer->conf_if && (gtsm_hops > 1)) {
5970 vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s",
5971 argv[0], VTY_NEWLINE);
5972 return CMD_WARNING;
5973 }
5974
5975 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
5976 }
5977
5978 DEFUN (no_neighbor_ttl_security,
5979 no_neighbor_ttl_security_cmd,
5980 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5981 NO_STR
5982 NEIGHBOR_STR
5983 NEIGHBOR_ADDR_STR2
5984 "Specify the maximum number of hops to the BGP peer\n")
5985 {
5986 struct peer *peer;
5987
5988 peer = peer_and_group_lookup_vty (vty, argv[0]);
5989 if (! peer)
5990 return CMD_WARNING;
5991
5992 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
5993 }
5994
5995 DEFUN (neighbor_addpath_tx_all_paths,
5996 neighbor_addpath_tx_all_paths_cmd,
5997 NEIGHBOR_CMD2 "addpath-tx-all-paths",
5998 NEIGHBOR_STR
5999 NEIGHBOR_ADDR_STR2
6000 "Use addpath to advertise all paths to a neighbor\n")
6001 {
6002 struct peer *peer;
6003
6004 peer = peer_and_group_lookup_vty (vty, argv[0]);
6005 if (! peer)
6006 return CMD_WARNING;
6007
6008 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
6009 bgp_node_safi (vty),
6010 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
6011 }
6012
6013 DEFUN (no_neighbor_addpath_tx_all_paths,
6014 no_neighbor_addpath_tx_all_paths_cmd,
6015 NO_NEIGHBOR_CMD2 "addpath-tx-all-paths",
6016 NO_STR
6017 NEIGHBOR_STR
6018 NEIGHBOR_ADDR_STR2
6019 "Use addpath to advertise all paths to a neighbor\n")
6020 {
6021 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
6022 bgp_node_safi (vty),
6023 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
6024 }
6025
6026 DEFUN (neighbor_addpath_tx_bestpath_per_as,
6027 neighbor_addpath_tx_bestpath_per_as_cmd,
6028 NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
6029 NEIGHBOR_STR
6030 NEIGHBOR_ADDR_STR2
6031 "Use addpath to advertise the bestpath per each neighboring AS\n")
6032 {
6033 struct peer *peer;
6034
6035 peer = peer_and_group_lookup_vty (vty, argv[0]);
6036 if (! peer)
6037 return CMD_WARNING;
6038
6039 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
6040 bgp_node_safi (vty),
6041 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6042 }
6043
6044 DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
6045 no_neighbor_addpath_tx_bestpath_per_as_cmd,
6046 NO_NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
6047 NO_STR
6048 NEIGHBOR_STR
6049 NEIGHBOR_ADDR_STR2
6050 "Use addpath to advertise the bestpath per each neighboring AS\n")
6051 {
6052 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
6053 bgp_node_safi (vty),
6054 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6055 }
6056
6057
6058 /* Address family configuration. */
6059 DEFUN (address_family_ipv4,
6060 address_family_ipv4_cmd,
6061 "address-family ipv4",
6062 "Enter Address Family command mode\n"
6063 "Address family\n")
6064 {
6065 vty->node = BGP_IPV4_NODE;
6066 return CMD_SUCCESS;
6067 }
6068
6069 DEFUN (address_family_ipv4_safi,
6070 address_family_ipv4_safi_cmd,
6071 "address-family ipv4 (unicast|multicast|vpn|encap)",
6072 "Enter Address Family command mode\n"
6073 "Address Family\n"
6074 BGP_SAFI_HELP_STR)
6075 {
6076 switch (bgp_vty_safi_from_arg(argv[0]))
6077 {
6078 case SAFI_MULTICAST:
6079 vty->node = BGP_IPV4M_NODE;
6080 break;
6081 case SAFI_ENCAP:
6082 vty->node = BGP_ENCAP_NODE;
6083 break;
6084 case SAFI_MPLS_VPN:
6085 vty->node = BGP_VPNV4_NODE;
6086 break;
6087 case SAFI_UNICAST:
6088 default:
6089 vty->node = BGP_IPV4_NODE;
6090 break;
6091 }
6092
6093 return CMD_SUCCESS;
6094 }
6095
6096 DEFUN (address_family_ipv6,
6097 address_family_ipv6_cmd,
6098 "address-family ipv6",
6099 "Enter Address Family command mode\n"
6100 "Address family\n")
6101 {
6102 vty->node = BGP_IPV6_NODE;
6103 return CMD_SUCCESS;
6104 }
6105
6106 DEFUN (address_family_ipv6_safi,
6107 address_family_ipv6_safi_cmd,
6108 "address-family ipv6 (unicast|multicast|vpn|encap)",
6109 "Enter Address Family command mode\n"
6110 "Address Family\n"
6111 BGP_SAFI_HELP_STR)
6112 {
6113 int idx_safi = 0;
6114 switch (bgp_vty_safi_from_arg(argv[idx_safi]))
6115 {
6116 case SAFI_MULTICAST:
6117 vty->node = BGP_IPV6M_NODE;
6118 break;
6119 case SAFI_ENCAP:
6120 vty->node = BGP_ENCAPV6_NODE;
6121 break;
6122 case SAFI_MPLS_VPN:
6123 vty->node = BGP_VPNV6_NODE;
6124 break;
6125 case SAFI_UNICAST:
6126 default:
6127 vty->node = BGP_IPV6_NODE;
6128 break;
6129 }
6130
6131 return CMD_SUCCESS;
6132 }
6133
6134 DEFUN (address_family_vpnv4,
6135 address_family_vpnv4_cmd,
6136 "address-family vpnv4",
6137 "Enter Address Family command mode\n"
6138 "Address family\n")
6139 {
6140 vty->node = BGP_VPNV4_NODE;
6141 return CMD_SUCCESS;
6142 }
6143
6144 DEFUN (address_family_vpnv6,
6145 address_family_vpnv6_cmd,
6146 "address-family vpnv6",
6147 "Enter Address Family command mode\n"
6148 "Address family\n")
6149 {
6150 vty->node = BGP_VPNV6_NODE;
6151 return CMD_SUCCESS;
6152 }
6153
6154 DEFUN (address_family_encap,
6155 address_family_encap_cmd,
6156 "address-family encap",
6157 "Enter Address Family command mode\n"
6158 "Address family\n")
6159 {
6160 vty->node = BGP_ENCAP_NODE;
6161 return CMD_SUCCESS;
6162 }
6163
6164 ALIAS (address_family_encap,
6165 address_family_encapv4_cmd,
6166 "address-family encapv4",
6167 "Enter Address Family command mode\n"
6168 "Address family\n")
6169
6170 DEFUN (address_family_encapv6,
6171 address_family_encapv6_cmd,
6172 "address-family encapv6",
6173 "Enter Address Family command mode\n"
6174 "Address family\n")
6175 {
6176 vty->node = BGP_ENCAPV6_NODE;
6177 return CMD_SUCCESS;
6178 }
6179
6180 DEFUN (exit_address_family,
6181 exit_address_family_cmd,
6182 "exit-address-family",
6183 "Exit from Address Family configuration mode\n")
6184 {
6185 if (vty->node == BGP_IPV4_NODE
6186 || vty->node == BGP_IPV4M_NODE
6187 || vty->node == BGP_VPNV4_NODE
6188 || vty->node == BGP_IPV6_NODE
6189 || vty->node == BGP_IPV6M_NODE
6190 || vty->node == BGP_VPNV6_NODE
6191 || vty->node == BGP_ENCAP_NODE
6192 || vty->node == BGP_ENCAPV6_NODE)
6193 vty->node = BGP_NODE;
6194 return CMD_SUCCESS;
6195 }
6196
6197 /* Recalculate bestpath and re-advertise a prefix */
6198 static int
6199 bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str,
6200 afi_t afi, safi_t safi, struct prefix_rd *prd)
6201 {
6202 int ret;
6203 struct prefix match;
6204 struct bgp_node *rn;
6205 struct bgp_node *rm;
6206 struct bgp *bgp;
6207 struct bgp_table *table;
6208 struct bgp_table *rib;
6209
6210 /* BGP structure lookup. */
6211 if (view_name)
6212 {
6213 bgp = bgp_lookup_by_name (view_name);
6214 if (bgp == NULL)
6215 {
6216 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
6217 return CMD_WARNING;
6218 }
6219 }
6220 else
6221 {
6222 bgp = bgp_get_default ();
6223 if (bgp == NULL)
6224 {
6225 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
6226 return CMD_WARNING;
6227 }
6228 }
6229
6230 /* Check IP address argument. */
6231 ret = str2prefix (ip_str, &match);
6232 if (! ret)
6233 {
6234 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
6235 return CMD_WARNING;
6236 }
6237
6238 match.family = afi2family (afi);
6239 rib = bgp->rib[afi][safi];
6240
6241 if (safi == SAFI_MPLS_VPN)
6242 {
6243 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
6244 {
6245 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6246 continue;
6247
6248 if ((table = rn->info) != NULL)
6249 {
6250 if ((rm = bgp_node_match (table, &match)) != NULL)
6251 {
6252 if (rm->p.prefixlen == match.prefixlen)
6253 {
6254 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6255 bgp_process (bgp, rm, afi, safi);
6256 }
6257 bgp_unlock_node (rm);
6258 }
6259 }
6260 }
6261 }
6262 else
6263 {
6264 if ((rn = bgp_node_match (rib, &match)) != NULL)
6265 {
6266 if (rn->p.prefixlen == match.prefixlen)
6267 {
6268 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6269 bgp_process (bgp, rn, afi, safi);
6270 }
6271 bgp_unlock_node (rn);
6272 }
6273 }
6274
6275 return CMD_SUCCESS;
6276 }
6277
6278 DEFUN (clear_ip_bgp_all,
6279 clear_ip_bgp_all_cmd,
6280 "clear ip bgp *",
6281 CLEAR_STR
6282 IP_STR
6283 BGP_STR
6284 "Clear all peers\n")
6285 {
6286 if (argc == 2)
6287 return bgp_clear_vty (vty, argv[1], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
6288
6289 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
6290 }
6291
6292 ALIAS (clear_ip_bgp_all,
6293 clear_ip_bgp_instance_all_cmd,
6294 "clear ip bgp " BGP_INSTANCE_CMD " *",
6295 CLEAR_STR
6296 IP_STR
6297 BGP_STR
6298 BGP_INSTANCE_HELP_STR
6299 "Clear all peers\n")
6300
6301 ALIAS (clear_ip_bgp_all,
6302 clear_bgp_all_cmd,
6303 "clear bgp *",
6304 CLEAR_STR
6305 BGP_STR
6306 "Clear all peers\n")
6307
6308 ALIAS (clear_ip_bgp_all,
6309 clear_bgp_instance_all_cmd,
6310 "clear bgp " BGP_INSTANCE_CMD " *",
6311 CLEAR_STR
6312 BGP_STR
6313 BGP_INSTANCE_HELP_STR
6314 "Clear all peers\n")
6315
6316 ALIAS (clear_ip_bgp_all,
6317 clear_bgp_ipv6_all_cmd,
6318 "clear bgp ipv6 *",
6319 CLEAR_STR
6320 BGP_STR
6321 "Address family\n"
6322 "Clear all peers\n")
6323
6324 ALIAS (clear_ip_bgp_all,
6325 clear_bgp_instance_ipv6_all_cmd,
6326 "clear bgp " BGP_INSTANCE_CMD " ipv6 *",
6327 CLEAR_STR
6328 BGP_STR
6329 BGP_INSTANCE_HELP_STR
6330 "Address family\n"
6331 "Clear all peers\n")
6332
6333 DEFUN (clear_ip_bgp_peer,
6334 clear_ip_bgp_peer_cmd,
6335 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
6336 CLEAR_STR
6337 IP_STR
6338 BGP_STR
6339 "BGP neighbor IP address to clear\n"
6340 "BGP IPv6 neighbor to clear\n"
6341 "BGP neighbor on interface to clear\n")
6342 {
6343 if (argc == 3)
6344 return bgp_clear_vty (vty, argv[1], 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[2]);
6345
6346 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
6347 }
6348
6349 ALIAS (clear_ip_bgp_peer,
6350 clear_ip_bgp_instance_peer_cmd,
6351 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6352 CLEAR_STR
6353 IP_STR
6354 BGP_STR
6355 BGP_INSTANCE_HELP_STR
6356 "BGP neighbor IP address to clear\n"
6357 "BGP IPv6 neighbor to clear\n"
6358 "BGP neighbor on interface to clear\n")
6359
6360 ALIAS (clear_ip_bgp_peer,
6361 clear_bgp_peer_cmd,
6362 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
6363 CLEAR_STR
6364 BGP_STR
6365 "BGP neighbor address to clear\n"
6366 "BGP IPv6 neighbor to clear\n"
6367 "BGP neighbor on interface to clear\n")
6368
6369 ALIAS (clear_ip_bgp_peer,
6370 clear_bgp_instance_peer_cmd,
6371 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6372 CLEAR_STR
6373 BGP_STR
6374 BGP_INSTANCE_HELP_STR
6375 "BGP neighbor IP address to clear\n"
6376 "BGP IPv6 neighbor to clear\n"
6377 "BGP neighbor on interface to clear\n")
6378
6379 ALIAS (clear_ip_bgp_peer,
6380 clear_bgp_ipv6_peer_cmd,
6381 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
6382 CLEAR_STR
6383 BGP_STR
6384 "Address family\n"
6385 "BGP neighbor address to clear\n"
6386 "BGP IPv6 neighbor to clear\n"
6387 "BGP neighbor on interface to clear\n")
6388
6389 ALIAS (clear_ip_bgp_peer,
6390 clear_bgp_instance_ipv6_peer_cmd,
6391 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD)",
6392 CLEAR_STR
6393 BGP_STR
6394 BGP_INSTANCE_HELP_STR
6395 "Address family\n"
6396 "BGP neighbor IP address to clear\n"
6397 "BGP IPv6 neighbor to clear\n"
6398 "BGP neighbor on interface to clear\n")
6399
6400 DEFUN (clear_ip_bgp_peer_group,
6401 clear_ip_bgp_peer_group_cmd,
6402 "clear ip bgp peer-group WORD",
6403 CLEAR_STR
6404 IP_STR
6405 BGP_STR
6406 "Clear all members of peer-group\n"
6407 "BGP peer-group name\n")
6408 {
6409 if (argc == 3)
6410 return bgp_clear_vty (vty, argv[1], 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[2]);
6411
6412 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
6413 }
6414
6415 ALIAS (clear_ip_bgp_peer_group,
6416 clear_ip_bgp_instance_peer_group_cmd,
6417 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
6418 CLEAR_STR
6419 IP_STR
6420 BGP_STR
6421 BGP_INSTANCE_HELP_STR
6422 "Clear all members of peer-group\n"
6423 "BGP peer-group name\n")
6424
6425 ALIAS (clear_ip_bgp_peer_group,
6426 clear_bgp_peer_group_cmd,
6427 "clear bgp peer-group WORD",
6428 CLEAR_STR
6429 BGP_STR
6430 "Clear all members of peer-group\n"
6431 "BGP peer-group name\n")
6432
6433 ALIAS (clear_ip_bgp_peer_group,
6434 clear_bgp_instance_peer_group_cmd,
6435 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD",
6436 CLEAR_STR
6437 BGP_STR
6438 BGP_INSTANCE_HELP_STR
6439 "Clear all members of peer-group\n"
6440 "BGP peer-group name\n")
6441
6442 ALIAS (clear_ip_bgp_peer_group,
6443 clear_bgp_ipv6_peer_group_cmd,
6444 "clear bgp ipv6 peer-group WORD",
6445 CLEAR_STR
6446 BGP_STR
6447 "Address family\n"
6448 "Clear all members of peer-group\n"
6449 "BGP peer-group name\n")
6450
6451 ALIAS (clear_ip_bgp_peer_group,
6452 clear_bgp_instance_ipv6_peer_group_cmd,
6453 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD",
6454 CLEAR_STR
6455 BGP_STR
6456 BGP_INSTANCE_HELP_STR
6457 "Address family\n"
6458 "Clear all members of peer-group\n"
6459 "BGP peer-group name\n")
6460
6461 DEFUN (clear_ip_bgp_external,
6462 clear_ip_bgp_external_cmd,
6463 "clear ip bgp external",
6464 CLEAR_STR
6465 IP_STR
6466 BGP_STR
6467 "Clear all external peers\n")
6468 {
6469 if (argc == 2)
6470 return bgp_clear_vty (vty, argv[1], 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6471
6472 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6473 }
6474
6475 ALIAS (clear_ip_bgp_external,
6476 clear_ip_bgp_instance_external_cmd,
6477 "clear ip bgp " BGP_INSTANCE_CMD " external",
6478 CLEAR_STR
6479 IP_STR
6480 BGP_STR
6481 BGP_INSTANCE_HELP_STR
6482 "Clear all external peers\n")
6483
6484 ALIAS (clear_ip_bgp_external,
6485 clear_bgp_external_cmd,
6486 "clear bgp external",
6487 CLEAR_STR
6488 BGP_STR
6489 "Clear all external peers\n")
6490
6491 ALIAS (clear_ip_bgp_external,
6492 clear_bgp_instance_external_cmd,
6493 "clear bgp " BGP_INSTANCE_CMD " external",
6494 CLEAR_STR
6495 BGP_STR
6496 BGP_INSTANCE_HELP_STR
6497 "Clear all external peers\n")
6498
6499 ALIAS (clear_ip_bgp_external,
6500 clear_bgp_ipv6_external_cmd,
6501 "clear bgp ipv6 external",
6502 CLEAR_STR
6503 BGP_STR
6504 "Address family\n"
6505 "Clear all external peers\n")
6506
6507 ALIAS (clear_ip_bgp_external,
6508 clear_bgp_instance_ipv6_external_cmd,
6509 "clear bgp " BGP_INSTANCE_CMD " ipv6 external",
6510 CLEAR_STR
6511 BGP_STR
6512 BGP_INSTANCE_HELP_STR
6513 "Address family\n"
6514 "Clear all external peers\n")
6515
6516 DEFUN (clear_ip_bgp_prefix,
6517 clear_ip_bgp_prefix_cmd,
6518 "clear ip bgp prefix A.B.C.D/M",
6519 CLEAR_STR
6520 IP_STR
6521 BGP_STR
6522 "Clear bestpath and re-advertise\n"
6523 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6524 {
6525 if (argc == 3)
6526 return bgp_clear_prefix (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL);
6527
6528 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
6529 }
6530
6531 ALIAS (clear_ip_bgp_prefix,
6532 clear_ip_bgp_instance_prefix_cmd,
6533 "clear ip bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6534 CLEAR_STR
6535 IP_STR
6536 BGP_STR
6537 BGP_INSTANCE_HELP_STR
6538 "Clear bestpath and re-advertise\n"
6539 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6540
6541 ALIAS (clear_ip_bgp_prefix,
6542 clear_bgp_prefix_cmd,
6543 "clear bgp prefix A.B.C.D/M",
6544 CLEAR_STR
6545 BGP_STR
6546 "Clear bestpath and re-advertise\n"
6547 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6548
6549 ALIAS (clear_ip_bgp_prefix,
6550 clear_bgp_instance_prefix_cmd,
6551 "clear bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6552 CLEAR_STR
6553 BGP_STR
6554 BGP_INSTANCE_HELP_STR
6555 "Clear bestpath and re-advertise\n"
6556 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6557
6558 DEFUN (clear_ip_bgp_as,
6559 clear_ip_bgp_as_cmd,
6560 "clear ip bgp " CMD_AS_RANGE,
6561 CLEAR_STR
6562 IP_STR
6563 BGP_STR
6564 "Clear peers with the AS number\n")
6565 {
6566 if (argc == 3)
6567 return bgp_clear_vty (vty, argv[1], 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[2]);
6568
6569 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
6570 }
6571
6572 ALIAS (clear_ip_bgp_as,
6573 clear_ip_bgp_instance_as_cmd,
6574 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6575 CLEAR_STR
6576 IP_STR
6577 BGP_STR
6578 BGP_INSTANCE_HELP_STR
6579 "Clear peers with the AS number\n")
6580
6581 ALIAS (clear_ip_bgp_as,
6582 clear_bgp_as_cmd,
6583 "clear bgp " CMD_AS_RANGE,
6584 CLEAR_STR
6585 BGP_STR
6586 "Clear peers with the AS number\n")
6587
6588 ALIAS (clear_ip_bgp_as,
6589 clear_bgp_instance_as_cmd,
6590 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6591 CLEAR_STR
6592 BGP_STR
6593 BGP_INSTANCE_HELP_STR
6594 "Clear peers with the AS number\n")
6595
6596 ALIAS (clear_ip_bgp_as,
6597 clear_bgp_ipv6_as_cmd,
6598 "clear bgp ipv6 " CMD_AS_RANGE,
6599 CLEAR_STR
6600 BGP_STR
6601 "Address family\n"
6602 "Clear peers with the AS number\n")
6603
6604 ALIAS (clear_ip_bgp_as,
6605 clear_bgp_instance_ipv6_as_cmd,
6606 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE,
6607 CLEAR_STR
6608 BGP_STR
6609 BGP_INSTANCE_HELP_STR
6610 "Address family\n"
6611 "Clear peers with the AS number\n")
6612
6613 /* Outbound soft-reconfiguration */
6614 DEFUN (clear_ip_bgp_all_soft_out,
6615 clear_ip_bgp_all_soft_out_cmd,
6616 "clear ip bgp * soft out",
6617 CLEAR_STR
6618 IP_STR
6619 BGP_STR
6620 "Clear all peers\n"
6621 BGP_SOFT_STR
6622 BGP_SOFT_OUT_STR)
6623 {
6624 if (argc == 2)
6625 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6626 BGP_CLEAR_SOFT_OUT, NULL);
6627
6628 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6629 BGP_CLEAR_SOFT_OUT, NULL);
6630 }
6631
6632 ALIAS (clear_ip_bgp_all_soft_out,
6633 clear_ip_bgp_instance_all_soft_out_cmd,
6634 "clear ip bgp " BGP_INSTANCE_CMD " * soft out",
6635 CLEAR_STR
6636 IP_STR
6637 BGP_STR
6638 BGP_INSTANCE_HELP_STR
6639 "Clear all peers\n"
6640 BGP_SOFT_STR
6641 BGP_SOFT_OUT_STR)
6642
6643 ALIAS (clear_ip_bgp_all_soft_out,
6644 clear_ip_bgp_all_out_cmd,
6645 "clear ip bgp * out",
6646 CLEAR_STR
6647 IP_STR
6648 BGP_STR
6649 "Clear all peers\n"
6650 BGP_SOFT_OUT_STR)
6651
6652 ALIAS (clear_ip_bgp_all_soft_out,
6653 clear_ip_bgp_instance_all_out_cmd,
6654 "clear ip bgp " BGP_INSTANCE_CMD " * out",
6655 CLEAR_STR
6656 IP_STR
6657 BGP_STR
6658 BGP_INSTANCE_HELP_STR
6659 "Clear all peers\n"
6660 BGP_SOFT_OUT_STR)
6661
6662 DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6663 clear_ip_bgp_all_ipv4_soft_out_cmd,
6664 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft out",
6665 CLEAR_STR
6666 IP_STR
6667 BGP_STR
6668 "Clear all peers\n"
6669 "Address family\n"
6670 BGP_SAFI_HELP_STR
6671 BGP_SOFT_STR
6672 BGP_SOFT_OUT_STR)
6673 {
6674 safi_t safi;
6675 safi = bgp_vty_safi_from_arg(argv[0]);
6676 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all,
6677 BGP_CLEAR_SOFT_OUT, NULL);
6678 }
6679
6680 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6681 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
6682 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft out",
6683 CLEAR_STR
6684 IP_STR
6685 BGP_STR
6686 BGP_INSTANCE_HELP_STR
6687 "Clear all peers\n"
6688 "Address family\n"
6689 BGP_SAFI_HELP_STR
6690 BGP_SOFT_OUT_STR)
6691 {
6692 safi_t safi;
6693 safi = bgp_vty_safi_from_arg(argv[2]);
6694 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all,
6695 BGP_CLEAR_SOFT_OUT, NULL);
6696 }
6697
6698 ALIAS (clear_ip_bgp_all_ipv4_soft_out,
6699 clear_ip_bgp_all_ipv4_out_cmd,
6700 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" out",
6701 CLEAR_STR
6702 IP_STR
6703 BGP_STR
6704 "Clear all peers\n"
6705 "Address family\n"
6706 BGP_SAFI_HELP_STR
6707 BGP_SOFT_OUT_STR)
6708
6709 ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out,
6710 clear_ip_bgp_instance_all_ipv4_out_cmd,
6711 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" out",
6712 CLEAR_STR
6713 IP_STR
6714 BGP_STR
6715 BGP_INSTANCE_HELP_STR
6716 "Clear all peers\n"
6717 "Address family\n"
6718 BGP_SAFI_HELP_STR
6719 BGP_SOFT_OUT_STR)
6720
6721 DEFUN (clear_bgp_all_soft_out,
6722 clear_bgp_all_soft_out_cmd,
6723 "clear bgp * soft out",
6724 CLEAR_STR
6725 BGP_STR
6726 "Clear all peers\n"
6727 BGP_SOFT_STR
6728 BGP_SOFT_OUT_STR)
6729 {
6730 if (argc == 2)
6731 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
6732 BGP_CLEAR_SOFT_OUT, NULL);
6733
6734 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6735 BGP_CLEAR_SOFT_OUT, NULL);
6736 }
6737
6738 ALIAS (clear_bgp_all_soft_out,
6739 clear_bgp_instance_all_soft_out_cmd,
6740 "clear bgp " BGP_INSTANCE_CMD " * soft out",
6741 CLEAR_STR
6742 BGP_STR
6743 BGP_INSTANCE_HELP_STR
6744 "Clear all peers\n"
6745 BGP_SOFT_STR
6746 BGP_SOFT_OUT_STR)
6747
6748 ALIAS (clear_bgp_all_soft_out,
6749 clear_bgp_all_out_cmd,
6750 "clear bgp * out",
6751 CLEAR_STR
6752 BGP_STR
6753 "Clear all peers\n"
6754 BGP_SOFT_OUT_STR)
6755
6756 ALIAS (clear_bgp_all_soft_out,
6757 clear_bgp_instance_all_out_cmd,
6758 "clear bgp " BGP_INSTANCE_CMD " * out",
6759 CLEAR_STR
6760 BGP_STR
6761 BGP_INSTANCE_HELP_STR
6762 "Clear all peers\n"
6763 BGP_SOFT_OUT_STR)
6764
6765 ALIAS (clear_bgp_all_soft_out,
6766 clear_bgp_ipv6_all_soft_out_cmd,
6767 "clear bgp ipv6 * soft out",
6768 CLEAR_STR
6769 BGP_STR
6770 "Address family\n"
6771 "Clear all peers\n"
6772 BGP_SOFT_STR
6773 BGP_SOFT_OUT_STR)
6774
6775 ALIAS (clear_bgp_all_soft_out,
6776 clear_bgp_instance_ipv6_all_soft_out_cmd,
6777 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft out",
6778 CLEAR_STR
6779 BGP_STR
6780 BGP_INSTANCE_HELP_STR
6781 "Address family\n"
6782 "Clear all peers\n"
6783 BGP_SOFT_STR
6784 BGP_SOFT_OUT_STR)
6785
6786 ALIAS (clear_bgp_all_soft_out,
6787 clear_bgp_ipv6_all_out_cmd,
6788 "clear bgp ipv6 * out",
6789 CLEAR_STR
6790 BGP_STR
6791 "Address family\n"
6792 "Clear all peers\n"
6793 BGP_SOFT_OUT_STR)
6794
6795 ALIAS (clear_bgp_all_soft_out,
6796 clear_bgp_instance_ipv6_all_out_cmd,
6797 "clear bgp " BGP_INSTANCE_CMD " ipv6 * out",
6798 CLEAR_STR
6799 BGP_STR
6800 BGP_INSTANCE_HELP_STR
6801 "Address family\n"
6802 "Clear all peers\n"
6803 BGP_SOFT_OUT_STR)
6804
6805 DEFUN (clear_bgp_ipv6_safi_prefix,
6806 clear_bgp_ipv6_safi_prefix_cmd,
6807 "clear bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M",
6808 CLEAR_STR
6809 BGP_STR
6810 "Address family\n"
6811 "Address Family Modifier\n"
6812 "Clear bestpath and re-advertise\n"
6813 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6814 {
6815 safi_t safi;
6816 safi = bgp_vty_safi_from_arg(argv[0]);
6817 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, safi, NULL);
6818 }
6819
6820 DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6821 clear_bgp_instance_ipv6_safi_prefix_cmd,
6822 "clear bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M",
6823 CLEAR_STR
6824 BGP_STR
6825 BGP_INSTANCE_HELP_STR
6826 "Address family\n"
6827 "Address Family Modifier\n"
6828 "Clear bestpath and re-advertise\n"
6829 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6830 {
6831 safi_t safi;
6832 safi = bgp_vty_safi_from_arg(argv[2]);
6833 return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, safi, NULL);
6834 }
6835
6836 DEFUN (clear_ip_bgp_peer_soft_out,
6837 clear_ip_bgp_peer_soft_out_cmd,
6838 "clear ip bgp (A.B.C.D|WORD) soft out",
6839 CLEAR_STR
6840 IP_STR
6841 BGP_STR
6842 "BGP neighbor address to clear\n"
6843 "BGP neighbor on interface to clear\n"
6844 BGP_SOFT_STR
6845 BGP_SOFT_OUT_STR)
6846 {
6847 if (argc == 3)
6848 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
6849 BGP_CLEAR_SOFT_OUT, argv[2]);
6850
6851 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6852 BGP_CLEAR_SOFT_OUT, argv[0]);
6853 }
6854
6855 ALIAS (clear_ip_bgp_peer_soft_out,
6856 clear_ip_bgp_instance_peer_soft_out_cmd,
6857 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft out",
6858 CLEAR_STR
6859 IP_STR
6860 BGP_STR
6861 BGP_INSTANCE_HELP_STR
6862 "BGP neighbor address to clear\n"
6863 "BGP neighbor on interface to clear\n"
6864 BGP_SOFT_STR
6865 BGP_SOFT_OUT_STR)
6866
6867 ALIAS (clear_ip_bgp_peer_soft_out,
6868 clear_ip_bgp_peer_out_cmd,
6869 "clear ip bgp (A.B.C.D|WORD) out",
6870 CLEAR_STR
6871 IP_STR
6872 BGP_STR
6873 "BGP neighbor address to clear\n"
6874 "BGP neighbor on interface to clear\n"
6875 BGP_SOFT_OUT_STR)
6876
6877 ALIAS (clear_ip_bgp_peer_soft_out,
6878 clear_ip_bgp_instance_peer_out_cmd,
6879 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) out",
6880 CLEAR_STR
6881 IP_STR
6882 BGP_STR
6883 BGP_INSTANCE_HELP_STR
6884 "BGP neighbor address to clear\n"
6885 "BGP neighbor on interface to clear\n"
6886 BGP_SOFT_OUT_STR)
6887
6888 DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6889 clear_ip_bgp_peer_ipv4_soft_out_cmd,
6890 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out",
6891 CLEAR_STR
6892 IP_STR
6893 BGP_STR
6894 "BGP neighbor address to clear\n"
6895 "BGP neighbor on interface to clear\n"
6896 "Address family\n"
6897 BGP_SAFI_HELP_STR
6898 BGP_SOFT_STR
6899 BGP_SOFT_OUT_STR)
6900 {
6901 safi_t safi;
6902 safi = bgp_vty_safi_from_arg(argv[1]);
6903 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer,
6904 BGP_CLEAR_SOFT_OUT, argv[0]);
6905 }
6906
6907 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out,
6908 clear_ip_bgp_instance_peer_ipv4_soft_out_cmd,
6909 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out",
6910 CLEAR_STR
6911 IP_STR
6912 BGP_STR
6913 BGP_INSTANCE_HELP_STR
6914 "BGP neighbor address to clear\n"
6915 "BGP neighbor on interface to clear\n"
6916 "Address family\n"
6917 BGP_SAFI_HELP_STR
6918 BGP_SOFT_STR
6919 BGP_SOFT_OUT_STR)
6920 {
6921 safi_t safi;
6922 safi = bgp_vty_safi_from_arg(argv[3]);
6923 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer,
6924 BGP_CLEAR_SOFT_OUT, argv[2]);
6925 }
6926
6927 ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6928 clear_ip_bgp_peer_ipv4_out_cmd,
6929 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out",
6930 CLEAR_STR
6931 IP_STR
6932 BGP_STR
6933 "BGP neighbor address to clear\n"
6934 "BGP neighbor on interface to clear\n"
6935 "Address family\n"
6936 BGP_SAFI_HELP_STR
6937 BGP_SOFT_OUT_STR)
6938
6939 ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out,
6940 clear_ip_bgp_instance_peer_ipv4_out_cmd,
6941 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out",
6942 CLEAR_STR
6943 IP_STR
6944 BGP_STR
6945 BGP_INSTANCE_HELP_STR
6946 "BGP neighbor address to clear\n"
6947 "BGP neighbor on interface to clear\n"
6948 "Address family\n"
6949 BGP_SAFI_HELP_STR
6950 BGP_SOFT_OUT_STR)
6951
6952 DEFUN (clear_bgp_peer_soft_out,
6953 clear_bgp_peer_soft_out_cmd,
6954 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
6955 CLEAR_STR
6956 BGP_STR
6957 "BGP neighbor address to clear\n"
6958 "BGP IPv6 neighbor to clear\n"
6959 "BGP neighbor on interface to clear\n"
6960 BGP_SOFT_STR
6961 BGP_SOFT_OUT_STR)
6962 {
6963 if (argc == 3)
6964 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
6965 BGP_CLEAR_SOFT_OUT, argv[2]);
6966
6967 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6968 BGP_CLEAR_SOFT_OUT, argv[0]);
6969 }
6970
6971 ALIAS (clear_bgp_peer_soft_out,
6972 clear_bgp_instance_peer_soft_out_cmd,
6973 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft out",
6974 CLEAR_STR
6975 BGP_STR
6976 BGP_INSTANCE_HELP_STR
6977 "BGP neighbor address to clear\n"
6978 "BGP IPv6 neighbor to clear\n"
6979 "BGP neighbor on interface to clear\n"
6980 BGP_SOFT_STR
6981 BGP_SOFT_OUT_STR)
6982
6983 ALIAS (clear_bgp_peer_soft_out,
6984 clear_bgp_ipv6_peer_soft_out_cmd,
6985 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6986 CLEAR_STR
6987 BGP_STR
6988 "Address family\n"
6989 "BGP neighbor address to clear\n"
6990 "BGP IPv6 neighbor to clear\n"
6991 "BGP neighbor on interface to clear\n"
6992 BGP_SOFT_STR
6993 BGP_SOFT_OUT_STR)
6994
6995 ALIAS (clear_bgp_peer_soft_out,
6996 clear_bgp_instance_ipv6_peer_soft_out_cmd,
6997 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6998 CLEAR_STR
6999 BGP_STR
7000 BGP_INSTANCE_HELP_STR
7001 "Address family\n"
7002 "BGP neighbor address to clear\n"
7003 "BGP IPv6 neighbor to clear\n"
7004 "BGP neighbor on interface to clear\n"
7005 BGP_SOFT_STR
7006 BGP_SOFT_OUT_STR)
7007
7008 ALIAS (clear_bgp_peer_soft_out,
7009 clear_bgp_peer_out_cmd,
7010 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
7011 CLEAR_STR
7012 BGP_STR
7013 "BGP neighbor address to clear\n"
7014 "BGP IPv6 neighbor to clear\n"
7015 "BGP neighbor on interface to clear\n"
7016 BGP_SOFT_OUT_STR)
7017
7018 ALIAS (clear_bgp_peer_soft_out,
7019 clear_bgp_instance_peer_out_cmd,
7020 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) out",
7021 CLEAR_STR
7022 BGP_STR
7023 BGP_INSTANCE_HELP_STR
7024 "BGP neighbor address to clear\n"
7025 "BGP IPv6 neighbor to clear\n"
7026 "BGP neighbor on interface to clear\n"
7027 BGP_SOFT_OUT_STR)
7028
7029 ALIAS (clear_bgp_peer_soft_out,
7030 clear_bgp_ipv6_peer_out_cmd,
7031 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
7032 CLEAR_STR
7033 BGP_STR
7034 "Address family\n"
7035 "BGP neighbor address to clear\n"
7036 "BGP IPv6 neighbor to clear\n"
7037 "BGP neighbor on interface to clear\n"
7038 BGP_SOFT_OUT_STR)
7039
7040 ALIAS (clear_bgp_peer_soft_out,
7041 clear_bgp_instance_ipv6_peer_out_cmd,
7042 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) out",
7043 CLEAR_STR
7044 BGP_STR
7045 BGP_INSTANCE_HELP_STR
7046 "Address family\n"
7047 "BGP neighbor address to clear\n"
7048 "BGP IPv6 neighbor to clear\n"
7049 "BGP neighbor on interface to clear\n"
7050 BGP_SOFT_OUT_STR)
7051
7052 DEFUN (clear_ip_bgp_peer_group_soft_out,
7053 clear_ip_bgp_peer_group_soft_out_cmd,
7054 "clear ip bgp peer-group WORD soft out",
7055 CLEAR_STR
7056 IP_STR
7057 BGP_STR
7058 "Clear all members of peer-group\n"
7059 "BGP peer-group name\n"
7060 BGP_SOFT_STR
7061 BGP_SOFT_OUT_STR)
7062 {
7063 if (argc == 3)
7064 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
7065 BGP_CLEAR_SOFT_OUT, argv[2]);
7066
7067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7068 BGP_CLEAR_SOFT_OUT, argv[0]);
7069 }
7070
7071 ALIAS (clear_ip_bgp_peer_group_soft_out,
7072 clear_ip_bgp_instance_peer_group_soft_out_cmd,
7073 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
7074 CLEAR_STR
7075 IP_STR
7076 BGP_STR
7077 BGP_INSTANCE_HELP_STR
7078 "Clear all members of peer-group\n"
7079 "BGP peer-group name\n"
7080 BGP_SOFT_STR
7081 BGP_SOFT_OUT_STR)
7082
7083 ALIAS (clear_ip_bgp_peer_group_soft_out,
7084 clear_ip_bgp_peer_group_out_cmd,
7085 "clear ip bgp peer-group WORD out",
7086 CLEAR_STR
7087 IP_STR
7088 BGP_STR
7089 "Clear all members of peer-group\n"
7090 "BGP peer-group name\n"
7091 BGP_SOFT_OUT_STR)
7092
7093 ALIAS (clear_ip_bgp_peer_group_soft_out,
7094 clear_ip_bgp_instance_peer_group_out_cmd,
7095 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD out",
7096 CLEAR_STR
7097 IP_STR
7098 BGP_STR
7099 BGP_INSTANCE_HELP_STR
7100 "Clear all members of peer-group\n"
7101 "BGP peer-group name\n"
7102 BGP_SOFT_OUT_STR)
7103
7104 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
7105 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
7106 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out",
7107 CLEAR_STR
7108 IP_STR
7109 BGP_STR
7110 "Clear all members of peer-group\n"
7111 "BGP peer-group name\n"
7112 "Address family\n"
7113 BGP_SAFI_HELP_STR
7114 BGP_SOFT_STR
7115 BGP_SOFT_OUT_STR)
7116 {
7117 safi_t safi;
7118 safi = bgp_vty_safi_from_arg(argv[1]);
7119 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group,
7120 BGP_CLEAR_SOFT_OUT, argv[0]);
7121 }
7122
7123 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
7124 clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd,
7125 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out",
7126 CLEAR_STR
7127 IP_STR
7128 BGP_STR
7129 BGP_INSTANCE_HELP_STR
7130 "Clear all members of peer-group\n"
7131 "BGP peer-group name\n"
7132 "Address family\n"
7133 BGP_SAFI_HELP_STR
7134 BGP_SOFT_STR
7135 BGP_SOFT_OUT_STR)
7136 {
7137 safi_t safi;
7138 safi = bgp_vty_safi_from_arg(argv[3]);
7139 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group,
7140 BGP_CLEAR_SOFT_OUT, argv[2]);
7141 }
7142
7143 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
7144 clear_ip_bgp_peer_group_ipv4_out_cmd,
7145 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out",
7146 CLEAR_STR
7147 IP_STR
7148 BGP_STR
7149 "Clear all members of peer-group\n"
7150 "BGP peer-group name\n"
7151 "Address family\n"
7152 BGP_SAFI_HELP_STR
7153 BGP_SOFT_OUT_STR)
7154
7155 ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
7156 clear_ip_bgp_instance_peer_group_ipv4_out_cmd,
7157 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out",
7158 CLEAR_STR
7159 IP_STR
7160 BGP_STR
7161 BGP_INSTANCE_HELP_STR
7162 "Clear all members of peer-group\n"
7163 "BGP peer-group name\n"
7164 "Address family\n"
7165 BGP_SAFI_HELP_STR
7166 BGP_SOFT_OUT_STR)
7167
7168 DEFUN (clear_bgp_peer_group_soft_out,
7169 clear_bgp_peer_group_soft_out_cmd,
7170 "clear bgp peer-group WORD soft out",
7171 CLEAR_STR
7172 BGP_STR
7173 "Clear all members of peer-group\n"
7174 "BGP peer-group name\n"
7175 BGP_SOFT_STR
7176 BGP_SOFT_OUT_STR)
7177 {
7178 if (argc == 3)
7179 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
7180 BGP_CLEAR_SOFT_OUT, argv[2]);
7181
7182 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7183 BGP_CLEAR_SOFT_OUT, argv[0]);
7184 }
7185
7186 ALIAS (clear_bgp_peer_group_soft_out,
7187 clear_bgp_instance_peer_group_soft_out_cmd,
7188 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
7189 CLEAR_STR
7190 BGP_STR
7191 BGP_INSTANCE_HELP_STR
7192 "Clear all members of peer-group\n"
7193 "BGP peer-group name\n"
7194 BGP_SOFT_STR
7195 BGP_SOFT_OUT_STR)
7196
7197 ALIAS (clear_bgp_peer_group_soft_out,
7198 clear_bgp_ipv6_peer_group_soft_out_cmd,
7199 "clear bgp ipv6 peer-group WORD soft out",
7200 CLEAR_STR
7201 BGP_STR
7202 "Address family\n"
7203 "Clear all members of peer-group\n"
7204 "BGP peer-group name\n"
7205 BGP_SOFT_STR
7206 BGP_SOFT_OUT_STR)
7207
7208 ALIAS (clear_bgp_peer_group_soft_out,
7209 clear_bgp_instance_ipv6_peer_group_soft_out_cmd,
7210 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft out",
7211 CLEAR_STR
7212 BGP_STR
7213 BGP_INSTANCE_HELP_STR
7214 "Address family\n"
7215 "Clear all members of peer-group\n"
7216 "BGP peer-group name\n"
7217 BGP_SOFT_STR
7218 BGP_SOFT_OUT_STR)
7219
7220 ALIAS (clear_bgp_peer_group_soft_out,
7221 clear_bgp_peer_group_out_cmd,
7222 "clear bgp peer-group WORD out",
7223 CLEAR_STR
7224 BGP_STR
7225 "Clear all members of peer-group\n"
7226 "BGP peer-group name\n"
7227 BGP_SOFT_OUT_STR)
7228
7229 ALIAS (clear_bgp_peer_group_soft_out,
7230 clear_bgp_instance_peer_group_out_cmd,
7231 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD out",
7232 CLEAR_STR
7233 BGP_STR
7234 BGP_INSTANCE_HELP_STR
7235 "Clear all members of peer-group\n"
7236 "BGP peer-group name\n"
7237 BGP_SOFT_OUT_STR)
7238
7239 ALIAS (clear_bgp_peer_group_soft_out,
7240 clear_bgp_ipv6_peer_group_out_cmd,
7241 "clear bgp ipv6 peer-group WORD out",
7242 CLEAR_STR
7243 BGP_STR
7244 "Address family\n"
7245 "Clear all members of peer-group\n"
7246 "BGP peer-group name\n"
7247 BGP_SOFT_OUT_STR)
7248
7249 ALIAS (clear_bgp_peer_group_soft_out,
7250 clear_bgp_instance_ipv6_peer_group_out_cmd,
7251 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD out",
7252 CLEAR_STR
7253 BGP_STR
7254 BGP_INSTANCE_HELP_STR
7255 "Address family\n"
7256 "Clear all members of peer-group\n"
7257 "BGP peer-group name\n"
7258 BGP_SOFT_OUT_STR)
7259
7260 DEFUN (clear_ip_bgp_external_soft_out,
7261 clear_ip_bgp_external_soft_out_cmd,
7262 "clear ip bgp external soft out",
7263 CLEAR_STR
7264 IP_STR
7265 BGP_STR
7266 "Clear all external peers\n"
7267 BGP_SOFT_STR
7268 BGP_SOFT_OUT_STR)
7269 {
7270 if (argc == 2)
7271 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7272 BGP_CLEAR_SOFT_OUT, NULL);
7273
7274 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7275 BGP_CLEAR_SOFT_OUT, NULL);
7276 }
7277
7278 ALIAS (clear_ip_bgp_external_soft_out,
7279 clear_ip_bgp_instance_external_soft_out_cmd,
7280 "clear ip bgp " BGP_INSTANCE_CMD " external soft out",
7281 CLEAR_STR
7282 IP_STR
7283 BGP_STR
7284 BGP_INSTANCE_HELP_STR
7285 "Clear all external peers\n"
7286 BGP_SOFT_STR
7287 BGP_SOFT_OUT_STR)
7288
7289 ALIAS (clear_ip_bgp_external_soft_out,
7290 clear_ip_bgp_external_out_cmd,
7291 "clear ip bgp external out",
7292 CLEAR_STR
7293 IP_STR
7294 BGP_STR
7295 "Clear all external peers\n"
7296 BGP_SOFT_OUT_STR)
7297
7298 ALIAS (clear_ip_bgp_external_soft_out,
7299 clear_ip_bgp_instance_external_out_cmd,
7300 "clear ip bgp " BGP_INSTANCE_CMD " external out",
7301 CLEAR_STR
7302 IP_STR
7303 BGP_STR
7304 BGP_INSTANCE_HELP_STR
7305 "Clear all external peers\n"
7306 BGP_SOFT_OUT_STR)
7307
7308 DEFUN (clear_ip_bgp_external_ipv4_soft_out,
7309 clear_ip_bgp_external_ipv4_soft_out_cmd,
7310 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft out",
7311 CLEAR_STR
7312 IP_STR
7313 BGP_STR
7314 "Clear all external peers\n"
7315 "Address family\n"
7316 BGP_SAFI_HELP_STR
7317 BGP_SOFT_STR
7318 BGP_SOFT_OUT_STR)
7319 {
7320 safi_t safi;
7321 safi = bgp_vty_safi_from_arg(argv[0]);
7322 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external,
7323 BGP_CLEAR_SOFT_OUT, NULL);
7324 }
7325
7326 DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out,
7327 clear_ip_bgp_instance_external_ipv4_soft_out_cmd,
7328 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft out",
7329 CLEAR_STR
7330 IP_STR
7331 BGP_STR
7332 BGP_INSTANCE_HELP_STR
7333 "Clear all external peers\n"
7334 "Address family\n"
7335 BGP_SAFI_HELP_STR
7336 BGP_SOFT_STR
7337 BGP_SOFT_OUT_STR)
7338 {
7339 safi_t safi;
7340 safi = bgp_vty_safi_from_arg(argv[2]);
7341 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external,
7342 BGP_CLEAR_SOFT_OUT, NULL);
7343 }
7344
7345 ALIAS (clear_ip_bgp_external_ipv4_soft_out,
7346 clear_ip_bgp_external_ipv4_out_cmd,
7347 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" out",
7348 CLEAR_STR
7349 IP_STR
7350 BGP_STR
7351 "Clear all external peers\n"
7352 "Address family\n"
7353 BGP_SAFI_HELP_STR
7354 BGP_SOFT_OUT_STR)
7355
7356 ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out,
7357 clear_ip_bgp_instance_external_ipv4_out_cmd,
7358 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" out",
7359 CLEAR_STR
7360 IP_STR
7361 BGP_STR
7362 BGP_INSTANCE_HELP_STR
7363 "Clear all external peers\n"
7364 "Address family\n"
7365 BGP_SAFI_HELP_STR
7366 BGP_SOFT_OUT_STR)
7367
7368 DEFUN (clear_bgp_external_soft_out,
7369 clear_bgp_external_soft_out_cmd,
7370 "clear bgp external soft out",
7371 CLEAR_STR
7372 BGP_STR
7373 "Clear all external peers\n"
7374 BGP_SOFT_STR
7375 BGP_SOFT_OUT_STR)
7376 {
7377 if (argc == 2)
7378 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
7379 BGP_CLEAR_SOFT_OUT, NULL);
7380
7381 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7382 BGP_CLEAR_SOFT_OUT, NULL);
7383 }
7384
7385 ALIAS (clear_bgp_external_soft_out,
7386 clear_bgp_instance_external_soft_out_cmd,
7387 "clear bgp " BGP_INSTANCE_CMD " external soft out",
7388 CLEAR_STR
7389 BGP_STR
7390 BGP_INSTANCE_HELP_STR
7391 "Clear all external peers\n"
7392 BGP_SOFT_STR
7393 BGP_SOFT_OUT_STR)
7394
7395 ALIAS (clear_bgp_external_soft_out,
7396 clear_bgp_ipv6_external_soft_out_cmd,
7397 "clear bgp ipv6 external soft out",
7398 CLEAR_STR
7399 BGP_STR
7400 "Address family\n"
7401 "Clear all external peers\n"
7402 BGP_SOFT_STR
7403 BGP_SOFT_OUT_STR)
7404
7405 ALIAS (clear_bgp_external_soft_out,
7406 clear_bgp_instance_ipv6_external_soft_out_cmd,
7407 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft out",
7408 CLEAR_STR
7409 BGP_STR
7410 BGP_INSTANCE_HELP_STR
7411 "Address family\n"
7412 "Clear all external peers\n"
7413 BGP_SOFT_STR
7414 BGP_SOFT_OUT_STR)
7415
7416 ALIAS (clear_bgp_external_soft_out,
7417 clear_bgp_external_out_cmd,
7418 "clear bgp external out",
7419 CLEAR_STR
7420 BGP_STR
7421 "Clear all external peers\n"
7422 BGP_SOFT_OUT_STR)
7423
7424 ALIAS (clear_bgp_external_soft_out,
7425 clear_bgp_instance_external_out_cmd,
7426 "clear bgp " BGP_INSTANCE_CMD " external out",
7427 CLEAR_STR
7428 BGP_STR
7429 BGP_INSTANCE_HELP_STR
7430 "Clear all external peers\n"
7431 BGP_SOFT_OUT_STR)
7432
7433 ALIAS (clear_bgp_external_soft_out,
7434 clear_bgp_ipv6_external_out_cmd,
7435 "clear bgp ipv6 external WORD out",
7436 CLEAR_STR
7437 BGP_STR
7438 "Address family\n"
7439 "Clear all external peers\n"
7440 BGP_SOFT_OUT_STR)
7441
7442 ALIAS (clear_bgp_external_soft_out,
7443 clear_bgp_instance_ipv6_external_out_cmd,
7444 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD out",
7445 CLEAR_STR
7446 BGP_STR
7447 BGP_INSTANCE_HELP_STR
7448 "Address family\n"
7449 "Clear all external peers\n"
7450 BGP_SOFT_OUT_STR)
7451
7452 DEFUN (clear_ip_bgp_as_soft_out,
7453 clear_ip_bgp_as_soft_out_cmd,
7454 "clear ip bgp " CMD_AS_RANGE " soft out",
7455 CLEAR_STR
7456 IP_STR
7457 BGP_STR
7458 "Clear peers with the AS number\n"
7459 BGP_SOFT_STR
7460 BGP_SOFT_OUT_STR)
7461 {
7462 if (argc == 3)
7463 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7464 BGP_CLEAR_SOFT_OUT, argv[2]);
7465
7466 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7467 BGP_CLEAR_SOFT_OUT, argv[0]);
7468 }
7469
7470 ALIAS (clear_ip_bgp_as_soft_out,
7471 clear_ip_bgp_instance_as_soft_out_cmd,
7472 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7473 CLEAR_STR
7474 IP_STR
7475 BGP_STR
7476 BGP_INSTANCE_HELP_STR
7477 "Clear peers with the AS number\n"
7478 BGP_SOFT_STR
7479 BGP_SOFT_OUT_STR)
7480
7481 ALIAS (clear_ip_bgp_as_soft_out,
7482 clear_ip_bgp_as_out_cmd,
7483 "clear ip bgp " CMD_AS_RANGE " out",
7484 CLEAR_STR
7485 IP_STR
7486 BGP_STR
7487 "Clear peers with the AS number\n"
7488 BGP_SOFT_OUT_STR)
7489
7490 ALIAS (clear_ip_bgp_as_soft_out,
7491 clear_ip_bgp_instance_as_out_cmd,
7492 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7493 CLEAR_STR
7494 IP_STR
7495 BGP_STR
7496 BGP_INSTANCE_HELP_STR
7497 "Clear peers with the AS number\n"
7498 BGP_SOFT_OUT_STR)
7499
7500 DEFUN (clear_ip_bgp_as_ipv4_soft_out,
7501 clear_ip_bgp_as_ipv4_soft_out_cmd,
7502 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out",
7503 CLEAR_STR
7504 IP_STR
7505 BGP_STR
7506 "Clear peers with the AS number\n"
7507 "Address family\n"
7508 BGP_SAFI_HELP_STR
7509 BGP_SOFT_STR
7510 BGP_SOFT_OUT_STR)
7511 {
7512 safi_t safi;
7513 safi = bgp_vty_safi_from_arg(argv[1]);
7514 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as,
7515 BGP_CLEAR_SOFT_OUT, argv[0]);
7516 }
7517
7518 DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out,
7519 clear_ip_bgp_instance_as_ipv4_soft_out_cmd,
7520 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out",
7521 CLEAR_STR
7522 IP_STR
7523 BGP_STR
7524 BGP_INSTANCE_HELP_STR
7525 "Clear peers with the AS number\n"
7526 "Address family\n"
7527 BGP_SAFI_HELP_STR
7528 BGP_SOFT_STR
7529 BGP_SOFT_OUT_STR)
7530 {
7531 safi_t safi;
7532 safi = bgp_vty_safi_from_arg(argv[3]);
7533 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as,
7534 BGP_CLEAR_SOFT_OUT, argv[2]);
7535 }
7536
7537 ALIAS (clear_ip_bgp_as_ipv4_soft_out,
7538 clear_ip_bgp_as_ipv4_out_cmd,
7539 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out",
7540 CLEAR_STR
7541 IP_STR
7542 BGP_STR
7543 "Clear peers with the AS number\n"
7544 "Address family\n"
7545 BGP_SAFI_HELP_STR
7546 BGP_SOFT_OUT_STR)
7547
7548 ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out,
7549 clear_ip_bgp_instance_as_ipv4_out_cmd,
7550 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out",
7551 CLEAR_STR
7552 IP_STR
7553 BGP_STR
7554 BGP_INSTANCE_HELP_STR
7555 "Clear peers with the AS number\n"
7556 "Address family\n"
7557 BGP_SAFI_HELP_STR
7558 BGP_SOFT_OUT_STR)
7559
7560 DEFUN (clear_bgp_as_soft_out,
7561 clear_bgp_as_soft_out_cmd,
7562 "clear bgp " CMD_AS_RANGE " soft out",
7563 CLEAR_STR
7564 BGP_STR
7565 "Clear peers with the AS number\n"
7566 BGP_SOFT_STR
7567 BGP_SOFT_OUT_STR)
7568 {
7569 if (argc == 3)
7570 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
7571 BGP_CLEAR_SOFT_OUT, argv[2]);
7572
7573 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7574 BGP_CLEAR_SOFT_OUT, argv[0]);
7575 }
7576
7577 ALIAS (clear_bgp_as_soft_out,
7578 clear_bgp_instance_as_soft_out_cmd,
7579 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7580 CLEAR_STR
7581 BGP_STR
7582 BGP_INSTANCE_HELP_STR
7583 "Clear peers with the AS number\n"
7584 BGP_SOFT_STR
7585 BGP_SOFT_OUT_STR)
7586
7587 ALIAS (clear_bgp_as_soft_out,
7588 clear_bgp_ipv6_as_soft_out_cmd,
7589 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
7590 CLEAR_STR
7591 BGP_STR
7592 "Address family\n"
7593 "Clear peers with the AS number\n"
7594 BGP_SOFT_STR
7595 BGP_SOFT_OUT_STR)
7596
7597 ALIAS (clear_bgp_as_soft_out,
7598 clear_bgp_instance_ipv6_as_soft_out_cmd,
7599 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft out",
7600 CLEAR_STR
7601 BGP_STR
7602 BGP_INSTANCE_HELP_STR
7603 "Address family\n"
7604 "Clear peers with the AS number\n"
7605 BGP_SOFT_STR
7606 BGP_SOFT_OUT_STR)
7607
7608 ALIAS (clear_bgp_as_soft_out,
7609 clear_bgp_as_out_cmd,
7610 "clear bgp " CMD_AS_RANGE " out",
7611 CLEAR_STR
7612 BGP_STR
7613 "Clear peers with the AS number\n"
7614 BGP_SOFT_OUT_STR)
7615
7616 ALIAS (clear_bgp_as_soft_out,
7617 clear_bgp_instance_as_out_cmd,
7618 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7619 CLEAR_STR
7620 BGP_STR
7621 BGP_INSTANCE_HELP_STR
7622 "Clear peers with the AS number\n"
7623 BGP_SOFT_OUT_STR)
7624
7625 ALIAS (clear_bgp_as_soft_out,
7626 clear_bgp_ipv6_as_out_cmd,
7627 "clear bgp ipv6 " CMD_AS_RANGE " out",
7628 CLEAR_STR
7629 BGP_STR
7630 "Address family\n"
7631 "Clear peers with the AS number\n"
7632 BGP_SOFT_OUT_STR)
7633
7634 ALIAS (clear_bgp_as_soft_out,
7635 clear_bgp_instance_ipv6_as_out_cmd,
7636 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " out",
7637 CLEAR_STR
7638 BGP_STR
7639 BGP_INSTANCE_HELP_STR
7640 "Address family\n"
7641 "Clear peers with the AS number\n"
7642 BGP_SOFT_OUT_STR)
7643
7644 /* Inbound soft-reconfiguration */
7645 DEFUN (clear_ip_bgp_all_soft_in,
7646 clear_ip_bgp_all_soft_in_cmd,
7647 "clear ip bgp * soft in",
7648 CLEAR_STR
7649 IP_STR
7650 BGP_STR
7651 "Clear all peers\n"
7652 BGP_SOFT_STR
7653 BGP_SOFT_IN_STR)
7654 {
7655 if (argc == 2)
7656 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7657 BGP_CLEAR_SOFT_IN, NULL);
7658
7659 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7660 BGP_CLEAR_SOFT_IN, NULL);
7661 }
7662
7663 ALIAS (clear_ip_bgp_all_soft_in,
7664 clear_ip_bgp_instance_all_soft_in_cmd,
7665 "clear ip bgp " BGP_INSTANCE_CMD " * soft in",
7666 CLEAR_STR
7667 IP_STR
7668 BGP_STR
7669 BGP_INSTANCE_HELP_STR
7670 "Clear all peers\n"
7671 BGP_SOFT_STR
7672 BGP_SOFT_IN_STR)
7673
7674 ALIAS (clear_ip_bgp_all_soft_in,
7675 clear_ip_bgp_all_in_cmd,
7676 "clear ip bgp * in",
7677 CLEAR_STR
7678 IP_STR
7679 BGP_STR
7680 "Clear all peers\n"
7681 BGP_SOFT_IN_STR)
7682
7683 ALIAS (clear_ip_bgp_all_soft_in,
7684 clear_ip_bgp_instance_all_in_cmd,
7685 "clear ip bgp " BGP_INSTANCE_CMD " * in",
7686 CLEAR_STR
7687 IP_STR
7688 BGP_STR
7689 BGP_INSTANCE_HELP_STR
7690 "Clear all peers\n"
7691 BGP_SOFT_IN_STR)
7692
7693 DEFUN (clear_ip_bgp_all_in_prefix_filter,
7694 clear_ip_bgp_all_in_prefix_filter_cmd,
7695 "clear ip bgp * in prefix-filter",
7696 CLEAR_STR
7697 IP_STR
7698 BGP_STR
7699 "Clear all peers\n"
7700 BGP_SOFT_IN_STR
7701 "Push out prefix-list ORF and do inbound soft reconfig\n")
7702 {
7703 if (argc== 2)
7704 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7705 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7706
7707 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7708 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7709 }
7710
7711 DEFUN (clear_ip_bgp_all_ipv4_soft_in,
7712 clear_ip_bgp_all_ipv4_soft_in_cmd,
7713 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft in",
7714 CLEAR_STR
7715 IP_STR
7716 BGP_STR
7717 "Clear all peers\n"
7718 "Address family\n"
7719 BGP_SAFI_HELP_STR
7720 BGP_SOFT_STR
7721 BGP_SOFT_IN_STR)
7722 {
7723 safi_t safi;
7724 safi = bgp_vty_safi_from_arg(argv[0]);
7725 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all,
7726 BGP_CLEAR_SOFT_IN, NULL);
7727 }
7728
7729 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
7730 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
7731 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft in",
7732 CLEAR_STR
7733 IP_STR
7734 BGP_STR
7735 BGP_INSTANCE_HELP_STR
7736 "Clear all peers\n"
7737 "Address family\n"
7738 BGP_SAFI_HELP_STR
7739 BGP_SOFT_STR
7740 BGP_SOFT_IN_STR)
7741 {
7742 safi_t safi;
7743 safi = bgp_vty_safi_from_arg(argv[2]);
7744 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all,
7745 BGP_CLEAR_SOFT_IN, NULL);
7746 }
7747
7748 ALIAS (clear_ip_bgp_all_ipv4_soft_in,
7749 clear_ip_bgp_all_ipv4_in_cmd,
7750 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in",
7751 CLEAR_STR
7752 IP_STR
7753 BGP_STR
7754 "Clear all peers\n"
7755 "Address family\n"
7756 BGP_SAFI_HELP_STR
7757 BGP_SOFT_IN_STR)
7758
7759 ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in,
7760 clear_ip_bgp_instance_all_ipv4_in_cmd,
7761 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" in",
7762 CLEAR_STR
7763 IP_STR
7764 BGP_STR
7765 BGP_INSTANCE_HELP_STR
7766 "Clear all peers\n"
7767 "Address family\n"
7768 BGP_SAFI_HELP_STR
7769 BGP_SOFT_IN_STR)
7770
7771 DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
7772 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
7773 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in prefix-filter",
7774 CLEAR_STR
7775 IP_STR
7776 BGP_STR
7777 "Clear all peers\n"
7778 "Address family\n"
7779 BGP_SAFI_HELP_STR
7780 BGP_SOFT_IN_STR
7781 "Push out prefix-list ORF and do inbound soft reconfig\n")
7782 {
7783 safi_t safi;
7784 safi = bgp_vty_safi_from_arg(argv[0]);
7785 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all,
7786 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7787 }
7788
7789 DEFUN (clear_bgp_all_soft_in,
7790 clear_bgp_all_soft_in_cmd,
7791 "clear bgp * soft in",
7792 CLEAR_STR
7793 BGP_STR
7794 "Clear all peers\n"
7795 BGP_SOFT_STR
7796 BGP_SOFT_IN_STR)
7797 {
7798 if (argc == 2)
7799 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
7800 BGP_CLEAR_SOFT_IN, NULL);
7801
7802 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7803 BGP_CLEAR_SOFT_IN, NULL);
7804 }
7805
7806 ALIAS (clear_bgp_all_soft_in,
7807 clear_bgp_instance_all_soft_in_cmd,
7808 "clear bgp " BGP_INSTANCE_CMD " * soft in",
7809 CLEAR_STR
7810 BGP_STR
7811 BGP_INSTANCE_HELP_STR
7812 "Clear all peers\n"
7813 BGP_SOFT_STR
7814 BGP_SOFT_IN_STR)
7815
7816 ALIAS (clear_bgp_all_soft_in,
7817 clear_bgp_ipv6_all_soft_in_cmd,
7818 "clear bgp ipv6 * soft in",
7819 CLEAR_STR
7820 BGP_STR
7821 "Address family\n"
7822 "Clear all peers\n"
7823 BGP_SOFT_STR
7824 BGP_SOFT_IN_STR)
7825
7826 ALIAS (clear_bgp_all_soft_in,
7827 clear_bgp_instance_ipv6_all_soft_in_cmd,
7828 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft in",
7829 CLEAR_STR
7830 BGP_STR
7831 BGP_INSTANCE_HELP_STR
7832 "Address family\n"
7833 "Clear all peers\n"
7834 BGP_SOFT_STR
7835 BGP_SOFT_IN_STR)
7836
7837 ALIAS (clear_bgp_all_soft_in,
7838 clear_bgp_all_in_cmd,
7839 "clear bgp * in",
7840 CLEAR_STR
7841 BGP_STR
7842 "Clear all peers\n"
7843 BGP_SOFT_IN_STR)
7844
7845 ALIAS (clear_bgp_all_soft_in,
7846 clear_bgp_instance_all_in_cmd,
7847 "clear bgp " BGP_INSTANCE_CMD " * in",
7848 CLEAR_STR
7849 BGP_STR
7850 BGP_INSTANCE_HELP_STR
7851 "Clear all peers\n"
7852 BGP_SOFT_IN_STR)
7853
7854 ALIAS (clear_bgp_all_soft_in,
7855 clear_bgp_ipv6_all_in_cmd,
7856 "clear bgp ipv6 * in",
7857 CLEAR_STR
7858 BGP_STR
7859 "Address family\n"
7860 "Clear all peers\n"
7861 BGP_SOFT_IN_STR)
7862
7863 ALIAS (clear_bgp_all_soft_in,
7864 clear_bgp_instance_ipv6_all_in_cmd,
7865 "clear bgp " BGP_INSTANCE_CMD " ipv6 * in",
7866 CLEAR_STR
7867 BGP_STR
7868 BGP_INSTANCE_HELP_STR
7869 "Address family\n"
7870 "Clear all peers\n"
7871 BGP_SOFT_IN_STR)
7872
7873 DEFUN (clear_bgp_all_in_prefix_filter,
7874 clear_bgp_all_in_prefix_filter_cmd,
7875 "clear bgp * in prefix-filter",
7876 CLEAR_STR
7877 BGP_STR
7878 "Clear all peers\n"
7879 BGP_SOFT_IN_STR
7880 "Push out prefix-list ORF and do inbound soft reconfig\n")
7881 {
7882 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7883 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7884 }
7885
7886 ALIAS (clear_bgp_all_in_prefix_filter,
7887 clear_bgp_ipv6_all_in_prefix_filter_cmd,
7888 "clear bgp ipv6 * in prefix-filter",
7889 CLEAR_STR
7890 BGP_STR
7891 "Address family\n"
7892 "Clear all peers\n"
7893 BGP_SOFT_IN_STR
7894 "Push out prefix-list ORF and do inbound soft reconfig\n")
7895
7896 DEFUN (clear_ip_bgp_peer_soft_in,
7897 clear_ip_bgp_peer_soft_in_cmd,
7898 "clear ip bgp (A.B.C.D|WORD) soft in",
7899 CLEAR_STR
7900 IP_STR
7901 BGP_STR
7902 "BGP neighbor address to clear\n"
7903 "BGP neighbor on interface to clear\n"
7904 BGP_SOFT_STR
7905 BGP_SOFT_IN_STR)
7906 {
7907 if (argc == 3)
7908 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
7909 BGP_CLEAR_SOFT_IN, argv[2]);
7910
7911 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7912 BGP_CLEAR_SOFT_IN, argv[0]);
7913 }
7914
7915 ALIAS (clear_ip_bgp_peer_soft_in,
7916 clear_ip_bgp_instance_peer_soft_in_cmd,
7917 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft in",
7918 CLEAR_STR
7919 IP_STR
7920 BGP_STR
7921 BGP_INSTANCE_HELP_STR
7922 "BGP neighbor address to clear\n"
7923 "BGP neighbor on interface to clear\n"
7924 BGP_SOFT_STR
7925 BGP_SOFT_IN_STR)
7926
7927 ALIAS (clear_ip_bgp_peer_soft_in,
7928 clear_ip_bgp_peer_in_cmd,
7929 "clear ip bgp (A.B.C.D|WORD) in",
7930 CLEAR_STR
7931 IP_STR
7932 BGP_STR
7933 "BGP neighbor address to clear\n"
7934 "BGP neighbor on interface to clear\n"
7935 BGP_SOFT_IN_STR)
7936
7937 ALIAS (clear_ip_bgp_peer_soft_in,
7938 clear_ip_bgp_instance_peer_in_cmd,
7939 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) in",
7940 CLEAR_STR
7941 IP_STR
7942 BGP_STR
7943 BGP_INSTANCE_HELP_STR
7944 "BGP neighbor address to clear\n"
7945 "BGP neighbor on interface to clear\n"
7946 BGP_SOFT_IN_STR)
7947
7948 DEFUN (clear_ip_bgp_peer_in_prefix_filter,
7949 clear_ip_bgp_peer_in_prefix_filter_cmd,
7950 "clear ip bgp (A.B.C.D|WORD) in prefix-filter",
7951 CLEAR_STR
7952 IP_STR
7953 BGP_STR
7954 "BGP neighbor address to clear\n"
7955 "BGP neighbor on interface to clear\n"
7956 BGP_SOFT_IN_STR
7957 "Push out the existing ORF prefix-list\n")
7958 {
7959 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7960 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7961 }
7962
7963 DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
7964 clear_ip_bgp_peer_ipv4_soft_in_cmd,
7965 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in",
7966 CLEAR_STR
7967 IP_STR
7968 BGP_STR
7969 "BGP neighbor address to clear\n"
7970 "BGP neighbor on interface to clear\n"
7971 "Address family\n"
7972 BGP_SAFI_HELP_STR
7973 BGP_SOFT_STR
7974 BGP_SOFT_IN_STR)
7975 {
7976 safi_t safi;
7977 safi = bgp_vty_safi_from_arg(argv[1]);
7978 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer,
7979 BGP_CLEAR_SOFT_IN, argv[0]);
7980 }
7981
7982 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in,
7983 clear_ip_bgp_instance_peer_ipv4_soft_in_cmd,
7984 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in",
7985 CLEAR_STR
7986 IP_STR
7987 BGP_STR
7988 BGP_INSTANCE_HELP_STR
7989 "BGP neighbor address to clear\n"
7990 "BGP neighbor on interface to clear\n"
7991 "Address family\n"
7992 BGP_SAFI_HELP_STR
7993 BGP_SOFT_STR
7994 BGP_SOFT_IN_STR)
7995 {
7996 safi_t safi;
7997 safi = bgp_vty_safi_from_arg(argv[3]);
7998 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer,
7999 BGP_CLEAR_SOFT_IN, argv[2]);
8000 }
8001
8002 ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
8003 clear_ip_bgp_peer_ipv4_in_cmd,
8004 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in",
8005 CLEAR_STR
8006 IP_STR
8007 BGP_STR
8008 "BGP neighbor address to clear\n"
8009 "BGP neighbor on interface to clear\n"
8010 "Address family\n"
8011 BGP_SAFI_HELP_STR
8012 BGP_SOFT_IN_STR)
8013
8014 ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in,
8015 clear_ip_bgp_instance_peer_ipv4_in_cmd,
8016 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in",
8017 CLEAR_STR
8018 IP_STR
8019 BGP_STR
8020 BGP_INSTANCE_HELP_STR
8021 "BGP neighbor address to clear\n"
8022 "BGP neighbor on interface to clear\n"
8023 "Address family\n"
8024 BGP_SAFI_HELP_STR
8025 BGP_SOFT_IN_STR)
8026
8027 DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
8028 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
8029 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in prefix-filter",
8030 CLEAR_STR
8031 IP_STR
8032 BGP_STR
8033 "BGP neighbor address to clear\n"
8034 "BGP neighbor on interface to clear\n"
8035 "Address family\n"
8036 BGP_SAFI_HELP_STR
8037 BGP_SOFT_IN_STR
8038 "Push out the existing ORF prefix-list\n")
8039 {
8040 safi_t safi;
8041 safi = bgp_vty_safi_from_arg(argv[1]);
8042 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer,
8043 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8044 }
8045
8046 DEFUN (clear_bgp_peer_soft_in,
8047 clear_bgp_peer_soft_in_cmd,
8048 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
8049 CLEAR_STR
8050 BGP_STR
8051 "BGP neighbor address to clear\n"
8052 "BGP IPv6 neighbor to clear\n"
8053 "BGP neighbor on interface to clear\n"
8054 BGP_SOFT_STR
8055 BGP_SOFT_IN_STR)
8056 {
8057 if (argc == 3)
8058 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
8059 BGP_CLEAR_SOFT_IN, argv[2]);
8060
8061 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
8062 BGP_CLEAR_SOFT_IN, argv[0]);
8063 }
8064
8065 ALIAS (clear_bgp_peer_soft_in,
8066 clear_bgp_instance_peer_soft_in_cmd,
8067 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft in",
8068 CLEAR_STR
8069 BGP_STR
8070 BGP_INSTANCE_HELP_STR
8071 "BGP neighbor address to clear\n"
8072 "BGP IPv6 neighbor to clear\n"
8073 "BGP neighbor on interface to clear\n"
8074 BGP_SOFT_STR
8075 BGP_SOFT_IN_STR)
8076
8077 ALIAS (clear_bgp_peer_soft_in,
8078 clear_bgp_ipv6_peer_soft_in_cmd,
8079 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
8080 CLEAR_STR
8081 BGP_STR
8082 "Address family\n"
8083 "BGP neighbor address to clear\n"
8084 "BGP IPv6 neighbor to clear\n"
8085 "BGP neighbor on interface to clear\n"
8086 BGP_SOFT_STR
8087 BGP_SOFT_IN_STR)
8088
8089 ALIAS (clear_bgp_peer_soft_in,
8090 clear_bgp_instance_ipv6_peer_soft_in_cmd,
8091 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
8092 CLEAR_STR
8093 BGP_STR
8094 BGP_INSTANCE_HELP_STR
8095 "Address family\n"
8096 "BGP neighbor address to clear\n"
8097 "BGP IPv6 neighbor to clear\n"
8098 "BGP neighbor on interface to clear\n"
8099 BGP_SOFT_STR
8100 BGP_SOFT_IN_STR)
8101
8102 ALIAS (clear_bgp_peer_soft_in,
8103 clear_bgp_peer_in_cmd,
8104 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
8105 CLEAR_STR
8106 BGP_STR
8107 "BGP neighbor address to clear\n"
8108 "BGP IPv6 neighbor to clear\n"
8109 "BGP neighbor on interface to clear\n"
8110 BGP_SOFT_IN_STR)
8111
8112 ALIAS (clear_bgp_peer_soft_in,
8113 clear_bgp_instance_peer_in_cmd,
8114 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) in",
8115 CLEAR_STR
8116 BGP_STR
8117 BGP_INSTANCE_HELP_STR
8118 "BGP neighbor address to clear\n"
8119 "BGP IPv6 neighbor to clear\n"
8120 "BGP neighbor on interface to clear\n"
8121 BGP_SOFT_IN_STR)
8122
8123 ALIAS (clear_bgp_peer_soft_in,
8124 clear_bgp_ipv6_peer_in_cmd,
8125 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
8126 CLEAR_STR
8127 BGP_STR
8128 "Address family\n"
8129 "BGP neighbor address to clear\n"
8130 "BGP IPv6 neighbor to clear\n"
8131 "BGP neighbor on interface to clear\n"
8132 BGP_SOFT_IN_STR)
8133
8134 ALIAS (clear_bgp_peer_soft_in,
8135 clear_bgp_instance_ipv6_peer_in_cmd,
8136 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) in",
8137 CLEAR_STR
8138 BGP_STR
8139 BGP_INSTANCE_HELP_STR
8140 "Address family\n"
8141 "BGP neighbor address to clear\n"
8142 "BGP IPv6 neighbor to clear\n"
8143 "BGP neighbor on interface to clear\n"
8144 BGP_SOFT_IN_STR)
8145
8146 DEFUN (clear_bgp_peer_in_prefix_filter,
8147 clear_bgp_peer_in_prefix_filter_cmd,
8148 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
8149 CLEAR_STR
8150 BGP_STR
8151 "BGP neighbor address to clear\n"
8152 "BGP IPv6 neighbor to clear\n"
8153 "BGP neighbor on interface to clear\n"
8154 BGP_SOFT_IN_STR
8155 "Push out the existing ORF prefix-list\n")
8156 {
8157 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
8158 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8159 }
8160
8161 ALIAS (clear_bgp_peer_in_prefix_filter,
8162 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
8163 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
8164 CLEAR_STR
8165 BGP_STR
8166 "Address family\n"
8167 "BGP neighbor address to clear\n"
8168 "BGP IPv6 neighbor to clear\n"
8169 "BGP neighbor on interface to clear\n"
8170 BGP_SOFT_IN_STR
8171 "Push out the existing ORF prefix-list\n")
8172
8173 DEFUN (clear_ip_bgp_peer_group_soft_in,
8174 clear_ip_bgp_peer_group_soft_in_cmd,
8175 "clear ip bgp peer-group WORD soft in",
8176 CLEAR_STR
8177 IP_STR
8178 BGP_STR
8179 "Clear all members of peer-group\n"
8180 "BGP peer-group name\n"
8181 BGP_SOFT_STR
8182 BGP_SOFT_IN_STR)
8183 {
8184 if (argc == 3)
8185 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8186 BGP_CLEAR_SOFT_IN, argv[2]);
8187
8188 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8189 BGP_CLEAR_SOFT_IN, argv[0]);
8190 }
8191
8192 ALIAS (clear_ip_bgp_peer_group_soft_in,
8193 clear_ip_bgp_instance_peer_group_soft_in_cmd,
8194 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8195 CLEAR_STR
8196 IP_STR
8197 BGP_STR
8198 BGP_INSTANCE_HELP_STR
8199 "Clear all members of peer-group\n"
8200 "BGP peer-group name\n"
8201 BGP_SOFT_STR
8202 BGP_SOFT_IN_STR)
8203
8204 ALIAS (clear_ip_bgp_peer_group_soft_in,
8205 clear_ip_bgp_peer_group_in_cmd,
8206 "clear ip bgp peer-group WORD in",
8207 CLEAR_STR
8208 IP_STR
8209 BGP_STR
8210 "Clear all members of peer-group\n"
8211 "BGP peer-group name\n"
8212 BGP_SOFT_IN_STR)
8213
8214 ALIAS (clear_ip_bgp_peer_group_soft_in,
8215 clear_ip_bgp_instance_peer_group_in_cmd,
8216 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8217 CLEAR_STR
8218 IP_STR
8219 BGP_STR
8220 BGP_INSTANCE_HELP_STR
8221 "Clear all members of peer-group\n"
8222 "BGP peer-group name\n"
8223 BGP_SOFT_IN_STR)
8224
8225 DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
8226 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
8227 "clear ip bgp peer-group WORD in prefix-filter",
8228 CLEAR_STR
8229 IP_STR
8230 BGP_STR
8231 "Clear all members of peer-group\n"
8232 "BGP peer-group name\n"
8233 BGP_SOFT_IN_STR
8234 "Push out prefix-list ORF and do inbound soft reconfig\n")
8235 {
8236 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8237 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8238 }
8239
8240 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
8241 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
8242 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in",
8243 CLEAR_STR
8244 IP_STR
8245 BGP_STR
8246 "Clear all members of peer-group\n"
8247 "BGP peer-group name\n"
8248 "Address family\n"
8249 BGP_SAFI_HELP_STR
8250 BGP_SOFT_STR
8251 BGP_SOFT_IN_STR)
8252 {
8253 safi_t safi;
8254 safi = bgp_vty_safi_from_arg(argv[1]);
8255 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group,
8256 BGP_CLEAR_SOFT_IN, argv[0]);
8257 }
8258
8259 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8260 clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd,
8261 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in",
8262 CLEAR_STR
8263 IP_STR
8264 BGP_STR
8265 BGP_INSTANCE_HELP_STR
8266 "Clear all members of peer-group\n"
8267 "BGP peer-group name\n"
8268 "Address family\n"
8269 BGP_SAFI_HELP_STR
8270 BGP_SOFT_STR
8271 BGP_SOFT_IN_STR)
8272 {
8273 safi_t safi;
8274 safi = bgp_vty_safi_from_arg(argv[3]);
8275 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group,
8276 BGP_CLEAR_SOFT_IN, argv[2]);
8277 }
8278
8279 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
8280 clear_ip_bgp_peer_group_ipv4_in_cmd,
8281 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in",
8282 CLEAR_STR
8283 IP_STR
8284 BGP_STR
8285 "Clear all members of peer-group\n"
8286 "BGP peer-group name\n"
8287 "Address family\n"
8288 BGP_SAFI_HELP_STR
8289 BGP_SOFT_IN_STR)
8290
8291 ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8292 clear_ip_bgp_instance_peer_group_ipv4_in_cmd,
8293 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in",
8294 CLEAR_STR
8295 IP_STR
8296 BGP_STR
8297 BGP_INSTANCE_HELP_STR
8298 "Clear all members of peer-group\n"
8299 "BGP peer-group name\n"
8300 "Address family\n"
8301 BGP_SAFI_HELP_STR
8302 BGP_SOFT_IN_STR)
8303
8304 DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
8305 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
8306 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in prefix-filter",
8307 CLEAR_STR
8308 IP_STR
8309 BGP_STR
8310 "Clear all members of peer-group\n"
8311 "BGP peer-group name\n"
8312 "Address family\n"
8313 BGP_SAFI_HELP_STR
8314 BGP_SOFT_IN_STR
8315 "Push out prefix-list ORF and do inbound soft reconfig\n")
8316 {
8317 safi_t safi;
8318 safi = bgp_vty_safi_from_arg(argv[1]);
8319 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group,
8320 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8321 }
8322
8323 DEFUN (clear_bgp_peer_group_soft_in,
8324 clear_bgp_peer_group_soft_in_cmd,
8325 "clear bgp peer-group WORD soft in",
8326 CLEAR_STR
8327 BGP_STR
8328 "Clear all members of peer-group\n"
8329 "BGP peer-group name\n"
8330 BGP_SOFT_STR
8331 BGP_SOFT_IN_STR)
8332 {
8333 if (argc == 3)
8334 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
8335 BGP_CLEAR_SOFT_IN, argv[2]);
8336
8337 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8338 BGP_CLEAR_SOFT_IN, argv[0]);
8339 }
8340
8341 ALIAS (clear_bgp_peer_group_soft_in,
8342 clear_bgp_instance_peer_group_soft_in_cmd,
8343 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8344 CLEAR_STR
8345 BGP_STR
8346 BGP_INSTANCE_HELP_STR
8347 "Clear all members of peer-group\n"
8348 "BGP peer-group name\n"
8349 BGP_SOFT_STR
8350 BGP_SOFT_IN_STR)
8351
8352 ALIAS (clear_bgp_peer_group_soft_in,
8353 clear_bgp_ipv6_peer_group_soft_in_cmd,
8354 "clear bgp ipv6 peer-group WORD soft in",
8355 CLEAR_STR
8356 BGP_STR
8357 "Address family\n"
8358 "Clear all members of peer-group\n"
8359 "BGP peer-group name\n"
8360 BGP_SOFT_STR
8361 BGP_SOFT_IN_STR)
8362
8363 ALIAS (clear_bgp_peer_group_soft_in,
8364 clear_bgp_instance_ipv6_peer_group_soft_in_cmd,
8365 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft in",
8366 CLEAR_STR
8367 BGP_STR
8368 BGP_INSTANCE_HELP_STR
8369 "Address family\n"
8370 "Clear all members of peer-group\n"
8371 "BGP peer-group name\n"
8372 BGP_SOFT_STR
8373 BGP_SOFT_IN_STR)
8374
8375 ALIAS (clear_bgp_peer_group_soft_in,
8376 clear_bgp_peer_group_in_cmd,
8377 "clear bgp peer-group WORD in",
8378 CLEAR_STR
8379 BGP_STR
8380 "Clear all members of peer-group\n"
8381 "BGP peer-group name\n"
8382 BGP_SOFT_IN_STR)
8383
8384 ALIAS (clear_bgp_peer_group_soft_in,
8385 clear_bgp_instance_peer_group_in_cmd,
8386 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8387 CLEAR_STR
8388 BGP_STR
8389 BGP_INSTANCE_HELP_STR
8390 "Clear all members of peer-group\n"
8391 "BGP peer-group name\n"
8392 BGP_SOFT_IN_STR)
8393
8394 ALIAS (clear_bgp_peer_group_soft_in,
8395 clear_bgp_ipv6_peer_group_in_cmd,
8396 "clear bgp ipv6 peer-group WORD in",
8397 CLEAR_STR
8398 BGP_STR
8399 "Address family\n"
8400 "Clear all members of peer-group\n"
8401 "BGP peer-group name\n"
8402 BGP_SOFT_IN_STR)
8403
8404 ALIAS (clear_bgp_peer_group_soft_in,
8405 clear_bgp_instance_ipv6_peer_group_in_cmd,
8406 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD in",
8407 CLEAR_STR
8408 BGP_STR
8409 BGP_INSTANCE_HELP_STR
8410 "Address family\n"
8411 "Clear all members of peer-group\n"
8412 "BGP peer-group name\n"
8413 BGP_SOFT_IN_STR)
8414
8415 DEFUN (clear_bgp_peer_group_in_prefix_filter,
8416 clear_bgp_peer_group_in_prefix_filter_cmd,
8417 "clear bgp peer-group WORD in prefix-filter",
8418 CLEAR_STR
8419 BGP_STR
8420 "Clear all members of peer-group\n"
8421 "BGP peer-group name\n"
8422 BGP_SOFT_IN_STR
8423 "Push out prefix-list ORF and do inbound soft reconfig\n")
8424 {
8425 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8426 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8427 }
8428
8429 ALIAS (clear_bgp_peer_group_in_prefix_filter,
8430 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
8431 "clear bgp ipv6 peer-group WORD in prefix-filter",
8432 CLEAR_STR
8433 BGP_STR
8434 "Address family\n"
8435 "Clear all members of peer-group\n"
8436 "BGP peer-group name\n"
8437 BGP_SOFT_IN_STR
8438 "Push out prefix-list ORF and do inbound soft reconfig\n")
8439
8440 DEFUN (clear_ip_bgp_external_soft_in,
8441 clear_ip_bgp_external_soft_in_cmd,
8442 "clear ip bgp external soft in",
8443 CLEAR_STR
8444 IP_STR
8445 BGP_STR
8446 "Clear all external peers\n"
8447 BGP_SOFT_STR
8448 BGP_SOFT_IN_STR)
8449 {
8450 if (argc == 2)
8451 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8452 BGP_CLEAR_SOFT_IN, NULL);
8453
8454 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8455 BGP_CLEAR_SOFT_IN, NULL);
8456 }
8457
8458 ALIAS (clear_ip_bgp_external_soft_in,
8459 clear_ip_bgp_instance_external_soft_in_cmd,
8460 "clear ip bgp " BGP_INSTANCE_CMD " external soft in",
8461 CLEAR_STR
8462 IP_STR
8463 BGP_STR
8464 BGP_INSTANCE_HELP_STR
8465 "Clear all external peers\n"
8466 BGP_SOFT_STR
8467 BGP_SOFT_IN_STR)
8468
8469 ALIAS (clear_ip_bgp_external_soft_in,
8470 clear_ip_bgp_external_in_cmd,
8471 "clear ip bgp external in",
8472 CLEAR_STR
8473 IP_STR
8474 BGP_STR
8475 "Clear all external peers\n"
8476 BGP_SOFT_IN_STR)
8477
8478 ALIAS (clear_ip_bgp_external_soft_in,
8479 clear_ip_bgp_instance_external_in_cmd,
8480 "clear ip bgp " BGP_INSTANCE_CMD " external in",
8481 CLEAR_STR
8482 IP_STR
8483 BGP_STR
8484 BGP_INSTANCE_HELP_STR
8485 "Clear all external peers\n"
8486 BGP_SOFT_IN_STR)
8487
8488 DEFUN (clear_ip_bgp_external_in_prefix_filter,
8489 clear_ip_bgp_external_in_prefix_filter_cmd,
8490 "clear ip bgp external in prefix-filter",
8491 CLEAR_STR
8492 IP_STR
8493 BGP_STR
8494 "Clear all external peers\n"
8495 BGP_SOFT_IN_STR
8496 "Push out prefix-list ORF and do inbound soft reconfig\n")
8497 {
8498 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8499 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8500 }
8501
8502 DEFUN (clear_ip_bgp_external_ipv4_soft_in,
8503 clear_ip_bgp_external_ipv4_soft_in_cmd,
8504 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft in",
8505 CLEAR_STR
8506 IP_STR
8507 BGP_STR
8508 "Clear all external peers\n"
8509 "Address family\n"
8510 BGP_SAFI_HELP_STR
8511 BGP_SOFT_STR
8512 BGP_SOFT_IN_STR)
8513 {
8514 safi_t safi;
8515 safi = bgp_vty_safi_from_arg(argv[0]);
8516 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external,
8517 BGP_CLEAR_SOFT_IN, NULL);
8518 }
8519
8520 DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in,
8521 clear_ip_bgp_instance_external_ipv4_soft_in_cmd,
8522 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft in",
8523 CLEAR_STR
8524 IP_STR
8525 BGP_STR
8526 BGP_INSTANCE_HELP_STR
8527 "Clear all external peers\n"
8528 "Address family\n"
8529 BGP_SAFI_HELP_STR
8530 BGP_SOFT_STR
8531 BGP_SOFT_IN_STR)
8532 {
8533 safi_t safi;
8534 safi = bgp_vty_safi_from_arg(argv[2]);
8535 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external,
8536 BGP_CLEAR_SOFT_IN, NULL);
8537 }
8538
8539 ALIAS (clear_ip_bgp_external_ipv4_soft_in,
8540 clear_ip_bgp_external_ipv4_in_cmd,
8541 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in",
8542 CLEAR_STR
8543 IP_STR
8544 BGP_STR
8545 "Clear all external peers\n"
8546 "Address family\n"
8547 BGP_SAFI_HELP_STR
8548 BGP_SOFT_IN_STR)
8549
8550 ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in,
8551 clear_ip_bgp_instance_external_ipv4_in_cmd,
8552 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" in",
8553 CLEAR_STR
8554 IP_STR
8555 BGP_STR
8556 BGP_INSTANCE_HELP_STR
8557 "Clear all external peers\n"
8558 "Address family\n"
8559 BGP_SAFI_HELP_STR
8560 BGP_SOFT_IN_STR)
8561
8562 DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
8563 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
8564 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in prefix-filter",
8565 CLEAR_STR
8566 IP_STR
8567 BGP_STR
8568 "Clear all external peers\n"
8569 "Address family\n"
8570 BGP_SAFI_HELP_STR
8571 BGP_SOFT_IN_STR
8572 "Push out prefix-list ORF and do inbound soft reconfig\n")
8573 {
8574 safi_t safi;
8575 safi = bgp_vty_safi_from_arg(argv[0]);
8576 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external,
8577 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8578 }
8579
8580 DEFUN (clear_bgp_external_soft_in,
8581 clear_bgp_external_soft_in_cmd,
8582 "clear bgp external soft in",
8583 CLEAR_STR
8584 BGP_STR
8585 "Clear all external peers\n"
8586 BGP_SOFT_STR
8587 BGP_SOFT_IN_STR)
8588 {
8589 if (argc == 2)
8590 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
8591 BGP_CLEAR_SOFT_IN, NULL);
8592
8593 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8594 BGP_CLEAR_SOFT_IN, NULL);
8595 }
8596
8597 ALIAS (clear_bgp_external_soft_in,
8598 clear_bgp_instance_external_soft_in_cmd,
8599 "clear bgp " BGP_INSTANCE_CMD " external soft in",
8600 CLEAR_STR
8601 BGP_STR
8602 BGP_INSTANCE_HELP_STR
8603 "Clear all external peers\n"
8604 BGP_SOFT_STR
8605 BGP_SOFT_IN_STR)
8606
8607 ALIAS (clear_bgp_external_soft_in,
8608 clear_bgp_ipv6_external_soft_in_cmd,
8609 "clear bgp ipv6 external soft in",
8610 CLEAR_STR
8611 BGP_STR
8612 "Address family\n"
8613 "Clear all external peers\n"
8614 BGP_SOFT_STR
8615 BGP_SOFT_IN_STR)
8616
8617 ALIAS (clear_bgp_external_soft_in,
8618 clear_bgp_instance_ipv6_external_soft_in_cmd,
8619 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft in",
8620 CLEAR_STR
8621 BGP_STR
8622 BGP_INSTANCE_HELP_STR
8623 "Address family\n"
8624 "Clear all external peers\n"
8625 BGP_SOFT_STR
8626 BGP_SOFT_IN_STR)
8627
8628 ALIAS (clear_bgp_external_soft_in,
8629 clear_bgp_external_in_cmd,
8630 "clear bgp external in",
8631 CLEAR_STR
8632 BGP_STR
8633 "Clear all external peers\n"
8634 BGP_SOFT_IN_STR)
8635
8636 ALIAS (clear_bgp_external_soft_in,
8637 clear_bgp_instance_external_in_cmd,
8638 "clear bgp " BGP_INSTANCE_CMD " external in",
8639 CLEAR_STR
8640 BGP_STR
8641 BGP_INSTANCE_HELP_STR
8642 "Clear all external peers\n"
8643 BGP_SOFT_IN_STR)
8644
8645 ALIAS (clear_bgp_external_soft_in,
8646 clear_bgp_ipv6_external_in_cmd,
8647 "clear bgp ipv6 external WORD in",
8648 CLEAR_STR
8649 BGP_STR
8650 "Address family\n"
8651 "Clear all external peers\n"
8652 BGP_SOFT_IN_STR)
8653
8654 ALIAS (clear_bgp_external_soft_in,
8655 clear_bgp_instance_ipv6_external_in_cmd,
8656 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD in",
8657 CLEAR_STR
8658 BGP_STR
8659 BGP_INSTANCE_HELP_STR
8660 "Address family\n"
8661 "Clear all external peers\n"
8662 BGP_SOFT_IN_STR)
8663
8664 DEFUN (clear_bgp_external_in_prefix_filter,
8665 clear_bgp_external_in_prefix_filter_cmd,
8666 "clear bgp external in prefix-filter",
8667 CLEAR_STR
8668 BGP_STR
8669 "Clear all external peers\n"
8670 BGP_SOFT_IN_STR
8671 "Push out prefix-list ORF and do inbound soft reconfig\n")
8672 {
8673 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8674 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8675 }
8676
8677 ALIAS (clear_bgp_external_in_prefix_filter,
8678 clear_bgp_ipv6_external_in_prefix_filter_cmd,
8679 "clear bgp ipv6 external in prefix-filter",
8680 CLEAR_STR
8681 BGP_STR
8682 "Address family\n"
8683 "Clear all external peers\n"
8684 BGP_SOFT_IN_STR
8685 "Push out prefix-list ORF and do inbound soft reconfig\n")
8686
8687 DEFUN (clear_ip_bgp_as_soft_in,
8688 clear_ip_bgp_as_soft_in_cmd,
8689 "clear ip bgp " CMD_AS_RANGE " soft in",
8690 CLEAR_STR
8691 IP_STR
8692 BGP_STR
8693 "Clear peers with the AS number\n"
8694 BGP_SOFT_STR
8695 BGP_SOFT_IN_STR)
8696 {
8697 if (argc == 3)
8698 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8699 BGP_CLEAR_SOFT_IN, argv[2]);
8700
8701 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8702 BGP_CLEAR_SOFT_IN, argv[0]);
8703 }
8704
8705 ALIAS (clear_ip_bgp_as_soft_in,
8706 clear_ip_bgp_instance_as_soft_in_cmd,
8707 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8708 CLEAR_STR
8709 IP_STR
8710 BGP_STR
8711 BGP_INSTANCE_HELP_STR
8712 "Clear peers with the AS number\n"
8713 BGP_SOFT_STR
8714 BGP_SOFT_IN_STR)
8715
8716 ALIAS (clear_ip_bgp_as_soft_in,
8717 clear_ip_bgp_as_in_cmd,
8718 "clear ip bgp " CMD_AS_RANGE " in",
8719 CLEAR_STR
8720 IP_STR
8721 BGP_STR
8722 "Clear peers with the AS number\n"
8723 BGP_SOFT_IN_STR)
8724
8725 ALIAS (clear_ip_bgp_as_soft_in,
8726 clear_ip_bgp_instance_as_in_cmd,
8727 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
8728 CLEAR_STR
8729 IP_STR
8730 BGP_STR
8731 BGP_INSTANCE_HELP_STR
8732 "Clear peers with the AS number\n"
8733 BGP_SOFT_IN_STR)
8734
8735 DEFUN (clear_ip_bgp_as_in_prefix_filter,
8736 clear_ip_bgp_as_in_prefix_filter_cmd,
8737 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
8738 CLEAR_STR
8739 IP_STR
8740 BGP_STR
8741 "Clear peers with the AS number\n"
8742 BGP_SOFT_IN_STR
8743 "Push out prefix-list ORF and do inbound soft reconfig\n")
8744 {
8745 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8746 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8747 }
8748
8749 DEFUN (clear_ip_bgp_as_ipv4_soft_in,
8750 clear_ip_bgp_as_ipv4_soft_in_cmd,
8751 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in",
8752 CLEAR_STR
8753 IP_STR
8754 BGP_STR
8755 "Clear peers with the AS number\n"
8756 "Address family\n"
8757 BGP_SAFI_HELP_STR
8758 BGP_SOFT_STR
8759 BGP_SOFT_IN_STR)
8760 {
8761 safi_t safi;
8762 safi = bgp_vty_safi_from_arg(argv[1]);
8763 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as,
8764 BGP_CLEAR_SOFT_IN, argv[0]);
8765 }
8766
8767 DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in,
8768 clear_ip_bgp_instance_as_ipv4_soft_in_cmd,
8769 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in",
8770 CLEAR_STR
8771 IP_STR
8772 BGP_STR
8773 BGP_INSTANCE_HELP_STR
8774 "Clear peers with the AS number\n"
8775 "Address family\n"
8776 BGP_SAFI_HELP_STR
8777 BGP_SOFT_STR
8778 BGP_SOFT_IN_STR)
8779 {
8780 safi_t safi;
8781 safi = bgp_vty_safi_from_arg(argv[3]);
8782 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as,
8783 BGP_CLEAR_SOFT_IN, argv[2]);
8784 }
8785
8786 ALIAS (clear_ip_bgp_as_ipv4_soft_in,
8787 clear_ip_bgp_as_ipv4_in_cmd,
8788 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in",
8789 CLEAR_STR
8790 IP_STR
8791 BGP_STR
8792 "Clear peers with the AS number\n"
8793 "Address family\n"
8794 BGP_SAFI_HELP_STR
8795 BGP_SOFT_IN_STR)
8796
8797 ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in,
8798 clear_ip_bgp_instance_as_ipv4_in_cmd,
8799 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in",
8800 CLEAR_STR
8801 IP_STR
8802 BGP_STR
8803 BGP_INSTANCE_HELP_STR
8804 "Clear peers with the AS number\n"
8805 "Address family\n"
8806 BGP_SAFI_HELP_STR
8807 BGP_SOFT_IN_STR)
8808
8809 DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
8810 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
8811 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in prefix-filter",
8812 CLEAR_STR
8813 IP_STR
8814 BGP_STR
8815 "Clear peers with the AS number\n"
8816 "Address family\n"
8817 BGP_SAFI_HELP_STR
8818 BGP_SOFT_IN_STR
8819 "Push out prefix-list ORF and do inbound soft reconfig\n")
8820 {
8821 safi_t safi;
8822 safi = bgp_vty_safi_from_arg(argv[1]);
8823 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as,
8824 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8825 }
8826
8827 DEFUN (clear_bgp_as_soft_in,
8828 clear_bgp_as_soft_in_cmd,
8829 "clear bgp " CMD_AS_RANGE " soft in",
8830 CLEAR_STR
8831 BGP_STR
8832 "Clear peers with the AS number\n"
8833 BGP_SOFT_STR
8834 BGP_SOFT_IN_STR)
8835 {
8836 if (argc == 3)
8837 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
8838 BGP_CLEAR_SOFT_IN, argv[2]);
8839
8840 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8841 BGP_CLEAR_SOFT_IN, argv[0]);
8842 }
8843
8844 ALIAS (clear_bgp_as_soft_in,
8845 clear_bgp_instance_as_soft_in_cmd,
8846 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8847 CLEAR_STR
8848 BGP_STR
8849 BGP_INSTANCE_HELP_STR
8850 "Clear peers with the AS number\n"
8851 BGP_SOFT_STR
8852 BGP_SOFT_IN_STR)
8853
8854 ALIAS (clear_bgp_as_soft_in,
8855 clear_bgp_ipv6_as_soft_in_cmd,
8856 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
8857 CLEAR_STR
8858 BGP_STR
8859 "Address family\n"
8860 "Clear peers with the AS number\n"
8861 BGP_SOFT_STR
8862 BGP_SOFT_IN_STR)
8863
8864 ALIAS (clear_bgp_as_soft_in,
8865 clear_bgp_instance_ipv6_as_soft_in_cmd,
8866 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft in",
8867 CLEAR_STR
8868 BGP_STR
8869 BGP_INSTANCE_HELP_STR
8870 "Address family\n"
8871 "Clear peers with the AS number\n"
8872 BGP_SOFT_STR
8873 BGP_SOFT_IN_STR)
8874
8875 ALIAS (clear_bgp_as_soft_in,
8876 clear_bgp_as_in_cmd,
8877 "clear bgp " CMD_AS_RANGE " in",
8878 CLEAR_STR
8879 BGP_STR
8880 "Clear peers with the AS number\n"
8881 BGP_SOFT_IN_STR)
8882
8883 ALIAS (clear_bgp_as_soft_in,
8884 clear_bgp_instance_as_in_cmd,
8885 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
8886 CLEAR_STR
8887 BGP_STR
8888 BGP_INSTANCE_HELP_STR
8889 "Clear peers with the AS number\n"
8890 BGP_SOFT_IN_STR)
8891
8892 ALIAS (clear_bgp_as_soft_in,
8893 clear_bgp_ipv6_as_in_cmd,
8894 "clear bgp ipv6 " CMD_AS_RANGE " in",
8895 CLEAR_STR
8896 BGP_STR
8897 "Address family\n"
8898 "Clear peers with the AS number\n"
8899 BGP_SOFT_IN_STR)
8900
8901 ALIAS (clear_bgp_as_soft_in,
8902 clear_bgp_instance_ipv6_as_in_cmd,
8903 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " in",
8904 CLEAR_STR
8905 BGP_STR
8906 BGP_INSTANCE_HELP_STR
8907 "Address family\n"
8908 "Clear peers with the AS number\n"
8909 BGP_SOFT_IN_STR)
8910
8911 DEFUN (clear_bgp_as_in_prefix_filter,
8912 clear_bgp_as_in_prefix_filter_cmd,
8913 "clear bgp " CMD_AS_RANGE " in prefix-filter",
8914 CLEAR_STR
8915 BGP_STR
8916 "Clear peers with the AS number\n"
8917 BGP_SOFT_IN_STR
8918 "Push out prefix-list ORF and do inbound soft reconfig\n")
8919 {
8920 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8921 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8922 }
8923
8924 ALIAS (clear_bgp_as_in_prefix_filter,
8925 clear_bgp_ipv6_as_in_prefix_filter_cmd,
8926 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
8927 CLEAR_STR
8928 BGP_STR
8929 "Address family\n"
8930 "Clear peers with the AS number\n"
8931 BGP_SOFT_IN_STR
8932 "Push out prefix-list ORF and do inbound soft reconfig\n")
8933
8934 /* Both soft-reconfiguration */
8935 DEFUN (clear_ip_bgp_all_soft,
8936 clear_ip_bgp_all_soft_cmd,
8937 "clear ip bgp * soft",
8938 CLEAR_STR
8939 IP_STR
8940 BGP_STR
8941 "Clear all peers\n"
8942 BGP_SOFT_STR)
8943 {
8944 if (argc == 2)
8945 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
8946 BGP_CLEAR_SOFT_BOTH, NULL);
8947
8948 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8949 BGP_CLEAR_SOFT_BOTH, NULL);
8950 }
8951
8952 ALIAS (clear_ip_bgp_all_soft,
8953 clear_ip_bgp_instance_all_soft_cmd,
8954 "clear ip bgp " BGP_INSTANCE_CMD " * soft",
8955 CLEAR_STR
8956 IP_STR
8957 BGP_STR
8958 BGP_INSTANCE_HELP_STR
8959 "Clear all peers\n"
8960 BGP_SOFT_STR)
8961
8962
8963 DEFUN (clear_ip_bgp_all_ipv4_soft,
8964 clear_ip_bgp_all_ipv4_soft_cmd,
8965 "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft",
8966 CLEAR_STR
8967 IP_STR
8968 BGP_STR
8969 "Clear all peers\n"
8970 "Address family\n"
8971 "Address Family Modifier\n"
8972 "Address Family Modifier\n"
8973 BGP_SOFT_STR)
8974 {
8975 safi_t safi;
8976 safi = bgp_vty_safi_from_arg(argv[0]);
8977 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all,
8978 BGP_CLEAR_SOFT_BOTH, NULL);
8979 }
8980
8981 DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
8982 clear_ip_bgp_instance_all_ipv4_soft_cmd,
8983 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft",
8984 CLEAR_STR
8985 IP_STR
8986 BGP_STR
8987 BGP_INSTANCE_HELP_STR
8988 "Clear all peers\n"
8989 "Address family\n"
8990 "Address Family Modifier\n"
8991 "Address Family Modifier\n"
8992 BGP_SOFT_STR)
8993 {
8994 safi_t safi;
8995 safi = bgp_vty_safi_from_arg(argv[2]);
8996 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all,
8997 BGP_CLEAR_SOFT_BOTH, NULL);
8998 }
8999
9000 DEFUN (clear_bgp_all_soft,
9001 clear_bgp_all_soft_cmd,
9002 "clear bgp * soft",
9003 CLEAR_STR
9004 BGP_STR
9005 "Clear all peers\n"
9006 BGP_SOFT_STR)
9007 {
9008 if (argc == 2)
9009 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
9010 BGP_CLEAR_SOFT_BOTH, NULL);
9011
9012 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
9013 BGP_CLEAR_SOFT_BOTH, NULL);
9014 }
9015
9016 ALIAS (clear_bgp_all_soft,
9017 clear_bgp_instance_all_soft_cmd,
9018 "clear bgp " BGP_INSTANCE_CMD " * soft",
9019 CLEAR_STR
9020 BGP_STR
9021 BGP_INSTANCE_HELP_STR
9022 "Clear all peers\n"
9023 BGP_SOFT_STR)
9024
9025 ALIAS (clear_bgp_all_soft,
9026 clear_bgp_ipv6_all_soft_cmd,
9027 "clear bgp ipv6 * soft",
9028 CLEAR_STR
9029 BGP_STR
9030 "Address family\n"
9031 "Clear all peers\n"
9032 BGP_SOFT_STR)
9033
9034 ALIAS (clear_bgp_all_soft,
9035 clear_bgp_instance_ipv6_all_soft_cmd,
9036 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft",
9037 CLEAR_STR
9038 BGP_STR
9039 BGP_INSTANCE_HELP_STR
9040 "Address family\n"
9041 "Clear all peers\n"
9042 BGP_SOFT_STR)
9043
9044 DEFUN (clear_ip_bgp_peer_soft,
9045 clear_ip_bgp_peer_soft_cmd,
9046 "clear ip bgp (A.B.C.D|WORD) soft",
9047 CLEAR_STR
9048 IP_STR
9049 BGP_STR
9050 "BGP neighbor address to clear\n"
9051 "BGP neighbor on interface to clear\n"
9052 BGP_SOFT_STR)
9053 {
9054 if (argc == 3)
9055 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
9056 BGP_CLEAR_SOFT_BOTH, argv[2]);
9057
9058 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
9059 BGP_CLEAR_SOFT_BOTH, argv[0]);
9060 }
9061
9062 ALIAS (clear_ip_bgp_peer_soft,
9063 clear_ip_bgp_instance_peer_soft_cmd,
9064 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft",
9065 CLEAR_STR
9066 IP_STR
9067 BGP_STR
9068 BGP_INSTANCE_HELP_STR
9069 "BGP neighbor address to clear\n"
9070 "BGP neighbor on interface to clear\n"
9071 BGP_SOFT_STR)
9072
9073 DEFUN (clear_ip_bgp_peer_ipv4_soft,
9074 clear_ip_bgp_peer_ipv4_soft_cmd,
9075 "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft",
9076 CLEAR_STR
9077 IP_STR
9078 BGP_STR
9079 "BGP neighbor address to clear\n"
9080 "BGP neighbor on interface to clear\n"
9081 "Address family\n"
9082 "Address Family Modifier\n"
9083 "Address Family Modifier\n"
9084 BGP_SOFT_STR)
9085 {
9086 safi_t safi;
9087 safi = bgp_vty_safi_from_arg(argv[1]);
9088 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer,
9089 BGP_CLEAR_SOFT_BOTH, argv[0]);
9090 }
9091
9092 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft,
9093 clear_ip_bgp_instance_peer_ipv4_soft_cmd,
9094 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft",
9095 CLEAR_STR
9096 IP_STR
9097 BGP_STR
9098 BGP_INSTANCE_HELP_STR
9099 "BGP neighbor address to clear\n"
9100 "BGP neighbor on interface to clear\n"
9101 "Address family\n"
9102 "Address Family Modifier\n"
9103 "Address Family Modifier\n"
9104 BGP_SOFT_STR)
9105 {
9106 safi_t safi;
9107 safi = bgp_vty_safi_from_arg(argv[3]);
9108 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer,
9109 BGP_CLEAR_SOFT_BOTH, argv[2]);
9110 }
9111
9112 DEFUN (clear_bgp_peer_soft,
9113 clear_bgp_peer_soft_cmd,
9114 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
9115 CLEAR_STR
9116 BGP_STR
9117 "BGP neighbor address to clear\n"
9118 "BGP IPv6 neighbor to clear\n"
9119 "BGP neighbor on interface to clear\n"
9120 BGP_SOFT_STR)
9121 {
9122 if (argc == 3)
9123 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
9124 BGP_CLEAR_SOFT_BOTH, argv[2]);
9125
9126 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
9127 BGP_CLEAR_SOFT_BOTH, argv[0]);
9128 }
9129
9130 ALIAS (clear_bgp_peer_soft,
9131 clear_bgp_instance_peer_soft_cmd,
9132 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft",
9133 CLEAR_STR
9134 BGP_STR
9135 BGP_INSTANCE_HELP_STR
9136 "BGP neighbor address to clear\n"
9137 "BGP IPv6 neighbor to clear\n"
9138 "BGP neighbor on interface to clear\n"
9139 BGP_SOFT_STR)
9140
9141 ALIAS (clear_bgp_peer_soft,
9142 clear_bgp_ipv6_peer_soft_cmd,
9143 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
9144 CLEAR_STR
9145 BGP_STR
9146 "Address family\n"
9147 "BGP neighbor address to clear\n"
9148 "BGP IPv6 neighbor to clear\n"
9149 "BGP neighbor on interface to clear\n"
9150 BGP_SOFT_STR)
9151
9152 ALIAS (clear_bgp_peer_soft,
9153 clear_bgp_instance_ipv6_peer_soft_cmd,
9154 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
9155 CLEAR_STR
9156 BGP_STR
9157 BGP_INSTANCE_HELP_STR
9158 "Address family\n"
9159 "BGP neighbor address to clear\n"
9160 "BGP IPv6 neighbor to clear\n"
9161 "BGP neighbor on interface to clear\n"
9162 BGP_SOFT_STR)
9163
9164 DEFUN (clear_ip_bgp_peer_group_soft,
9165 clear_ip_bgp_peer_group_soft_cmd,
9166 "clear ip bgp peer-group WORD soft",
9167 CLEAR_STR
9168 IP_STR
9169 BGP_STR
9170 "Clear all members of peer-group\n"
9171 "BGP peer-group name\n"
9172 BGP_SOFT_STR)
9173 {
9174 if (argc == 3)
9175 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
9176 BGP_CLEAR_SOFT_BOTH, argv[2]);
9177
9178 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
9179 BGP_CLEAR_SOFT_BOTH, argv[0]);
9180 }
9181
9182 ALIAS (clear_ip_bgp_peer_group_soft,
9183 clear_ip_bgp_instance_peer_group_soft_cmd,
9184 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9185 CLEAR_STR
9186 IP_STR
9187 BGP_STR
9188 BGP_INSTANCE_HELP_STR
9189 "Clear all members of peer-group\n"
9190 "BGP peer-group name\n"
9191 BGP_SOFT_STR)
9192
9193 DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
9194 clear_ip_bgp_peer_group_ipv4_soft_cmd,
9195 "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft",
9196 CLEAR_STR
9197 IP_STR
9198 BGP_STR
9199 "Clear all members of peer-group\n"
9200 "BGP peer-group name\n"
9201 "Address family\n"
9202 BGP_SAFI_HELP_STR
9203 BGP_SOFT_STR)
9204 {
9205 safi_t safi;
9206 safi = bgp_vty_safi_from_arg(argv[1]);
9207 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group,
9208 BGP_CLEAR_SOFT_BOTH, argv[0]);
9209 }
9210
9211 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft,
9212 clear_ip_bgp_instance_peer_group_ipv4_soft_cmd,
9213 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft",
9214 CLEAR_STR
9215 IP_STR
9216 BGP_STR
9217 BGP_INSTANCE_HELP_STR
9218 "Clear all members of peer-group\n"
9219 "BGP peer-group name\n"
9220 "Address family\n"
9221 BGP_SAFI_HELP_STR
9222 BGP_SOFT_STR)
9223 {
9224 safi_t safi;
9225 safi = bgp_vty_safi_from_arg(argv[3]);
9226 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group,
9227 BGP_CLEAR_SOFT_BOTH, argv[2]);
9228 }
9229
9230 DEFUN (clear_bgp_peer_group_soft,
9231 clear_bgp_peer_group_soft_cmd,
9232 "clear bgp peer-group WORD soft",
9233 CLEAR_STR
9234 BGP_STR
9235 "Clear all members of peer-group\n"
9236 "BGP peer-group name\n"
9237 BGP_SOFT_STR)
9238 {
9239 if (argc == 3)
9240 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
9241 BGP_CLEAR_SOFT_BOTH, argv[2]);
9242
9243 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
9244 BGP_CLEAR_SOFT_BOTH, argv[0]);
9245 }
9246
9247 ALIAS (clear_bgp_peer_group_soft,
9248 clear_bgp_instance_peer_group_soft_cmd,
9249 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9250 CLEAR_STR
9251 BGP_STR
9252 BGP_INSTANCE_HELP_STR
9253 "Clear all members of peer-group\n"
9254 "BGP peer-group name\n"
9255 BGP_SOFT_STR)
9256
9257 ALIAS (clear_bgp_peer_group_soft,
9258 clear_bgp_ipv6_peer_group_soft_cmd,
9259 "clear bgp ipv6 peer-group WORD soft",
9260 CLEAR_STR
9261 BGP_STR
9262 "Address family\n"
9263 "Clear all members of peer-group\n"
9264 "BGP peer-group name\n"
9265 BGP_SOFT_STR)
9266
9267 ALIAS (clear_bgp_peer_group_soft,
9268 clear_bgp_instance_ipv6_peer_group_soft_cmd,
9269 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft",
9270 CLEAR_STR
9271 BGP_STR
9272 BGP_INSTANCE_HELP_STR
9273 "Address family\n"
9274 "Clear all members of peer-group\n"
9275 "BGP peer-group name\n"
9276 BGP_SOFT_STR)
9277
9278 DEFUN (clear_ip_bgp_external_soft,
9279 clear_ip_bgp_external_soft_cmd,
9280 "clear ip bgp external soft",
9281 CLEAR_STR
9282 IP_STR
9283 BGP_STR
9284 "Clear all external peers\n"
9285 BGP_SOFT_STR)
9286 {
9287 if (argc == 2)
9288 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
9289 BGP_CLEAR_SOFT_BOTH, NULL);
9290
9291 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
9292 BGP_CLEAR_SOFT_BOTH, NULL);
9293 }
9294
9295 ALIAS (clear_ip_bgp_external_soft,
9296 clear_ip_bgp_instance_external_soft_cmd,
9297 "clear ip bgp " BGP_INSTANCE_CMD " external soft",
9298 CLEAR_STR
9299 IP_STR
9300 BGP_STR
9301 BGP_INSTANCE_HELP_STR
9302 "Clear all external peers\n"
9303 BGP_SOFT_STR)
9304
9305 DEFUN (clear_ip_bgp_external_ipv4_soft,
9306 clear_ip_bgp_external_ipv4_soft_cmd,
9307 "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft",
9308 CLEAR_STR
9309 IP_STR
9310 BGP_STR
9311 "Clear all external peers\n"
9312 "Address family\n"
9313 BGP_SAFI_HELP_STR
9314 BGP_SOFT_STR)
9315 {
9316 safi_t safi;
9317 safi = bgp_vty_safi_from_arg(argv[0]);
9318 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external,
9319 BGP_CLEAR_SOFT_BOTH, NULL);
9320 }
9321
9322 DEFUN (clear_ip_bgp_instance_external_ipv4_soft,
9323 clear_ip_bgp_instance_external_ipv4_soft_cmd,
9324 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft",
9325 CLEAR_STR
9326 IP_STR
9327 BGP_STR
9328 BGP_INSTANCE_HELP_STR
9329 "Clear all external peers\n"
9330 "Address family\n"
9331 BGP_SAFI_HELP_STR
9332 BGP_SOFT_STR)
9333 {
9334 safi_t safi;
9335 safi = bgp_vty_safi_from_arg(argv[2]);
9336 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external,
9337 BGP_CLEAR_SOFT_BOTH, NULL);
9338 }
9339
9340 DEFUN (clear_bgp_external_soft,
9341 clear_bgp_external_soft_cmd,
9342 "clear bgp external soft",
9343 CLEAR_STR
9344 BGP_STR
9345 "Clear all external peers\n"
9346 BGP_SOFT_STR)
9347 {
9348 if (argc == 2)
9349 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
9350 BGP_CLEAR_SOFT_BOTH, NULL);
9351
9352 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
9353 BGP_CLEAR_SOFT_BOTH, NULL);
9354 }
9355
9356 ALIAS (clear_bgp_external_soft,
9357 clear_bgp_instance_external_soft_cmd,
9358 "clear bgp " BGP_INSTANCE_CMD " external soft",
9359 CLEAR_STR
9360 BGP_STR
9361 BGP_INSTANCE_HELP_STR
9362 "Clear all external peers\n"
9363 BGP_SOFT_STR)
9364
9365 ALIAS (clear_bgp_external_soft,
9366 clear_bgp_ipv6_external_soft_cmd,
9367 "clear bgp ipv6 external soft",
9368 CLEAR_STR
9369 BGP_STR
9370 "Address family\n"
9371 "Clear all external peers\n"
9372 BGP_SOFT_STR)
9373
9374 ALIAS (clear_bgp_external_soft,
9375 clear_bgp_instance_ipv6_external_soft_cmd,
9376 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft",
9377 CLEAR_STR
9378 BGP_STR
9379 BGP_INSTANCE_HELP_STR
9380 "Address family\n"
9381 "Clear all external peers\n"
9382 BGP_SOFT_STR)
9383
9384 DEFUN (clear_ip_bgp_as_soft,
9385 clear_ip_bgp_as_soft_cmd,
9386 "clear ip bgp " CMD_AS_RANGE " soft",
9387 CLEAR_STR
9388 IP_STR
9389 BGP_STR
9390 "Clear peers with the AS number\n"
9391 BGP_SOFT_STR)
9392 {
9393 if (argc == 3)
9394 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
9395 BGP_CLEAR_SOFT_BOTH, argv[2]);
9396
9397 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
9398 BGP_CLEAR_SOFT_BOTH, argv[0]);
9399 }
9400
9401 ALIAS (clear_ip_bgp_as_soft,
9402 clear_ip_bgp_instance_as_soft_cmd,
9403 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9404 CLEAR_STR
9405 IP_STR
9406 BGP_STR
9407 BGP_INSTANCE_HELP_STR
9408 "Clear peers with the AS number\n"
9409 BGP_SOFT_STR)
9410
9411 DEFUN (clear_ip_bgp_as_ipv4_soft,
9412 clear_ip_bgp_as_ipv4_soft_cmd,
9413 "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft",
9414 CLEAR_STR
9415 IP_STR
9416 BGP_STR
9417 "Clear peers with the AS number\n"
9418 "Address family\n"
9419 "Address Family Modifier\n"
9420 "Address Family Modifier\n"
9421 BGP_SOFT_STR)
9422 {
9423 safi_t safi;
9424 safi = bgp_vty_safi_from_arg(argv[1]);
9425 return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as,
9426 BGP_CLEAR_SOFT_BOTH, argv[0]);
9427 }
9428
9429 DEFUN (clear_ip_bgp_instance_as_ipv4_soft,
9430 clear_ip_bgp_instance_as_ipv4_soft_cmd,
9431 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft",
9432 CLEAR_STR
9433 IP_STR
9434 BGP_STR
9435 BGP_INSTANCE_HELP_STR
9436 "Clear peers with the AS number\n"
9437 "Address family\n"
9438 "Address Family Modifier\n"
9439 "Address Family Modifier\n"
9440 BGP_SOFT_STR)
9441 {
9442 safi_t safi;
9443 safi = bgp_vty_safi_from_arg(argv[3]);
9444 return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as,
9445 BGP_CLEAR_SOFT_BOTH, argv[2]);
9446 }
9447
9448 DEFUN (clear_bgp_as_soft,
9449 clear_bgp_as_soft_cmd,
9450 "clear bgp " CMD_AS_RANGE " soft",
9451 CLEAR_STR
9452 BGP_STR
9453 "Clear peers with the AS number\n"
9454 BGP_SOFT_STR)
9455 {
9456 if (argc == 3)
9457 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
9458 BGP_CLEAR_SOFT_BOTH, argv[2]);
9459
9460 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
9461 BGP_CLEAR_SOFT_BOTH, argv[0]);
9462 }
9463
9464 ALIAS (clear_bgp_as_soft,
9465 clear_bgp_instance_as_soft_cmd,
9466 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9467 CLEAR_STR
9468 BGP_STR
9469 BGP_INSTANCE_HELP_STR
9470 "Clear peers with the AS number\n"
9471 BGP_SOFT_STR)
9472
9473 ALIAS (clear_bgp_as_soft,
9474 clear_bgp_ipv6_as_soft_cmd,
9475 "clear bgp ipv6 " CMD_AS_RANGE " soft",
9476 CLEAR_STR
9477 BGP_STR
9478 "Address family\n"
9479 "Clear peers with the AS number\n"
9480 BGP_SOFT_STR)
9481
9482 ALIAS (clear_bgp_as_soft,
9483 clear_bgp_instance_ipv6_as_soft_cmd,
9484 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft",
9485 CLEAR_STR
9486 BGP_STR
9487 BGP_INSTANCE_HELP_STR
9488 "Address family\n"
9489 "Clear peers with the AS number\n"
9490 BGP_SOFT_STR)
9491
9492 DEFUN (show_bgp_views,
9493 show_bgp_views_cmd,
9494 "show bgp views",
9495 SHOW_STR
9496 BGP_STR
9497 "Show the defined BGP views\n")
9498 {
9499 struct list *inst = bm->bgp;
9500 struct listnode *node;
9501 struct bgp *bgp;
9502
9503 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9504 {
9505 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
9506 return CMD_WARNING;
9507 }
9508
9509 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
9510 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
9511 {
9512 /* Skip VRFs. */
9513 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
9514 continue;
9515 vty_out (vty, "\t%s (AS%u)%s",
9516 bgp->name ? bgp->name : "(null)",
9517 bgp->as, VTY_NEWLINE);
9518 }
9519
9520 return CMD_SUCCESS;
9521 }
9522
9523 DEFUN (show_bgp_vrfs,
9524 show_bgp_vrfs_cmd,
9525 "show bgp vrfs {json}",
9526 SHOW_STR
9527 BGP_STR
9528 "Show BGP VRFs\n"
9529 "JavaScript Object Notation\n")
9530 {
9531 struct list *inst = bm->bgp;
9532 struct listnode *node;
9533 struct bgp *bgp;
9534 u_char uj = use_json(argc, argv);
9535 json_object *json = NULL;
9536 json_object *json_vrfs = NULL;
9537 int count = 0;
9538 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
9539
9540 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9541 {
9542 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
9543 return CMD_WARNING;
9544 }
9545
9546 if (uj)
9547 {
9548 json = json_object_new_object();
9549 json_vrfs = json_object_new_object();
9550 }
9551
9552 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
9553 {
9554 const char *name, *type;
9555 struct peer *peer;
9556 struct listnode *node, *nnode;
9557 int peers_cfg, peers_estb;
9558 json_object *json_vrf = NULL;
9559 int vrf_id_ui;
9560
9561 /* Skip Views. */
9562 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
9563 continue;
9564
9565 count++;
9566 if (!uj && count == 1)
9567 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9568
9569 peers_cfg = peers_estb = 0;
9570 if (uj)
9571 json_vrf = json_object_new_object();
9572
9573
9574 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9575 {
9576 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9577 continue;
9578 peers_cfg++;
9579 if (peer->status == Established)
9580 peers_estb++;
9581 }
9582
9583 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9584 {
9585 name = "Default";
9586 type = "DFLT";
9587 }
9588 else
9589 {
9590 name = bgp->name;
9591 type = "VRF";
9592 }
9593
9594 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
9595 if (uj)
9596 {
9597 json_object_string_add(json_vrf, "type", type);
9598 json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
9599 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
9600 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
9601 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
9602
9603 json_object_object_add(json_vrfs, name, json_vrf);
9604 }
9605 else
9606 vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s",
9607 type, vrf_id_ui, inet_ntoa (bgp->router_id),
9608 peers_cfg, peers_estb, name,
9609 VTY_NEWLINE);
9610 }
9611
9612 if (uj)
9613 {
9614 json_object_object_add(json, "vrfs", json_vrfs);
9615
9616 json_object_int_add(json, "totalVrfs", count);
9617
9618 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9619 json_object_free(json);
9620 }
9621 else
9622 {
9623 if (count)
9624 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
9625 VTY_NEWLINE, count, VTY_NEWLINE);
9626 }
9627
9628 return CMD_SUCCESS;
9629 }
9630
9631 DEFUN (show_bgp_memory,
9632 show_bgp_memory_cmd,
9633 "show bgp memory",
9634 SHOW_STR
9635 BGP_STR
9636 "Global BGP memory statistics\n")
9637 {
9638 char memstrbuf[MTYPE_MEMSTR_LEN];
9639 unsigned long count;
9640
9641 /* RIB related usage stats */
9642 count = mtype_stats_alloc (MTYPE_BGP_NODE);
9643 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
9644 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9645 count * sizeof (struct bgp_node)),
9646 VTY_NEWLINE);
9647
9648 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
9649 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
9650 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9651 count * sizeof (struct bgp_info)),
9652 VTY_NEWLINE);
9653 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
9654 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
9655 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9656 count * sizeof (struct bgp_info_extra)),
9657 VTY_NEWLINE);
9658
9659 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
9660 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
9661 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9662 count * sizeof (struct bgp_static)),
9663 VTY_NEWLINE);
9664
9665 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
9666 vty_out (vty, "%ld Packets, using %s of memory%s", count,
9667 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9668 count * sizeof (struct bpacket)),
9669 VTY_NEWLINE);
9670
9671 /* Adj-In/Out */
9672 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
9673 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
9674 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9675 count * sizeof (struct bgp_adj_in)),
9676 VTY_NEWLINE);
9677 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
9678 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
9679 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9680 count * sizeof (struct bgp_adj_out)),
9681 VTY_NEWLINE);
9682
9683 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
9684 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
9685 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9686 count * sizeof (struct bgp_nexthop_cache)),
9687 VTY_NEWLINE);
9688
9689 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
9690 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
9691 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9692 count * sizeof (struct bgp_damp_info)),
9693 VTY_NEWLINE);
9694
9695 /* Attributes */
9696 count = attr_count();
9697 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
9698 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9699 count * sizeof(struct attr)),
9700 VTY_NEWLINE);
9701 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
9702 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
9703 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9704 count * sizeof(struct attr_extra)),
9705 VTY_NEWLINE);
9706
9707 if ((count = attr_unknown_count()))
9708 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
9709
9710 /* AS_PATH attributes */
9711 count = aspath_count ();
9712 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
9713 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9714 count * sizeof (struct aspath)),
9715 VTY_NEWLINE);
9716
9717 count = mtype_stats_alloc (MTYPE_AS_SEG);
9718 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
9719 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9720 count * sizeof (struct assegment)),
9721 VTY_NEWLINE);
9722
9723 /* Other attributes */
9724 if ((count = community_count ()))
9725 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9726 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9727 count * sizeof (struct community)),
9728 VTY_NEWLINE);
9729 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
9730 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9731 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9732 count * sizeof (struct ecommunity)),
9733 VTY_NEWLINE);
9734
9735 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
9736 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
9737 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9738 count * sizeof (struct cluster_list)),
9739 VTY_NEWLINE);
9740
9741 /* Peer related usage */
9742 count = mtype_stats_alloc (MTYPE_BGP_PEER);
9743 vty_out (vty, "%ld peers, using %s of memory%s", count,
9744 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9745 count * sizeof (struct peer)),
9746 VTY_NEWLINE);
9747
9748 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
9749 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
9750 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9751 count * sizeof (struct peer_group)),
9752 VTY_NEWLINE);
9753
9754 /* Other */
9755 if ((count = mtype_stats_alloc (MTYPE_HASH)))
9756 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
9757 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9758 count * sizeof (struct hash)),
9759 VTY_NEWLINE);
9760 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
9761 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
9762 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9763 count * sizeof (struct hash_backet)),
9764 VTY_NEWLINE);
9765 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
9766 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
9767 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9768 count * sizeof (regex_t)),
9769 VTY_NEWLINE);
9770 return CMD_SUCCESS;
9771 }
9772
9773 /* Show BGP peer's summary information. */
9774 static int
9775 bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9776 u_char use_json, json_object *json)
9777 {
9778 struct peer *peer;
9779 struct listnode *node, *nnode;
9780 unsigned int count = 0, dn_count = 0;
9781 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
9782 char neighbor_buf[VTY_BUFSIZ];
9783 int neighbor_col_default_width = 16;
9784 int len;
9785 int max_neighbor_width = 0;
9786 json_object *json_peer = NULL;
9787 json_object *json_peers = NULL;
9788
9789 if (use_json)
9790 {
9791 if (json == NULL)
9792 json = json_object_new_object();
9793
9794 json_peers = json_object_new_object();
9795 }
9796 else
9797 {
9798 /* Loop over all neighbors that will be displayed to determine how many
9799 * characters are needed for the Neighbor column
9800 */
9801 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9802 {
9803 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9804 continue;
9805
9806 if (peer->afc[afi][safi])
9807 {
9808 memset(dn_flag, '\0', sizeof(dn_flag));
9809 if (peer_dynamic_neighbor(peer))
9810 dn_flag[0] = '*';
9811
9812 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
9813 sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host);
9814 else
9815 sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host);
9816
9817 len = strlen(neighbor_buf);
9818
9819 if (len > max_neighbor_width)
9820 max_neighbor_width = len;
9821 }
9822 }
9823
9824 /* Originally we displayed the Neighbor column as 16
9825 * characters wide so make that the default
9826 */
9827 if (max_neighbor_width < neighbor_col_default_width)
9828 max_neighbor_width = neighbor_col_default_width;
9829 }
9830
9831 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9832 {
9833 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9834 continue;
9835
9836 if (peer->afc[afi][safi])
9837 {
9838 if (!count)
9839 {
9840 unsigned long ents;
9841 char memstrbuf[MTYPE_MEMSTR_LEN];
9842 int vrf_id_ui;
9843
9844 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
9845
9846 /* Usage summary and header */
9847 if (use_json)
9848 {
9849 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
9850 json_object_int_add(json, "as", bgp->as);
9851 json_object_int_add(json, "vrfId", vrf_id_ui);
9852 json_object_string_add(json, "vrfName",
9853 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9854 ? "Default" : bgp->name);
9855 }
9856 else
9857 {
9858 vty_out (vty,
9859 "BGP router identifier %s, local AS number %u vrf-id %d",
9860 inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui);
9861 vty_out (vty, "%s", VTY_NEWLINE);
9862 }
9863
9864 if (bgp_update_delay_configured(bgp))
9865 {
9866 if (use_json)
9867 {
9868 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
9869
9870 if (bgp->v_update_delay != bgp->v_establish_wait)
9871 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
9872
9873 if (bgp_update_delay_active(bgp))
9874 {
9875 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
9876 json_object_boolean_true_add(json, "updateDelayInProgress");
9877 }
9878 else
9879 {
9880 if (bgp->update_delay_over)
9881 {
9882 json_object_string_add(json, "updateDelayFirstNeighbor",
9883 bgp->update_delay_begin_time);
9884 json_object_string_add(json, "updateDelayBestpathResumed",
9885 bgp->update_delay_end_time);
9886 json_object_string_add(json, "updateDelayZebraUpdateResume",
9887 bgp->update_delay_zebra_resume_time);
9888 json_object_string_add(json, "updateDelayPeerUpdateResume",
9889 bgp->update_delay_peers_resume_time);
9890 }
9891 }
9892 }
9893 else
9894 {
9895 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
9896 bgp->v_update_delay, VTY_NEWLINE);
9897 if (bgp->v_update_delay != bgp->v_establish_wait)
9898 vty_out (vty, " Establish wait: %d seconds%s",
9899 bgp->v_establish_wait, VTY_NEWLINE);
9900
9901 if (bgp_update_delay_active(bgp))
9902 {
9903 vty_out (vty, " First neighbor established: %s%s",
9904 bgp->update_delay_begin_time, VTY_NEWLINE);
9905 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
9906 }
9907 else
9908 {
9909 if (bgp->update_delay_over)
9910 {
9911 vty_out (vty, " First neighbor established: %s%s",
9912 bgp->update_delay_begin_time, VTY_NEWLINE);
9913 vty_out (vty, " Best-paths resumed: %s%s",
9914 bgp->update_delay_end_time, VTY_NEWLINE);
9915 vty_out (vty, " zebra update resumed: %s%s",
9916 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
9917 vty_out (vty, " peers update resumed: %s%s",
9918 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
9919 }
9920 }
9921 }
9922 }
9923
9924 if (use_json)
9925 {
9926 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9927 json_object_boolean_true_add(json, "maxMedOnStartup");
9928 if (bgp->v_maxmed_admin)
9929 json_object_boolean_true_add(json, "maxMedAdministrative");
9930
9931 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
9932
9933 ents = bgp_table_count (bgp->rib[afi][safi]);
9934 json_object_int_add(json, "ribCount", ents);
9935 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
9936
9937 ents = listcount (bgp->peer);
9938 json_object_int_add(json, "peerCount", ents);
9939 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
9940
9941 if ((ents = listcount (bgp->group)))
9942 {
9943 json_object_int_add(json, "peerGroupCount", ents);
9944 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
9945 }
9946
9947 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9948 json_object_boolean_true_add(json, "dampeningEnabled");
9949 }
9950 else
9951 {
9952 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9953 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
9954 if (bgp->v_maxmed_admin)
9955 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
9956
9957 vty_out(vty, "BGP table version %" PRIu64 "%s",
9958 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
9959
9960 ents = bgp_table_count (bgp->rib[afi][safi]);
9961 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
9962 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9963 ents * sizeof (struct bgp_node)),
9964 VTY_NEWLINE);
9965
9966 /* Peer related usage */
9967 ents = listcount (bgp->peer);
9968 vty_out (vty, "Peers %ld, using %s of memory%s",
9969 ents,
9970 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9971 ents * sizeof (struct peer)),
9972 VTY_NEWLINE);
9973
9974 if ((ents = listcount (bgp->group)))
9975 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
9976 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9977 ents * sizeof (struct peer_group)),
9978 VTY_NEWLINE);
9979
9980 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9981 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
9982 vty_out (vty, "%s", VTY_NEWLINE);
9983
9984 /* Subtract 8 here because 'Neighbor' is 8 characters */
9985 vty_out (vty, "Neighbor");
9986 vty_out (vty, "%*s", max_neighbor_width - 8, " ");
9987 vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE);
9988 }
9989 }
9990
9991 count++;
9992
9993 if (use_json)
9994 {
9995 json_peer = json_object_new_object();
9996
9997 if (peer_dynamic_neighbor(peer))
9998 json_object_boolean_true_add(json_peer, "dynamicPeer");
9999
10000 if (peer->hostname)
10001 json_object_string_add(json_peer, "hostname", peer->hostname);
10002
10003 if (peer->domainname)
10004 json_object_string_add(json_peer, "domainname", peer->domainname);
10005
10006 json_object_int_add(json_peer, "remoteAs", peer->as);
10007 json_object_int_add(json_peer, "version", 4);
10008 json_object_int_add(json_peer, "msgRcvd",
10009 peer->open_in + peer->update_in + peer->keepalive_in
10010 + peer->notify_in + peer->refresh_in
10011 + peer->dynamic_cap_in);
10012 json_object_int_add(json_peer, "msgSent",
10013 peer->open_out + peer->update_out + peer->keepalive_out
10014 + peer->notify_out + peer->refresh_out
10015 + peer->dynamic_cap_out);
10016
10017 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
10018 json_object_int_add(json_peer, "outq", peer->obuf->count);
10019 json_object_int_add(json_peer, "inq", 0);
10020 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
10021 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
10022
10023 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10024 json_object_string_add(json_peer, "state", "Idle (Admin)");
10025 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10026 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
10027 else
10028 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
10029
10030 if (peer->conf_if)
10031 json_object_string_add(json_peer, "idType", "interface");
10032 else if (peer->su.sa.sa_family == AF_INET)
10033 json_object_string_add(json_peer, "idType", "ipv4");
10034 else if (peer->su.sa.sa_family == AF_INET6)
10035 json_object_string_add(json_peer, "idType", "ipv6");
10036
10037 json_object_object_add(json_peers, peer->host, json_peer);
10038 }
10039 else
10040 {
10041 memset(dn_flag, '\0', sizeof(dn_flag));
10042 if (peer_dynamic_neighbor(peer))
10043 {
10044 dn_count++;
10045 dn_flag[0] = '*';
10046 }
10047
10048 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
10049 len = vty_out (vty, "%s%s(%s) ", dn_flag, peer->hostname,
10050 peer->host);
10051 else
10052 len = vty_out (vty, "%s%s ", dn_flag, peer->host);
10053
10054 /* pad the neighbor column with spaces */
10055 if (len < max_neighbor_width)
10056 vty_out (vty, "%*s", max_neighbor_width - len, " ");
10057
10058 vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s",
10059 peer->as,
10060 peer->open_in + peer->update_in + peer->keepalive_in
10061 + peer->notify_in + peer->refresh_in
10062 + peer->dynamic_cap_in,
10063 peer->open_out + peer->update_out + peer->keepalive_out
10064 + peer->notify_out + peer->refresh_out
10065 + peer->dynamic_cap_out,
10066 peer->version[afi][safi],
10067 0,
10068 peer->obuf->count,
10069 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
10070
10071 if (peer->status == Established)
10072 vty_out (vty, " %12ld", peer->pcount[afi][safi]);
10073 else
10074 {
10075 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10076 vty_out (vty, " Idle (Admin)");
10077 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10078 vty_out (vty, " Idle (PfxCt)");
10079 else
10080 vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status));
10081 }
10082 vty_out (vty, "%s", VTY_NEWLINE);
10083 }
10084 }
10085 }
10086
10087 if (use_json)
10088 {
10089 json_object_object_add(json, "peers", json_peers);
10090
10091 json_object_int_add(json, "totalPeers", count);
10092 json_object_int_add(json, "dynamicPeers", dn_count);
10093
10094 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
10095 json_object_free(json);
10096 }
10097 else
10098 {
10099 if (count)
10100 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
10101 count, VTY_NEWLINE);
10102 else
10103 {
10104 if (use_json)
10105 vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s",
10106 afi_safi_print(afi, safi), VTY_NEWLINE);
10107 else
10108 vty_out (vty, "No %s neighbor is configured%s",
10109 afi_safi_print(afi, safi), VTY_NEWLINE);
10110 }
10111
10112 if (dn_count && ! use_json)
10113 {
10114 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
10115 vty_out(vty,
10116 "%d dynamic neighbor(s), limit %d%s",
10117 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
10118 }
10119 }
10120
10121 return CMD_SUCCESS;
10122 }
10123
10124 static void
10125 bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi,
10126 u_char use_json, json_object *json)
10127 {
10128 int is_first = 1;
10129 int afi_wildcard = (afi == AFI_MAX);
10130 int safi_wildcard = (safi == SAFI_MAX);
10131 int is_wildcard = (afi_wildcard || safi_wildcard);
10132 if (use_json && is_wildcard)
10133 vty_out (vty, "{%s", VTY_NEWLINE);
10134 if (afi_wildcard)
10135 afi = 1; /* AFI_IP */
10136 while (afi < AFI_MAX)
10137 {
10138 if (safi_wildcard)
10139 safi = 1; /* SAFI_UNICAST */
10140 while (safi < SAFI_MAX)
10141 {
10142 if (is_wildcard)
10143 {
10144 if (use_json)
10145 {
10146 json = json_object_new_object();
10147
10148 if (! is_first)
10149 vty_out (vty, ",%s", VTY_NEWLINE);
10150 else
10151 is_first = 0;
10152
10153 vty_out(vty, "\"%s\":", afi_safi_json(afi, safi));
10154 }
10155 else
10156 {
10157 vty_out (vty, "%s%s Summary:%s",
10158 VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE);
10159 }
10160 }
10161 bgp_show_summary (vty, bgp, afi, safi, use_json, json);
10162 if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */
10163 safi = SAFI_ENCAP;
10164 else
10165 safi++;
10166 if (safi == SAFI_RESERVED_3) /* handle special cases to match zebra.h */
10167 safi++;
10168 if (! safi_wildcard)
10169 safi = SAFI_MAX;
10170 }
10171 afi++;
10172 if (! afi_wildcard ||
10173 afi == AFI_ETHER) /* special case, not handled yet */
10174 afi = AFI_MAX;
10175 }
10176
10177 if (use_json && is_wildcard)
10178 vty_out (vty, "}%s", VTY_NEWLINE);
10179
10180 }
10181
10182 static int
10183 bgp_show_summary_vty (struct vty *vty, const char *name,
10184 afi_t afi, safi_t safi, u_char use_json)
10185 {
10186 struct bgp *bgp;
10187
10188 if (name)
10189 {
10190 bgp = bgp_lookup_by_name (name);
10191
10192 if (! bgp)
10193 {
10194 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10195 return CMD_WARNING;
10196 }
10197
10198 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL);
10199 return CMD_SUCCESS;
10200 }
10201
10202 bgp = bgp_get_default ();
10203
10204 if (bgp)
10205 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL);
10206
10207 return CMD_SUCCESS;
10208 }
10209
10210 static void
10211 bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
10212 u_char use_json)
10213 {
10214 struct listnode *node, *nnode;
10215 struct bgp *bgp;
10216 json_object *json = NULL;
10217 int is_first = 1;
10218
10219 if (use_json)
10220 vty_out (vty, "{%s", VTY_NEWLINE);
10221
10222 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
10223 {
10224 if (use_json)
10225 {
10226 if (!(json = json_object_new_object()))
10227 {
10228 zlog_err("Unable to allocate memory for JSON object");
10229 vty_out (vty,
10230 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
10231 VTY_NEWLINE);
10232 return;
10233 }
10234
10235 if (! is_first)
10236 vty_out (vty, ",%s", VTY_NEWLINE);
10237 else
10238 is_first = 0;
10239
10240 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
10241 ? "Default" : bgp->name);
10242 }
10243 else
10244 {
10245 vty_out (vty, "%sInstance %s:%s",
10246 VTY_NEWLINE,
10247 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
10248 ? "Default" : bgp->name, VTY_NEWLINE);
10249 }
10250 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json);
10251 }
10252
10253 if (use_json)
10254 vty_out (vty, "}%s", VTY_NEWLINE);
10255
10256 }
10257
10258 /* `show ip bgp summary' commands. */
10259 DEFUN (show_ip_bgp_summary,
10260 show_ip_bgp_summary_cmd,
10261 "show ip bgp summary {json}",
10262 SHOW_STR
10263 IP_STR
10264 BGP_STR
10265 "Summary of BGP neighbor status\n"
10266 "JavaScript Object Notation\n")
10267 {
10268 u_char uj = use_json(argc, argv);
10269 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
10270 }
10271
10272 DEFUN (show_ip_bgp_instance_summary,
10273 show_ip_bgp_instance_summary_cmd,
10274 "show ip bgp " BGP_INSTANCE_CMD " summary {json}",
10275 SHOW_STR
10276 IP_STR
10277 BGP_STR
10278 BGP_INSTANCE_HELP_STR
10279 "Summary of BGP neighbor status\n"
10280 "JavaScript Object Notation\n")
10281 {
10282 u_char uj = use_json(argc, argv);
10283 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj);
10284 }
10285
10286 DEFUN (show_ip_bgp_instance_all_summary,
10287 show_ip_bgp_instance_all_summary_cmd,
10288 "show ip bgp " BGP_INSTANCE_ALL_CMD " summary {json}",
10289 SHOW_STR
10290 IP_STR
10291 BGP_STR
10292 BGP_INSTANCE_ALL_HELP_STR
10293 "Summary of BGP neighbor status\n"
10294 "JavaScript Object Notation\n")
10295 {
10296 u_char uj = use_json(argc, argv);
10297
10298 bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj);
10299 return CMD_SUCCESS;
10300 }
10301
10302 DEFUN (show_ip_bgp_ipv4_summary,
10303 show_ip_bgp_ipv4_summary_cmd,
10304 "show ip bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}",
10305 SHOW_STR
10306 IP_STR
10307 BGP_STR
10308 "Address family\n"
10309 BGP_SAFI_HELP_STR
10310 "Summary of BGP neighbor status\n"
10311 "JavaScript Object Notation\n")
10312 {
10313 u_char uj = use_json(argc, argv);
10314
10315 return bgp_show_summary_vty (vty, NULL, AFI_IP, bgp_vty_safi_from_arg(argv[0]), uj);
10316 }
10317
10318 ALIAS (show_ip_bgp_ipv4_summary,
10319 show_bgp_ipv4_safi_summary_cmd,
10320 "show bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}",
10321 SHOW_STR
10322 BGP_STR
10323 "Address family\n"
10324 BGP_SAFI_HELP_STR
10325 "Summary of BGP neighbor status\n"
10326 "JavaScript Object Notation\n")
10327
10328 DEFUN (show_ip_bgp_instance_ipv4_summary,
10329 show_ip_bgp_instance_ipv4_summary_cmd,
10330 "show ip bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}",
10331 SHOW_STR
10332 IP_STR
10333 BGP_STR
10334 "BGP view\n"
10335 "View name\n"
10336 "Address family\n"
10337 BGP_SAFI_HELP_STR
10338 "Summary of BGP neighbor status\n"
10339 "JavaScript Object Notation\n")
10340 {
10341 u_char uj = use_json(argc, argv);
10342 safi_t safi;
10343 safi = bgp_vty_safi_from_arg(argv[1]);
10344 return bgp_show_summary_vty (vty, argv[0], AFI_IP, safi, uj);
10345 }
10346
10347 ALIAS (show_ip_bgp_instance_ipv4_summary,
10348 show_bgp_instance_ipv4_safi_summary_cmd,
10349 "show bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}",
10350 SHOW_STR
10351 BGP_STR
10352 "BGP view\n"
10353 "View name\n"
10354 BGP_AFI_SAFI_HELP_STR
10355 "Summary of BGP neighbor status\n")
10356
10357 DEFUN (show_bgp_summary,
10358 show_bgp_summary_cmd,
10359 "show bgp summary {json}",
10360 SHOW_STR
10361 BGP_STR
10362 "Summary of BGP neighbor status\n"
10363 "JavaScript Object Notation\n")
10364 {
10365 return bgp_show_summary_vty (vty, NULL, AFI_MAX, SAFI_MAX, use_json(argc, argv));
10366 }
10367
10368 DEFUN (show_bgp_instance_summary,
10369 show_bgp_instance_summary_cmd,
10370 "show bgp " BGP_INSTANCE_CMD " summary {json}",
10371 SHOW_STR
10372 BGP_STR
10373 BGP_INSTANCE_HELP_STR
10374 "Summary of BGP neighbor status\n"
10375 "JavaScript Object Notation\n")
10376 {
10377 return bgp_show_summary_vty (vty, argv[1], AFI_MAX, SAFI_MAX, use_json(argc, argv));
10378 }
10379
10380 DEFUN (show_bgp_instance_all_summary,
10381 show_bgp_instance_all_summary_cmd,
10382 "show bgp " BGP_INSTANCE_ALL_CMD " summary {json}",
10383 SHOW_STR
10384 BGP_STR
10385 BGP_INSTANCE_ALL_HELP_STR
10386 "Summary of BGP neighbor status\n"
10387 "JavaScript Object Notation\n")
10388 {
10389 u_char uj = use_json(argc, argv);
10390
10391 bgp_show_all_instances_summary_vty (vty, AFI_MAX, SAFI_MAX, uj);
10392 return CMD_SUCCESS;
10393 }
10394
10395 DEFUN (show_bgp_ipv4_summary,
10396 show_bgp_ipv4_summary_cmd,
10397 "show bgp ipv4 summary {json}",
10398 SHOW_STR
10399 BGP_STR
10400 "Address family\n"
10401 "Summary of BGP neighbor status\n"
10402 "JavaScript Object Notation\n")
10403 {
10404 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MAX, use_json(argc, argv));
10405 }
10406
10407 DEFUN (show_bgp_instance_ipv4_summary,
10408 show_bgp_instance_ipv4_summary_cmd,
10409 "show bgp " BGP_INSTANCE_CMD " ipv4 summary {json}",
10410 SHOW_STR
10411 BGP_STR
10412 BGP_INSTANCE_HELP_STR
10413 "Address family\n"
10414 "Summary of BGP neighbor status\n"
10415 "JavaScript Object Notation\n")
10416 {
10417 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_MAX, use_json(argc, argv));
10418 }
10419
10420 DEFUN (show_bgp_instance_ipv4_all_summary,
10421 show_bgp_instance_ipv4_all_summary_cmd,
10422 "show bgp " BGP_INSTANCE_ALL_CMD " ipv4 summary {json}",
10423 SHOW_STR
10424 BGP_STR
10425 BGP_INSTANCE_ALL_HELP_STR
10426 "Address family\n"
10427 "Summary of BGP neighbor status\n"
10428 "JavaScript Object Notation\n")
10429 {
10430 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_MAX, use_json(argc, argv));
10431 }
10432
10433 DEFUN (show_bgp_ipv6_summary,
10434 show_bgp_ipv6_summary_cmd,
10435 "show bgp ipv6 summary {json}",
10436 SHOW_STR
10437 BGP_STR
10438 "Address family\n"
10439 "Summary of BGP neighbor status\n"
10440 "JavaScript Object Notation\n")
10441 {
10442 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MAX, use_json(argc, argv));
10443 }
10444
10445 DEFUN (show_bgp_instance_ipv6_summary,
10446 show_bgp_instance_ipv6_summary_cmd,
10447 "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}",
10448 SHOW_STR
10449 BGP_STR
10450 BGP_INSTANCE_HELP_STR
10451 "Address family\n"
10452 "Summary of BGP neighbor status\n"
10453 "JavaScript Object Notation\n")
10454 {
10455 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MAX, use_json(argc, argv));
10456 }
10457
10458 DEFUN (show_bgp_instance_ipv6_all_summary,
10459 show_bgp_instance_ipv6_all_summary_cmd,
10460 "show bgp " BGP_INSTANCE_ALL_CMD " ipv6 summary {json}",
10461 SHOW_STR
10462 BGP_STR
10463 BGP_INSTANCE_ALL_HELP_STR
10464 "Address family\n"
10465 "Summary of BGP neighbor status\n"
10466 "JavaScript Object Notation\n")
10467 {
10468 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MAX, use_json(argc, argv));
10469 }
10470
10471 DEFUN (show_bgp_ipv6_safi_summary,
10472 show_bgp_ipv6_safi_summary_cmd,
10473 "show bgp ipv6 "BGP_SAFI_CMD_STR" summary {json}",
10474 SHOW_STR
10475 BGP_STR
10476 "Address family\n"
10477 BGP_SAFI_HELP_STR
10478 "Summary of BGP neighbor status\n"
10479 "JavaScript Object Notation\n")
10480 {
10481 u_char uj = use_json(argc, argv);
10482
10483 return bgp_show_summary_vty (vty, NULL, AFI_IP6, bgp_vty_safi_from_arg(argv[0]), uj);
10484 }
10485
10486 DEFUN (show_bgp_instance_ipv6_safi_summary,
10487 show_bgp_instance_ipv6_safi_summary_cmd,
10488 "show bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" summary {json}",
10489 SHOW_STR
10490 BGP_STR
10491 BGP_INSTANCE_HELP_STR
10492 BGP_AFI_SAFI_HELP_STR
10493 "Summary of BGP neighbor status\n"
10494 "JavaScript Object Notation\n")
10495 {
10496 u_char uj = use_json(argc, argv);
10497 safi_t safi;
10498 safi = bgp_vty_safi_from_arg(argv[2]);
10499 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, safi, uj);
10500 }
10501
10502 /* old command */
10503 DEFUN (show_ipv6_bgp_summary,
10504 show_ipv6_bgp_summary_cmd,
10505 "show ipv6 bgp summary {json}",
10506 SHOW_STR
10507 IPV6_STR
10508 BGP_STR
10509 "Summary of BGP neighbor status\n"
10510 "JavaScript Object Notation\n")
10511 {
10512 u_char uj = use_json(argc, argv);
10513 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
10514 }
10515
10516 /* old command */
10517 DEFUN (show_ipv6_mbgp_summary,
10518 show_ipv6_mbgp_summary_cmd,
10519 "show ipv6 mbgp summary {json}",
10520 SHOW_STR
10521 IPV6_STR
10522 MBGP_STR
10523 "Summary of BGP neighbor status\n"
10524 "JavaScript Object Notation\n")
10525 {
10526 u_char uj = use_json(argc, argv);
10527 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
10528 }
10529
10530 const char *
10531 afi_safi_print (afi_t afi, safi_t safi)
10532 {
10533 if (afi == AFI_IP && safi == SAFI_UNICAST)
10534 return "IPv4 Unicast";
10535 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
10536 return "IPv4 Multicast";
10537 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10538 return "IPv4 VPN";
10539 else if (afi == AFI_IP && safi == SAFI_ENCAP)
10540 return "IPv4 Encap";
10541 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
10542 return "IPv6 Unicast";
10543 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
10544 return "IPv6 Multicast";
10545 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
10546 return "IPv6 VPN";
10547 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
10548 return "IPv6 Encap";
10549 else
10550 return "Unknown";
10551 }
10552
10553 const char *
10554 afi_safi_json (afi_t afi, safi_t safi)
10555 {
10556 if (afi == AFI_IP && safi == SAFI_UNICAST)
10557 return "IPv4Unicast";
10558 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
10559 return "IPv4Multicast";
10560 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10561 return "IPv4VPN";
10562 else if (afi == AFI_IP && safi == SAFI_ENCAP)
10563 return "IPv4Encap";
10564 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
10565 return "IPv6Unicast";
10566 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
10567 return "IPv6Multicast";
10568 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
10569 return "IPv6VPN";
10570 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
10571 return "IPv6Encap";
10572 else
10573 return "Unknown";
10574 }
10575
10576 /* Show BGP peer's information. */
10577 enum show_type
10578 {
10579 show_all,
10580 show_peer
10581 };
10582
10583 static void
10584 bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10585 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
10586 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
10587 {
10588 /* Send-Mode */
10589 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
10590 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10591 {
10592 if (use_json)
10593 {
10594 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10595 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
10596 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10597 json_object_string_add(json_pref, "sendMode", "advertised");
10598 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10599 json_object_string_add(json_pref, "sendMode", "received");
10600 }
10601 else
10602 {
10603 vty_out (vty, " Send-mode: ");
10604 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10605 vty_out (vty, "advertised");
10606 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10607 vty_out (vty, "%sreceived",
10608 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
10609 ", " : "");
10610 vty_out (vty, "%s", VTY_NEWLINE);
10611 }
10612 }
10613
10614 /* Receive-Mode */
10615 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
10616 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10617 {
10618 if (use_json)
10619 {
10620 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10621 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
10622 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10623 json_object_string_add(json_pref, "recvMode", "advertised");
10624 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10625 json_object_string_add(json_pref, "recvMode", "received");
10626 }
10627 else
10628 {
10629 vty_out (vty, " Receive-mode: ");
10630 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10631 vty_out (vty, "advertised");
10632 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10633 vty_out (vty, "%sreceived",
10634 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
10635 ", " : "");
10636 vty_out (vty, "%s", VTY_NEWLINE);
10637 }
10638 }
10639 }
10640
10641 static void
10642 bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10643 u_char use_json, json_object *json_neigh)
10644 {
10645 struct bgp_filter *filter;
10646 struct peer_af *paf;
10647 char orf_pfx_name[BUFSIZ];
10648 int orf_pfx_count;
10649 json_object *json_af = NULL;
10650 json_object *json_prefA = NULL;
10651 json_object *json_prefB = NULL;
10652 json_object *json_addr = NULL;
10653
10654 if (use_json)
10655 {
10656 json_addr = json_object_new_object();
10657 json_af = json_object_new_object();
10658 filter = &p->filter[afi][safi];
10659
10660 if (peer_group_active(p))
10661 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
10662
10663 paf = peer_af_find(p, afi, safi);
10664 if (paf && PAF_SUBGRP(paf))
10665 {
10666 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
10667 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
10668 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
10669 }
10670
10671 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10672 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10673 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10674 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10675 {
10676 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
10677 json_prefA = json_object_new_object();
10678 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10679 PEER_CAP_ORF_PREFIX_SM_ADV,
10680 PEER_CAP_ORF_PREFIX_RM_ADV,
10681 PEER_CAP_ORF_PREFIX_SM_RCV,
10682 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
10683 json_object_object_add(json_af, "orfPrefixList", json_prefA);
10684 }
10685
10686 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10687 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10688 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10689 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10690 {
10691 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
10692 json_prefB = json_object_new_object();
10693 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10694 PEER_CAP_ORF_PREFIX_SM_ADV,
10695 PEER_CAP_ORF_PREFIX_RM_ADV,
10696 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10697 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
10698 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
10699 }
10700
10701 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10702 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10703 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10704 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10705 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10706 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10707 json_object_object_add(json_addr, "afDependentCap", json_af);
10708 else
10709 json_object_free(json_af);
10710
10711 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10712 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10713
10714 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10715 || orf_pfx_count)
10716 {
10717 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10718 json_object_boolean_true_add(json_neigh, "orfSent");
10719 if (orf_pfx_count)
10720 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
10721 }
10722 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10723 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
10724
10725 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10726 json_object_boolean_true_add(json_addr, "routeReflectorClient");
10727 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10728 json_object_boolean_true_add(json_addr, "routeServerClient");
10729 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10730 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
10731
10732 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10733 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
10734 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
10735 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
10736 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10737 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
10738 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10739 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
10740
10741 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10742 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
10743
10744 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10745 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
10746
10747 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10748 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
10749
10750 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10751 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10752 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
10753 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10754 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
10755 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10756 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
10757 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10758 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
10759 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10760 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10761 {
10762 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10763 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10764 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
10765 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10766 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
10767 else
10768 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
10769 }
10770 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10771 {
10772 if (p->default_rmap[afi][safi].name)
10773 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
10774
10775 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10776 json_object_boolean_true_add(json_addr, "defaultSent");
10777 else
10778 json_object_boolean_true_add(json_addr, "defaultNotSent");
10779 }
10780
10781 if (filter->plist[FILTER_IN].name
10782 || filter->dlist[FILTER_IN].name
10783 || filter->aslist[FILTER_IN].name
10784 || filter->map[RMAP_IN].name)
10785 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
10786 if (filter->plist[FILTER_OUT].name
10787 || filter->dlist[FILTER_OUT].name
10788 || filter->aslist[FILTER_OUT].name
10789 || filter->map[RMAP_OUT].name
10790 || filter->usmap.name)
10791 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
10792
10793 /* prefix-list */
10794 if (filter->plist[FILTER_IN].name)
10795 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
10796 if (filter->plist[FILTER_OUT].name)
10797 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
10798
10799 /* distribute-list */
10800 if (filter->dlist[FILTER_IN].name)
10801 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
10802 if (filter->dlist[FILTER_OUT].name)
10803 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
10804
10805 /* filter-list. */
10806 if (filter->aslist[FILTER_IN].name)
10807 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
10808 if (filter->aslist[FILTER_OUT].name)
10809 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
10810
10811 /* route-map. */
10812 if (filter->map[RMAP_IN].name)
10813 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
10814 if (filter->map[RMAP_OUT].name)
10815 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
10816
10817 /* unsuppress-map */
10818 if (filter->usmap.name)
10819 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
10820
10821 /* Receive prefix count */
10822 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
10823
10824 /* Maximum prefix */
10825 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10826 {
10827 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
10828 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
10829 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
10830 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
10831 if (p->pmax_restart[afi][safi])
10832 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
10833 }
10834 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
10835
10836 }
10837 else
10838 {
10839 filter = &p->filter[afi][safi];
10840
10841 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
10842 VTY_NEWLINE);
10843
10844 if (peer_group_active(p))
10845 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
10846
10847 paf = peer_af_find(p, afi, safi);
10848 if (paf && PAF_SUBGRP(paf))
10849 {
10850 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
10851 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
10852 vty_out (vty, " Packet Queue length %d%s",
10853 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
10854 }
10855 else
10856 {
10857 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
10858 }
10859 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10860 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10861 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10862 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10863 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10864 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10865 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
10866
10867 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10868 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10869 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10870 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10871 {
10872 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10873 ORF_TYPE_PREFIX, VTY_NEWLINE);
10874 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10875 PEER_CAP_ORF_PREFIX_SM_ADV,
10876 PEER_CAP_ORF_PREFIX_RM_ADV,
10877 PEER_CAP_ORF_PREFIX_SM_RCV,
10878 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
10879 }
10880 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10881 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10882 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10883 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10884 {
10885 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10886 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
10887 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10888 PEER_CAP_ORF_PREFIX_SM_ADV,
10889 PEER_CAP_ORF_PREFIX_RM_ADV,
10890 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10891 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
10892 }
10893
10894 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10895 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10896
10897 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10898 || orf_pfx_count)
10899 {
10900 vty_out (vty, " Outbound Route Filter (ORF):");
10901 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10902 vty_out (vty, " sent;");
10903 if (orf_pfx_count)
10904 vty_out (vty, " received (%d entries)", orf_pfx_count);
10905 vty_out (vty, "%s", VTY_NEWLINE);
10906 }
10907 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10908 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
10909
10910 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10911 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
10912 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10913 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
10914 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10915 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
10916
10917 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10918 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
10919 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
10920 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
10921 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10922 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
10923 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10924 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
10925
10926 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10927 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
10928
10929 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10930 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
10931
10932 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10933 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
10934
10935 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10936 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10937 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
10938 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10939 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10940 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10941 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10942 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10943 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10944 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10945 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10946 {
10947 vty_out (vty, " Community attribute sent to this neighbor");
10948 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10949 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10950 vty_out (vty, "(both)%s", VTY_NEWLINE);
10951 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10952 vty_out (vty, "(extended)%s", VTY_NEWLINE);
10953 else
10954 vty_out (vty, "(standard)%s", VTY_NEWLINE);
10955 }
10956 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10957 {
10958 vty_out (vty, " Default information originate,");
10959
10960 if (p->default_rmap[afi][safi].name)
10961 vty_out (vty, " default route-map %s%s,",
10962 p->default_rmap[afi][safi].map ? "*" : "",
10963 p->default_rmap[afi][safi].name);
10964 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10965 vty_out (vty, " default sent%s", VTY_NEWLINE);
10966 else
10967 vty_out (vty, " default not sent%s", VTY_NEWLINE);
10968 }
10969
10970 if (filter->plist[FILTER_IN].name
10971 || filter->dlist[FILTER_IN].name
10972 || filter->aslist[FILTER_IN].name
10973 || filter->map[RMAP_IN].name)
10974 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
10975 if (filter->plist[FILTER_OUT].name
10976 || filter->dlist[FILTER_OUT].name
10977 || filter->aslist[FILTER_OUT].name
10978 || filter->map[RMAP_OUT].name
10979 || filter->usmap.name)
10980 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
10981
10982 /* prefix-list */
10983 if (filter->plist[FILTER_IN].name)
10984 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
10985 filter->plist[FILTER_IN].plist ? "*" : "",
10986 filter->plist[FILTER_IN].name,
10987 VTY_NEWLINE);
10988 if (filter->plist[FILTER_OUT].name)
10989 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
10990 filter->plist[FILTER_OUT].plist ? "*" : "",
10991 filter->plist[FILTER_OUT].name,
10992 VTY_NEWLINE);
10993
10994 /* distribute-list */
10995 if (filter->dlist[FILTER_IN].name)
10996 vty_out (vty, " Incoming update network filter list is %s%s%s",
10997 filter->dlist[FILTER_IN].alist ? "*" : "",
10998 filter->dlist[FILTER_IN].name,
10999 VTY_NEWLINE);
11000 if (filter->dlist[FILTER_OUT].name)
11001 vty_out (vty, " Outgoing update network filter list is %s%s%s",
11002 filter->dlist[FILTER_OUT].alist ? "*" : "",
11003 filter->dlist[FILTER_OUT].name,
11004 VTY_NEWLINE);
11005
11006 /* filter-list. */
11007 if (filter->aslist[FILTER_IN].name)
11008 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
11009 filter->aslist[FILTER_IN].aslist ? "*" : "",
11010 filter->aslist[FILTER_IN].name,
11011 VTY_NEWLINE);
11012 if (filter->aslist[FILTER_OUT].name)
11013 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
11014 filter->aslist[FILTER_OUT].aslist ? "*" : "",
11015 filter->aslist[FILTER_OUT].name,
11016 VTY_NEWLINE);
11017
11018 /* route-map. */
11019 if (filter->map[RMAP_IN].name)
11020 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
11021 filter->map[RMAP_IN].map ? "*" : "",
11022 filter->map[RMAP_IN].name,
11023 VTY_NEWLINE);
11024 if (filter->map[RMAP_OUT].name)
11025 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
11026 filter->map[RMAP_OUT].map ? "*" : "",
11027 filter->map[RMAP_OUT].name,
11028 VTY_NEWLINE);
11029
11030 /* unsuppress-map */
11031 if (filter->usmap.name)
11032 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
11033 filter->usmap.map ? "*" : "",
11034 filter->usmap.name, VTY_NEWLINE);
11035
11036 /* Receive prefix count */
11037 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
11038
11039 /* Maximum prefix */
11040 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
11041 {
11042 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
11043 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
11044 ? " (warning-only)" : "", VTY_NEWLINE);
11045 vty_out (vty, " Threshold for warning message %d%%",
11046 p->pmax_threshold[afi][safi]);
11047 if (p->pmax_restart[afi][safi])
11048 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
11049 vty_out (vty, "%s", VTY_NEWLINE);
11050 }
11051
11052 vty_out (vty, "%s", VTY_NEWLINE);
11053 }
11054 }
11055
11056 static void
11057 bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json)
11058 {
11059 struct bgp *bgp;
11060 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
11061 char timebuf[BGP_UPTIME_LEN];
11062 char dn_flag[2];
11063 const char *subcode_str;
11064 const char *code_str;
11065 afi_t afi;
11066 safi_t safi;
11067 u_int16_t i;
11068 u_char *msg;
11069 json_object *json_neigh = NULL;
11070
11071 bgp = p->bgp;
11072
11073 if (use_json)
11074 json_neigh = json_object_new_object();
11075
11076 if (!use_json)
11077 {
11078 if (p->conf_if) /* Configured interface name. */
11079 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
11080 BGP_PEER_SU_UNSPEC(p) ? "None" :
11081 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
11082 else /* Configured IP address. */
11083 {
11084 memset(dn_flag, '\0', sizeof(dn_flag));
11085 if (peer_dynamic_neighbor(p))
11086 dn_flag[0] = '*';
11087
11088 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
11089 }
11090 }
11091
11092 if (use_json)
11093 {
11094 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
11095 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
11096 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
11097 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
11098
11099 json_object_int_add(json_neigh, "remoteAs", p->as);
11100
11101 if (p->change_local_as)
11102 json_object_int_add(json_neigh, "localAs", p->change_local_as);
11103 else
11104 json_object_int_add(json_neigh, "localAs", p->local_as);
11105
11106 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
11107 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
11108
11109 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
11110 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
11111 }
11112 else
11113 {
11114 if ((p->as_type == AS_SPECIFIED) ||
11115 (p->as_type == AS_EXTERNAL) ||
11116 (p->as_type == AS_INTERNAL))
11117 vty_out (vty, "remote AS %u, ", p->as);
11118 else
11119 vty_out (vty, "remote AS Unspecified, ");
11120 vty_out (vty, "local AS %u%s%s, ",
11121 p->change_local_as ? p->change_local_as : p->local_as,
11122 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
11123 " no-prepend" : "",
11124 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
11125 " replace-as" : "");
11126 }
11127 /* peer type internal, external, confed-internal or confed-external */
11128 if (p->as == p->local_as)
11129 {
11130 if (use_json)
11131 {
11132 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11133 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
11134 else
11135 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
11136 }
11137 else
11138 {
11139 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11140 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
11141 else
11142 vty_out (vty, "internal link%s", VTY_NEWLINE);
11143 }
11144 }
11145 else
11146 {
11147 if (use_json)
11148 {
11149 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
11150 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
11151 else
11152 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
11153 }
11154 else
11155 {
11156 if (bgp_confederation_peers_check(bgp, p->as))
11157 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
11158 else
11159 vty_out (vty, "external link%s", VTY_NEWLINE);
11160 }
11161 }
11162
11163 /* Description. */
11164 if (p->desc)
11165 {
11166 if (use_json)
11167 json_object_string_add(json_neigh, "nbrDesc", p->desc);
11168 else
11169 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
11170 }
11171
11172 if (p->hostname)
11173 {
11174 if (use_json)
11175 {
11176 if (p->hostname)
11177 json_object_string_add(json_neigh, "hostname", p->hostname);
11178
11179 if (p->domainname)
11180 json_object_string_add(json_neigh, "domainname", p->domainname);
11181 }
11182 else
11183 {
11184 if (p->domainname && (p->domainname[0] != '\0'))
11185 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
11186 VTY_NEWLINE);
11187 else
11188 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
11189 }
11190
11191 }
11192
11193 /* Peer-group */
11194 if (p->group)
11195 {
11196 if (use_json)
11197 {
11198 json_object_string_add(json_neigh, "peerGroup", p->group->name);
11199
11200 if (dn_flag[0])
11201 {
11202 struct prefix prefix, *range = NULL;
11203
11204 sockunion2hostprefix(&(p->su), &prefix);
11205 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
11206
11207 if (range)
11208 {
11209 prefix2str(range, buf1, sizeof(buf1));
11210 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
11211 }
11212 }
11213 }
11214 else
11215 {
11216 vty_out (vty, " Member of peer-group %s for session parameters%s",
11217 p->group->name, VTY_NEWLINE);
11218
11219 if (dn_flag[0])
11220 {
11221 struct prefix prefix, *range = NULL;
11222
11223 sockunion2hostprefix(&(p->su), &prefix);
11224 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
11225
11226 if (range)
11227 {
11228 prefix2str(range, buf1, sizeof(buf1));
11229 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
11230 }
11231 }
11232 }
11233 }
11234
11235 if (use_json)
11236 {
11237 /* Administrative shutdown. */
11238 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11239 json_object_boolean_true_add(json_neigh, "adminShutDown");
11240
11241 /* BGP Version. */
11242 json_object_int_add(json_neigh, "bgpVersion", 4);
11243 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
11244
11245 /* Confederation */
11246 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
11247 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
11248
11249 /* Status. */
11250 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
11251
11252 if (p->status == Established)
11253 {
11254 time_t uptime;
11255 struct tm *tm;
11256
11257 uptime = bgp_clock();
11258 uptime -= p->uptime;
11259 tm = gmtime(&uptime);
11260
11261 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11262 }
11263
11264 else if (p->status == Active)
11265 {
11266 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11267 json_object_string_add(json_neigh, "bgpStateIs", "passive");
11268 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11269 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
11270 }
11271
11272 /* read timer */
11273 time_t uptime;
11274 struct tm *tm;
11275
11276 uptime = bgp_clock();
11277 uptime -= p->readtime;
11278 tm = gmtime(&uptime);
11279 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11280
11281 uptime = bgp_clock();
11282 uptime -= p->last_write;
11283 tm = gmtime(&uptime);
11284 json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11285
11286 uptime = bgp_clock();
11287 uptime -= p->update_time;
11288 tm = gmtime(&uptime);
11289 json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs",
11290 (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11291
11292 /* Configured timer values. */
11293 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
11294 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
11295
11296 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11297 {
11298 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
11299 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
11300 }
11301 }
11302 else
11303 {
11304 /* Administrative shutdown. */
11305 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11306 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
11307
11308 /* BGP Version. */
11309 vty_out (vty, " BGP version 4");
11310 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
11311 VTY_NEWLINE);
11312
11313 /* Confederation */
11314 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
11315 && bgp_confederation_peers_check (bgp, p->as))
11316 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
11317
11318 /* Status. */
11319 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
11320
11321 if (p->status == Established)
11322 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11323
11324 else if (p->status == Active)
11325 {
11326 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11327 vty_out (vty, " (passive)");
11328 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11329 vty_out (vty, " (NSF passive)");
11330 }
11331 vty_out (vty, "%s", VTY_NEWLINE);
11332
11333 /* read timer */
11334 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11335 vty_out (vty, ", Last write %s%s",
11336 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
11337
11338 /* Configured timer values. */
11339 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
11340 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
11341 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11342 {
11343 vty_out (vty, " Configured hold time is %d", p->holdtime);
11344 vty_out (vty, ", keepalive interval is %d seconds%s",
11345 p->keepalive, VTY_NEWLINE);
11346 }
11347 }
11348 /* Capability. */
11349 if (p->status == Established)
11350 {
11351 if (p->cap
11352 || p->afc_adv[AFI_IP][SAFI_UNICAST]
11353 || p->afc_recv[AFI_IP][SAFI_UNICAST]
11354 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
11355 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
11356 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
11357 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
11358 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
11359 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
11360 || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
11361 || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
11362 || p->afc_adv[AFI_IP6][SAFI_ENCAP]
11363 || p->afc_recv[AFI_IP6][SAFI_ENCAP]
11364 || p->afc_adv[AFI_IP][SAFI_ENCAP]
11365 || p->afc_recv[AFI_IP][SAFI_ENCAP]
11366 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
11367 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
11368 {
11369 if (use_json)
11370 {
11371 json_object *json_cap = NULL;
11372
11373 json_cap = json_object_new_object();
11374
11375 /* AS4 */
11376 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11377 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11378 {
11379 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11380 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
11381 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11382 json_object_string_add(json_cap, "4byteAs", "advertised");
11383 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11384 json_object_string_add(json_cap, "4byteAs", "received");
11385 }
11386
11387 /* AddPath */
11388 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11389 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11390 {
11391 json_object *json_add = NULL;
11392 const char *print_store;
11393
11394 json_add = json_object_new_object();
11395
11396 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11397 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11398 {
11399 json_object *json_sub = NULL;
11400 json_sub = json_object_new_object();
11401 print_store = afi_safi_print (afi, safi);
11402
11403 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11404 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11405 {
11406 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))
11407 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
11408 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11409 json_object_boolean_true_add(json_sub, "txAdvertised");
11410 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11411 json_object_boolean_true_add(json_sub, "txReceived");
11412 }
11413
11414 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11415 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11416 {
11417 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))
11418 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
11419 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11420 json_object_boolean_true_add(json_sub, "rxAdvertised");
11421 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11422 json_object_boolean_true_add(json_sub, "rxReceived");
11423 }
11424
11425 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11426 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
11427 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11428 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11429 json_object_object_add(json_add, print_store, json_sub);
11430 else
11431 json_object_free(json_sub);
11432 }
11433
11434 json_object_object_add(json_cap, "addPath", json_add);
11435 }
11436
11437 /* Dynamic */
11438 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11439 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11440 {
11441 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11442 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
11443 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11444 json_object_string_add(json_cap, "dynamic", "advertised");
11445 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11446 json_object_string_add(json_cap, "dynamic", "received");
11447 }
11448
11449 /* Extended nexthop */
11450 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11451 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11452 {
11453 json_object *json_nxt = NULL;
11454 const char *print_store;
11455
11456
11457 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11458 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
11459 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11460 json_object_string_add(json_cap, "extendedNexthop", "advertised");
11461 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11462 json_object_string_add(json_cap, "extendedNexthop", "received");
11463
11464 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11465 {
11466 json_nxt = json_object_new_object();
11467
11468 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11469 {
11470 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11471 {
11472 print_store = afi_safi_print (AFI_IP, safi);
11473 json_object_string_add(json_nxt, print_store, "recieved");
11474 }
11475 }
11476 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
11477 }
11478 }
11479
11480 /* Route Refresh */
11481 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11482 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11483 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11484 {
11485 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)))
11486 {
11487 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
11488 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
11489 else
11490 {
11491 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11492 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
11493 else
11494 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
11495 }
11496 }
11497 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11498 json_object_string_add(json_cap, "routeRefresh", "advertised");
11499 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11500 json_object_string_add(json_cap, "routeRefresh", "received");
11501 }
11502
11503 /* Multiprotocol Extensions */
11504 json_object *json_multi = NULL;
11505 json_multi = json_object_new_object();
11506
11507 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11508 {
11509 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11510 {
11511 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11512 {
11513 json_object *json_exten = NULL;
11514 json_exten = json_object_new_object();
11515
11516 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
11517 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
11518 else if (p->afc_adv[afi][safi])
11519 json_object_boolean_true_add(json_exten, "advertised");
11520 else if (p->afc_recv[afi][safi])
11521 json_object_boolean_true_add(json_exten, "received");
11522
11523 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
11524 }
11525 }
11526 }
11527 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
11528
11529 /* Gracefull Restart */
11530 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11531 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11532 {
11533 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11534 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
11535 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11536 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
11537 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11538 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
11539
11540 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11541 {
11542 int restart_af_count = 0;
11543 json_object *json_restart = NULL;
11544 json_restart = json_object_new_object();
11545
11546 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
11547
11548 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11549 {
11550 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11551 {
11552 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11553 {
11554 json_object *json_sub = NULL;
11555 json_sub = json_object_new_object();
11556
11557 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
11558 json_object_boolean_true_add(json_sub, "preserved");
11559 restart_af_count++;
11560 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
11561 }
11562 }
11563 }
11564 if (! restart_af_count)
11565 {
11566 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
11567 json_object_free(json_restart);
11568 }
11569 else
11570 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
11571 }
11572 }
11573 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
11574 }
11575 else
11576 {
11577 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
11578
11579 /* AS4 */
11580 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11581 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11582 {
11583 vty_out (vty, " 4 Byte AS:");
11584 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11585 vty_out (vty, " advertised");
11586 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11587 vty_out (vty, " %sreceived",
11588 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
11589 vty_out (vty, "%s", VTY_NEWLINE);
11590 }
11591
11592 /* AddPath */
11593 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11594 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11595 {
11596 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
11597
11598 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11599 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11600 {
11601 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11602 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11603 {
11604 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
11605
11606 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11607 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
11608
11609 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11610 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
11611
11612 vty_out (vty, "%s", VTY_NEWLINE);
11613 }
11614
11615 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11616 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11617 {
11618 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
11619
11620 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11621 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
11622
11623 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11624 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
11625
11626 vty_out (vty, "%s", VTY_NEWLINE);
11627 }
11628 }
11629 }
11630
11631 /* Dynamic */
11632 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11633 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11634 {
11635 vty_out (vty, " Dynamic:");
11636 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11637 vty_out (vty, " advertised");
11638 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11639 vty_out (vty, " %sreceived",
11640 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
11641 vty_out (vty, "%s", VTY_NEWLINE);
11642 }
11643
11644 /* Extended nexthop */
11645 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11646 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11647 {
11648 vty_out (vty, " Extended nexthop:");
11649 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11650 vty_out (vty, " advertised");
11651 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11652 vty_out (vty, " %sreceived",
11653 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
11654 vty_out (vty, "%s", VTY_NEWLINE);
11655
11656 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11657 {
11658 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11659 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11660 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11661 vty_out (vty, " %s%s",
11662 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
11663 }
11664 }
11665
11666 /* Route Refresh */
11667 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11668 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11669 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11670 {
11671 vty_out (vty, " Route refresh:");
11672 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11673 vty_out (vty, " advertised");
11674 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11675 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11676 vty_out (vty, " %sreceived(%s)",
11677 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
11678 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
11679 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
11680 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
11681
11682 vty_out (vty, "%s", VTY_NEWLINE);
11683 }
11684
11685 /* Multiprotocol Extensions */
11686 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11687 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11688 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11689 {
11690 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
11691 if (p->afc_adv[afi][safi])
11692 vty_out (vty, " advertised");
11693 if (p->afc_recv[afi][safi])
11694 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
11695 vty_out (vty, "%s", VTY_NEWLINE);
11696 }
11697
11698 /* Hostname capability */
11699 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
11700 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
11701 {
11702 vty_out (vty, " Hostname Capability:");
11703 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
11704 vty_out (vty, " advertised");
11705 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
11706 vty_out (vty, " %sreceived",
11707 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
11708 vty_out (vty, "%s", VTY_NEWLINE);
11709 }
11710
11711 /* Gracefull Restart */
11712 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11713 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11714 {
11715 vty_out (vty, " Graceful Restart Capabilty:");
11716 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11717 vty_out (vty, " advertised");
11718 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11719 vty_out (vty, " %sreceived",
11720 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
11721 vty_out (vty, "%s", VTY_NEWLINE);
11722
11723 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11724 {
11725 int restart_af_count = 0;
11726
11727 vty_out (vty, " Remote Restart timer is %d seconds%s",
11728 p->v_gr_restart, VTY_NEWLINE);
11729 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11730
11731 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11732 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11733 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11734 {
11735 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
11736 afi_safi_print (afi, safi),
11737 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
11738 "preserved" : "not preserved");
11739 restart_af_count++;
11740 }
11741 if (! restart_af_count)
11742 vty_out (vty, "none");
11743 vty_out (vty, "%s", VTY_NEWLINE);
11744 }
11745 }
11746 }
11747 }
11748 }
11749
11750 /* graceful restart information */
11751 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11752 || p->t_gr_restart
11753 || p->t_gr_stale)
11754 {
11755 json_object *json_grace = NULL;
11756 json_object *json_grace_send = NULL;
11757 json_object *json_grace_recv = NULL;
11758 int eor_send_af_count = 0;
11759 int eor_receive_af_count = 0;
11760
11761 if (use_json)
11762 {
11763 json_grace = json_object_new_object();
11764 json_grace_send = json_object_new_object();
11765 json_grace_recv = json_object_new_object();
11766
11767 if (p->status == Established)
11768 {
11769 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11770 {
11771 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11772 {
11773 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11774 {
11775 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
11776 eor_send_af_count++;
11777 }
11778 }
11779 }
11780 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11781 {
11782 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11783 {
11784 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11785 {
11786 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
11787 eor_receive_af_count++;
11788 }
11789 }
11790 }
11791 }
11792
11793 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
11794 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
11795
11796 if (p->t_gr_restart)
11797 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
11798
11799 if (p->t_gr_stale)
11800 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
11801
11802 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
11803 }
11804 else
11805 {
11806 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
11807 if (p->status == Established)
11808 {
11809 vty_out (vty, " End-of-RIB send: ");
11810 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11811 {
11812 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11813 {
11814 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11815 {
11816 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
11817 afi_safi_print (afi, safi));
11818 eor_send_af_count++;
11819 }
11820 }
11821 }
11822 vty_out (vty, "%s", VTY_NEWLINE);
11823 vty_out (vty, " End-of-RIB received: ");
11824 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11825 {
11826 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11827 {
11828 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11829 {
11830 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
11831 afi_safi_print (afi, safi));
11832 eor_receive_af_count++;
11833 }
11834 }
11835 }
11836 vty_out (vty, "%s", VTY_NEWLINE);
11837 }
11838
11839 if (p->t_gr_restart)
11840 vty_out (vty, " The remaining time of restart timer is %ld%s",
11841 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
11842
11843 if (p->t_gr_stale)
11844 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
11845 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
11846 }
11847 }
11848 if (use_json)
11849 {
11850 json_object *json_stat = NULL;
11851 json_stat = json_object_new_object();
11852 /* Packet counts. */
11853 json_object_int_add(json_stat, "depthInq", 0);
11854 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
11855 json_object_int_add(json_stat, "opensSent", p->open_out);
11856 json_object_int_add(json_stat, "opensRecv", p->open_in);
11857 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
11858 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
11859 json_object_int_add(json_stat, "updatesSent", p->update_out);
11860 json_object_int_add(json_stat, "updatesRecv", p->update_in);
11861 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
11862 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
11863 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
11864 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
11865 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
11866 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
11867 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);
11868 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);
11869 json_object_object_add(json_neigh, "messageStats", json_stat);
11870 }
11871 else
11872 {
11873 /* Packet counts. */
11874 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
11875 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
11876 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
11877 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
11878 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
11879 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
11880 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
11881 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
11882 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
11883 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
11884 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
11885 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
11886 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
11887 p->dynamic_cap_in, VTY_NEWLINE);
11888 }
11889
11890 if (use_json)
11891 {
11892 /* advertisement-interval */
11893 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
11894
11895 /* Update-source. */
11896 if (p->update_if || p->update_source)
11897 {
11898 if (p->update_if)
11899 json_object_string_add(json_neigh, "updateSource", p->update_if);
11900 else if (p->update_source)
11901 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11902 }
11903 }
11904 else
11905 {
11906 /* advertisement-interval */
11907 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
11908 p->v_routeadv, VTY_NEWLINE);
11909
11910 /* Update-source. */
11911 if (p->update_if || p->update_source)
11912 {
11913 vty_out (vty, " Update source is ");
11914 if (p->update_if)
11915 vty_out (vty, "%s", p->update_if);
11916 else if (p->update_source)
11917 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11918 vty_out (vty, "%s", VTY_NEWLINE);
11919 }
11920
11921 vty_out (vty, "%s", VTY_NEWLINE);
11922 }
11923
11924 /* Address Family Information */
11925 json_object *json_hold = NULL;
11926
11927 if (use_json)
11928 json_hold = json_object_new_object();
11929
11930 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11931 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11932 if (p->afc[afi][safi])
11933 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
11934
11935 if (use_json)
11936 {
11937 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
11938 json_object_int_add(json_neigh, "connectionsEstablished", p->established);
11939 json_object_int_add(json_neigh, "connectionsDropped", p->dropped);
11940 }
11941 else
11942 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
11943 VTY_NEWLINE);
11944
11945 if (! p->last_reset)
11946 {
11947 if (use_json)
11948 json_object_string_add(json_neigh, "lastReset", "never");
11949 else
11950 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
11951 }
11952 else
11953 {
11954 if (use_json)
11955 {
11956 time_t uptime;
11957 struct tm *tm;
11958
11959 uptime = bgp_clock();
11960 uptime -= p->resettime;
11961 tm = gmtime(&uptime);
11962 json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11963 json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
11964 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
11965 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
11966 {
11967 char errorcodesubcode_hexstr[5];
11968 char errorcodesubcode_str[256];
11969
11970 code_str = bgp_notify_code_str(p->notify.code);
11971 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
11972
11973 sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode);
11974 json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr);
11975 snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str);
11976 json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str);
11977 }
11978 }
11979 else
11980 {
11981 vty_out (vty, " Last reset %s, ",
11982 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11983
11984 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
11985 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
11986 {
11987 code_str = bgp_notify_code_str(p->notify.code);
11988 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
11989 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
11990 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
11991 code_str, subcode_str, VTY_NEWLINE);
11992 }
11993 else
11994 {
11995 vty_out (vty, "due to %s%s",
11996 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
11997 }
11998
11999 if (p->last_reset_cause_size)
12000 {
12001 msg = p->last_reset_cause;
12002 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
12003 for (i = 1; i <= p->last_reset_cause_size; i++)
12004 {
12005 vty_out(vty, "%02X", *msg++);
12006
12007 if (i != p->last_reset_cause_size)
12008 {
12009 if (i % 16 == 0)
12010 {
12011 vty_out(vty, "%s ", VTY_NEWLINE);
12012 }
12013 else if (i % 4 == 0)
12014 {
12015 vty_out(vty, " ");
12016 }
12017 }
12018 }
12019 vty_out(vty, "%s", VTY_NEWLINE);
12020 }
12021 }
12022 }
12023
12024 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
12025 {
12026 if (use_json)
12027 json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax");
12028 else
12029 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
12030
12031 if (p->t_pmax_restart)
12032 {
12033 if (use_json)
12034 {
12035 json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom");
12036 json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
12037 }
12038 else
12039 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
12040 p->host, thread_timer_remain_second (p->t_pmax_restart),
12041 VTY_NEWLINE);
12042 }
12043 else
12044 {
12045 if (use_json)
12046 json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp");
12047 else
12048 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
12049 p->host, VTY_NEWLINE);
12050 }
12051 }
12052
12053 /* EBGP Multihop and GTSM */
12054 if (p->sort != BGP_PEER_IBGP)
12055 {
12056 if (use_json)
12057 {
12058 if (p->gtsm_hops > 0)
12059 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
12060 else if (p->ttl > 1)
12061 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
12062 }
12063 else
12064 {
12065 if (p->gtsm_hops > 0)
12066 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
12067 p->gtsm_hops, VTY_NEWLINE);
12068 else if (p->ttl > 1)
12069 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
12070 p->ttl, VTY_NEWLINE);
12071 }
12072 }
12073 else
12074 {
12075 if (p->gtsm_hops > 0)
12076 {
12077 if (use_json)
12078 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
12079 else
12080 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
12081 p->gtsm_hops, VTY_NEWLINE);
12082 }
12083 }
12084
12085 /* Local address. */
12086 if (p->su_local)
12087 {
12088 if (use_json)
12089 {
12090 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
12091 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
12092 }
12093 else
12094 vty_out (vty, "Local host: %s, Local port: %d%s",
12095 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
12096 ntohs (p->su_local->sin.sin_port),
12097 VTY_NEWLINE);
12098 }
12099
12100 /* Remote address. */
12101 if (p->su_remote)
12102 {
12103 if (use_json)
12104 {
12105 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
12106 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
12107 }
12108 else
12109 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
12110 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
12111 ntohs (p->su_remote->sin.sin_port),
12112 VTY_NEWLINE);
12113 }
12114
12115 /* Nexthop display. */
12116 if (p->su_local)
12117 {
12118 if (use_json)
12119 {
12120 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
12121 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
12122 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
12123 if (p->shared_network)
12124 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
12125 else
12126 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
12127 }
12128 else
12129 {
12130 vty_out (vty, "Nexthop: %s%s",
12131 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
12132 VTY_NEWLINE);
12133 vty_out (vty, "Nexthop global: %s%s",
12134 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
12135 VTY_NEWLINE);
12136 vty_out (vty, "Nexthop local: %s%s",
12137 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
12138 VTY_NEWLINE);
12139 vty_out (vty, "BGP connection: %s%s",
12140 p->shared_network ? "shared network" : "non shared network",
12141 VTY_NEWLINE);
12142 }
12143 }
12144
12145 /* Timer information. */
12146 if (use_json)
12147 {
12148 json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect);
12149 if (p->status == Established && p->rtt)
12150 json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt);
12151 if (p->t_start)
12152 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
12153 if (p->t_connect)
12154 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
12155 if (p->t_routeadv)
12156 {
12157 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
12158 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
12159 }
12160
12161 if (p->t_read)
12162 json_object_string_add(json_neigh, "readThread", "on");
12163 else
12164 json_object_string_add(json_neigh, "readThread", "off");
12165 if (p->t_write)
12166 json_object_string_add(json_neigh, "writeThread", "on");
12167 else
12168 json_object_string_add(json_neigh, "writeThread", "off");
12169 }
12170 else
12171 {
12172 vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s",
12173 p->v_connect, VTY_NEWLINE);
12174 if (p->status == Established && p->rtt)
12175 vty_out (vty, "Estimated round trip time: %d ms%s",
12176 p->rtt, VTY_NEWLINE);
12177 if (p->t_start)
12178 vty_out (vty, "Next start timer due in %ld seconds%s",
12179 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
12180 if (p->t_connect)
12181 vty_out (vty, "Next connect timer due in %ld seconds%s",
12182 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
12183 if (p->t_routeadv)
12184 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
12185 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
12186 VTY_NEWLINE);
12187
12188 vty_out (vty, "Read thread: %s Write thread: %s%s",
12189 p->t_read ? "on" : "off",
12190 p->t_write ? "on" : "off",
12191 VTY_NEWLINE);
12192 }
12193
12194 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
12195 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
12196 bgp_capability_vty_out (vty, p, use_json, json_neigh);
12197
12198 if (!use_json)
12199 vty_out (vty, "%s", VTY_NEWLINE);
12200
12201 /* BFD information. */
12202 bgp_bfd_show_info(vty, p, use_json, json_neigh);
12203
12204 if (use_json)
12205 {
12206 if (p->conf_if) /* Configured interface name. */
12207 json_object_object_add(json, p->conf_if, json_neigh);
12208 else /* Configured IP address. */
12209 json_object_object_add(json, p->host, json_neigh);
12210 }
12211 }
12212
12213 static int
12214 bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
12215 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
12216 {
12217 struct listnode *node, *nnode;
12218 struct peer *peer;
12219 int find = 0;
12220
12221 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
12222 {
12223 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
12224 continue;
12225
12226 switch (type)
12227 {
12228 case show_all:
12229 bgp_show_peer (vty, peer, use_json, json);
12230 break;
12231 case show_peer:
12232 if (conf_if)
12233 {
12234 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
12235 (peer->hostname && !strcmp(peer->hostname, conf_if)))
12236 {
12237 find = 1;
12238 bgp_show_peer (vty, peer, use_json, json);
12239 }
12240 }
12241 else
12242 {
12243 if (sockunion_same (&peer->su, su))
12244 {
12245 find = 1;
12246 bgp_show_peer (vty, peer, use_json, json);
12247 }
12248 }
12249 break;
12250 }
12251 }
12252
12253 if (type == show_peer && ! find)
12254 {
12255 if (use_json)
12256 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
12257 else
12258 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
12259 }
12260
12261 if (use_json)
12262 {
12263 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
12264 json_object_free(json);
12265 }
12266 else
12267 {
12268 vty_out (vty, "%s", VTY_NEWLINE);
12269 }
12270
12271 return CMD_SUCCESS;
12272 }
12273
12274 static int
12275 bgp_show_neighbor_vty (struct vty *vty, const char *name,
12276 enum show_type type, const char *ip_str, u_char use_json,
12277 json_object *json)
12278 {
12279 int ret;
12280 struct bgp *bgp;
12281 union sockunion su;
12282
12283 if (use_json && (json == NULL))
12284 json = json_object_new_object();
12285
12286 if (name)
12287 {
12288 bgp = bgp_lookup_by_name (name);
12289 if (! bgp)
12290 {
12291 if (use_json)
12292 {
12293 json_object_boolean_true_add(json, "bgpNoSuchInstance");
12294 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
12295 json_object_free(json);
12296 }
12297 else
12298 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
12299
12300 return CMD_WARNING;
12301 }
12302 }
12303 else
12304 {
12305 bgp = bgp_get_default ();
12306 }
12307
12308 if (bgp)
12309 {
12310 if (ip_str)
12311 {
12312 ret = str2sockunion (ip_str, &su);
12313 if (ret < 0)
12314 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
12315 else
12316 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
12317 }
12318 else
12319 {
12320 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
12321 }
12322 }
12323
12324 return CMD_SUCCESS;
12325 }
12326
12327 static void
12328 bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
12329 {
12330 struct listnode *node, *nnode;
12331 struct bgp *bgp;
12332 json_object *json = NULL;
12333 int is_first = 1;
12334
12335 if (use_json)
12336 vty_out (vty, "{%s", VTY_NEWLINE);
12337
12338 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
12339 {
12340 if (use_json)
12341 {
12342 if (!(json = json_object_new_object()))
12343 {
12344 zlog_err("Unable to allocate memory for JSON object");
12345 vty_out (vty,
12346 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
12347 VTY_NEWLINE);
12348 return;
12349 }
12350
12351 json_object_int_add(json, "vrfId",
12352 (bgp->vrf_id == VRF_UNKNOWN)
12353 ? -1 : bgp->vrf_id);
12354 json_object_string_add(json, "vrfName",
12355 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12356 ? "Default" : bgp->name);
12357
12358 if (! is_first)
12359 vty_out (vty, ",%s", VTY_NEWLINE);
12360 else
12361 is_first = 0;
12362
12363 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12364 ? "Default" : bgp->name);
12365 }
12366 else
12367 {
12368 vty_out (vty, "%sInstance %s:%s",
12369 VTY_NEWLINE,
12370 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
12371 ? "Default" : bgp->name,
12372 VTY_NEWLINE);
12373 }
12374 bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json);
12375 }
12376
12377 if (use_json)
12378 vty_out (vty, "}%s", VTY_NEWLINE);
12379 }
12380
12381 /* "show ip bgp neighbors" commands. */
12382 DEFUN (show_ip_bgp_neighbors,
12383 show_ip_bgp_neighbors_cmd,
12384 "show ip bgp neighbors {json}",
12385 SHOW_STR
12386 IP_STR
12387 BGP_STR
12388 "Detailed information on TCP and BGP neighbor connections\n"
12389 "JavaScript Object Notation\n")
12390 {
12391 u_char uj = use_json(argc, argv);
12392
12393 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj, NULL);
12394 }
12395
12396 ALIAS (show_ip_bgp_neighbors,
12397 show_ip_bgp_ipv4_neighbors_cmd,
12398 "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors {json}",
12399 SHOW_STR
12400 IP_STR
12401 BGP_STR
12402 "Address family\n"
12403 BGP_SAFI_HELP_STR
12404 "Detailed information on TCP and BGP neighbor connections\n"
12405 "JavaScript Object Notation\n")
12406
12407 ALIAS (show_ip_bgp_neighbors,
12408 show_bgp_neighbors_cmd,
12409 "show bgp neighbors {json}",
12410 SHOW_STR
12411 BGP_STR
12412 "Detailed information on TCP and BGP neighbor connections\n"
12413 "JavaScript Object Notation\n")
12414
12415 ALIAS (show_ip_bgp_neighbors,
12416 show_bgp_ipv6_neighbors_cmd,
12417 "show bgp ipv6 neighbors {json}",
12418 SHOW_STR
12419 BGP_STR
12420 "Address family\n"
12421 "Detailed information on TCP and BGP neighbor connections\n"
12422 "JavaScript Object Notation\n")
12423
12424 DEFUN (show_ip_bgp_neighbors_peer,
12425 show_ip_bgp_neighbors_peer_cmd,
12426 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12427 SHOW_STR
12428 IP_STR
12429 BGP_STR
12430 "Detailed information on TCP and BGP neighbor connections\n"
12431 "Neighbor to display information about\n"
12432 "Neighbor to display information about\n"
12433 "Neighbor on bgp configured interface\n"
12434 "JavaScript Object Notation\n")
12435 {
12436 u_char uj = use_json(argc, argv);
12437
12438 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj, NULL);
12439 }
12440
12441 ALIAS (show_ip_bgp_neighbors_peer,
12442 show_ip_bgp_ipv4_neighbors_peer_cmd,
12443 "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12444 SHOW_STR
12445 IP_STR
12446 BGP_STR
12447 "Address family\n"
12448 BGP_SAFI_HELP_STR
12449 "Detailed information on TCP and BGP neighbor connections\n"
12450 "Neighbor to display information about\n"
12451 "Neighbor to display information about\n"
12452 "Neighbor on bgp configured interface\n"
12453 "JavaScript Object Notation\n")
12454
12455 ALIAS (show_ip_bgp_neighbors_peer,
12456 show_bgp_neighbors_peer_cmd,
12457 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12458 SHOW_STR
12459 BGP_STR
12460 "Detailed information on TCP and BGP neighbor connections\n"
12461 "Neighbor to display information about\n"
12462 "Neighbor to display information about\n"
12463 "Neighbor on bgp configured interface\n"
12464 "JavaScript Object Notation\n")
12465
12466 ALIAS (show_ip_bgp_neighbors_peer,
12467 show_bgp_ipv6_neighbors_peer_cmd,
12468 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12469 SHOW_STR
12470 BGP_STR
12471 "Address family\n"
12472 "Detailed information on TCP and BGP neighbor connections\n"
12473 "Neighbor to display information about\n"
12474 "Neighbor to display information about\n"
12475 "Neighbor on bgp configured interface\n"
12476 "JavaScript Object Notation\n")
12477
12478 DEFUN (show_ip_bgp_instance_neighbors,
12479 show_ip_bgp_instance_neighbors_cmd,
12480 "show ip bgp " BGP_INSTANCE_CMD " neighbors {json}",
12481 SHOW_STR
12482 IP_STR
12483 BGP_STR
12484 BGP_INSTANCE_HELP_STR
12485 "Detailed information on TCP and BGP neighbor connections\n"
12486 "JavaScript Object Notation\n")
12487 {
12488 u_char uj = use_json(argc, argv);
12489
12490 return bgp_show_neighbor_vty (vty, argv[1], show_all, NULL, uj, NULL);
12491 }
12492
12493 DEFUN (show_ip_bgp_instance_all_neighbors,
12494 show_ip_bgp_instance_all_neighbors_cmd,
12495 "show ip bgp " BGP_INSTANCE_ALL_CMD " neighbors {json}",
12496 SHOW_STR
12497 IP_STR
12498 BGP_STR
12499 BGP_INSTANCE_ALL_HELP_STR
12500 "Detailed information on TCP and BGP neighbor connections\n"
12501 "JavaScript Object Notation\n")
12502 {
12503 u_char uj = use_json(argc, argv);
12504
12505 bgp_show_all_instances_neighbors_vty (vty, uj);
12506 return CMD_SUCCESS;
12507 }
12508
12509 ALIAS (show_ip_bgp_instance_neighbors,
12510 show_bgp_instance_neighbors_cmd,
12511 "show bgp " BGP_INSTANCE_CMD " neighbors {json}",
12512 SHOW_STR
12513 BGP_STR
12514 BGP_INSTANCE_HELP_STR
12515 "Detailed information on TCP and BGP neighbor connections\n"
12516 "JavaScript Object Notation\n")
12517
12518 ALIAS (show_ip_bgp_instance_neighbors,
12519 show_bgp_instance_ipv6_neighbors_cmd,
12520 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors {json}",
12521 SHOW_STR
12522 BGP_STR
12523 BGP_INSTANCE_HELP_STR
12524 "Address family\n"
12525 "Detailed information on TCP and BGP neighbor connections\n"
12526 "JavaScript Object Notation\n")
12527
12528 DEFUN (show_ip_bgp_instance_neighbors_peer,
12529 show_ip_bgp_instance_neighbors_peer_cmd,
12530 "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12531 SHOW_STR
12532 IP_STR
12533 BGP_STR
12534 BGP_INSTANCE_HELP_STR
12535 "Detailed information on TCP and BGP neighbor connections\n"
12536 "Neighbor to display information about\n"
12537 "Neighbor to display information about\n"
12538 "Neighbor on bgp configured interface\n"
12539 "JavaScript Object Notation\n")
12540 {
12541 u_char uj = use_json(argc, argv);
12542
12543 return bgp_show_neighbor_vty (vty, argv[1], show_peer, argv[2], uj, NULL);
12544 }
12545
12546 ALIAS (show_ip_bgp_instance_neighbors_peer,
12547 show_bgp_instance_neighbors_peer_cmd,
12548 "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12549 SHOW_STR
12550 BGP_STR
12551 BGP_INSTANCE_HELP_STR
12552 "Detailed information on TCP and BGP neighbor connections\n"
12553 "Neighbor to display information about\n"
12554 "Neighbor to display information about\n"
12555 "Neighbor on bgp configured interface\n"
12556 "JavaScript Object Notation\n")
12557
12558 ALIAS (show_ip_bgp_instance_neighbors_peer,
12559 show_bgp_instance_ipv6_neighbors_peer_cmd,
12560 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12561 SHOW_STR
12562 BGP_STR
12563 BGP_INSTANCE_HELP_STR
12564 "Address family\n"
12565 "Detailed information on TCP and BGP neighbor connections\n"
12566 "Neighbor to display information about\n"
12567 "Neighbor to display information about\n"
12568 "Neighbor on bgp configured interface\n"
12569 "JavaScript Object Notation\n")
12570
12571 /* Show BGP's AS paths internal data. There are both `show ip bgp
12572 paths' and `show ip mbgp paths'. Those functions results are the
12573 same.*/
12574 DEFUN (show_ip_bgp_paths,
12575 show_ip_bgp_paths_cmd,
12576 "show ip bgp paths",
12577 SHOW_STR
12578 IP_STR
12579 BGP_STR
12580 "Path information\n")
12581 {
12582 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
12583 aspath_print_all_vty (vty);
12584 return CMD_SUCCESS;
12585 }
12586
12587 DEFUN (show_ip_bgp_ipv4_paths,
12588 show_ip_bgp_ipv4_paths_cmd,
12589 "show ip bgp ipv4 "BGP_SAFI_CMD_STR" paths",
12590 SHOW_STR
12591 IP_STR
12592 BGP_STR
12593 "Address family\n"
12594 BGP_SAFI_HELP_STR
12595 "Path information\n")
12596 {
12597 vty_out (vty, "Address Refcnt Path\r\n");
12598 aspath_print_all_vty (vty);
12599
12600 return CMD_SUCCESS;
12601 }
12602
12603 #include "hash.h"
12604
12605 static void
12606 community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
12607 {
12608 struct community *com;
12609
12610 com = (struct community *) backet->data;
12611 vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
12612 community_str (com), VTY_NEWLINE);
12613 }
12614
12615 /* Show BGP's community internal data. */
12616 DEFUN (show_ip_bgp_community_info,
12617 show_ip_bgp_community_info_cmd,
12618 "show ip bgp community-info",
12619 SHOW_STR
12620 IP_STR
12621 BGP_STR
12622 "List all bgp community information\n")
12623 {
12624 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
12625
12626 hash_iterate (community_hash (),
12627 (void (*) (struct hash_backet *, void *))
12628 community_show_all_iterator,
12629 vty);
12630
12631 return CMD_SUCCESS;
12632 }
12633
12634 DEFUN (show_ip_bgp_attr_info,
12635 show_ip_bgp_attr_info_cmd,
12636 "show ip bgp attribute-info",
12637 SHOW_STR
12638 IP_STR
12639 BGP_STR
12640 "List all bgp attribute information\n")
12641 {
12642 attr_show_all (vty);
12643 return CMD_SUCCESS;
12644 }
12645
12646 static int bgp_show_update_groups(struct vty *vty, const char *name,
12647 int afi, int safi,
12648 uint64_t subgrp_id)
12649 {
12650 struct bgp *bgp;
12651
12652 if (name)
12653 bgp = bgp_lookup_by_name (name);
12654 else
12655 bgp = bgp_get_default ();
12656
12657 if (bgp)
12658 update_group_show(bgp, afi, safi, vty, subgrp_id);
12659 return CMD_SUCCESS;
12660 }
12661
12662 static void
12663 bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
12664 {
12665 struct listnode *node, *nnode;
12666 struct bgp *bgp;
12667
12668 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
12669 {
12670 vty_out (vty, "%sInstance %s:%s",
12671 VTY_NEWLINE,
12672 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name,
12673 VTY_NEWLINE);
12674 update_group_show(bgp, afi, safi, vty, 0);
12675 }
12676 }
12677
12678 DEFUN (show_ip_bgp_updgrps,
12679 show_ip_bgp_updgrps_cmd,
12680 "show ip bgp update-groups",
12681 SHOW_STR
12682 IP_STR
12683 BGP_STR
12684 "Detailed info about dynamic update groups\n")
12685 {
12686 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
12687 }
12688
12689 DEFUN (show_ip_bgp_instance_updgrps,
12690 show_ip_bgp_instance_updgrps_cmd,
12691 "show ip bgp " BGP_INSTANCE_CMD " update-groups",
12692 SHOW_STR
12693 IP_STR
12694 BGP_STR
12695 BGP_INSTANCE_HELP_STR
12696 "Detailed info about dynamic update groups\n")
12697 {
12698 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, 0));
12699 }
12700
12701 DEFUN (show_ip_bgp_instance_all_updgrps,
12702 show_ip_bgp_instance_all_updgrps_cmd,
12703 "show ip bgp " BGP_INSTANCE_ALL_CMD " update-groups",
12704 SHOW_STR
12705 IP_STR
12706 BGP_STR
12707 BGP_INSTANCE_ALL_HELP_STR
12708 "Detailed info about dynamic update groups\n")
12709 {
12710 bgp_show_all_instances_updgrps_vty (vty, AFI_IP, SAFI_UNICAST);
12711 return CMD_SUCCESS;
12712 }
12713
12714 DEFUN (show_bgp_ipv6_updgrps,
12715 show_bgp_ipv6_updgrps_cmd,
12716 "show bgp update-groups",
12717 SHOW_STR
12718 BGP_STR
12719 "Detailed info about v6 dynamic update groups\n")
12720 {
12721 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
12722 }
12723
12724 DEFUN (show_bgp_instance_ipv6_updgrps,
12725 show_bgp_instance_ipv6_updgrps_cmd,
12726 "show bgp " BGP_INSTANCE_CMD " update-groups",
12727 SHOW_STR
12728 BGP_STR
12729 BGP_INSTANCE_HELP_STR
12730 "Detailed info about v6 dynamic update groups\n")
12731 {
12732 return (bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, 0));
12733 }
12734
12735 DEFUN (show_bgp_instance_all_ipv6_updgrps,
12736 show_bgp_instance_all_ipv6_updgrps_cmd,
12737 "show bgp " BGP_INSTANCE_ALL_CMD " update-groups",
12738 SHOW_STR
12739 BGP_STR
12740 BGP_INSTANCE_ALL_HELP_STR
12741 "Detailed info about v6 dynamic update groups\n")
12742 {
12743 bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST);
12744 return CMD_SUCCESS;
12745 }
12746
12747 DEFUN (show_bgp_updgrps,
12748 show_bgp_updgrps_cmd,
12749 "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups",
12750 SHOW_STR
12751 BGP_STR
12752 "Address family\n"
12753 BGP_SAFI_HELP_STR
12754 "Detailed info about dynamic update groups\n")
12755 {
12756 afi_t afi;
12757 safi_t safi;
12758
12759 afi = bgp_vty_safi_from_arg(argv[0]);
12760 safi = bgp_vty_safi_from_arg(argv[1]);
12761 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
12762 }
12763
12764 DEFUN (show_ip_bgp_updgrps_s,
12765 show_ip_bgp_updgrps_s_cmd,
12766 "show ip bgp update-groups SUBGROUP-ID",
12767 SHOW_STR
12768 IP_STR
12769 BGP_STR
12770 "Detailed info about dynamic update groups\n"
12771 "Specific subgroup to display detailed info for\n")
12772 {
12773 uint64_t subgrp_id;
12774
12775 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12776 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
12777 }
12778
12779 DEFUN (show_ip_bgp_instance_updgrps_s,
12780 show_ip_bgp_instance_updgrps_s_cmd,
12781 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12782 SHOW_STR
12783 IP_STR
12784 BGP_STR
12785 BGP_INSTANCE_HELP_STR
12786 "Detailed info about dynamic update groups\n"
12787 "Specific subgroup to display detailed info for\n")
12788 {
12789 uint64_t subgrp_id;
12790
12791 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12792 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, subgrp_id));
12793 }
12794
12795 DEFUN (show_bgp_ipv6_updgrps_s,
12796 show_bgp_ipv6_updgrps_s_cmd,
12797 "show bgp update-groups SUBGROUP-ID",
12798 SHOW_STR
12799 BGP_STR
12800 "Detailed info about v6 dynamic update groups\n"
12801 "Specific subgroup to display detailed info for\n")
12802 {
12803 uint64_t subgrp_id;
12804
12805 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12806 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
12807 }
12808
12809 DEFUN (show_bgp_instance_ipv6_updgrps_s,
12810 show_bgp_instance_ipv6_updgrps_s_cmd,
12811 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12812 SHOW_STR
12813 BGP_STR
12814 "Detailed info about v6 dynamic update groups\n"
12815 "Specific subgroup to display detailed info for\n")
12816 {
12817 uint64_t subgrp_id;
12818
12819 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12820 return(bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, subgrp_id));
12821 }
12822
12823 DEFUN (show_bgp_updgrps_s,
12824 show_bgp_updgrps_s_cmd,
12825 "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID",
12826 SHOW_STR
12827 BGP_STR
12828 "Address family\n"
12829 BGP_AFI_SAFI_HELP_STR
12830 "Detailed info about v6 dynamic update groups\n"
12831 "Specific subgroup to display detailed info for")
12832 {
12833 afi_t afi;
12834 safi_t safi;
12835 uint64_t subgrp_id;
12836
12837 afi = bgp_vty_safi_from_arg(argv[0]);
12838 safi = bgp_vty_safi_from_arg(argv[1]);
12839 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12840 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
12841 }
12842
12843 DEFUN (show_bgp_updgrps_stats,
12844 show_bgp_updgrps_stats_cmd,
12845 "show bgp update-groups statistics",
12846 SHOW_STR
12847 BGP_STR
12848 "BGP update groups\n"
12849 "Statistics\n")
12850 {
12851 struct bgp *bgp;
12852
12853 bgp = bgp_get_default();
12854 if (bgp)
12855 update_group_show_stats(bgp, vty);
12856
12857 return CMD_SUCCESS;
12858 }
12859
12860 DEFUN (show_bgp_instance_updgrps_stats,
12861 show_bgp_instance_updgrps_stats_cmd,
12862 "show bgp " BGP_INSTANCE_CMD " update-groups statistics",
12863 SHOW_STR
12864 BGP_STR
12865 BGP_INSTANCE_HELP_STR
12866 "BGP update groups\n"
12867 "Statistics\n")
12868 {
12869 struct bgp *bgp;
12870
12871 bgp = bgp_lookup_by_name (argv[1]);
12872 if (bgp)
12873 update_group_show_stats(bgp, vty);
12874
12875 return CMD_SUCCESS;
12876 }
12877
12878 static void
12879 show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
12880 afi_t afi, safi_t safi,
12881 const char *what, uint64_t subgrp_id)
12882 {
12883 struct bgp *bgp;
12884
12885 if (name)
12886 bgp = bgp_lookup_by_name (name);
12887 else
12888 bgp = bgp_get_default ();
12889
12890 if (bgp)
12891 {
12892 if (!strcmp(what, "advertise-queue"))
12893 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
12894 else if (!strcmp(what, "advertised-routes"))
12895 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
12896 else if (!strcmp(what, "packet-queue"))
12897 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
12898 }
12899 }
12900
12901 DEFUN (show_ip_bgp_updgrps_adj,
12902 show_ip_bgp_updgrps_adj_cmd,
12903 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12904 SHOW_STR
12905 IP_STR
12906 BGP_STR
12907 "BGP update groups\n"
12908 "Advertisement queue\n"
12909 "Announced routes\n"
12910 "Packet queue\n")
12911
12912 {
12913 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[0], 0);
12914 return CMD_SUCCESS;
12915 }
12916
12917 DEFUN (show_ip_bgp_instance_updgrps_adj,
12918 show_ip_bgp_instance_updgrps_adj_cmd,
12919 "show ip bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12920 SHOW_STR
12921 IP_STR
12922 BGP_STR
12923 BGP_INSTANCE_HELP_STR
12924 "BGP update groups\n"
12925 "Advertisement queue\n"
12926 "Announced routes\n"
12927 "Packet queue\n")
12928
12929 {
12930 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[2], 0);
12931 return CMD_SUCCESS;
12932 }
12933
12934 DEFUN (show_bgp_updgrps_afi_adj,
12935 show_bgp_updgrps_afi_adj_cmd,
12936 "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups (advertise-queue|advertised-routes|packet-queue)",
12937 SHOW_STR
12938 BGP_STR
12939 "Address family\n"
12940 BGP_SAFI_HELP_STR
12941 "BGP update groups\n"
12942 "Advertisement queue\n"
12943 "Announced routes\n"
12944 "Packet queue\n"
12945 "Specific subgroup info wanted for\n")
12946 {
12947 afi_t afi;
12948 safi_t safi;
12949
12950 afi = bgp_vty_safi_from_arg(argv[0]);
12951 safi = bgp_vty_safi_from_arg(argv[1]);
12952 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0);
12953 return CMD_SUCCESS;
12954 }
12955
12956 DEFUN (show_bgp_updgrps_adj,
12957 show_bgp_updgrps_adj_cmd,
12958 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12959 SHOW_STR
12960 BGP_STR
12961 "BGP update groups\n"
12962 "Advertisement queue\n"
12963 "Announced routes\n"
12964 "Packet queue\n")
12965 {
12966 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[0], 0);
12967 return CMD_SUCCESS;
12968 }
12969
12970 DEFUN (show_bgp_instance_updgrps_adj,
12971 show_bgp_instance_updgrps_adj_cmd,
12972 "show bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12973 SHOW_STR
12974 BGP_STR
12975 BGP_INSTANCE_HELP_STR
12976 "BGP update groups\n"
12977 "Advertisement queue\n"
12978 "Announced routes\n"
12979 "Packet queue\n")
12980 {
12981 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[2], 0);
12982 return CMD_SUCCESS;
12983 }
12984
12985 DEFUN (show_ip_bgp_updgrps_adj_s,
12986 show_ip_bgp_updgrps_adj_s_cmd,
12987 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12988 SHOW_STR
12989 IP_STR
12990 BGP_STR
12991 "BGP update groups\n"
12992 "Specific subgroup to display info for\n"
12993 "Advertisement queue\n"
12994 "Announced routes\n"
12995 "Packet queue\n")
12996
12997 {
12998 uint64_t subgrp_id;
12999
13000 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
13001
13002 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
13003 return CMD_SUCCESS;
13004 }
13005
13006 DEFUN (show_ip_bgp_instance_updgrps_adj_s,
13007 show_ip_bgp_instance_updgrps_adj_s_cmd,
13008 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
13009 SHOW_STR
13010 IP_STR
13011 BGP_STR
13012 BGP_INSTANCE_HELP_STR
13013 "BGP update groups\n"
13014 "Specific subgroup to display info for\n"
13015 "Advertisement queue\n"
13016 "Announced routes\n"
13017 "Packet queue\n")
13018
13019 {
13020 uint64_t subgrp_id;
13021
13022 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
13023
13024 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
13025 return CMD_SUCCESS;
13026 }
13027
13028 DEFUN (show_bgp_updgrps_afi_adj_s,
13029 show_bgp_updgrps_afi_adj_s_cmd,
13030 "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
13031 SHOW_STR
13032 BGP_STR
13033 "Address family\n"
13034 BGP_SAFI_HELP_STR
13035 "BGP update groups\n"
13036 "Specific subgroup to display info for\n"
13037 "Advertisement queue\n"
13038 "Announced routes\n"
13039 "Packet queue\n"
13040 "Specific subgroup info wanted for\n")
13041 {
13042 afi_t afi;
13043 safi_t safi;
13044 uint64_t subgrp_id;
13045
13046 afi = bgp_vty_safi_from_arg(argv[0]);
13047 safi = bgp_vty_safi_from_arg(argv[1]);
13048 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
13049
13050 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
13051 return CMD_SUCCESS;
13052 }
13053
13054 DEFUN (show_bgp_updgrps_adj_s,
13055 show_bgp_updgrps_adj_s_cmd,
13056 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
13057 SHOW_STR
13058 BGP_STR
13059 "BGP update groups\n"
13060 "Specific subgroup to display info for\n"
13061 "Advertisement queue\n"
13062 "Announced routes\n"
13063 "Packet queue\n")
13064 {
13065 uint64_t subgrp_id;
13066
13067 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
13068
13069 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
13070 return CMD_SUCCESS;
13071 }
13072
13073 DEFUN (show_bgp_instance_updgrps_adj_s,
13074 show_bgp_instance_updgrps_adj_s_cmd,
13075 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
13076 SHOW_STR
13077 BGP_STR
13078 BGP_INSTANCE_HELP_STR
13079 "BGP update groups\n"
13080 "Specific subgroup to display info for\n"
13081 "Advertisement queue\n"
13082 "Announced routes\n"
13083 "Packet queue\n")
13084 {
13085 uint64_t subgrp_id;
13086
13087 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
13088
13089 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
13090 return CMD_SUCCESS;
13091 }
13092
13093
13094
13095 static int
13096 bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
13097 {
13098 struct listnode *node, *nnode;
13099 struct prefix *range;
13100 struct peer *conf;
13101 struct peer *peer;
13102 char buf[PREFIX2STR_BUFFER];
13103 afi_t afi;
13104 safi_t safi;
13105 const char *peer_status;
13106 const char *af_str;
13107 int lr_count;
13108 int dynamic;
13109 int af_cfgd;
13110
13111 conf = group->conf;
13112
13113 if (conf->as_type == AS_SPECIFIED ||
13114 conf->as_type == AS_EXTERNAL) {
13115 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
13116 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
13117 } else if (conf->as_type == AS_INTERNAL) {
13118 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
13119 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
13120 } else {
13121 vty_out (vty, "%sBGP peer-group %s%s",
13122 VTY_NEWLINE, group->name, VTY_NEWLINE);
13123 }
13124
13125 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
13126 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
13127 else
13128 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
13129
13130 /* Display AFs configured. */
13131 vty_out (vty, " Configured address-families:");
13132 for (afi = AFI_IP; afi < AFI_MAX; afi++)
13133 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
13134 {
13135 if (conf->afc[afi][safi])
13136 {
13137 af_cfgd = 1;
13138 vty_out (vty, " %s;", afi_safi_print(afi, safi));
13139 }
13140 }
13141 if (!af_cfgd)
13142 vty_out (vty, " none%s", VTY_NEWLINE);
13143 else
13144 vty_out (vty, "%s", VTY_NEWLINE);
13145
13146 /* Display listen ranges (for dynamic neighbors), if any */
13147 for (afi = AFI_IP; afi < AFI_MAX; afi++)
13148 {
13149 if (afi == AFI_IP)
13150 af_str = "IPv4";
13151 else if (afi == AFI_IP6)
13152 af_str = "IPv6";
13153 else
13154 af_str = "???";
13155 lr_count = listcount(group->listen_range[afi]);
13156 if (lr_count)
13157 {
13158 vty_out(vty,
13159 " %d %s listen range(s)%s",
13160 lr_count, af_str, VTY_NEWLINE);
13161
13162
13163 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
13164 nnode, range))
13165 {
13166 prefix2str(range, buf, sizeof(buf));
13167 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
13168 }
13169 }
13170 }
13171
13172 /* Display group members and their status */
13173 if (listcount(group->peer))
13174 {
13175 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
13176 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
13177 {
13178 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
13179 peer_status = "Idle (Admin)";
13180 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
13181 peer_status = "Idle (PfxCt)";
13182 else
13183 peer_status = LOOKUP(bgp_status_msg, peer->status);
13184
13185 dynamic = peer_dynamic_neighbor(peer);
13186 vty_out (vty, " %s %s %s %s",
13187 peer->host, dynamic ? "(dynamic)" : "",
13188 peer_status, VTY_NEWLINE);
13189 }
13190 }
13191
13192 return CMD_SUCCESS;
13193 }
13194
13195 /* Show BGP peer group's information. */
13196 enum show_group_type
13197 {
13198 show_all_groups,
13199 show_peer_group
13200 };
13201
13202 static int
13203 bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
13204 enum show_group_type type, const char *group_name)
13205 {
13206 struct listnode *node, *nnode;
13207 struct peer_group *group;
13208 int find = 0;
13209
13210 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
13211 {
13212 switch (type)
13213 {
13214 case show_all_groups:
13215 bgp_show_one_peer_group (vty, group);
13216 break;
13217 case show_peer_group:
13218 if (group_name && (strcmp(group->name, group_name) == 0))
13219 {
13220 find = 1;
13221 bgp_show_one_peer_group (vty, group);
13222 }
13223 break;
13224 }
13225 }
13226
13227 if (type == show_peer_group && ! find)
13228 vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
13229
13230 return CMD_SUCCESS;
13231 }
13232
13233 static int
13234 bgp_show_peer_group_vty (struct vty *vty, const char *name,
13235 enum show_group_type type, const char *group_name)
13236 {
13237 struct bgp *bgp;
13238 int ret = CMD_SUCCESS;
13239
13240 if (name)
13241 bgp = bgp_lookup_by_name (name);
13242 else
13243 bgp = bgp_get_default ();
13244
13245 if (! bgp)
13246 {
13247 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
13248 return CMD_WARNING;
13249 }
13250
13251 ret = bgp_show_peer_group (vty, bgp, type, group_name);
13252
13253 return ret;
13254 }
13255
13256 DEFUN (show_ip_bgp_peer_groups,
13257 show_ip_bgp_peer_groups_cmd,
13258 "show ip bgp peer-group",
13259 SHOW_STR
13260 IP_STR
13261 BGP_STR
13262 "Detailed information on all BGP peer groups\n")
13263 {
13264 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
13265 }
13266
13267 DEFUN (show_ip_bgp_instance_peer_groups,
13268 show_ip_bgp_instance_peer_groups_cmd,
13269 "show ip bgp " BGP_INSTANCE_CMD " peer-group",
13270 SHOW_STR
13271 IP_STR
13272 BGP_STR
13273 BGP_INSTANCE_HELP_STR
13274 "Detailed information on all BGP peer groups\n")
13275 {
13276 return bgp_show_peer_group_vty (vty, argv[1], show_all_groups, NULL);
13277 }
13278
13279 DEFUN (show_ip_bgp_peer_group,
13280 show_ip_bgp_peer_group_cmd,
13281 "show ip bgp peer-group WORD",
13282 SHOW_STR
13283 IP_STR
13284 BGP_STR
13285 "BGP peer-group name\n"
13286 "Detailed information on a BGP peer group\n")
13287 {
13288 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
13289 }
13290
13291 DEFUN (show_ip_bgp_instance_peer_group,
13292 show_ip_bgp_instance_peer_group_cmd,
13293 "show ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
13294 SHOW_STR
13295 IP_STR
13296 BGP_STR
13297 BGP_INSTANCE_HELP_STR
13298 "BGP peer-group name\n"
13299 "Detailed information on a BGP peer group\n")
13300 {
13301 return bgp_show_peer_group_vty (vty, argv[1], show_peer_group, argv[2]);
13302 }
13303
13304 /* Redistribute VTY commands. */
13305
13306 DEFUN (bgp_redistribute_ipv4,
13307 bgp_redistribute_ipv4_cmd,
13308 "redistribute " FRR_IP_REDIST_STR_BGPD,
13309 "Redistribute information from another routing protocol\n"
13310 FRR_IP_REDIST_HELP_STR_BGPD)
13311 {
13312 int type;
13313
13314 type = proto_redistnum (AFI_IP, argv[0]);
13315 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13316 {
13317 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13318 return CMD_WARNING;
13319 }
13320 bgp_redist_add(vty->index, AFI_IP, type, 0);
13321 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13322 }
13323
13324 DEFUN (bgp_redistribute_ipv4_rmap,
13325 bgp_redistribute_ipv4_rmap_cmd,
13326 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD",
13327 "Redistribute information from another routing protocol\n"
13328 FRR_IP_REDIST_HELP_STR_BGPD
13329 "Route map reference\n"
13330 "Pointer to route-map entries\n")
13331 {
13332 int type;
13333 struct bgp_redist *red;
13334
13335 type = proto_redistnum (AFI_IP, argv[0]);
13336 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13337 {
13338 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13339 return CMD_WARNING;
13340 }
13341
13342 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13343 bgp_redistribute_rmap_set (red, argv[1]);
13344 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13345 }
13346
13347 DEFUN (bgp_redistribute_ipv4_metric,
13348 bgp_redistribute_ipv4_metric_cmd,
13349 "redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295>",
13350 "Redistribute information from another routing protocol\n"
13351 FRR_IP_REDIST_HELP_STR_BGPD
13352 "Metric for redistributed routes\n"
13353 "Default metric\n")
13354 {
13355 int type;
13356 u_int32_t metric;
13357 struct bgp_redist *red;
13358
13359 type = proto_redistnum (AFI_IP, argv[0]);
13360 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13361 {
13362 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13363 return CMD_WARNING;
13364 }
13365 VTY_GET_INTEGER ("metric", metric, argv[1]);
13366
13367 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13368 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13369 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13370 }
13371
13372 DEFUN (bgp_redistribute_ipv4_rmap_metric,
13373 bgp_redistribute_ipv4_rmap_metric_cmd,
13374 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13375 "Redistribute information from another routing protocol\n"
13376 FRR_IP_REDIST_HELP_STR_BGPD
13377 "Route map reference\n"
13378 "Pointer to route-map entries\n"
13379 "Metric for redistributed routes\n"
13380 "Default metric\n")
13381 {
13382 int type;
13383 u_int32_t metric;
13384 struct bgp_redist *red;
13385
13386 type = proto_redistnum (AFI_IP, argv[0]);
13387 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13388 {
13389 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13390 return CMD_WARNING;
13391 }
13392 VTY_GET_INTEGER ("metric", metric, argv[2]);
13393
13394 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13395 bgp_redistribute_rmap_set (red, argv[1]);
13396 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13397 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13398 }
13399
13400 DEFUN (bgp_redistribute_ipv4_metric_rmap,
13401 bgp_redistribute_ipv4_metric_rmap_cmd,
13402 "redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13403 "Redistribute information from another routing protocol\n"
13404 FRR_IP_REDIST_HELP_STR_BGPD
13405 "Metric for redistributed routes\n"
13406 "Default metric\n"
13407 "Route map reference\n"
13408 "Pointer to route-map entries\n")
13409 {
13410 int type;
13411 u_int32_t metric;
13412 struct bgp_redist *red;
13413
13414 type = proto_redistnum (AFI_IP, argv[0]);
13415 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13416 {
13417 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13418 return CMD_WARNING;
13419 }
13420 VTY_GET_INTEGER ("metric", metric, argv[1]);
13421
13422 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13423 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13424 bgp_redistribute_rmap_set (red, argv[2]);
13425 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13426 }
13427
13428 DEFUN (bgp_redistribute_ipv4_ospf,
13429 bgp_redistribute_ipv4_ospf_cmd,
13430 "redistribute (ospf|table) <1-65535>",
13431 "Redistribute information from another routing protocol\n"
13432 "Open Shortest Path First (OSPFv2)\n"
13433 "Non-main Kernel Routing Table\n"
13434 "Instance ID/Table ID\n")
13435 {
13436 u_short instance;
13437 u_short protocol;
13438
13439 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13440
13441 if (strncmp(argv[0], "o", 1) == 0)
13442 protocol = ZEBRA_ROUTE_OSPF;
13443 else
13444 protocol = ZEBRA_ROUTE_TABLE;
13445
13446 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13447 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13448 }
13449
13450 DEFUN (bgp_redistribute_ipv4_ospf_rmap,
13451 bgp_redistribute_ipv4_ospf_rmap_cmd,
13452 "redistribute (ospf|table) <1-65535> route-map WORD",
13453 "Redistribute information from another routing protocol\n"
13454 "Open Shortest Path First (OSPFv2)\n"
13455 "Non-main Kernel Routing Table\n"
13456 "Instance ID/Table ID\n"
13457 "Route map reference\n"
13458 "Pointer to route-map entries\n")
13459 {
13460 struct bgp_redist *red;
13461 u_short instance;
13462 int protocol;
13463
13464 if (strncmp(argv[0], "o", 1) == 0)
13465 protocol = ZEBRA_ROUTE_OSPF;
13466 else
13467 protocol = ZEBRA_ROUTE_TABLE;
13468
13469 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13470 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13471 bgp_redistribute_rmap_set (red, argv[2]);
13472 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13473 }
13474
13475 DEFUN (bgp_redistribute_ipv4_ospf_metric,
13476 bgp_redistribute_ipv4_ospf_metric_cmd,
13477 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
13478 "Redistribute information from another routing protocol\n"
13479 "Open Shortest Path First (OSPFv2)\n"
13480 "Non-main Kernel Routing Table\n"
13481 "Instance ID/Table ID\n"
13482 "Metric for redistributed routes\n"
13483 "Default metric\n")
13484 {
13485 u_int32_t metric;
13486 struct bgp_redist *red;
13487 u_short instance;
13488 int protocol;
13489
13490 if (strncmp(argv[0], "o", 1) == 0)
13491 protocol = ZEBRA_ROUTE_OSPF;
13492 else
13493 protocol = ZEBRA_ROUTE_TABLE;
13494
13495 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13496 VTY_GET_INTEGER ("metric", metric, argv[2]);
13497
13498 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13499 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13500 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13501 }
13502
13503 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
13504 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
13505 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
13506 "Redistribute information from another routing protocol\n"
13507 "Open Shortest Path First (OSPFv2)\n"
13508 "Non-main Kernel Routing Table\n"
13509 "Instance ID/Table ID\n"
13510 "Route map reference\n"
13511 "Pointer to route-map entries\n"
13512 "Metric for redistributed routes\n"
13513 "Default metric\n")
13514 {
13515 u_int32_t metric;
13516 struct bgp_redist *red;
13517 u_short instance;
13518 int protocol;
13519
13520 if (strncmp(argv[0], "o", 1) == 0)
13521 protocol = ZEBRA_ROUTE_OSPF;
13522 else
13523 protocol = ZEBRA_ROUTE_TABLE;
13524
13525 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13526 VTY_GET_INTEGER ("metric", metric, argv[3]);
13527
13528 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13529 bgp_redistribute_rmap_set (red, argv[2]);
13530 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13531 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13532 }
13533
13534 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
13535 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
13536 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
13537 "Redistribute information from another routing protocol\n"
13538 "Open Shortest Path First (OSPFv2)\n"
13539 "Non-main Kernel Routing Table\n"
13540 "Instance ID/Table ID\n"
13541 "Metric for redistributed routes\n"
13542 "Default metric\n"
13543 "Route map reference\n"
13544 "Pointer to route-map entries\n")
13545 {
13546 u_int32_t metric;
13547 struct bgp_redist *red;
13548 u_short instance;
13549 int protocol;
13550
13551 if (strncmp(argv[0], "o", 1) == 0)
13552 protocol = ZEBRA_ROUTE_OSPF;
13553 else
13554 protocol = ZEBRA_ROUTE_TABLE;
13555
13556 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13557 VTY_GET_INTEGER ("metric", metric, argv[2]);
13558
13559 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13560 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13561 bgp_redistribute_rmap_set (red, argv[3]);
13562 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13563 }
13564
13565 DEFUN (no_bgp_redistribute_ipv4_ospf,
13566 no_bgp_redistribute_ipv4_ospf_cmd,
13567 "no redistribute (ospf|table) <1-65535>",
13568 NO_STR
13569 "Redistribute information from another routing protocol\n"
13570 "Open Shortest Path First (OSPFv2)\n"
13571 "Non-main Kernel Routing Table\n"
13572 "Instance ID/Table ID\n")
13573 {
13574 u_short instance;
13575 int protocol;
13576
13577 if (strncmp(argv[0], "o", 1) == 0)
13578 protocol = ZEBRA_ROUTE_OSPF;
13579 else
13580 protocol = ZEBRA_ROUTE_TABLE;
13581
13582 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13583 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
13584 }
13585
13586 ALIAS (no_bgp_redistribute_ipv4_ospf,
13587 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
13588 "no redistribute (ospf|table) <1-65535> route-map WORD",
13589 NO_STR
13590 "Redistribute information from another routing protocol\n"
13591 "Open Shortest Path First (OSPFv2)\n"
13592 "Non-main Kernel Routing Table\n"
13593 "Instance ID/Table ID\n"
13594 "Route map reference\n"
13595 "Pointer to route-map entries\n")
13596
13597 ALIAS (no_bgp_redistribute_ipv4_ospf,
13598 no_bgp_redistribute_ipv4_ospf_metric_cmd,
13599 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
13600 NO_STR
13601 "Redistribute information from another routing protocol\n"
13602 "Open Shortest Path First (OSPFv2)\n"
13603 "Non-main Kernel Routing Table\n"
13604 "Instance ID/Table ID\n"
13605 "Metric for redistributed routes\n"
13606 "Default metric\n")
13607
13608 ALIAS (no_bgp_redistribute_ipv4_ospf,
13609 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
13610 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
13611 NO_STR
13612 "Redistribute information from another routing protocol\n"
13613 "Open Shortest Path First (OSPFv2)\n"
13614 "Non-main Kernel Routing Table\n"
13615 "Instance ID/Table ID\n"
13616 "Route map reference\n"
13617 "Pointer to route-map entries\n"
13618 "Metric for redistributed routes\n"
13619 "Default metric\n")
13620
13621 ALIAS (no_bgp_redistribute_ipv4_ospf,
13622 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
13623 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
13624 NO_STR
13625 "Redistribute information from another routing protocol\n"
13626 "Open Shortest Path First (OSPFv2)\n"
13627 "Non-main Kernel Routing Table\n"
13628 "Instance ID/Table ID\n"
13629 "Metric for redistributed routes\n"
13630 "Default metric\n"
13631 "Route map reference\n"
13632 "Pointer to route-map entries\n")
13633
13634 DEFUN (no_bgp_redistribute_ipv4,
13635 no_bgp_redistribute_ipv4_cmd,
13636 "no redistribute " FRR_IP_REDIST_STR_BGPD,
13637 NO_STR
13638 "Redistribute information from another routing protocol\n"
13639 FRR_IP_REDIST_HELP_STR_BGPD)
13640 {
13641 int type;
13642
13643 type = proto_redistnum (AFI_IP, argv[0]);
13644 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13645 {
13646 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13647 return CMD_WARNING;
13648 }
13649 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
13650 }
13651
13652 ALIAS (no_bgp_redistribute_ipv4,
13653 no_bgp_redistribute_ipv4_rmap_cmd,
13654 "no redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD",
13655 NO_STR
13656 "Redistribute information from another routing protocol\n"
13657 FRR_IP_REDIST_HELP_STR_BGPD
13658 "Route map reference\n"
13659 "Pointer to route-map entries\n")
13660
13661 ALIAS (no_bgp_redistribute_ipv4,
13662 no_bgp_redistribute_ipv4_metric_cmd,
13663 "no redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295>",
13664 NO_STR
13665 "Redistribute information from another routing protocol\n"
13666 FRR_IP_REDIST_HELP_STR_BGPD
13667 "Metric for redistributed routes\n"
13668 "Default metric\n")
13669
13670 ALIAS (no_bgp_redistribute_ipv4,
13671 no_bgp_redistribute_ipv4_rmap_metric_cmd,
13672 "no redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13673 NO_STR
13674 "Redistribute information from another routing protocol\n"
13675 FRR_IP_REDIST_HELP_STR_BGPD
13676 "Route map reference\n"
13677 "Pointer to route-map entries\n"
13678 "Metric for redistributed routes\n"
13679 "Default metric\n")
13680
13681 ALIAS (no_bgp_redistribute_ipv4,
13682 no_bgp_redistribute_ipv4_metric_rmap_cmd,
13683 "no redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13684 NO_STR
13685 "Redistribute information from another routing protocol\n"
13686 FRR_IP_REDIST_HELP_STR_BGPD
13687 "Metric for redistributed routes\n"
13688 "Default metric\n"
13689 "Route map reference\n"
13690 "Pointer to route-map entries\n")
13691
13692 DEFUN (bgp_redistribute_ipv6,
13693 bgp_redistribute_ipv6_cmd,
13694 "redistribute " FRR_IP6_REDIST_STR_BGPD,
13695 "Redistribute information from another routing protocol\n"
13696 FRR_IP6_REDIST_HELP_STR_BGPD)
13697 {
13698 int type;
13699
13700 type = proto_redistnum (AFI_IP6, argv[0]);
13701 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13702 {
13703 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13704 return CMD_WARNING;
13705 }
13706
13707 bgp_redist_add(vty->index, AFI_IP6, type, 0);
13708 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13709 }
13710
13711 DEFUN (bgp_redistribute_ipv6_rmap,
13712 bgp_redistribute_ipv6_rmap_cmd,
13713 "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD",
13714 "Redistribute information from another routing protocol\n"
13715 FRR_IP6_REDIST_HELP_STR_BGPD
13716 "Route map reference\n"
13717 "Pointer to route-map entries\n")
13718 {
13719 int type;
13720 struct bgp_redist *red;
13721
13722 type = proto_redistnum (AFI_IP6, argv[0]);
13723 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13724 {
13725 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13726 return CMD_WARNING;
13727 }
13728
13729 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13730 bgp_redistribute_rmap_set (red, argv[1]);
13731 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13732 }
13733
13734 DEFUN (bgp_redistribute_ipv6_metric,
13735 bgp_redistribute_ipv6_metric_cmd,
13736 "redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
13737 "Redistribute information from another routing protocol\n"
13738 FRR_IP6_REDIST_HELP_STR_BGPD
13739 "Metric for redistributed routes\n"
13740 "Default metric\n")
13741 {
13742 int type;
13743 u_int32_t metric;
13744 struct bgp_redist *red;
13745
13746 type = proto_redistnum (AFI_IP6, argv[0]);
13747 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13748 {
13749 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13750 return CMD_WARNING;
13751 }
13752 VTY_GET_INTEGER ("metric", metric, argv[1]);
13753
13754 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13755 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
13756 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13757 }
13758
13759 DEFUN (bgp_redistribute_ipv6_rmap_metric,
13760 bgp_redistribute_ipv6_rmap_metric_cmd,
13761 "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13762 "Redistribute information from another routing protocol\n"
13763 FRR_IP6_REDIST_HELP_STR_BGPD
13764 "Route map reference\n"
13765 "Pointer to route-map entries\n"
13766 "Metric for redistributed routes\n"
13767 "Default metric\n")
13768 {
13769 int type;
13770 u_int32_t metric;
13771 struct bgp_redist *red;
13772
13773 type = proto_redistnum (AFI_IP6, argv[0]);
13774 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13775 {
13776 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13777 return CMD_WARNING;
13778 }
13779 VTY_GET_INTEGER ("metric", metric, argv[2]);
13780
13781 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13782 bgp_redistribute_rmap_set (red, argv[1]);
13783 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
13784 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13785 }
13786
13787 DEFUN (bgp_redistribute_ipv6_metric_rmap,
13788 bgp_redistribute_ipv6_metric_rmap_cmd,
13789 "redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13790 "Redistribute information from another routing protocol\n"
13791 FRR_IP6_REDIST_HELP_STR_BGPD
13792 "Metric for redistributed routes\n"
13793 "Default metric\n"
13794 "Route map reference\n"
13795 "Pointer to route-map entries\n")
13796 {
13797 int type;
13798 u_int32_t metric;
13799 struct bgp_redist *red;
13800
13801 type = proto_redistnum (AFI_IP6, argv[0]);
13802 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13803 {
13804 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13805 return CMD_WARNING;
13806 }
13807 VTY_GET_INTEGER ("metric", metric, argv[1]);
13808
13809 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13810 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
13811 bgp_redistribute_rmap_set (red, argv[2]);
13812 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13813 }
13814
13815 DEFUN (no_bgp_redistribute_ipv6,
13816 no_bgp_redistribute_ipv6_cmd,
13817 "no redistribute " FRR_IP6_REDIST_STR_BGPD,
13818 NO_STR
13819 "Redistribute information from another routing protocol\n"
13820 FRR_IP6_REDIST_HELP_STR_BGPD)
13821 {
13822 int type;
13823
13824 type = proto_redistnum (AFI_IP6, argv[0]);
13825 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13826 {
13827 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13828 return CMD_WARNING;
13829 }
13830
13831 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
13832 }
13833
13834 ALIAS (no_bgp_redistribute_ipv6,
13835 no_bgp_redistribute_ipv6_rmap_cmd,
13836 "no redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD",
13837 NO_STR
13838 "Redistribute information from another routing protocol\n"
13839 FRR_IP6_REDIST_HELP_STR_BGPD
13840 "Route map reference\n"
13841 "Pointer to route-map entries\n")
13842
13843 ALIAS (no_bgp_redistribute_ipv6,
13844 no_bgp_redistribute_ipv6_metric_cmd,
13845 "no redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
13846 NO_STR
13847 "Redistribute information from another routing protocol\n"
13848 FRR_IP6_REDIST_HELP_STR_BGPD
13849 "Metric for redistributed routes\n"
13850 "Default metric\n")
13851
13852 ALIAS (no_bgp_redistribute_ipv6,
13853 no_bgp_redistribute_ipv6_rmap_metric_cmd,
13854 "no redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13855 NO_STR
13856 "Redistribute information from another routing protocol\n"
13857 FRR_IP6_REDIST_HELP_STR_BGPD
13858 "Route map reference\n"
13859 "Pointer to route-map entries\n"
13860 "Metric for redistributed routes\n"
13861 "Default metric\n")
13862
13863 ALIAS (no_bgp_redistribute_ipv6,
13864 no_bgp_redistribute_ipv6_metric_rmap_cmd,
13865 "no redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13866 NO_STR
13867 "Redistribute information from another routing protocol\n"
13868 FRR_IP6_REDIST_HELP_STR_BGPD
13869 "Metric for redistributed routes\n"
13870 "Default metric\n"
13871 "Route map reference\n"
13872 "Pointer to route-map entries\n")
13873
13874 int
13875 bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
13876 safi_t safi, int *write)
13877 {
13878 int i;
13879
13880 /* Unicast redistribution only. */
13881 if (safi != SAFI_UNICAST)
13882 return 0;
13883
13884 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
13885 {
13886 /* Redistribute BGP does not make sense. */
13887 if (i != ZEBRA_ROUTE_BGP)
13888 {
13889 struct list *red_list;
13890 struct listnode *node;
13891 struct bgp_redist *red;
13892
13893 red_list = bgp->redist[afi][i];
13894 if (!red_list)
13895 continue;
13896
13897 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
13898 {
13899 /* Display "address-family" when it is not yet diplayed. */
13900 bgp_config_write_family_header (vty, afi, safi, write);
13901
13902 /* "redistribute" configuration. */
13903 vty_out (vty, " redistribute %s", zebra_route_string(i));
13904 if (red->instance)
13905 vty_out (vty, " %d", red->instance);
13906 if (red->redist_metric_flag)
13907 vty_out (vty, " metric %u", red->redist_metric);
13908 if (red->rmap.name)
13909 vty_out (vty, " route-map %s", red->rmap.name);
13910 vty_out (vty, "%s", VTY_NEWLINE);
13911 }
13912 }
13913 }
13914 return *write;
13915 }
13916
13917 /* BGP node structure. */
13918 static struct cmd_node bgp_node =
13919 {
13920 BGP_NODE,
13921 "%s(config-router)# ",
13922 1,
13923 };
13924
13925 static struct cmd_node bgp_ipv4_unicast_node =
13926 {
13927 BGP_IPV4_NODE,
13928 "%s(config-router-af)# ",
13929 1,
13930 };
13931
13932 static struct cmd_node bgp_ipv4_multicast_node =
13933 {
13934 BGP_IPV4M_NODE,
13935 "%s(config-router-af)# ",
13936 1,
13937 };
13938
13939 static struct cmd_node bgp_ipv6_unicast_node =
13940 {
13941 BGP_IPV6_NODE,
13942 "%s(config-router-af)# ",
13943 1,
13944 };
13945
13946 static struct cmd_node bgp_ipv6_multicast_node =
13947 {
13948 BGP_IPV6M_NODE,
13949 "%s(config-router-af)# ",
13950 1,
13951 };
13952
13953 static struct cmd_node bgp_vpnv4_node =
13954 {
13955 BGP_VPNV4_NODE,
13956 "%s(config-router-af)# ",
13957 1
13958 };
13959
13960 static struct cmd_node bgp_vpnv6_node =
13961 {
13962 BGP_VPNV6_NODE,
13963 "%s(config-router-af-vpnv6)# ",
13964 1
13965 };
13966
13967 static struct cmd_node bgp_encap_node =
13968 {
13969 BGP_ENCAP_NODE,
13970 "%s(config-router-af-encap)# ",
13971 1
13972 };
13973
13974 static struct cmd_node bgp_encapv6_node =
13975 {
13976 BGP_ENCAPV6_NODE,
13977 "%s(config-router-af-encapv6)# ",
13978 1
13979 };
13980
13981 static void community_list_vty (void);
13982
13983 void
13984 bgp_vty_init (void)
13985 {
13986 /* Install bgp top node. */
13987 install_node (&bgp_node, bgp_config_write);
13988 install_node (&bgp_ipv4_unicast_node, NULL);
13989 install_node (&bgp_ipv4_multicast_node, NULL);
13990 install_node (&bgp_ipv6_unicast_node, NULL);
13991 install_node (&bgp_ipv6_multicast_node, NULL);
13992 install_node (&bgp_vpnv4_node, NULL);
13993 install_node (&bgp_vpnv6_node, NULL);
13994 install_node (&bgp_encap_node, NULL);
13995 install_node (&bgp_encapv6_node, NULL);
13996
13997 /* Install default VTY commands to new nodes. */
13998 install_default (BGP_NODE);
13999 install_default (BGP_IPV4_NODE);
14000 install_default (BGP_IPV4M_NODE);
14001 install_default (BGP_IPV6_NODE);
14002 install_default (BGP_IPV6M_NODE);
14003 install_default (BGP_VPNV4_NODE);
14004 install_default (BGP_VPNV6_NODE);
14005 install_default (BGP_ENCAP_NODE);
14006 install_default (BGP_ENCAPV6_NODE);
14007
14008 /* "bgp multiple-instance" commands. */
14009 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
14010 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
14011
14012 /* "bgp config-type" commands. */
14013 install_element (CONFIG_NODE, &bgp_config_type_cmd);
14014 install_element (CONFIG_NODE, &no_bgp_config_type_val_cmd);
14015
14016 /* bgp route-map delay-timer commands. */
14017 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
14018 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
14019 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
14020
14021 /* Dummy commands (Currently not supported) */
14022 install_element (BGP_NODE, &no_synchronization_cmd);
14023 install_element (BGP_NODE, &no_auto_summary_cmd);
14024
14025 /* "router bgp" commands. */
14026 install_element (CONFIG_NODE, &router_bgp_cmd);
14027 install_element (CONFIG_NODE, &router_bgp_instance_cmd);
14028 install_element (CONFIG_NODE, &router_bgp_noasn_cmd);
14029
14030 /* "no router bgp" commands. */
14031 install_element (CONFIG_NODE, &no_router_bgp_cmd);
14032 install_element (CONFIG_NODE, &no_router_bgp_instance_cmd);
14033 install_element (CONFIG_NODE, &no_router_bgp_noasn_cmd);
14034
14035 /* "bgp router-id" commands. */
14036 install_element (BGP_NODE, &bgp_router_id_cmd);
14037 install_element (BGP_NODE, &no_bgp_router_id_cmd);
14038 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
14039
14040 /* "bgp cluster-id" commands. */
14041 install_element (BGP_NODE, &bgp_cluster_id_cmd);
14042 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
14043 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
14044 install_element (BGP_NODE, &no_bgp_cluster_id_ip_cmd);
14045 install_element (BGP_NODE, &no_bgp_cluster_id_decimal_cmd);
14046
14047 /* "bgp confederation" commands. */
14048 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
14049 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
14050 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
14051
14052 /* "bgp confederation peers" commands. */
14053 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
14054 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
14055
14056 /* bgp max-med command */
14057 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
14058 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
14059 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
14060 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
14061 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
14062 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
14063 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
14064 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
14065 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
14066
14067 /* bgp disable-ebgp-connected-nh-check */
14068 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
14069 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
14070
14071 /* bgp update-delay command */
14072 install_element (BGP_NODE, &bgp_update_delay_cmd);
14073 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
14074 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
14075 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
14076
14077 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
14078 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
14079
14080 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
14081 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
14082
14083 /* "maximum-paths" commands. */
14084 install_element (BGP_NODE, &bgp_maxpaths_cmd);
14085 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
14086 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
14087 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
14088 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
14089 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
14090 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
14091 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
14092 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
14093 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
14094 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
14095 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
14096 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
14097 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
14098 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
14099 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
14100 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
14101 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
14102 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
14103 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
14104 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
14105 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
14106 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
14107 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
14108
14109 /* "timers bgp" commands. */
14110 install_element (BGP_NODE, &bgp_timers_cmd);
14111 install_element (BGP_NODE, &no_bgp_timers_cmd);
14112 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
14113
14114 /* route-map delay-timer commands - per instance for backwards compat. */
14115 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
14116 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
14117 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
14118
14119 /* "bgp client-to-client reflection" commands */
14120 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
14121 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
14122
14123 /* "bgp always-compare-med" commands */
14124 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
14125 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
14126
14127 /* "bgp deterministic-med" commands */
14128 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
14129 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
14130
14131 /* "bgp graceful-restart" commands */
14132 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
14133 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
14134 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
14135 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
14136 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
14137 install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd);
14138 install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd);
14139 install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_val_cmd);
14140
14141 /* "bgp fast-external-failover" commands */
14142 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
14143 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
14144
14145 /* "bgp enforce-first-as" commands */
14146 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
14147 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
14148
14149 /* "bgp bestpath compare-routerid" commands */
14150 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
14151 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
14152
14153 /* "bgp bestpath as-path ignore" commands */
14154 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
14155 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
14156
14157 /* "bgp bestpath as-path confed" commands */
14158 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
14159 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
14160
14161 /* "bgp bestpath as-path multipath-relax" commands */
14162 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
14163 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
14164
14165 /* "bgp log-neighbor-changes" commands */
14166 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
14167 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
14168
14169 /* "bgp bestpath med" commands */
14170 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
14171 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
14172 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
14173 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
14174 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
14175 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
14176
14177 /* "no bgp default ipv4-unicast" commands. */
14178 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
14179 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
14180
14181 /* "bgp network import-check" commands. */
14182 install_element (BGP_NODE, &bgp_network_import_check_cmd);
14183 install_element (BGP_NODE, &bgp_network_import_check_exact_cmd);
14184 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
14185
14186 /* "bgp default local-preference" commands. */
14187 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
14188 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
14189 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
14190
14191 /* bgp default show-hostname */
14192 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
14193 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
14194
14195 /* "bgp default subgroup-pkt-queue-max" commands. */
14196 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
14197 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
14198 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_val_cmd);
14199
14200 /* bgp ibgp-allow-policy-mods command */
14201 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
14202 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
14203
14204 /* "bgp listen limit" commands. */
14205 install_element (BGP_NODE, &bgp_listen_limit_cmd);
14206 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
14207 install_element (BGP_NODE, &no_bgp_listen_limit_val_cmd);
14208
14209 /* "bgp listen range" commands. */
14210 install_element (BGP_NODE, &bgp_listen_range_cmd);
14211 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
14212
14213 /* "neighbor remote-as" commands. */
14214 install_element (BGP_NODE, &neighbor_remote_as_cmd);
14215 install_element (BGP_NODE, &neighbor_interface_config_cmd);
14216 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
14217 install_element (BGP_NODE, &neighbor_interface_config_peergroup_cmd);
14218 install_element (BGP_NODE, &neighbor_interface_config_v6only_peergroup_cmd);
14219 install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd);
14220 install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd);
14221 install_element (BGP_NODE, &no_neighbor_cmd);
14222 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
14223 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
14224 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_cmd);
14225 install_element (BGP_NODE, &no_neighbor_interface_config_peergroup_cmd);
14226 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_peergroup_cmd);
14227 install_element (BGP_NODE, &no_neighbor_interface_config_remote_as_cmd);
14228 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_remote_as_cmd);
14229
14230 /* "neighbor peer-group" commands. */
14231 install_element (BGP_NODE, &neighbor_peer_group_cmd);
14232 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
14233 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
14234
14235 /* "neighbor local-as" commands. */
14236 install_element (BGP_NODE, &neighbor_local_as_cmd);
14237 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
14238 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
14239 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
14240 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
14241 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
14242 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
14243
14244 /* "neighbor solo" commands. */
14245 install_element (BGP_NODE, &neighbor_solo_cmd);
14246 install_element (BGP_NODE, &no_neighbor_solo_cmd);
14247
14248 /* "neighbor password" commands. */
14249 install_element (BGP_NODE, &neighbor_password_cmd);
14250 install_element (BGP_NODE, &no_neighbor_password_cmd);
14251 install_element (BGP_NODE, &no_neighbor_password_val_cmd);
14252
14253 /* "neighbor activate" commands. */
14254 install_element (BGP_NODE, &neighbor_activate_cmd);
14255 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
14256 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
14257 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
14258 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
14259 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
14260 install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
14261 install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
14262 install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
14263
14264 /* "no neighbor activate" commands. */
14265 install_element (BGP_NODE, &no_neighbor_activate_cmd);
14266 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
14267 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
14268 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
14269 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
14270 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
14271 install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
14272 install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
14273 install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
14274
14275 /* "neighbor peer-group" set commands.
14276 * Long term we should only accept this command under BGP_NODE and not all of
14277 * the afi/safi sub-contexts. For now though we need to accept it for backwards
14278 * compatibility. This changed when we stopped requiring that peers be assigned
14279 * to their peer-group under each address-family sub-context.
14280 */
14281 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
14282 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
14283 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
14284 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
14285 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
14286 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
14287 install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd);
14288 install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd);
14289 install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd);
14290
14291 /* "no neighbor peer-group unset" commands. */
14292 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
14293 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
14294 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
14295 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
14296 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
14297 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
14298 install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd);
14299 install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd);
14300 install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd);
14301
14302 /* "neighbor softreconfiguration inbound" commands.*/
14303 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
14304 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
14305 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
14306 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
14307 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
14308 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
14309 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
14310 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
14311 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
14312 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
14313 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
14314 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
14315 install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
14316 install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
14317 install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
14318 install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
14319 install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
14320 install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
14321
14322 /* "neighbor attribute-unchanged" commands. */
14323 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
14324 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
14325 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
14326 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
14327 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
14328 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
14329 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
14330 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
14331 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
14332 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
14333 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
14334 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
14335 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
14336 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
14337 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
14338 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
14339 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
14340 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
14341 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
14342 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
14343 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
14344 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
14345 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
14346 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
14347 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
14348 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
14349 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
14350 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
14351 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
14352 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
14353 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
14354 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
14355 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
14356 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
14357 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14358 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14359 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14360 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14361 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14362 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14363 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14364 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14365 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14366 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14367 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
14368 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
14369 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
14370 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
14371 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
14372 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
14373 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
14374 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
14375 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
14376 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
14377 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
14378 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
14379 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
14380 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
14381 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
14382 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
14383 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
14384 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
14385 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
14386 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
14387 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
14388 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
14389 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
14390 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
14391 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
14392 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
14393 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
14394 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
14395 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
14396 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
14397 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
14398 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
14399 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
14400 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
14401 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
14402 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
14403 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
14404 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
14405 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
14406 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
14407 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
14408 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
14409 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
14410 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
14411 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
14412 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
14413 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
14414 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
14415 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
14416 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
14417 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
14418 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
14419 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
14420 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
14421 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
14422 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
14423 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
14424 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
14425 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
14426 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
14427 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
14428 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
14429 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
14430 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
14431 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
14432 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
14433 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
14434 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
14435 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
14436 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
14437 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
14438 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
14439 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
14440 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
14441 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
14442 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
14443 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
14444 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
14445 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14446 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14447 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14448 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14449 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14450 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14451 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14452 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14453 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14454 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14455 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
14456 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged1_cmd);
14457 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged2_cmd);
14458 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged3_cmd);
14459 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged4_cmd);
14460 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged5_cmd);
14461 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged6_cmd);
14462 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged7_cmd);
14463 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged8_cmd);
14464 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged9_cmd);
14465 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged10_cmd);
14466 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
14467 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged1_cmd);
14468 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged2_cmd);
14469 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged3_cmd);
14470 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged4_cmd);
14471 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged5_cmd);
14472 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged6_cmd);
14473 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged7_cmd);
14474 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged8_cmd);
14475 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged9_cmd);
14476 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged10_cmd);
14477
14478 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
14479 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged1_cmd);
14480 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged2_cmd);
14481 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged3_cmd);
14482 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged4_cmd);
14483 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged5_cmd);
14484 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged6_cmd);
14485 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged7_cmd);
14486 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged8_cmd);
14487 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged9_cmd);
14488 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged10_cmd);
14489 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
14490 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged1_cmd);
14491 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged2_cmd);
14492 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged3_cmd);
14493 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged4_cmd);
14494 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged5_cmd);
14495 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged6_cmd);
14496 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged7_cmd);
14497 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged8_cmd);
14498 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged9_cmd);
14499 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged10_cmd);
14500
14501 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
14502 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged1_cmd);
14503 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged2_cmd);
14504 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged3_cmd);
14505 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged4_cmd);
14506 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged5_cmd);
14507 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged6_cmd);
14508 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged7_cmd);
14509 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged8_cmd);
14510 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged9_cmd);
14511 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged10_cmd);
14512 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
14513 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
14514 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
14515 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
14516 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
14517 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
14518 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
14519 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
14520 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
14521 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
14522 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
14523
14524 /* "nexthop-local unchanged" commands */
14525 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
14526 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
14527
14528 /* "neighbor next-hop-self" commands. */
14529 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
14530 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
14531 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
14532 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
14533 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
14534 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
14535 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
14536 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
14537 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
14538 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
14539 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
14540 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
14541 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
14542 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
14543 install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
14544 install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
14545 install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
14546 install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
14547
14548 /* "neighbor next-hop-self force" commands. */
14549 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
14550 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
14551 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
14552 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14553 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
14554 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
14555 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
14556 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
14557 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
14558 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
14559 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
14560 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14561 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd);
14562 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd);
14563
14564 /* "neighbor as-override" commands. */
14565 install_element (BGP_NODE, &neighbor_as_override_cmd);
14566 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
14567 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
14568 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
14569 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
14570 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
14571 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
14572 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
14573 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
14574 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
14575 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
14576 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
14577 install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd);
14578 install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd);
14579
14580 /* "neighbor remove-private-AS" commands. */
14581 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
14582 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
14583 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
14584 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
14585 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
14586 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14587 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14588 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14589 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
14590 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
14591 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
14592 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14593 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14594 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14595 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14596 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14597 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
14598 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
14599 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
14600 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
14601 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14602 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14603 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14604 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14605 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
14606 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
14607 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
14608 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
14609 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
14610 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14611 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14612 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14613 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
14614 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
14615 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
14616 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
14617 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14618 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14619 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14620 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14621 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
14622 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
14623 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
14624 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14625 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14626 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14627 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14628 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14629 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
14630 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
14631 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd);
14632 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd);
14633 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
14634 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14635 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14636 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14637 install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
14638 install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
14639 install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
14640 install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
14641
14642 /* "neighbor send-community" commands.*/
14643 install_element (BGP_NODE, &neighbor_send_community_cmd);
14644 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
14645 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
14646 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
14647 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
14648 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
14649 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
14650 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
14651 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
14652 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
14653 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
14654 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
14655 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
14656 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
14657 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
14658 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
14659 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
14660 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
14661 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
14662 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
14663 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
14664 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
14665 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
14666 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
14667 install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
14668 install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
14669 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
14670 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
14671 install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
14672 install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
14673 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
14674 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
14675 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
14676 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
14677 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
14678 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
14679
14680 /* "neighbor route-reflector" commands.*/
14681 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
14682 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
14683 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
14684 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
14685 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
14686 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
14687 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
14688 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
14689 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
14690 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
14691 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
14692 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
14693 install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
14694 install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
14695 install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
14696 install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
14697 install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
14698 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
14699
14700 /* "neighbor route-server" commands.*/
14701 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
14702 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
14703 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
14704 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
14705 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
14706 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
14707 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
14708 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
14709 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
14710 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
14711 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
14712 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
14713 install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
14714 install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
14715 install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
14716 install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
14717 install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
14718 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
14719
14720 /* "neighbor addpath-tx-all-paths" commands.*/
14721 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
14722 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14723 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14724 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14725 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14726 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14727 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14728 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14729 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14730 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14731 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14732 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14733 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14734 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14735
14736 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14737 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14738 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14739 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14740 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14741 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14742 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14743 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14744 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14745 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14746 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14747 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14748 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14749 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14750 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14751
14752 /* "neighbor passive" commands. */
14753 install_element (BGP_NODE, &neighbor_passive_cmd);
14754 install_element (BGP_NODE, &no_neighbor_passive_cmd);
14755
14756
14757 /* "neighbor shutdown" commands. */
14758 install_element (BGP_NODE, &neighbor_shutdown_cmd);
14759 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
14760
14761 /* "neighbor capability extended-nexthop" commands.*/
14762 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
14763 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
14764
14765 /* "neighbor capability orf prefix-list" commands.*/
14766 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
14767 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
14768 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
14769 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
14770 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
14771 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14772 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
14773 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
14774 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
14775 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14776
14777 /* "neighbor capability dynamic" commands.*/
14778 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
14779 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
14780
14781 /* "neighbor dont-capability-negotiate" commands. */
14782 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
14783 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
14784
14785 /* "neighbor ebgp-multihop" commands. */
14786 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
14787 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
14788 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
14789 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
14790
14791 /* "neighbor disable-connected-check" commands. */
14792 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
14793 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
14794 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
14795 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
14796
14797 /* "neighbor description" commands. */
14798 install_element (BGP_NODE, &neighbor_description_cmd);
14799 install_element (BGP_NODE, &no_neighbor_description_cmd);
14800 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
14801
14802 /* "neighbor update-source" commands. "*/
14803 install_element (BGP_NODE, &neighbor_update_source_cmd);
14804 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
14805
14806 /* "neighbor default-originate" commands. */
14807 install_element (BGP_NODE, &neighbor_default_originate_cmd);
14808 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
14809 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
14810 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
14811 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
14812 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
14813 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
14814 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
14815 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
14816 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
14817 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
14818 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
14819 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
14820 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
14821 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
14822 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
14823 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
14824 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
14825 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
14826 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
14827
14828 /* "neighbor port" commands. */
14829 install_element (BGP_NODE, &neighbor_port_cmd);
14830 install_element (BGP_NODE, &no_neighbor_port_cmd);
14831 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
14832
14833 /* "neighbor weight" commands. */
14834 install_element (BGP_NODE, &neighbor_weight_cmd);
14835 install_element (BGP_NODE, &no_neighbor_weight_cmd);
14836 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
14837 install_element (BGP_IPV4_NODE, &neighbor_weight_cmd);
14838 install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd);
14839 install_element (BGP_IPV4_NODE, &no_neighbor_weight_val_cmd);
14840 install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd);
14841 install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd);
14842 install_element (BGP_IPV4M_NODE, &no_neighbor_weight_val_cmd);
14843 install_element (BGP_IPV6_NODE, &neighbor_weight_cmd);
14844 install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd);
14845 install_element (BGP_IPV6_NODE, &no_neighbor_weight_val_cmd);
14846 install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd);
14847 install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd);
14848 install_element (BGP_IPV6M_NODE, &no_neighbor_weight_val_cmd);
14849 install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd);
14850 install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd);
14851 install_element (BGP_VPNV4_NODE, &no_neighbor_weight_val_cmd);
14852 install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd);
14853 install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd);
14854 install_element (BGP_VPNV6_NODE, &no_neighbor_weight_val_cmd);
14855 install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd);
14856 install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd);
14857 install_element (BGP_ENCAP_NODE, &no_neighbor_weight_val_cmd);
14858 install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd);
14859 install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd);
14860 install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_val_cmd);
14861
14862 /* "neighbor override-capability" commands. */
14863 install_element (BGP_NODE, &neighbor_override_capability_cmd);
14864 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
14865
14866 /* "neighbor strict-capability-match" commands. */
14867 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
14868 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
14869
14870 /* "neighbor timers" commands. */
14871 install_element (BGP_NODE, &neighbor_timers_cmd);
14872 install_element (BGP_NODE, &no_neighbor_timers_cmd);
14873 install_element (BGP_NODE, &no_neighbor_timers_val_cmd);
14874
14875 /* "neighbor timers connect" commands. */
14876 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
14877 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
14878 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
14879
14880 /* "neighbor advertisement-interval" commands. */
14881 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
14882 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
14883 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
14884
14885 /* "neighbor interface" commands. */
14886 install_element (BGP_NODE, &neighbor_interface_cmd);
14887 install_element (BGP_NODE, &no_neighbor_interface_cmd);
14888
14889 /* "neighbor distribute" commands. */
14890 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
14891 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
14892 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
14893 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
14894 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
14895 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
14896 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
14897 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
14898 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
14899 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
14900 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
14901 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
14902 install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);
14903 install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd);
14904 install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd);
14905 install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd);
14906 install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd);
14907 install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd);
14908
14909 /* "neighbor prefix-list" commands. */
14910 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
14911 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
14912 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
14913 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
14914 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
14915 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
14916 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
14917 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
14918 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
14919 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
14920 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
14921 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
14922 install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd);
14923 install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd);
14924 install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd);
14925 install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd);
14926 install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd);
14927 install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd);
14928
14929 /* "neighbor filter-list" commands. */
14930 install_element (BGP_NODE, &neighbor_filter_list_cmd);
14931 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
14932 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
14933 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
14934 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
14935 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
14936 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
14937 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
14938 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
14939 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
14940 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
14941 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
14942 install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd);
14943 install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd);
14944 install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd);
14945 install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd);
14946 install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd);
14947 install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd);
14948
14949 /* "neighbor route-map" commands. */
14950 install_element (BGP_NODE, &neighbor_route_map_cmd);
14951 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
14952 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
14953 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
14954 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
14955 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
14956 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
14957 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
14958 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
14959 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
14960 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
14961 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
14962 install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd);
14963 install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd);
14964 install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd);
14965 install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd);
14966 install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd);
14967 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd);
14968
14969 /* "neighbor unsuppress-map" commands. */
14970 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
14971 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
14972 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
14973 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
14974 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
14975 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
14976 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
14977 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
14978 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
14979 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
14980 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
14981 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
14982 install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
14983 install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
14984 install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd);
14985 install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd);
14986 install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd);
14987 install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd);
14988
14989 /* "neighbor maximum-prefix" commands. */
14990 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
14991 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
14992 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
14993 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14994 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
14995 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14996 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
14997 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
14998 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14999 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15000 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15001 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15002 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15003 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
15004 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
15005 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
15006 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15007 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
15008 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15009 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
15010 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
15011 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15012 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15013 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15014 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15015 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15016 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
15017 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
15018 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
15019 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15020 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
15021 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15022 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
15023 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
15024 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15025 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15026 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15027 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15028 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15029 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
15030 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
15031 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
15032 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15033 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
15034 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15035 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
15036 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
15037 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15038 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15039 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15040 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15041 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15042 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
15043 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
15044 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
15045 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15046 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
15047 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15048 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
15049 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
15050 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15051 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15052 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15053 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15054 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15055 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
15056 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
15057 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
15058 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15059 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
15060 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15061 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
15062 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
15063 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15064 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15065 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15066 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15067 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15068 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd);
15069 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
15070 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd);
15071 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15072 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd);
15073 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15074 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd);
15075 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
15076 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15077 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15078 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15079 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15080 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15081
15082 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd);
15083 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd);
15084 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd);
15085 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15086 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd);
15087 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15088 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd);
15089 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_val_cmd);
15090 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15091 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15092 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15093 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15094 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15095
15096 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd);
15097 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
15098 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
15099 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
15100 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
15101 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
15102 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd);
15103 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
15104 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
15105 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
15106 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
15107 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
15108 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
15109
15110 /* "neighbor allowas-in" */
15111 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
15112 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
15113 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
15114 install_element (BGP_NODE, &no_neighbor_allowas_in_val_cmd);
15115 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
15116 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
15117 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
15118 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_val_cmd);
15119 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
15120 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
15121 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
15122 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_val_cmd);
15123 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
15124 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
15125 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
15126 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_val_cmd);
15127 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
15128 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
15129 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
15130 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_val_cmd);
15131 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
15132 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
15133 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
15134 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_val_cmd);
15135 install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd);
15136 install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_arg_cmd);
15137 install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);
15138 install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_val_cmd);
15139 install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd);
15140 install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_arg_cmd);
15141 install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd);
15142 install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd);
15143 install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_arg_cmd);
15144 install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd);
15145
15146 /* address-family commands. */
15147 install_element (BGP_NODE, &address_family_ipv4_cmd);
15148 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
15149 install_element (BGP_NODE, &address_family_ipv6_cmd);
15150 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
15151 install_element (BGP_NODE, &address_family_vpnv4_cmd);
15152 install_element (BGP_NODE, &address_family_vpnv6_cmd);
15153 install_element (BGP_NODE, &address_family_encap_cmd);
15154 install_element (BGP_NODE, &address_family_encapv4_cmd);
15155 install_element (BGP_NODE, &address_family_encapv6_cmd);
15156
15157 /* "exit-address-family" command. */
15158 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
15159 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
15160 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
15161 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
15162 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
15163 install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
15164 install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
15165 install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
15166
15167 /* "clear ip bgp commands" */
15168 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
15169 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
15170 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
15171 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_cmd);
15172 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
15173 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_cmd);
15174 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
15175 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_cmd);
15176 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
15177 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_cmd);
15178
15179 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
15180 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
15181 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
15182 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_cmd);
15183 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
15184 install_element (ENABLE_NODE, &clear_bgp_instance_peer_cmd);
15185 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
15186 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_cmd);
15187 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
15188 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_cmd);
15189 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
15190 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_cmd);
15191 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
15192 install_element (ENABLE_NODE, &clear_bgp_instance_external_cmd);
15193 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
15194 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_cmd);
15195 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
15196 install_element (ENABLE_NODE, &clear_bgp_instance_as_cmd);
15197 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
15198 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_cmd);
15199
15200 /* "clear ip bgp neighbor soft in" */
15201 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
15202 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
15203 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
15204 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_cmd);
15205 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
15206 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
15207 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_in_cmd);
15208 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
15209 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_in_cmd);
15210 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
15211 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
15212 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_in_cmd);
15213 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
15214 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_in_cmd);
15215 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
15216 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
15217 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_in_cmd);
15218 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
15219 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_in_cmd);
15220 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
15221 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
15222 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_in_cmd);
15223 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
15224 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_in_cmd);
15225 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
15226 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
15227 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
15228 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
15229 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_cmd);
15230 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
15231 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
15232 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_in_cmd);
15233 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
15234 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_in_cmd);
15235 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
15236 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
15237 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd);
15238 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
15239 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_in_cmd);
15240 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
15241 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
15242 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_in_cmd);
15243 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
15244 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_in_cmd);
15245 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
15246 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
15247 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_in_cmd);
15248 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
15249 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd);
15250 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
15251 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
15252 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
15253 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
15254 install_element (ENABLE_NODE, &clear_bgp_instance_all_in_cmd);
15255 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
15256 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
15257 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_in_cmd);
15258 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
15259 install_element (ENABLE_NODE, &clear_bgp_instance_peer_in_cmd);
15260 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
15261 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
15262 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_in_cmd);
15263 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
15264 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_in_cmd);
15265 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
15266 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
15267 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_in_cmd);
15268 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
15269 install_element (ENABLE_NODE, &clear_bgp_instance_external_in_cmd);
15270 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
15271 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
15272 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_in_cmd);
15273 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
15274 install_element (ENABLE_NODE, &clear_bgp_instance_as_in_cmd);
15275 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
15276 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
15277 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_in_cmd);
15278 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
15279 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_in_cmd);
15280 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
15281 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
15282 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_in_cmd);
15283 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
15284 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_in_cmd);
15285 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
15286 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
15287 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_in_cmd);
15288 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
15289 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_in_cmd);
15290 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
15291 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
15292 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_in_cmd);
15293 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
15294 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_in_cmd);
15295 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
15296 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
15297 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_in_cmd);
15298 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
15299 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_in_cmd);
15300 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
15301
15302 /* clear ip bgp prefix */
15303 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
15304 install_element (ENABLE_NODE, &clear_ip_bgp_instance_prefix_cmd);
15305 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
15306 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
15307
15308 /* "clear ip bgp neighbor soft out" */
15309 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
15310 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
15311 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
15312 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_out_cmd);
15313 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
15314 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_out_cmd);
15315 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
15316 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_out_cmd);
15317 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
15318 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_out_cmd);
15319 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
15320 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_out_cmd);
15321 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
15322 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_out_cmd);
15323 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
15324 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_out_cmd);
15325 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
15326 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_out_cmd);
15327 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
15328 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_out_cmd);
15329 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
15330 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
15331 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
15332 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_out_cmd);
15333 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
15334 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_out_cmd);
15335 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
15336 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_out_cmd);
15337 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
15338 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd);
15339 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
15340 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_out_cmd);
15341 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
15342 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_out_cmd);
15343 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
15344 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_out_cmd);
15345 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
15346 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd);
15347 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
15348 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd);
15349 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
15350 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
15351 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
15352 install_element (ENABLE_NODE, &clear_bgp_instance_all_out_cmd);
15353 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
15354 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_out_cmd);
15355 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
15356 install_element (ENABLE_NODE, &clear_bgp_instance_peer_out_cmd);
15357 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
15358 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_out_cmd);
15359 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
15360 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_out_cmd);
15361 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
15362 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_out_cmd);
15363 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
15364 install_element (ENABLE_NODE, &clear_bgp_instance_external_out_cmd);
15365 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
15366 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_out_cmd);
15367 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
15368 install_element (ENABLE_NODE, &clear_bgp_instance_as_out_cmd);
15369 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
15370 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_out_cmd);
15371 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
15372 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_out_cmd);
15373 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
15374 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_out_cmd);
15375 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
15376 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_out_cmd);
15377 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
15378 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_out_cmd);
15379 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
15380 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_out_cmd);
15381 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
15382 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_out_cmd);
15383 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
15384 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_out_cmd);
15385 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
15386 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_out_cmd);
15387 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
15388 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_out_cmd);
15389
15390 /* "clear ip bgp neighbor soft" */
15391 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
15392 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
15393 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
15394 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_cmd);
15395 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
15396 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_cmd);
15397 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
15398 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_cmd);
15399 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
15400 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_cmd);
15401 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
15402 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
15403 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
15404 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_cmd);
15405 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
15406 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_cmd);
15407 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
15408 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd);
15409 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
15410 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd);
15411 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
15412 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
15413 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
15414 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_cmd);
15415 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
15416 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_cmd);
15417 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
15418 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_cmd);
15419 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
15420 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_cmd);
15421 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
15422 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_cmd);
15423 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
15424 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_cmd);
15425 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
15426 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_cmd);
15427 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
15428 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_cmd);
15429 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
15430 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_cmd);
15431
15432 /* "show ip bgp summary" commands. */
15433 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
15434 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
15435 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
15436 install_element (VIEW_NODE, &show_ip_bgp_instance_all_updgrps_cmd);
15437 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
15438 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
15439 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
15440 install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
15441 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
15442 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
15443 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
15444 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
15445 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
15446 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
15447 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
15448 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
15449 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
15450 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
15451 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
15452 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
15453 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
15454 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
15455 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
15456 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
15457 install_element (VIEW_NODE, &show_ip_bgp_instance_all_summary_cmd);
15458 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
15459 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
15460 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
15461 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
15462 install_element (VIEW_NODE, &show_bgp_ipv4_summary_cmd);
15463 install_element (VIEW_NODE, &show_bgp_instance_ipv4_summary_cmd);
15464 install_element (VIEW_NODE, &show_bgp_instance_ipv4_all_summary_cmd);
15465 install_element (VIEW_NODE, &show_bgp_summary_cmd);
15466 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
15467 install_element (VIEW_NODE, &show_bgp_instance_all_summary_cmd);
15468 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
15469 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
15470 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
15471 install_element (VIEW_NODE, &show_bgp_instance_ipv6_all_summary_cmd);
15472 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
15473
15474 /* "show ip bgp neighbors" commands. */
15475 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
15476 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
15477 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
15478 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15479 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
15480 install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd);
15481 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
15482
15483 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
15484 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
15485 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
15486 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
15487 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
15488 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
15489 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
15490 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
15491
15492 /* Old commands. */
15493 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
15494 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
15495
15496 /* "show ip bgp peer-group" commands. */
15497 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
15498 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
15499 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
15500 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
15501
15502 /* "show ip bgp paths" commands. */
15503 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
15504 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
15505
15506 /* "show ip bgp community" commands. */
15507 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
15508
15509 /* "show ip bgp attribute-info" commands. */
15510 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
15511
15512 /* "redistribute" commands. */
15513 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
15514 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
15515 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15516 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15517 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
15518 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15519 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15520 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15521 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15522 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
15523 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15524 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15525 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15526 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15527 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15528 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15529 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15530 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15531 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15532 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15533 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
15534 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
15535 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15536 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15537 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
15538 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15539 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15540 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15541 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15542 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
15543 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15544 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15545 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15546 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15547 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15548 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15549 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15550 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15551 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15552 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15553 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
15554 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
15555 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
15556 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
15557 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
15558 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
15559 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
15560 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
15561 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
15562 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
15563
15564 /* ttl_security commands */
15565 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
15566 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
15567
15568 /* "show bgp memory" commands. */
15569 install_element (VIEW_NODE, &show_bgp_memory_cmd);
15570
15571 /* "show bgp views" commands. */
15572 install_element (VIEW_NODE, &show_bgp_views_cmd);
15573
15574 /* "show bgp vrfs" commands. */
15575 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
15576
15577 /* Community-list. */
15578 community_list_vty ();
15579 }
15580
15581 #include "memory.h"
15582 #include "bgp_regex.h"
15583 #include "bgp_clist.h"
15584 #include "bgp_ecommunity.h"
15585
15586 /* VTY functions. */
15587
15588 /* Direction value to string conversion. */
15589 static const char *
15590 community_direct_str (int direct)
15591 {
15592 switch (direct)
15593 {
15594 case COMMUNITY_DENY:
15595 return "deny";
15596 case COMMUNITY_PERMIT:
15597 return "permit";
15598 default:
15599 return "unknown";
15600 }
15601 }
15602
15603 /* Display error string. */
15604 static void
15605 community_list_perror (struct vty *vty, int ret)
15606 {
15607 switch (ret)
15608 {
15609 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
15610 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
15611 break;
15612 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
15613 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
15614 break;
15615 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
15616 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
15617 break;
15618 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
15619 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
15620 break;
15621 }
15622 }
15623
15624 /* VTY interface for community_set() function. */
15625 static int
15626 community_list_set_vty (struct vty *vty, int argc, const char **argv,
15627 int style, int reject_all_digit_name)
15628 {
15629 int ret;
15630 int direct;
15631 char *str;
15632
15633 /* Check the list type. */
15634 if (strncmp (argv[1], "p", 1) == 0)
15635 direct = COMMUNITY_PERMIT;
15636 else if (strncmp (argv[1], "d", 1) == 0)
15637 direct = COMMUNITY_DENY;
15638 else
15639 {
15640 vty_out (vty, "%% Matching condition must be permit or deny%s",
15641 VTY_NEWLINE);
15642 return CMD_WARNING;
15643 }
15644
15645 /* All digit name check. */
15646 if (reject_all_digit_name && all_digit (argv[0]))
15647 {
15648 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15649 return CMD_WARNING;
15650 }
15651
15652 /* Concat community string argument. */
15653 if (argc > 1)
15654 str = argv_concat (argv, argc, 2);
15655 else
15656 str = NULL;
15657
15658 /* When community_list_set() return nevetive value, it means
15659 malformed community string. */
15660 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
15661
15662 /* Free temporary community list string allocated by
15663 argv_concat(). */
15664 if (str)
15665 XFREE (MTYPE_TMP, str);
15666
15667 if (ret < 0)
15668 {
15669 /* Display error string. */
15670 community_list_perror (vty, ret);
15671 return CMD_WARNING;
15672 }
15673
15674 return CMD_SUCCESS;
15675 }
15676
15677 /* Communiyt-list entry delete. */
15678 static int
15679 community_list_unset_vty (struct vty *vty, int argc, const char **argv,
15680 int style, int delete_all)
15681 {
15682 int ret;
15683 int direct = 0;
15684 char *str = NULL;
15685
15686 if (argc > 1)
15687 {
15688 /* Check the list direct. */
15689 if (strncmp (argv[1], "p", 1) == 0)
15690 direct = COMMUNITY_PERMIT;
15691 else if (strncmp (argv[1], "d", 1) == 0)
15692 direct = COMMUNITY_DENY;
15693 else
15694 {
15695 vty_out (vty, "%% Matching condition must be permit or deny%s",
15696 VTY_NEWLINE);
15697 return CMD_WARNING;
15698 }
15699
15700 /* Concat community string argument. */
15701 str = argv_concat (argv, argc, 2);
15702 }
15703
15704 /* Unset community list. */
15705 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
15706
15707 /* Free temporary community list string allocated by
15708 argv_concat(). */
15709 if (str)
15710 XFREE (MTYPE_TMP, str);
15711
15712 if (ret < 0)
15713 {
15714 community_list_perror (vty, ret);
15715 return CMD_WARNING;
15716 }
15717
15718 return CMD_SUCCESS;
15719 }
15720
15721 /* "community-list" keyword help string. */
15722 #define COMMUNITY_LIST_STR "Add a community list entry\n"
15723
15724 DEFUN (ip_community_list_standard,
15725 ip_community_list_standard_cmd,
15726 "ip community-list <1-99> (deny|permit) .AA:NN",
15727 IP_STR
15728 COMMUNITY_LIST_STR
15729 "Community list number (standard)\n"
15730 "Specify community to reject\n"
15731 "Specify community to accept\n"
15732 COMMUNITY_VAL_STR)
15733 {
15734 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15735 }
15736
15737 ALIAS (ip_community_list_standard,
15738 ip_community_list_standard2_cmd,
15739 "ip community-list <1-99> (deny|permit)",
15740 IP_STR
15741 COMMUNITY_LIST_STR
15742 "Community list number (standard)\n"
15743 "Specify community to reject\n"
15744 "Specify community to accept\n")
15745
15746 DEFUN (ip_community_list_expanded,
15747 ip_community_list_expanded_cmd,
15748 "ip community-list <100-500> (deny|permit) .LINE",
15749 IP_STR
15750 COMMUNITY_LIST_STR
15751 "Community list number (expanded)\n"
15752 "Specify community to reject\n"
15753 "Specify community to accept\n"
15754 "An ordered list as a regular-expression\n")
15755 {
15756 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15757 }
15758
15759 DEFUN (ip_community_list_name_standard,
15760 ip_community_list_name_standard_cmd,
15761 "ip community-list standard WORD (deny|permit) .AA:NN",
15762 IP_STR
15763 COMMUNITY_LIST_STR
15764 "Add a standard community-list entry\n"
15765 "Community list name\n"
15766 "Specify community to reject\n"
15767 "Specify community to accept\n"
15768 COMMUNITY_VAL_STR)
15769 {
15770 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15771 }
15772
15773 ALIAS (ip_community_list_name_standard,
15774 ip_community_list_name_standard2_cmd,
15775 "ip community-list standard WORD (deny|permit)",
15776 IP_STR
15777 COMMUNITY_LIST_STR
15778 "Add a standard community-list entry\n"
15779 "Community list name\n"
15780 "Specify community to reject\n"
15781 "Specify community to accept\n")
15782
15783 DEFUN (ip_community_list_name_expanded,
15784 ip_community_list_name_expanded_cmd,
15785 "ip community-list expanded WORD (deny|permit) .LINE",
15786 IP_STR
15787 COMMUNITY_LIST_STR
15788 "Add an expanded community-list entry\n"
15789 "Community list name\n"
15790 "Specify community to reject\n"
15791 "Specify community to accept\n"
15792 "An ordered list as a regular-expression\n")
15793 {
15794 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15795 }
15796
15797 DEFUN (no_ip_community_list_standard_all,
15798 no_ip_community_list_standard_all_cmd,
15799 "no ip community-list <1-99>",
15800 NO_STR
15801 IP_STR
15802 COMMUNITY_LIST_STR
15803 "Community list number (standard)\n")
15804 {
15805 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15806 }
15807
15808 DEFUN (no_ip_community_list_standard_direction,
15809 no_ip_community_list_standard_direction_cmd,
15810 "no ip community-list <1-99> (deny|permit)",
15811 NO_STR
15812 IP_STR
15813 COMMUNITY_LIST_STR
15814 "Community list number (standard)\n"
15815 "Specify community to reject\n"
15816 "Specify community to accept\n")
15817 {
15818 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15819 }
15820
15821
15822 DEFUN (no_ip_community_list_expanded_all,
15823 no_ip_community_list_expanded_all_cmd,
15824 "no ip community-list <100-500>",
15825 NO_STR
15826 IP_STR
15827 COMMUNITY_LIST_STR
15828 "Community list number (expanded)\n")
15829 {
15830 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15831 }
15832
15833 DEFUN (no_ip_community_list_name_standard_all,
15834 no_ip_community_list_name_standard_all_cmd,
15835 "no ip community-list standard WORD",
15836 NO_STR
15837 IP_STR
15838 COMMUNITY_LIST_STR
15839 "Add a standard community-list entry\n"
15840 "Community list name\n")
15841 {
15842 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15843 }
15844
15845 DEFUN (no_ip_community_list_name_expanded_all,
15846 no_ip_community_list_name_expanded_all_cmd,
15847 "no ip community-list expanded WORD",
15848 NO_STR
15849 IP_STR
15850 COMMUNITY_LIST_STR
15851 "Add an expanded community-list entry\n"
15852 "Community list name\n")
15853 {
15854 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15855 }
15856
15857 DEFUN (no_ip_community_list_standard,
15858 no_ip_community_list_standard_cmd,
15859 "no ip community-list <1-99> (deny|permit) .AA:NN",
15860 NO_STR
15861 IP_STR
15862 COMMUNITY_LIST_STR
15863 "Community list number (standard)\n"
15864 "Specify community to reject\n"
15865 "Specify community to accept\n"
15866 COMMUNITY_VAL_STR)
15867 {
15868 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15869 }
15870
15871 DEFUN (no_ip_community_list_expanded,
15872 no_ip_community_list_expanded_cmd,
15873 "no ip community-list <100-500> (deny|permit) .LINE",
15874 NO_STR
15875 IP_STR
15876 COMMUNITY_LIST_STR
15877 "Community list number (expanded)\n"
15878 "Specify community to reject\n"
15879 "Specify community to accept\n"
15880 "An ordered list as a regular-expression\n")
15881 {
15882 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15883 }
15884
15885 DEFUN (no_ip_community_list_name_standard,
15886 no_ip_community_list_name_standard_cmd,
15887 "no ip community-list standard WORD (deny|permit) .AA:NN",
15888 NO_STR
15889 IP_STR
15890 COMMUNITY_LIST_STR
15891 "Specify a standard community-list\n"
15892 "Community list name\n"
15893 "Specify community to reject\n"
15894 "Specify community to accept\n"
15895 COMMUNITY_VAL_STR)
15896 {
15897 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15898 }
15899
15900 DEFUN (no_ip_community_list_name_standard_brief,
15901 no_ip_community_list_name_standard_brief_cmd,
15902 "no ip community-list standard WORD (deny|permit)",
15903 NO_STR
15904 IP_STR
15905 COMMUNITY_LIST_STR
15906 "Specify a standard community-list\n"
15907 "Community list name\n"
15908 "Specify community to reject\n"
15909 "Specify community to accept\n")
15910 {
15911 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15912 }
15913
15914 DEFUN (no_ip_community_list_name_expanded,
15915 no_ip_community_list_name_expanded_cmd,
15916 "no ip community-list expanded WORD (deny|permit) .LINE",
15917 NO_STR
15918 IP_STR
15919 COMMUNITY_LIST_STR
15920 "Specify an expanded community-list\n"
15921 "Community list name\n"
15922 "Specify community to reject\n"
15923 "Specify community to accept\n"
15924 "An ordered list as a regular-expression\n")
15925 {
15926 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15927 }
15928
15929 static void
15930 community_list_show (struct vty *vty, struct community_list *list)
15931 {
15932 struct community_entry *entry;
15933
15934 for (entry = list->head; entry; entry = entry->next)
15935 {
15936 if (entry == list->head)
15937 {
15938 if (all_digit (list->name))
15939 vty_out (vty, "Community %s list %s%s",
15940 entry->style == COMMUNITY_LIST_STANDARD ?
15941 "standard" : "(expanded) access",
15942 list->name, VTY_NEWLINE);
15943 else
15944 vty_out (vty, "Named Community %s list %s%s",
15945 entry->style == COMMUNITY_LIST_STANDARD ?
15946 "standard" : "expanded",
15947 list->name, VTY_NEWLINE);
15948 }
15949 if (entry->any)
15950 vty_out (vty, " %s%s",
15951 community_direct_str (entry->direct), VTY_NEWLINE);
15952 else
15953 vty_out (vty, " %s %s%s",
15954 community_direct_str (entry->direct),
15955 entry->style == COMMUNITY_LIST_STANDARD
15956 ? community_str (entry->u.com) : entry->config,
15957 VTY_NEWLINE);
15958 }
15959 }
15960
15961 DEFUN (show_ip_community_list,
15962 show_ip_community_list_cmd,
15963 "show ip community-list",
15964 SHOW_STR
15965 IP_STR
15966 "List community-list\n")
15967 {
15968 struct community_list *list;
15969 struct community_list_master *cm;
15970
15971 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
15972 if (! cm)
15973 return CMD_SUCCESS;
15974
15975 for (list = cm->num.head; list; list = list->next)
15976 community_list_show (vty, list);
15977
15978 for (list = cm->str.head; list; list = list->next)
15979 community_list_show (vty, list);
15980
15981 return CMD_SUCCESS;
15982 }
15983
15984 DEFUN (show_ip_community_list_arg,
15985 show_ip_community_list_arg_cmd,
15986 "show ip community-list (<1-500>|WORD)",
15987 SHOW_STR
15988 IP_STR
15989 "List community-list\n"
15990 "Community-list number\n"
15991 "Community-list name\n")
15992 {
15993 struct community_list *list;
15994
15995 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
15996 if (! list)
15997 {
15998 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
15999 return CMD_WARNING;
16000 }
16001
16002 community_list_show (vty, list);
16003
16004 return CMD_SUCCESS;
16005 }
16006
16007 static int
16008 extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
16009 int style, int reject_all_digit_name)
16010 {
16011 int ret;
16012 int direct;
16013 char *str;
16014
16015 /* Check the list type. */
16016 if (strncmp (argv[1], "p", 1) == 0)
16017 direct = COMMUNITY_PERMIT;
16018 else if (strncmp (argv[1], "d", 1) == 0)
16019 direct = COMMUNITY_DENY;
16020 else
16021 {
16022 vty_out (vty, "%% Matching condition must be permit or deny%s",
16023 VTY_NEWLINE);
16024 return CMD_WARNING;
16025 }
16026
16027 /* All digit name check. */
16028 if (reject_all_digit_name && all_digit (argv[0]))
16029 {
16030 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
16031 return CMD_WARNING;
16032 }
16033
16034 /* Concat community string argument. */
16035 if (argc > 1)
16036 str = argv_concat (argv, argc, 2);
16037 else
16038 str = NULL;
16039
16040 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
16041
16042 /* Free temporary community list string allocated by
16043 argv_concat(). */
16044 if (str)
16045 XFREE (MTYPE_TMP, str);
16046
16047 if (ret < 0)
16048 {
16049 community_list_perror (vty, ret);
16050 return CMD_WARNING;
16051 }
16052 return CMD_SUCCESS;
16053 }
16054
16055 static int
16056 extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
16057 int style, int delete_all)
16058 {
16059 int ret;
16060 int direct = 0;
16061 char *str = NULL;
16062
16063 if (argc > 1)
16064 {
16065 /* Check the list direct. */
16066 if (strncmp (argv[1], "p", 1) == 0)
16067 direct = COMMUNITY_PERMIT;
16068 else if (strncmp (argv[1], "d", 1) == 0)
16069 direct = COMMUNITY_DENY;
16070 else
16071 {
16072 vty_out (vty, "%% Matching condition must be permit or deny%s",
16073 VTY_NEWLINE);
16074 return CMD_WARNING;
16075 }
16076
16077 /* Concat community string argument. */
16078 str = argv_concat (argv, argc, 2);
16079 }
16080
16081 /* Unset community list. */
16082 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
16083
16084 /* Free temporary community list string allocated by
16085 argv_concat(). */
16086 if (str)
16087 XFREE (MTYPE_TMP, str);
16088
16089 if (ret < 0)
16090 {
16091 community_list_perror (vty, ret);
16092 return CMD_WARNING;
16093 }
16094
16095 return CMD_SUCCESS;
16096 }
16097
16098 /* "extcommunity-list" keyword help string. */
16099 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
16100 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
16101
16102 DEFUN (ip_extcommunity_list_standard,
16103 ip_extcommunity_list_standard_cmd,
16104 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
16105 IP_STR
16106 EXTCOMMUNITY_LIST_STR
16107 "Extended Community list number (standard)\n"
16108 "Specify community to reject\n"
16109 "Specify community to accept\n"
16110 EXTCOMMUNITY_VAL_STR)
16111 {
16112 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16113 }
16114
16115 ALIAS (ip_extcommunity_list_standard,
16116 ip_extcommunity_list_standard2_cmd,
16117 "ip extcommunity-list <1-99> (deny|permit)",
16118 IP_STR
16119 EXTCOMMUNITY_LIST_STR
16120 "Extended Community list number (standard)\n"
16121 "Specify community to reject\n"
16122 "Specify community to accept\n")
16123
16124 DEFUN (ip_extcommunity_list_expanded,
16125 ip_extcommunity_list_expanded_cmd,
16126 "ip extcommunity-list <100-500> (deny|permit) .LINE",
16127 IP_STR
16128 EXTCOMMUNITY_LIST_STR
16129 "Extended Community list number (expanded)\n"
16130 "Specify community to reject\n"
16131 "Specify community to accept\n"
16132 "An ordered list as a regular-expression\n")
16133 {
16134 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
16135 }
16136
16137 DEFUN (ip_extcommunity_list_name_standard,
16138 ip_extcommunity_list_name_standard_cmd,
16139 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
16140 IP_STR
16141 EXTCOMMUNITY_LIST_STR
16142 "Specify standard extcommunity-list\n"
16143 "Extended Community list name\n"
16144 "Specify community to reject\n"
16145 "Specify community to accept\n"
16146 EXTCOMMUNITY_VAL_STR)
16147 {
16148 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
16149 }
16150
16151 ALIAS (ip_extcommunity_list_name_standard,
16152 ip_extcommunity_list_name_standard2_cmd,
16153 "ip extcommunity-list standard WORD (deny|permit)",
16154 IP_STR
16155 EXTCOMMUNITY_LIST_STR
16156 "Specify standard extcommunity-list\n"
16157 "Extended Community list name\n"
16158 "Specify community to reject\n"
16159 "Specify community to accept\n")
16160
16161 DEFUN (ip_extcommunity_list_name_expanded,
16162 ip_extcommunity_list_name_expanded_cmd,
16163 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
16164 IP_STR
16165 EXTCOMMUNITY_LIST_STR
16166 "Specify expanded extcommunity-list\n"
16167 "Extended Community list name\n"
16168 "Specify community to reject\n"
16169 "Specify community to accept\n"
16170 "An ordered list as a regular-expression\n")
16171 {
16172 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
16173 }
16174
16175 DEFUN (no_ip_extcommunity_list_standard_all,
16176 no_ip_extcommunity_list_standard_all_cmd,
16177 "no ip extcommunity-list <1-99>",
16178 NO_STR
16179 IP_STR
16180 EXTCOMMUNITY_LIST_STR
16181 "Extended Community list number (standard)\n")
16182 {
16183 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
16184 }
16185
16186 DEFUN (no_ip_extcommunity_list_standard_direction,
16187 no_ip_extcommunity_list_standard_direction_cmd,
16188 "no ip extcommunity-list <1-99> (deny|permit)",
16189 NO_STR
16190 IP_STR
16191 EXTCOMMUNITY_LIST_STR
16192 "Extended Community list number (standard)\n"
16193 "Specify community to reject\n"
16194 "Specify community to accept\n")
16195 {
16196 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16197 }
16198
16199 DEFUN (no_ip_extcommunity_list_expanded_all,
16200 no_ip_extcommunity_list_expanded_all_cmd,
16201 "no ip extcommunity-list <100-500>",
16202 NO_STR
16203 IP_STR
16204 EXTCOMMUNITY_LIST_STR
16205 "Extended Community list number (expanded)\n")
16206 {
16207 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
16208 }
16209
16210 DEFUN (no_ip_extcommunity_list_name_standard_all,
16211 no_ip_extcommunity_list_name_standard_all_cmd,
16212 "no ip extcommunity-list standard WORD",
16213 NO_STR
16214 IP_STR
16215 EXTCOMMUNITY_LIST_STR
16216 "Specify standard extcommunity-list\n"
16217 "Extended Community list name\n")
16218 {
16219 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
16220 }
16221
16222 DEFUN (no_ip_extcommunity_list_name_expanded_all,
16223 no_ip_extcommunity_list_name_expanded_all_cmd,
16224 "no ip extcommunity-list expanded WORD",
16225 NO_STR
16226 IP_STR
16227 EXTCOMMUNITY_LIST_STR
16228 "Specify expanded extcommunity-list\n"
16229 "Extended Community list name\n")
16230 {
16231 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
16232 }
16233
16234 DEFUN (no_ip_extcommunity_list_standard,
16235 no_ip_extcommunity_list_standard_cmd,
16236 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
16237 NO_STR
16238 IP_STR
16239 EXTCOMMUNITY_LIST_STR
16240 "Extended Community list number (standard)\n"
16241 "Specify community to reject\n"
16242 "Specify community to accept\n"
16243 EXTCOMMUNITY_VAL_STR)
16244 {
16245 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16246 }
16247
16248 DEFUN (no_ip_extcommunity_list_expanded,
16249 no_ip_extcommunity_list_expanded_cmd,
16250 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
16251 NO_STR
16252 IP_STR
16253 EXTCOMMUNITY_LIST_STR
16254 "Extended Community list number (expanded)\n"
16255 "Specify community to reject\n"
16256 "Specify community to accept\n"
16257 "An ordered list as a regular-expression\n")
16258 {
16259 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
16260 }
16261
16262 DEFUN (no_ip_extcommunity_list_name_standard,
16263 no_ip_extcommunity_list_name_standard_cmd,
16264 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
16265 NO_STR
16266 IP_STR
16267 EXTCOMMUNITY_LIST_STR
16268 "Specify standard extcommunity-list\n"
16269 "Extended Community list name\n"
16270 "Specify community to reject\n"
16271 "Specify community to accept\n"
16272 EXTCOMMUNITY_VAL_STR)
16273 {
16274 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16275 }
16276
16277 DEFUN (no_ip_extcommunity_list_name_standard_brief,
16278 no_ip_extcommunity_list_name_standard_brief_cmd,
16279 "no ip extcommunity-list standard WORD (deny|permit)",
16280 NO_STR
16281 IP_STR
16282 EXTCOMMUNITY_LIST_STR
16283 "Specify standard extcommunity-list\n"
16284 "Extended Community list name\n"
16285 "Specify community to reject\n"
16286 "Specify community to accept\n")
16287 {
16288 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
16289 }
16290
16291 DEFUN (no_ip_extcommunity_list_name_expanded,
16292 no_ip_extcommunity_list_name_expanded_cmd,
16293 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
16294 NO_STR
16295 IP_STR
16296 EXTCOMMUNITY_LIST_STR
16297 "Specify expanded extcommunity-list\n"
16298 "Community list name\n"
16299 "Specify community to reject\n"
16300 "Specify community to accept\n"
16301 "An ordered list as a regular-expression\n")
16302 {
16303 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
16304 }
16305
16306 static void
16307 extcommunity_list_show (struct vty *vty, struct community_list *list)
16308 {
16309 struct community_entry *entry;
16310
16311 for (entry = list->head; entry; entry = entry->next)
16312 {
16313 if (entry == list->head)
16314 {
16315 if (all_digit (list->name))
16316 vty_out (vty, "Extended community %s list %s%s",
16317 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16318 "standard" : "(expanded) access",
16319 list->name, VTY_NEWLINE);
16320 else
16321 vty_out (vty, "Named extended community %s list %s%s",
16322 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16323 "standard" : "expanded",
16324 list->name, VTY_NEWLINE);
16325 }
16326 if (entry->any)
16327 vty_out (vty, " %s%s",
16328 community_direct_str (entry->direct), VTY_NEWLINE);
16329 else
16330 vty_out (vty, " %s %s%s",
16331 community_direct_str (entry->direct),
16332 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
16333 entry->u.ecom->str : entry->config,
16334 VTY_NEWLINE);
16335 }
16336 }
16337
16338 DEFUN (show_ip_extcommunity_list,
16339 show_ip_extcommunity_list_cmd,
16340 "show ip extcommunity-list",
16341 SHOW_STR
16342 IP_STR
16343 "List extended-community list\n")
16344 {
16345 struct community_list *list;
16346 struct community_list_master *cm;
16347
16348 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
16349 if (! cm)
16350 return CMD_SUCCESS;
16351
16352 for (list = cm->num.head; list; list = list->next)
16353 extcommunity_list_show (vty, list);
16354
16355 for (list = cm->str.head; list; list = list->next)
16356 extcommunity_list_show (vty, list);
16357
16358 return CMD_SUCCESS;
16359 }
16360
16361 DEFUN (show_ip_extcommunity_list_arg,
16362 show_ip_extcommunity_list_arg_cmd,
16363 "show ip extcommunity-list (<1-500>|WORD)",
16364 SHOW_STR
16365 IP_STR
16366 "List extended-community list\n"
16367 "Extcommunity-list number\n"
16368 "Extcommunity-list name\n")
16369 {
16370 struct community_list *list;
16371
16372 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
16373 if (! list)
16374 {
16375 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
16376 return CMD_WARNING;
16377 }
16378
16379 extcommunity_list_show (vty, list);
16380
16381 return CMD_SUCCESS;
16382 }
16383
16384 /* Return configuration string of community-list entry. */
16385 static const char *
16386 community_list_config_str (struct community_entry *entry)
16387 {
16388 const char *str;
16389
16390 if (entry->any)
16391 str = "";
16392 else
16393 {
16394 if (entry->style == COMMUNITY_LIST_STANDARD)
16395 str = community_str (entry->u.com);
16396 else
16397 str = entry->config;
16398 }
16399 return str;
16400 }
16401
16402 /* Display community-list and extcommunity-list configuration. */
16403 static int
16404 community_list_config_write (struct vty *vty)
16405 {
16406 struct community_list *list;
16407 struct community_entry *entry;
16408 struct community_list_master *cm;
16409 int write = 0;
16410
16411 /* Community-list. */
16412 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
16413
16414 for (list = cm->num.head; list; list = list->next)
16415 for (entry = list->head; entry; entry = entry->next)
16416 {
16417 vty_out (vty, "ip community-list %s %s %s%s",
16418 list->name, community_direct_str (entry->direct),
16419 community_list_config_str (entry),
16420 VTY_NEWLINE);
16421 write++;
16422 }
16423 for (list = cm->str.head; list; list = list->next)
16424 for (entry = list->head; entry; entry = entry->next)
16425 {
16426 vty_out (vty, "ip community-list %s %s %s %s%s",
16427 entry->style == COMMUNITY_LIST_STANDARD
16428 ? "standard" : "expanded",
16429 list->name, community_direct_str (entry->direct),
16430 community_list_config_str (entry),
16431 VTY_NEWLINE);
16432 write++;
16433 }
16434
16435 /* Extcommunity-list. */
16436 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
16437
16438 for (list = cm->num.head; list; list = list->next)
16439 for (entry = list->head; entry; entry = entry->next)
16440 {
16441 vty_out (vty, "ip extcommunity-list %s %s %s%s",
16442 list->name, community_direct_str (entry->direct),
16443 community_list_config_str (entry), VTY_NEWLINE);
16444 write++;
16445 }
16446 for (list = cm->str.head; list; list = list->next)
16447 for (entry = list->head; entry; entry = entry->next)
16448 {
16449 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
16450 entry->style == EXTCOMMUNITY_LIST_STANDARD
16451 ? "standard" : "expanded",
16452 list->name, community_direct_str (entry->direct),
16453 community_list_config_str (entry), VTY_NEWLINE);
16454 write++;
16455 }
16456 return write;
16457 }
16458
16459 static struct cmd_node community_list_node =
16460 {
16461 COMMUNITY_LIST_NODE,
16462 "",
16463 1 /* Export to vtysh. */
16464 };
16465
16466 static void
16467 community_list_vty (void)
16468 {
16469 install_node (&community_list_node, community_list_config_write);
16470
16471 /* Community-list. */
16472 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
16473 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
16474 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
16475 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
16476 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
16477 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
16478 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
16479 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
16480 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
16481 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
16482 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
16483 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
16484 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
16485 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
16486 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
16487 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
16488 install_element (VIEW_NODE, &show_ip_community_list_cmd);
16489 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
16490
16491 /* Extcommunity-list. */
16492 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
16493 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
16494 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
16495 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
16496 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
16497 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
16498 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
16499 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
16500 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
16501 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
16502 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
16503 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
16504 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
16505 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
16506 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
16507 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
16508 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
16509 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
16510 }