]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_vty.c
[bgpd] Stability fixes including bugs 397, 492
[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 "command.h"
24 #include "prefix.h"
25 #include "plist.h"
26 #include "buffer.h"
27 #include "linklist.h"
28 #include "stream.h"
29 #include "thread.h"
30 #include "log.h"
31 #include "memory.h"
32 #include "hash.h"
33
34 #include "bgpd/bgpd.h"
35 #include "bgpd/bgp_advertise.h"
36 #include "bgpd/bgp_attr.h"
37 #include "bgpd/bgp_aspath.h"
38 #include "bgpd/bgp_community.h"
39 #include "bgpd/bgp_ecommunity.h"
40 #include "bgpd/bgp_damp.h"
41 #include "bgpd/bgp_debug.h"
42 #include "bgpd/bgp_fsm.h"
43 #include "bgpd/bgp_mplsvpn.h"
44 #include "bgpd/bgp_nexthop.h"
45 #include "bgpd/bgp_open.h"
46 #include "bgpd/bgp_regex.h"
47 #include "bgpd/bgp_route.h"
48 #include "bgpd/bgp_zebra.h"
49 #include "bgpd/bgp_table.h"
50 #include "bgpd/bgp_vty.h"
51
52 extern struct in_addr router_id_zebra;
53
54 /* Utility function to get address family from current node. */
55 afi_t
56 bgp_node_afi (struct vty *vty)
57 {
58 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
59 return AFI_IP6;
60 return AFI_IP;
61 }
62
63 /* Utility function to get subsequent address family from current
64 node. */
65 safi_t
66 bgp_node_safi (struct vty *vty)
67 {
68 if (vty->node == BGP_VPNV4_NODE)
69 return SAFI_MPLS_VPN;
70 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
71 return SAFI_MULTICAST;
72 return SAFI_UNICAST;
73 }
74
75 static int
76 peer_address_self_check (union sockunion *su)
77 {
78 struct interface *ifp = NULL;
79
80 if (su->sa.sa_family == AF_INET)
81 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
82 #ifdef HAVE_IPV6
83 else if (su->sa.sa_family == AF_INET6)
84 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr);
85 #endif /* HAVE IPV6 */
86
87 if (ifp)
88 return 1;
89
90 return 0;
91 }
92
93 /* Utility function for looking up peer from VTY. */
94 static struct peer *
95 peer_lookup_vty (struct vty *vty, const char *ip_str)
96 {
97 int ret;
98 struct bgp *bgp;
99 union sockunion su;
100 struct peer *peer;
101
102 bgp = vty->index;
103
104 ret = str2sockunion (ip_str, &su);
105 if (ret < 0)
106 {
107 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
108 return NULL;
109 }
110
111 peer = peer_lookup (bgp, &su);
112 if (! peer)
113 {
114 vty_out (vty, "%% Specify remote-as or peer-group commands first%s", VTY_NEWLINE);
115 return NULL;
116 }
117 return peer;
118 }
119
120 /* Utility function for looking up peer or peer group. */
121 static struct peer *
122 peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
123 {
124 int ret;
125 struct bgp *bgp;
126 union sockunion su;
127 struct peer *peer;
128 struct peer_group *group;
129
130 bgp = vty->index;
131
132 ret = str2sockunion (peer_str, &su);
133 if (ret == 0)
134 {
135 peer = peer_lookup (bgp, &su);
136 if (peer)
137 return peer;
138 }
139 else
140 {
141 group = peer_group_lookup (bgp, peer_str);
142 if (group)
143 return group->conf;
144 }
145
146 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
147 VTY_NEWLINE);
148
149 return NULL;
150 }
151
152 static int
153 bgp_vty_return (struct vty *vty, int ret)
154 {
155 const char *str = NULL;
156
157 switch (ret)
158 {
159 case BGP_ERR_INVALID_VALUE:
160 str = "Invalid value";
161 break;
162 case BGP_ERR_INVALID_FLAG:
163 str = "Invalid flag";
164 break;
165 case BGP_ERR_PEER_INACTIVE:
166 str = "Activate the neighbor for the address family first";
167 break;
168 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
169 str = "Invalid command for a peer-group member";
170 break;
171 case BGP_ERR_PEER_GROUP_SHUTDOWN:
172 str = "Peer-group has been shutdown. Activate the peer-group first";
173 break;
174 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
175 str = "This peer is a peer-group member. Please change peer-group configuration";
176 break;
177 case BGP_ERR_PEER_FLAG_CONFLICT:
178 str = "Can't set override-capability and strict-capability-match at the same time";
179 break;
180 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
181 str = "No activate for peergroup can be given only if peer-group has no members";
182 break;
183 case BGP_ERR_PEER_BELONGS_TO_GROUP:
184 str = "No activate for an individual peer-group member is invalid";
185 break;
186 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
187 str = "Activate the peer-group for the address family first";
188 break;
189 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
190 str = "Specify remote-as or peer-group remote AS first";
191 break;
192 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
193 str = "Cannot change the peer-group. Deconfigure first";
194 break;
195 case BGP_ERR_PEER_GROUP_MISMATCH:
196 str = "Cannot have different peer-group for the neighbor";
197 break;
198 case BGP_ERR_PEER_FILTER_CONFLICT:
199 str = "Prefix/distribute list can not co-exist";
200 break;
201 case BGP_ERR_NOT_INTERNAL_PEER:
202 str = "Invalid command. Not an internal neighbor";
203 break;
204 case BGP_ERR_REMOVE_PRIVATE_AS:
205 str = "Private AS cannot be removed for IBGP peers";
206 break;
207 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
208 str = "Local-AS allowed only for EBGP peers";
209 break;
210 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
211 str = "Cannot have local-as same as BGP AS number";
212 break;
213 case BGP_ERR_TCPSIG_FAILED:
214 str = "Error while applying TCP-Sig to session(s)";
215 break;
216 }
217 if (str)
218 {
219 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
220 return CMD_WARNING;
221 }
222 return CMD_SUCCESS;
223 }
224
225 /* BGP global configuration. */
226
227 DEFUN (bgp_multiple_instance_func,
228 bgp_multiple_instance_cmd,
229 "bgp multiple-instance",
230 BGP_STR
231 "Enable bgp multiple instance\n")
232 {
233 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
234 return CMD_SUCCESS;
235 }
236
237 DEFUN (no_bgp_multiple_instance,
238 no_bgp_multiple_instance_cmd,
239 "no bgp multiple-instance",
240 NO_STR
241 BGP_STR
242 "BGP multiple instance\n")
243 {
244 int ret;
245
246 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
247 if (ret < 0)
248 {
249 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
250 return CMD_WARNING;
251 }
252 return CMD_SUCCESS;
253 }
254
255 DEFUN (bgp_config_type,
256 bgp_config_type_cmd,
257 "bgp config-type (cisco|zebra)",
258 BGP_STR
259 "Configuration type\n"
260 "cisco\n"
261 "zebra\n")
262 {
263 if (strncmp (argv[0], "c", 1) == 0)
264 bgp_option_set (BGP_OPT_CONFIG_CISCO);
265 else
266 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
267
268 return CMD_SUCCESS;
269 }
270
271 DEFUN (no_bgp_config_type,
272 no_bgp_config_type_cmd,
273 "no bgp config-type",
274 NO_STR
275 BGP_STR
276 "Display configuration type\n")
277 {
278 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
279 return CMD_SUCCESS;
280 }
281
282 DEFUN (no_synchronization,
283 no_synchronization_cmd,
284 "no synchronization",
285 NO_STR
286 "Perform IGP synchronization\n")
287 {
288 return CMD_SUCCESS;
289 }
290
291 DEFUN (no_auto_summary,
292 no_auto_summary_cmd,
293 "no auto-summary",
294 NO_STR
295 "Enable automatic network number summarization\n")
296 {
297 return CMD_SUCCESS;
298 }
299
300 DEFUN_DEPRECATED (neighbor_version,
301 neighbor_version_cmd,
302 NEIGHBOR_CMD "version (4|4-)",
303 NEIGHBOR_STR
304 NEIGHBOR_ADDR_STR
305 "Set the BGP version to match a neighbor\n"
306 "Neighbor's BGP version\n")
307 {
308 return CMD_SUCCESS;
309 }
310 \f
311 /* "router bgp" commands. */
312 DEFUN (router_bgp,
313 router_bgp_cmd,
314 "router bgp " CMD_AS_RANGE,
315 ROUTER_STR
316 BGP_STR
317 AS_STR)
318 {
319 int ret;
320 as_t as;
321 struct bgp *bgp;
322 const char *name = NULL;
323
324 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
325
326 if (argc == 2)
327 name = argv[1];
328
329 ret = bgp_get (&bgp, &as, name);
330 switch (ret)
331 {
332 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
333 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
334 VTY_NEWLINE);
335 return CMD_WARNING;
336 case BGP_ERR_AS_MISMATCH:
337 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
338 return CMD_WARNING;
339 case BGP_ERR_INSTANCE_MISMATCH:
340 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
341 vty_out (vty, "BGP instance is already running; AS is %u%s",
342 as, VTY_NEWLINE);
343 return CMD_WARNING;
344 }
345
346 vty->node = BGP_NODE;
347 vty->index = bgp;
348
349 return CMD_SUCCESS;
350 }
351
352 ALIAS (router_bgp,
353 router_bgp_view_cmd,
354 "router bgp " CMD_AS_RANGE " view WORD",
355 ROUTER_STR
356 BGP_STR
357 AS_STR
358 "BGP view\n"
359 "view name\n")
360 \f
361 /* "no router bgp" commands. */
362 DEFUN (no_router_bgp,
363 no_router_bgp_cmd,
364 "no router bgp " CMD_AS_RANGE,
365 NO_STR
366 ROUTER_STR
367 BGP_STR
368 AS_STR)
369 {
370 as_t as;
371 struct bgp *bgp;
372 const char *name = NULL;
373
374 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
375
376 if (argc == 2)
377 name = argv[1];
378
379 /* Lookup bgp structure. */
380 bgp = bgp_lookup (as, name);
381 if (! bgp)
382 {
383 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
384 return CMD_WARNING;
385 }
386
387 bgp_delete (bgp);
388
389 return CMD_SUCCESS;
390 }
391
392 ALIAS (no_router_bgp,
393 no_router_bgp_view_cmd,
394 "no router bgp " CMD_AS_RANGE " view WORD",
395 NO_STR
396 ROUTER_STR
397 BGP_STR
398 AS_STR
399 "BGP view\n"
400 "view name\n")
401 \f
402 /* BGP router-id. */
403
404 DEFUN (bgp_router_id,
405 bgp_router_id_cmd,
406 "bgp router-id A.B.C.D",
407 BGP_STR
408 "Override configured router identifier\n"
409 "Manually configured router identifier\n")
410 {
411 int ret;
412 struct in_addr id;
413 struct bgp *bgp;
414
415 bgp = vty->index;
416
417 ret = inet_aton (argv[0], &id);
418 if (! ret)
419 {
420 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
421 return CMD_WARNING;
422 }
423
424 bgp->router_id_static = id;
425 bgp_router_id_set (bgp, &id);
426
427 return CMD_SUCCESS;
428 }
429
430 DEFUN (no_bgp_router_id,
431 no_bgp_router_id_cmd,
432 "no bgp router-id",
433 NO_STR
434 BGP_STR
435 "Override configured router identifier\n")
436 {
437 int ret;
438 struct in_addr id;
439 struct bgp *bgp;
440
441 bgp = vty->index;
442
443 if (argc == 1)
444 {
445 ret = inet_aton (argv[0], &id);
446 if (! ret)
447 {
448 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
449 return CMD_WARNING;
450 }
451
452 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
453 {
454 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
455 return CMD_WARNING;
456 }
457 }
458
459 bgp->router_id_static.s_addr = 0;
460 bgp_router_id_set (bgp, &router_id_zebra);
461
462 return CMD_SUCCESS;
463 }
464
465 ALIAS (no_bgp_router_id,
466 no_bgp_router_id_val_cmd,
467 "no bgp router-id A.B.C.D",
468 NO_STR
469 BGP_STR
470 "Override configured router identifier\n"
471 "Manually configured router identifier\n")
472 \f
473 /* BGP Cluster ID. */
474
475 DEFUN (bgp_cluster_id,
476 bgp_cluster_id_cmd,
477 "bgp cluster-id A.B.C.D",
478 BGP_STR
479 "Configure Route-Reflector Cluster-id\n"
480 "Route-Reflector Cluster-id in IP address format\n")
481 {
482 int ret;
483 struct bgp *bgp;
484 struct in_addr cluster;
485
486 bgp = vty->index;
487
488 ret = inet_aton (argv[0], &cluster);
489 if (! ret)
490 {
491 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
492 return CMD_WARNING;
493 }
494
495 bgp_cluster_id_set (bgp, &cluster);
496
497 return CMD_SUCCESS;
498 }
499
500 ALIAS (bgp_cluster_id,
501 bgp_cluster_id32_cmd,
502 "bgp cluster-id <1-4294967295>",
503 BGP_STR
504 "Configure Route-Reflector Cluster-id\n"
505 "Route-Reflector Cluster-id as 32 bit quantity\n")
506
507 DEFUN (no_bgp_cluster_id,
508 no_bgp_cluster_id_cmd,
509 "no bgp cluster-id",
510 NO_STR
511 BGP_STR
512 "Configure Route-Reflector Cluster-id\n")
513 {
514 int ret;
515 struct bgp *bgp;
516 struct in_addr cluster;
517
518 bgp = vty->index;
519
520 if (argc == 1)
521 {
522 ret = inet_aton (argv[0], &cluster);
523 if (! ret)
524 {
525 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
526 return CMD_WARNING;
527 }
528 }
529
530 bgp_cluster_id_unset (bgp);
531
532 return CMD_SUCCESS;
533 }
534
535 ALIAS (no_bgp_cluster_id,
536 no_bgp_cluster_id_arg_cmd,
537 "no bgp cluster-id A.B.C.D",
538 NO_STR
539 BGP_STR
540 "Configure Route-Reflector Cluster-id\n"
541 "Route-Reflector Cluster-id in IP address format\n")
542 \f
543 DEFUN (bgp_confederation_identifier,
544 bgp_confederation_identifier_cmd,
545 "bgp confederation identifier " CMD_AS_RANGE,
546 "BGP specific commands\n"
547 "AS confederation parameters\n"
548 "AS number\n"
549 "Set routing domain confederation AS\n")
550 {
551 struct bgp *bgp;
552 as_t as;
553
554 bgp = vty->index;
555
556 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
557
558 bgp_confederation_id_set (bgp, as);
559
560 return CMD_SUCCESS;
561 }
562
563 DEFUN (no_bgp_confederation_identifier,
564 no_bgp_confederation_identifier_cmd,
565 "no bgp confederation identifier",
566 NO_STR
567 "BGP specific commands\n"
568 "AS confederation parameters\n"
569 "AS number\n")
570 {
571 struct bgp *bgp;
572 as_t as;
573
574 bgp = vty->index;
575
576 if (argc == 1)
577 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
578
579 bgp_confederation_id_unset (bgp);
580
581 return CMD_SUCCESS;
582 }
583
584 ALIAS (no_bgp_confederation_identifier,
585 no_bgp_confederation_identifier_arg_cmd,
586 "no bgp confederation identifier " CMD_AS_RANGE,
587 NO_STR
588 "BGP specific commands\n"
589 "AS confederation parameters\n"
590 "AS number\n"
591 "Set routing domain confederation AS\n")
592 \f
593 DEFUN (bgp_confederation_peers,
594 bgp_confederation_peers_cmd,
595 "bgp confederation peers ." CMD_AS_RANGE,
596 "BGP specific commands\n"
597 "AS confederation parameters\n"
598 "Peer ASs in BGP confederation\n"
599 AS_STR)
600 {
601 struct bgp *bgp;
602 as_t as;
603 int i;
604
605 bgp = vty->index;
606
607 for (i = 0; i < argc; i++)
608 {
609 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
610
611 if (bgp->as == as)
612 {
613 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
614 VTY_NEWLINE);
615 continue;
616 }
617
618 bgp_confederation_peers_add (bgp, as);
619 }
620 return CMD_SUCCESS;
621 }
622
623 DEFUN (no_bgp_confederation_peers,
624 no_bgp_confederation_peers_cmd,
625 "no bgp confederation peers ." CMD_AS_RANGE,
626 NO_STR
627 "BGP specific commands\n"
628 "AS confederation parameters\n"
629 "Peer ASs in BGP confederation\n"
630 AS_STR)
631 {
632 struct bgp *bgp;
633 as_t as;
634 int i;
635
636 bgp = vty->index;
637
638 for (i = 0; i < argc; i++)
639 {
640 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
641
642 bgp_confederation_peers_remove (bgp, as);
643 }
644 return CMD_SUCCESS;
645 }
646 \f
647 /* BGP timers. */
648
649 DEFUN (bgp_timers,
650 bgp_timers_cmd,
651 "timers bgp <0-65535> <0-65535>",
652 "Adjust routing timers\n"
653 "BGP timers\n"
654 "Keepalive interval\n"
655 "Holdtime\n")
656 {
657 struct bgp *bgp;
658 unsigned long keepalive = 0;
659 unsigned long holdtime = 0;
660
661 bgp = vty->index;
662
663 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
664 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
665
666 /* Holdtime value check. */
667 if (holdtime < 3 && holdtime != 0)
668 {
669 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
670 VTY_NEWLINE);
671 return CMD_WARNING;
672 }
673
674 bgp_timers_set (bgp, keepalive, holdtime);
675
676 return CMD_SUCCESS;
677 }
678
679 DEFUN (no_bgp_timers,
680 no_bgp_timers_cmd,
681 "no timers bgp",
682 NO_STR
683 "Adjust routing timers\n"
684 "BGP timers\n")
685 {
686 struct bgp *bgp;
687
688 bgp = vty->index;
689 bgp_timers_unset (bgp);
690
691 return CMD_SUCCESS;
692 }
693
694 ALIAS (no_bgp_timers,
695 no_bgp_timers_arg_cmd,
696 "no timers bgp <0-65535> <0-65535>",
697 NO_STR
698 "Adjust routing timers\n"
699 "BGP timers\n"
700 "Keepalive interval\n"
701 "Holdtime\n")
702 \f
703 DEFUN (bgp_client_to_client_reflection,
704 bgp_client_to_client_reflection_cmd,
705 "bgp client-to-client reflection",
706 "BGP specific commands\n"
707 "Configure client to client route reflection\n"
708 "reflection of routes allowed\n")
709 {
710 struct bgp *bgp;
711
712 bgp = vty->index;
713 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
714 return CMD_SUCCESS;
715 }
716
717 DEFUN (no_bgp_client_to_client_reflection,
718 no_bgp_client_to_client_reflection_cmd,
719 "no bgp client-to-client reflection",
720 NO_STR
721 "BGP specific commands\n"
722 "Configure client to client route reflection\n"
723 "reflection of routes allowed\n")
724 {
725 struct bgp *bgp;
726
727 bgp = vty->index;
728 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
729 return CMD_SUCCESS;
730 }
731
732 /* "bgp always-compare-med" configuration. */
733 DEFUN (bgp_always_compare_med,
734 bgp_always_compare_med_cmd,
735 "bgp always-compare-med",
736 "BGP specific commands\n"
737 "Allow comparing MED from different neighbors\n")
738 {
739 struct bgp *bgp;
740
741 bgp = vty->index;
742 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
743 return CMD_SUCCESS;
744 }
745
746 DEFUN (no_bgp_always_compare_med,
747 no_bgp_always_compare_med_cmd,
748 "no bgp always-compare-med",
749 NO_STR
750 "BGP specific commands\n"
751 "Allow comparing MED from different neighbors\n")
752 {
753 struct bgp *bgp;
754
755 bgp = vty->index;
756 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
757 return CMD_SUCCESS;
758 }
759 \f
760 /* "bgp deterministic-med" configuration. */
761 DEFUN (bgp_deterministic_med,
762 bgp_deterministic_med_cmd,
763 "bgp deterministic-med",
764 "BGP specific commands\n"
765 "Pick the best-MED path among paths advertised from the neighboring AS\n")
766 {
767 struct bgp *bgp;
768
769 bgp = vty->index;
770 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
771 return CMD_SUCCESS;
772 }
773
774 DEFUN (no_bgp_deterministic_med,
775 no_bgp_deterministic_med_cmd,
776 "no bgp deterministic-med",
777 NO_STR
778 "BGP specific commands\n"
779 "Pick the best-MED path among paths advertised from the neighboring AS\n")
780 {
781 struct bgp *bgp;
782
783 bgp = vty->index;
784 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
785 return CMD_SUCCESS;
786 }
787
788 /* "bgp graceful-restart" configuration. */
789 DEFUN (bgp_graceful_restart,
790 bgp_graceful_restart_cmd,
791 "bgp graceful-restart",
792 "BGP specific commands\n"
793 "Graceful restart capability parameters\n")
794 {
795 struct bgp *bgp;
796
797 bgp = vty->index;
798 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
799 return CMD_SUCCESS;
800 }
801
802 DEFUN (no_bgp_graceful_restart,
803 no_bgp_graceful_restart_cmd,
804 "no bgp graceful-restart",
805 NO_STR
806 "BGP specific commands\n"
807 "Graceful restart capability parameters\n")
808 {
809 struct bgp *bgp;
810
811 bgp = vty->index;
812 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
813 return CMD_SUCCESS;
814 }
815
816 DEFUN (bgp_graceful_restart_stalepath_time,
817 bgp_graceful_restart_stalepath_time_cmd,
818 "bgp graceful-restart stalepath-time <1-3600>",
819 "BGP specific commands\n"
820 "Graceful restart capability parameters\n"
821 "Set the max time to hold onto restarting peer's stale paths\n"
822 "Delay value (seconds)\n")
823 {
824 struct bgp *bgp;
825 u_int32_t stalepath;
826
827 bgp = vty->index;
828 if (! bgp)
829 return CMD_WARNING;
830
831 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
832 bgp->stalepath_time = stalepath;
833 return CMD_SUCCESS;
834 }
835
836 DEFUN (no_bgp_graceful_restart_stalepath_time,
837 no_bgp_graceful_restart_stalepath_time_cmd,
838 "no bgp graceful-restart stalepath-time",
839 NO_STR
840 "BGP specific commands\n"
841 "Graceful restart capability parameters\n"
842 "Set the max time to hold onto restarting peer's stale paths\n")
843 {
844 struct bgp *bgp;
845
846 bgp = vty->index;
847 if (! bgp)
848 return CMD_WARNING;
849
850 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
851 return CMD_SUCCESS;
852 }
853
854 ALIAS (no_bgp_graceful_restart_stalepath_time,
855 no_bgp_graceful_restart_stalepath_time_val_cmd,
856 "no bgp graceful-restart stalepath-time <1-3600>",
857 NO_STR
858 "BGP specific commands\n"
859 "Graceful restart capability parameters\n"
860 "Set the max time to hold onto restarting peer's stale paths\n"
861 "Delay value (seconds)\n")
862
863 /* "bgp fast-external-failover" configuration. */
864 DEFUN (bgp_fast_external_failover,
865 bgp_fast_external_failover_cmd,
866 "bgp fast-external-failover",
867 BGP_STR
868 "Immediately reset session if a link to a directly connected external peer goes down\n")
869 {
870 struct bgp *bgp;
871
872 bgp = vty->index;
873 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
874 return CMD_SUCCESS;
875 }
876
877 DEFUN (no_bgp_fast_external_failover,
878 no_bgp_fast_external_failover_cmd,
879 "no bgp fast-external-failover",
880 NO_STR
881 BGP_STR
882 "Immediately reset session if a link to a directly connected external peer goes down\n")
883 {
884 struct bgp *bgp;
885
886 bgp = vty->index;
887 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
888 return CMD_SUCCESS;
889 }
890 \f
891 /* "bgp enforce-first-as" configuration. */
892 DEFUN (bgp_enforce_first_as,
893 bgp_enforce_first_as_cmd,
894 "bgp enforce-first-as",
895 BGP_STR
896 "Enforce the first AS for EBGP routes\n")
897 {
898 struct bgp *bgp;
899
900 bgp = vty->index;
901 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
902 return CMD_SUCCESS;
903 }
904
905 DEFUN (no_bgp_enforce_first_as,
906 no_bgp_enforce_first_as_cmd,
907 "no bgp enforce-first-as",
908 NO_STR
909 BGP_STR
910 "Enforce the first AS for EBGP routes\n")
911 {
912 struct bgp *bgp;
913
914 bgp = vty->index;
915 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
916 return CMD_SUCCESS;
917 }
918 \f
919 /* "bgp bestpath compare-routerid" configuration. */
920 DEFUN (bgp_bestpath_compare_router_id,
921 bgp_bestpath_compare_router_id_cmd,
922 "bgp bestpath compare-routerid",
923 "BGP specific commands\n"
924 "Change the default bestpath selection\n"
925 "Compare router-id for identical EBGP paths\n")
926 {
927 struct bgp *bgp;
928
929 bgp = vty->index;
930 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
931 return CMD_SUCCESS;
932 }
933
934 DEFUN (no_bgp_bestpath_compare_router_id,
935 no_bgp_bestpath_compare_router_id_cmd,
936 "no bgp bestpath compare-routerid",
937 NO_STR
938 "BGP specific commands\n"
939 "Change the default bestpath selection\n"
940 "Compare router-id for identical EBGP paths\n")
941 {
942 struct bgp *bgp;
943
944 bgp = vty->index;
945 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
946 return CMD_SUCCESS;
947 }
948 \f
949 /* "bgp bestpath as-path ignore" configuration. */
950 DEFUN (bgp_bestpath_aspath_ignore,
951 bgp_bestpath_aspath_ignore_cmd,
952 "bgp bestpath as-path ignore",
953 "BGP specific commands\n"
954 "Change the default bestpath selection\n"
955 "AS-path attribute\n"
956 "Ignore as-path length in selecting a route\n")
957 {
958 struct bgp *bgp;
959
960 bgp = vty->index;
961 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
962 return CMD_SUCCESS;
963 }
964
965 DEFUN (no_bgp_bestpath_aspath_ignore,
966 no_bgp_bestpath_aspath_ignore_cmd,
967 "no bgp bestpath as-path ignore",
968 NO_STR
969 "BGP specific commands\n"
970 "Change the default bestpath selection\n"
971 "AS-path attribute\n"
972 "Ignore as-path length in selecting a route\n")
973 {
974 struct bgp *bgp;
975
976 bgp = vty->index;
977 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
978 return CMD_SUCCESS;
979 }
980 \f
981 /* "bgp bestpath as-path confed" configuration. */
982 DEFUN (bgp_bestpath_aspath_confed,
983 bgp_bestpath_aspath_confed_cmd,
984 "bgp bestpath as-path confed",
985 "BGP specific commands\n"
986 "Change the default bestpath selection\n"
987 "AS-path attribute\n"
988 "Compare path lengths including confederation sets & sequences in selecting a route\n")
989 {
990 struct bgp *bgp;
991
992 bgp = vty->index;
993 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
994 return CMD_SUCCESS;
995 }
996
997 DEFUN (no_bgp_bestpath_aspath_confed,
998 no_bgp_bestpath_aspath_confed_cmd,
999 "no bgp bestpath as-path confed",
1000 NO_STR
1001 "BGP specific commands\n"
1002 "Change the default bestpath selection\n"
1003 "AS-path attribute\n"
1004 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1005 {
1006 struct bgp *bgp;
1007
1008 bgp = vty->index;
1009 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1010 return CMD_SUCCESS;
1011 }
1012 \f
1013 /* "bgp log-neighbor-changes" configuration. */
1014 DEFUN (bgp_log_neighbor_changes,
1015 bgp_log_neighbor_changes_cmd,
1016 "bgp log-neighbor-changes",
1017 "BGP specific commands\n"
1018 "Log neighbor up/down and reset reason\n")
1019 {
1020 struct bgp *bgp;
1021
1022 bgp = vty->index;
1023 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1024 return CMD_SUCCESS;
1025 }
1026
1027 DEFUN (no_bgp_log_neighbor_changes,
1028 no_bgp_log_neighbor_changes_cmd,
1029 "no bgp log-neighbor-changes",
1030 NO_STR
1031 "BGP specific commands\n"
1032 "Log neighbor up/down and reset reason\n")
1033 {
1034 struct bgp *bgp;
1035
1036 bgp = vty->index;
1037 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1038 return CMD_SUCCESS;
1039 }
1040 \f
1041 /* "bgp bestpath med" configuration. */
1042 DEFUN (bgp_bestpath_med,
1043 bgp_bestpath_med_cmd,
1044 "bgp bestpath med (confed|missing-as-worst)",
1045 "BGP specific commands\n"
1046 "Change the default bestpath selection\n"
1047 "MED attribute\n"
1048 "Compare MED among confederation paths\n"
1049 "Treat missing MED as the least preferred one\n")
1050 {
1051 struct bgp *bgp;
1052
1053 bgp = vty->index;
1054
1055 if (strncmp (argv[0], "confed", 1) == 0)
1056 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1057 else
1058 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1059
1060 return CMD_SUCCESS;
1061 }
1062
1063 DEFUN (bgp_bestpath_med2,
1064 bgp_bestpath_med2_cmd,
1065 "bgp bestpath med confed missing-as-worst",
1066 "BGP specific commands\n"
1067 "Change the default bestpath selection\n"
1068 "MED attribute\n"
1069 "Compare MED among confederation paths\n"
1070 "Treat missing MED as the least preferred one\n")
1071 {
1072 struct bgp *bgp;
1073
1074 bgp = vty->index;
1075 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1076 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1077 return CMD_SUCCESS;
1078 }
1079
1080 ALIAS (bgp_bestpath_med2,
1081 bgp_bestpath_med3_cmd,
1082 "bgp bestpath med missing-as-worst confed",
1083 "BGP specific commands\n"
1084 "Change the default bestpath selection\n"
1085 "MED attribute\n"
1086 "Treat missing MED as the least preferred one\n"
1087 "Compare MED among confederation paths\n")
1088
1089 DEFUN (no_bgp_bestpath_med,
1090 no_bgp_bestpath_med_cmd,
1091 "no bgp bestpath med (confed|missing-as-worst)",
1092 NO_STR
1093 "BGP specific commands\n"
1094 "Change the default bestpath selection\n"
1095 "MED attribute\n"
1096 "Compare MED among confederation paths\n"
1097 "Treat missing MED as the least preferred one\n")
1098 {
1099 struct bgp *bgp;
1100
1101 bgp = vty->index;
1102
1103 if (strncmp (argv[0], "confed", 1) == 0)
1104 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1105 else
1106 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1107
1108 return CMD_SUCCESS;
1109 }
1110
1111 DEFUN (no_bgp_bestpath_med2,
1112 no_bgp_bestpath_med2_cmd,
1113 "no bgp bestpath med confed missing-as-worst",
1114 NO_STR
1115 "BGP specific commands\n"
1116 "Change the default bestpath selection\n"
1117 "MED attribute\n"
1118 "Compare MED among confederation paths\n"
1119 "Treat missing MED as the least preferred one\n")
1120 {
1121 struct bgp *bgp;
1122
1123 bgp = vty->index;
1124 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
1125 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1126 return CMD_SUCCESS;
1127 }
1128
1129 ALIAS (no_bgp_bestpath_med2,
1130 no_bgp_bestpath_med3_cmd,
1131 "no bgp bestpath med missing-as-worst confed",
1132 NO_STR
1133 "BGP specific commands\n"
1134 "Change the default bestpath selection\n"
1135 "MED attribute\n"
1136 "Treat missing MED as the least preferred one\n"
1137 "Compare MED among confederation paths\n")
1138 \f
1139 /* "no bgp default ipv4-unicast". */
1140 DEFUN (no_bgp_default_ipv4_unicast,
1141 no_bgp_default_ipv4_unicast_cmd,
1142 "no bgp default ipv4-unicast",
1143 NO_STR
1144 "BGP specific commands\n"
1145 "Configure BGP defaults\n"
1146 "Activate ipv4-unicast for a peer by default\n")
1147 {
1148 struct bgp *bgp;
1149
1150 bgp = vty->index;
1151 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1152 return CMD_SUCCESS;
1153 }
1154
1155 DEFUN (bgp_default_ipv4_unicast,
1156 bgp_default_ipv4_unicast_cmd,
1157 "bgp default ipv4-unicast",
1158 "BGP specific commands\n"
1159 "Configure BGP defaults\n"
1160 "Activate ipv4-unicast for a peer by default\n")
1161 {
1162 struct bgp *bgp;
1163
1164 bgp = vty->index;
1165 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
1166 return CMD_SUCCESS;
1167 }
1168 \f
1169 /* "bgp import-check" configuration. */
1170 DEFUN (bgp_network_import_check,
1171 bgp_network_import_check_cmd,
1172 "bgp network import-check",
1173 "BGP specific commands\n"
1174 "BGP network command\n"
1175 "Check BGP network route exists in IGP\n")
1176 {
1177 struct bgp *bgp;
1178
1179 bgp = vty->index;
1180 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
1181 return CMD_SUCCESS;
1182 }
1183
1184 DEFUN (no_bgp_network_import_check,
1185 no_bgp_network_import_check_cmd,
1186 "no bgp network import-check",
1187 NO_STR
1188 "BGP specific commands\n"
1189 "BGP network command\n"
1190 "Check BGP network route exists in IGP\n")
1191 {
1192 struct bgp *bgp;
1193
1194 bgp = vty->index;
1195 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
1196 return CMD_SUCCESS;
1197 }
1198 \f
1199 DEFUN (bgp_default_local_preference,
1200 bgp_default_local_preference_cmd,
1201 "bgp default local-preference <0-4294967295>",
1202 "BGP specific commands\n"
1203 "Configure BGP defaults\n"
1204 "local preference (higher=more preferred)\n"
1205 "Configure default local preference value\n")
1206 {
1207 struct bgp *bgp;
1208 u_int32_t local_pref;
1209
1210 bgp = vty->index;
1211
1212 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
1213
1214 bgp_default_local_preference_set (bgp, local_pref);
1215
1216 return CMD_SUCCESS;
1217 }
1218
1219 DEFUN (no_bgp_default_local_preference,
1220 no_bgp_default_local_preference_cmd,
1221 "no bgp default local-preference",
1222 NO_STR
1223 "BGP specific commands\n"
1224 "Configure BGP defaults\n"
1225 "local preference (higher=more preferred)\n")
1226 {
1227 struct bgp *bgp;
1228
1229 bgp = vty->index;
1230 bgp_default_local_preference_unset (bgp);
1231 return CMD_SUCCESS;
1232 }
1233
1234 ALIAS (no_bgp_default_local_preference,
1235 no_bgp_default_local_preference_val_cmd,
1236 "no bgp default local-preference <0-4294967295>",
1237 NO_STR
1238 "BGP specific commands\n"
1239 "Configure BGP defaults\n"
1240 "local preference (higher=more preferred)\n"
1241 "Configure default local preference value\n")
1242 \f
1243 static int
1244 peer_remote_as_vty (struct vty *vty, const char *peer_str,
1245 const char *as_str, afi_t afi, safi_t safi)
1246 {
1247 int ret;
1248 struct bgp *bgp;
1249 as_t as;
1250 union sockunion su;
1251
1252 bgp = vty->index;
1253
1254 /* Get AS number. */
1255 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
1256
1257 /* If peer is peer group, call proper function. */
1258 ret = str2sockunion (peer_str, &su);
1259 if (ret < 0)
1260 {
1261 ret = peer_group_remote_as (bgp, peer_str, &as);
1262 if (ret < 0)
1263 {
1264 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1265 return CMD_WARNING;
1266 }
1267 return CMD_SUCCESS;
1268 }
1269
1270 if (peer_address_self_check (&su))
1271 {
1272 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1273 VTY_NEWLINE);
1274 return CMD_WARNING;
1275 }
1276
1277 ret = peer_remote_as (bgp, &su, &as, afi, safi);
1278
1279 /* This peer belongs to peer group. */
1280 switch (ret)
1281 {
1282 case BGP_ERR_PEER_GROUP_MEMBER:
1283 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
1284 return CMD_WARNING;
1285 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
1286 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);
1287 return CMD_WARNING;
1288 }
1289 return bgp_vty_return (vty, ret);
1290 }
1291
1292 DEFUN (neighbor_remote_as,
1293 neighbor_remote_as_cmd,
1294 NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
1295 NEIGHBOR_STR
1296 NEIGHBOR_ADDR_STR2
1297 "Specify a BGP neighbor\n"
1298 AS_STR)
1299 {
1300 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
1301 }
1302 \f
1303 DEFUN (neighbor_peer_group,
1304 neighbor_peer_group_cmd,
1305 "neighbor WORD peer-group",
1306 NEIGHBOR_STR
1307 "Neighbor tag\n"
1308 "Configure peer-group\n")
1309 {
1310 struct bgp *bgp;
1311 struct peer_group *group;
1312
1313 bgp = vty->index;
1314
1315 group = peer_group_get (bgp, argv[0]);
1316 if (! group)
1317 return CMD_WARNING;
1318
1319 return CMD_SUCCESS;
1320 }
1321
1322 DEFUN (no_neighbor,
1323 no_neighbor_cmd,
1324 NO_NEIGHBOR_CMD2,
1325 NO_STR
1326 NEIGHBOR_STR
1327 NEIGHBOR_ADDR_STR2)
1328 {
1329 int ret;
1330 union sockunion su;
1331 struct peer_group *group;
1332 struct peer *peer;
1333
1334 ret = str2sockunion (argv[0], &su);
1335 if (ret < 0)
1336 {
1337 group = peer_group_lookup (vty->index, argv[0]);
1338 if (group)
1339 peer_group_delete (group);
1340 else
1341 {
1342 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1343 return CMD_WARNING;
1344 }
1345 }
1346 else
1347 {
1348 peer = peer_lookup (vty->index, &su);
1349 if (peer)
1350 peer_delete (peer);
1351 }
1352
1353 return CMD_SUCCESS;
1354 }
1355
1356 ALIAS (no_neighbor,
1357 no_neighbor_remote_as_cmd,
1358 NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
1359 NO_STR
1360 NEIGHBOR_STR
1361 NEIGHBOR_ADDR_STR
1362 "Specify a BGP neighbor\n"
1363 AS_STR)
1364
1365 DEFUN (no_neighbor_peer_group,
1366 no_neighbor_peer_group_cmd,
1367 "no neighbor WORD peer-group",
1368 NO_STR
1369 NEIGHBOR_STR
1370 "Neighbor tag\n"
1371 "Configure peer-group\n")
1372 {
1373 struct peer_group *group;
1374
1375 group = peer_group_lookup (vty->index, argv[0]);
1376 if (group)
1377 peer_group_delete (group);
1378 else
1379 {
1380 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1381 return CMD_WARNING;
1382 }
1383 return CMD_SUCCESS;
1384 }
1385
1386 DEFUN (no_neighbor_peer_group_remote_as,
1387 no_neighbor_peer_group_remote_as_cmd,
1388 "no neighbor WORD remote-as " CMD_AS_RANGE,
1389 NO_STR
1390 NEIGHBOR_STR
1391 "Neighbor tag\n"
1392 "Specify a BGP neighbor\n"
1393 AS_STR)
1394 {
1395 struct peer_group *group;
1396
1397 group = peer_group_lookup (vty->index, argv[0]);
1398 if (group)
1399 peer_group_remote_as_delete (group);
1400 else
1401 {
1402 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
1403 return CMD_WARNING;
1404 }
1405 return CMD_SUCCESS;
1406 }
1407 \f
1408 DEFUN (neighbor_local_as,
1409 neighbor_local_as_cmd,
1410 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
1411 NEIGHBOR_STR
1412 NEIGHBOR_ADDR_STR2
1413 "Specify a local-as number\n"
1414 "AS number used as local AS\n")
1415 {
1416 struct peer *peer;
1417 int ret;
1418
1419 peer = peer_and_group_lookup_vty (vty, argv[0]);
1420 if (! peer)
1421 return CMD_WARNING;
1422
1423 ret = peer_local_as_set (peer, atoi (argv[1]), 0);
1424 return bgp_vty_return (vty, ret);
1425 }
1426
1427 DEFUN (neighbor_local_as_no_prepend,
1428 neighbor_local_as_no_prepend_cmd,
1429 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
1430 NEIGHBOR_STR
1431 NEIGHBOR_ADDR_STR2
1432 "Specify a local-as number\n"
1433 "AS number used as local AS\n"
1434 "Do not prepend local-as to updates from ebgp peers\n")
1435 {
1436 struct peer *peer;
1437 int ret;
1438
1439 peer = peer_and_group_lookup_vty (vty, argv[0]);
1440 if (! peer)
1441 return CMD_WARNING;
1442
1443 ret = peer_local_as_set (peer, atoi (argv[1]), 1);
1444 return bgp_vty_return (vty, ret);
1445 }
1446
1447 DEFUN (no_neighbor_local_as,
1448 no_neighbor_local_as_cmd,
1449 NO_NEIGHBOR_CMD2 "local-as",
1450 NO_STR
1451 NEIGHBOR_STR
1452 NEIGHBOR_ADDR_STR2
1453 "Specify a local-as number\n")
1454 {
1455 struct peer *peer;
1456 int ret;
1457
1458 peer = peer_and_group_lookup_vty (vty, argv[0]);
1459 if (! peer)
1460 return CMD_WARNING;
1461
1462 ret = peer_local_as_unset (peer);
1463 return bgp_vty_return (vty, ret);
1464 }
1465
1466 ALIAS (no_neighbor_local_as,
1467 no_neighbor_local_as_val_cmd,
1468 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
1469 NO_STR
1470 NEIGHBOR_STR
1471 NEIGHBOR_ADDR_STR2
1472 "Specify a local-as number\n"
1473 "AS number used as local AS\n")
1474
1475 ALIAS (no_neighbor_local_as,
1476 no_neighbor_local_as_val2_cmd,
1477 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
1478 NO_STR
1479 NEIGHBOR_STR
1480 NEIGHBOR_ADDR_STR2
1481 "Specify a local-as number\n"
1482 "AS number used as local AS\n"
1483 "Do not prepend local-as to updates from ebgp peers\n")
1484 \f
1485 DEFUN (neighbor_password,
1486 neighbor_password_cmd,
1487 NEIGHBOR_CMD2 "password LINE",
1488 NEIGHBOR_STR
1489 NEIGHBOR_ADDR_STR2
1490 "Set a password\n"
1491 "The password\n")
1492 {
1493 struct peer *peer;
1494 int ret;
1495
1496 peer = peer_and_group_lookup_vty (vty, argv[0]);
1497 if (! peer)
1498 return CMD_WARNING;
1499
1500 ret = peer_password_set (peer, argv[1]);
1501 return bgp_vty_return (vty, ret);
1502 }
1503
1504 DEFUN (no_neighbor_password,
1505 no_neighbor_password_cmd,
1506 NO_NEIGHBOR_CMD2 "password",
1507 NO_STR
1508 NEIGHBOR_STR
1509 NEIGHBOR_ADDR_STR2
1510 "Set a password\n")
1511 {
1512 struct peer *peer;
1513 int ret;
1514
1515 peer = peer_and_group_lookup_vty (vty, argv[0]);
1516 if (! peer)
1517 return CMD_WARNING;
1518
1519 ret = peer_password_unset (peer);
1520 return bgp_vty_return (vty, ret);
1521 }
1522 \f
1523 DEFUN (neighbor_activate,
1524 neighbor_activate_cmd,
1525 NEIGHBOR_CMD2 "activate",
1526 NEIGHBOR_STR
1527 NEIGHBOR_ADDR_STR2
1528 "Enable the Address Family for this Neighbor\n")
1529 {
1530 struct peer *peer;
1531
1532 peer = peer_and_group_lookup_vty (vty, argv[0]);
1533 if (! peer)
1534 return CMD_WARNING;
1535
1536 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1537
1538 return CMD_SUCCESS;
1539 }
1540
1541 DEFUN (no_neighbor_activate,
1542 no_neighbor_activate_cmd,
1543 NO_NEIGHBOR_CMD2 "activate",
1544 NO_STR
1545 NEIGHBOR_STR
1546 NEIGHBOR_ADDR_STR2
1547 "Enable the Address Family for this Neighbor\n")
1548 {
1549 int ret;
1550 struct peer *peer;
1551
1552 /* Lookup peer. */
1553 peer = peer_and_group_lookup_vty (vty, argv[0]);
1554 if (! peer)
1555 return CMD_WARNING;
1556
1557 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
1558
1559 return bgp_vty_return (vty, ret);
1560 }
1561 \f
1562 DEFUN (neighbor_set_peer_group,
1563 neighbor_set_peer_group_cmd,
1564 NEIGHBOR_CMD "peer-group WORD",
1565 NEIGHBOR_STR
1566 NEIGHBOR_ADDR_STR
1567 "Member of the peer-group\n"
1568 "peer-group name\n")
1569 {
1570 int ret;
1571 as_t as;
1572 union sockunion su;
1573 struct bgp *bgp;
1574 struct peer_group *group;
1575
1576 bgp = vty->index;
1577
1578 ret = str2sockunion (argv[0], &su);
1579 if (ret < 0)
1580 {
1581 vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
1582 return CMD_WARNING;
1583 }
1584
1585 group = peer_group_lookup (bgp, argv[1]);
1586 if (! group)
1587 {
1588 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1589 return CMD_WARNING;
1590 }
1591
1592 if (peer_address_self_check (&su))
1593 {
1594 vty_out (vty, "%% Can not configure the local system as neighbor%s",
1595 VTY_NEWLINE);
1596 return CMD_WARNING;
1597 }
1598
1599 ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
1600 bgp_node_safi (vty), &as);
1601
1602 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
1603 {
1604 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);
1605 return CMD_WARNING;
1606 }
1607
1608 return bgp_vty_return (vty, ret);
1609 }
1610
1611 DEFUN (no_neighbor_set_peer_group,
1612 no_neighbor_set_peer_group_cmd,
1613 NO_NEIGHBOR_CMD "peer-group WORD",
1614 NO_STR
1615 NEIGHBOR_STR
1616 NEIGHBOR_ADDR_STR
1617 "Member of the peer-group\n"
1618 "peer-group name\n")
1619 {
1620 int ret;
1621 struct bgp *bgp;
1622 struct peer *peer;
1623 struct peer_group *group;
1624
1625 bgp = vty->index;
1626
1627 peer = peer_lookup_vty (vty, argv[0]);
1628 if (! peer)
1629 return CMD_WARNING;
1630
1631 group = peer_group_lookup (bgp, argv[1]);
1632 if (! group)
1633 {
1634 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
1635 return CMD_WARNING;
1636 }
1637
1638 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
1639 bgp_node_safi (vty));
1640
1641 return bgp_vty_return (vty, ret);
1642 }
1643 \f
1644 static int
1645 peer_flag_modify_vty (struct vty *vty, const char *ip_str,
1646 u_int16_t flag, int set)
1647 {
1648 int ret;
1649 struct peer *peer;
1650
1651 peer = peer_and_group_lookup_vty (vty, ip_str);
1652 if (! peer)
1653 return CMD_WARNING;
1654
1655 if (set)
1656 ret = peer_flag_set (peer, flag);
1657 else
1658 ret = peer_flag_unset (peer, flag);
1659
1660 return bgp_vty_return (vty, ret);
1661 }
1662
1663 static int
1664 peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
1665 {
1666 return peer_flag_modify_vty (vty, ip_str, flag, 1);
1667 }
1668
1669 static int
1670 peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
1671 {
1672 return peer_flag_modify_vty (vty, ip_str, flag, 0);
1673 }
1674
1675 /* neighbor passive. */
1676 DEFUN (neighbor_passive,
1677 neighbor_passive_cmd,
1678 NEIGHBOR_CMD2 "passive",
1679 NEIGHBOR_STR
1680 NEIGHBOR_ADDR_STR2
1681 "Don't send open messages to this neighbor\n")
1682 {
1683 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1684 }
1685
1686 DEFUN (no_neighbor_passive,
1687 no_neighbor_passive_cmd,
1688 NO_NEIGHBOR_CMD2 "passive",
1689 NO_STR
1690 NEIGHBOR_STR
1691 NEIGHBOR_ADDR_STR2
1692 "Don't send open messages to this neighbor\n")
1693 {
1694 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
1695 }
1696 \f
1697 /* neighbor shutdown. */
1698 DEFUN (neighbor_shutdown,
1699 neighbor_shutdown_cmd,
1700 NEIGHBOR_CMD2 "shutdown",
1701 NEIGHBOR_STR
1702 NEIGHBOR_ADDR_STR2
1703 "Administratively shut down this neighbor\n")
1704 {
1705 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1706 }
1707
1708 DEFUN (no_neighbor_shutdown,
1709 no_neighbor_shutdown_cmd,
1710 NO_NEIGHBOR_CMD2 "shutdown",
1711 NO_STR
1712 NEIGHBOR_STR
1713 NEIGHBOR_ADDR_STR2
1714 "Administratively shut down this neighbor\n")
1715 {
1716 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
1717 }
1718 \f
1719 /* Deprecated neighbor capability route-refresh. */
1720 DEFUN_DEPRECATED (neighbor_capability_route_refresh,
1721 neighbor_capability_route_refresh_cmd,
1722 NEIGHBOR_CMD2 "capability route-refresh",
1723 NEIGHBOR_STR
1724 NEIGHBOR_ADDR_STR2
1725 "Advertise capability to the peer\n"
1726 "Advertise route-refresh capability to this neighbor\n")
1727 {
1728 return CMD_SUCCESS;
1729 }
1730
1731 DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
1732 no_neighbor_capability_route_refresh_cmd,
1733 NO_NEIGHBOR_CMD2 "capability route-refresh",
1734 NO_STR
1735 NEIGHBOR_STR
1736 NEIGHBOR_ADDR_STR2
1737 "Advertise capability to the peer\n"
1738 "Advertise route-refresh capability to this neighbor\n")
1739 {
1740 return CMD_SUCCESS;
1741 }
1742 \f
1743 /* neighbor capability dynamic. */
1744 DEFUN (neighbor_capability_dynamic,
1745 neighbor_capability_dynamic_cmd,
1746 NEIGHBOR_CMD2 "capability dynamic",
1747 NEIGHBOR_STR
1748 NEIGHBOR_ADDR_STR2
1749 "Advertise capability to the peer\n"
1750 "Advertise dynamic capability to this neighbor\n")
1751 {
1752 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1753 }
1754
1755 DEFUN (no_neighbor_capability_dynamic,
1756 no_neighbor_capability_dynamic_cmd,
1757 NO_NEIGHBOR_CMD2 "capability dynamic",
1758 NO_STR
1759 NEIGHBOR_STR
1760 NEIGHBOR_ADDR_STR2
1761 "Advertise capability to the peer\n"
1762 "Advertise dynamic capability to this neighbor\n")
1763 {
1764 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
1765 }
1766 \f
1767 /* neighbor dont-capability-negotiate */
1768 DEFUN (neighbor_dont_capability_negotiate,
1769 neighbor_dont_capability_negotiate_cmd,
1770 NEIGHBOR_CMD2 "dont-capability-negotiate",
1771 NEIGHBOR_STR
1772 NEIGHBOR_ADDR_STR2
1773 "Do not perform capability negotiation\n")
1774 {
1775 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1776 }
1777
1778 DEFUN (no_neighbor_dont_capability_negotiate,
1779 no_neighbor_dont_capability_negotiate_cmd,
1780 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
1781 NO_STR
1782 NEIGHBOR_STR
1783 NEIGHBOR_ADDR_STR2
1784 "Do not perform capability negotiation\n")
1785 {
1786 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
1787 }
1788 \f
1789 static int
1790 peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
1791 safi_t safi, u_int32_t flag, int set)
1792 {
1793 int ret;
1794 struct peer *peer;
1795
1796 peer = peer_and_group_lookup_vty (vty, peer_str);
1797 if (! peer)
1798 return CMD_WARNING;
1799
1800 if (set)
1801 ret = peer_af_flag_set (peer, afi, safi, flag);
1802 else
1803 ret = peer_af_flag_unset (peer, afi, safi, flag);
1804
1805 return bgp_vty_return (vty, ret);
1806 }
1807
1808 static int
1809 peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
1810 safi_t safi, u_int32_t flag)
1811 {
1812 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
1813 }
1814
1815 static int
1816 peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
1817 safi_t safi, u_int32_t flag)
1818 {
1819 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
1820 }
1821 \f
1822 /* neighbor capability orf prefix-list. */
1823 DEFUN (neighbor_capability_orf_prefix,
1824 neighbor_capability_orf_prefix_cmd,
1825 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1826 NEIGHBOR_STR
1827 NEIGHBOR_ADDR_STR2
1828 "Advertise capability to the peer\n"
1829 "Advertise ORF capability to the peer\n"
1830 "Advertise prefixlist ORF capability to this neighbor\n"
1831 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1832 "Capability to RECEIVE the ORF from this neighbor\n"
1833 "Capability to SEND the ORF to this neighbor\n")
1834 {
1835 u_int16_t flag = 0;
1836
1837 if (strncmp (argv[1], "s", 1) == 0)
1838 flag = PEER_FLAG_ORF_PREFIX_SM;
1839 else if (strncmp (argv[1], "r", 1) == 0)
1840 flag = PEER_FLAG_ORF_PREFIX_RM;
1841 else if (strncmp (argv[1], "b", 1) == 0)
1842 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1843 else
1844 return CMD_WARNING;
1845
1846 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1847 bgp_node_safi (vty), flag);
1848 }
1849
1850 DEFUN (no_neighbor_capability_orf_prefix,
1851 no_neighbor_capability_orf_prefix_cmd,
1852 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
1853 NO_STR
1854 NEIGHBOR_STR
1855 NEIGHBOR_ADDR_STR2
1856 "Advertise capability to the peer\n"
1857 "Advertise ORF capability to the peer\n"
1858 "Advertise prefixlist ORF capability to this neighbor\n"
1859 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
1860 "Capability to RECEIVE the ORF from this neighbor\n"
1861 "Capability to SEND the ORF to this neighbor\n")
1862 {
1863 u_int16_t flag = 0;
1864
1865 if (strncmp (argv[1], "s", 1) == 0)
1866 flag = PEER_FLAG_ORF_PREFIX_SM;
1867 else if (strncmp (argv[1], "r", 1) == 0)
1868 flag = PEER_FLAG_ORF_PREFIX_RM;
1869 else if (strncmp (argv[1], "b", 1) == 0)
1870 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
1871 else
1872 return CMD_WARNING;
1873
1874 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1875 bgp_node_safi (vty), flag);
1876 }
1877 \f
1878 /* neighbor next-hop-self. */
1879 DEFUN (neighbor_nexthop_self,
1880 neighbor_nexthop_self_cmd,
1881 NEIGHBOR_CMD2 "next-hop-self",
1882 NEIGHBOR_STR
1883 NEIGHBOR_ADDR_STR2
1884 "Disable the next hop calculation for this neighbor\n")
1885 {
1886 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1887 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1888 }
1889
1890 DEFUN (no_neighbor_nexthop_self,
1891 no_neighbor_nexthop_self_cmd,
1892 NO_NEIGHBOR_CMD2 "next-hop-self",
1893 NO_STR
1894 NEIGHBOR_STR
1895 NEIGHBOR_ADDR_STR2
1896 "Disable the next hop calculation for this neighbor\n")
1897 {
1898 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1899 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
1900 }
1901 \f
1902 /* neighbor remove-private-AS. */
1903 DEFUN (neighbor_remove_private_as,
1904 neighbor_remove_private_as_cmd,
1905 NEIGHBOR_CMD2 "remove-private-AS",
1906 NEIGHBOR_STR
1907 NEIGHBOR_ADDR_STR2
1908 "Remove private AS number from outbound updates\n")
1909 {
1910 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1911 bgp_node_safi (vty),
1912 PEER_FLAG_REMOVE_PRIVATE_AS);
1913 }
1914
1915 DEFUN (no_neighbor_remove_private_as,
1916 no_neighbor_remove_private_as_cmd,
1917 NO_NEIGHBOR_CMD2 "remove-private-AS",
1918 NO_STR
1919 NEIGHBOR_STR
1920 NEIGHBOR_ADDR_STR2
1921 "Remove private AS number from outbound updates\n")
1922 {
1923 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1924 bgp_node_safi (vty),
1925 PEER_FLAG_REMOVE_PRIVATE_AS);
1926 }
1927 \f
1928 /* neighbor send-community. */
1929 DEFUN (neighbor_send_community,
1930 neighbor_send_community_cmd,
1931 NEIGHBOR_CMD2 "send-community",
1932 NEIGHBOR_STR
1933 NEIGHBOR_ADDR_STR2
1934 "Send Community attribute to this neighbor\n")
1935 {
1936 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1937 bgp_node_safi (vty),
1938 PEER_FLAG_SEND_COMMUNITY);
1939 }
1940
1941 DEFUN (no_neighbor_send_community,
1942 no_neighbor_send_community_cmd,
1943 NO_NEIGHBOR_CMD2 "send-community",
1944 NO_STR
1945 NEIGHBOR_STR
1946 NEIGHBOR_ADDR_STR2
1947 "Send Community attribute to this neighbor\n")
1948 {
1949 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1950 bgp_node_safi (vty),
1951 PEER_FLAG_SEND_COMMUNITY);
1952 }
1953 \f
1954 /* neighbor send-community extended. */
1955 DEFUN (neighbor_send_community_type,
1956 neighbor_send_community_type_cmd,
1957 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1958 NEIGHBOR_STR
1959 NEIGHBOR_ADDR_STR2
1960 "Send Community attribute to this neighbor\n"
1961 "Send Standard and Extended Community attributes\n"
1962 "Send Extended Community attributes\n"
1963 "Send Standard Community attributes\n")
1964 {
1965 if (strncmp (argv[1], "s", 1) == 0)
1966 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1967 bgp_node_safi (vty),
1968 PEER_FLAG_SEND_COMMUNITY);
1969 if (strncmp (argv[1], "e", 1) == 0)
1970 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1971 bgp_node_safi (vty),
1972 PEER_FLAG_SEND_EXT_COMMUNITY);
1973
1974 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
1975 bgp_node_safi (vty),
1976 (PEER_FLAG_SEND_COMMUNITY|
1977 PEER_FLAG_SEND_EXT_COMMUNITY));
1978 }
1979
1980 DEFUN (no_neighbor_send_community_type,
1981 no_neighbor_send_community_type_cmd,
1982 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
1983 NO_STR
1984 NEIGHBOR_STR
1985 NEIGHBOR_ADDR_STR2
1986 "Send Community attribute to this neighbor\n"
1987 "Send Standard and Extended Community attributes\n"
1988 "Send Extended Community attributes\n"
1989 "Send Standard Community attributes\n")
1990 {
1991 if (strncmp (argv[1], "s", 1) == 0)
1992 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1993 bgp_node_safi (vty),
1994 PEER_FLAG_SEND_COMMUNITY);
1995 if (strncmp (argv[1], "e", 1) == 0)
1996 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
1997 bgp_node_safi (vty),
1998 PEER_FLAG_SEND_EXT_COMMUNITY);
1999
2000 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2001 bgp_node_safi (vty),
2002 (PEER_FLAG_SEND_COMMUNITY |
2003 PEER_FLAG_SEND_EXT_COMMUNITY));
2004 }
2005 \f
2006 /* neighbor soft-reconfig. */
2007 DEFUN (neighbor_soft_reconfiguration,
2008 neighbor_soft_reconfiguration_cmd,
2009 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2010 NEIGHBOR_STR
2011 NEIGHBOR_ADDR_STR2
2012 "Per neighbor soft reconfiguration\n"
2013 "Allow inbound soft reconfiguration for this neighbor\n")
2014 {
2015 return peer_af_flag_set_vty (vty, argv[0],
2016 bgp_node_afi (vty), bgp_node_safi (vty),
2017 PEER_FLAG_SOFT_RECONFIG);
2018 }
2019
2020 DEFUN (no_neighbor_soft_reconfiguration,
2021 no_neighbor_soft_reconfiguration_cmd,
2022 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
2023 NO_STR
2024 NEIGHBOR_STR
2025 NEIGHBOR_ADDR_STR2
2026 "Per neighbor soft reconfiguration\n"
2027 "Allow inbound soft reconfiguration for this neighbor\n")
2028 {
2029 return peer_af_flag_unset_vty (vty, argv[0],
2030 bgp_node_afi (vty), bgp_node_safi (vty),
2031 PEER_FLAG_SOFT_RECONFIG);
2032 }
2033 \f
2034 DEFUN (neighbor_route_reflector_client,
2035 neighbor_route_reflector_client_cmd,
2036 NEIGHBOR_CMD2 "route-reflector-client",
2037 NEIGHBOR_STR
2038 NEIGHBOR_ADDR_STR2
2039 "Configure a neighbor as Route Reflector client\n")
2040 {
2041 struct peer *peer;
2042
2043
2044 peer = peer_and_group_lookup_vty (vty, argv[0]);
2045 if (! peer)
2046 return CMD_WARNING;
2047
2048 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2049 bgp_node_safi (vty),
2050 PEER_FLAG_REFLECTOR_CLIENT);
2051 }
2052
2053 DEFUN (no_neighbor_route_reflector_client,
2054 no_neighbor_route_reflector_client_cmd,
2055 NO_NEIGHBOR_CMD2 "route-reflector-client",
2056 NO_STR
2057 NEIGHBOR_STR
2058 NEIGHBOR_ADDR_STR2
2059 "Configure a neighbor as Route Reflector client\n")
2060 {
2061 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2062 bgp_node_safi (vty),
2063 PEER_FLAG_REFLECTOR_CLIENT);
2064 }
2065 \f
2066 static int
2067 peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
2068 int afi, int safi)
2069 {
2070 int ret;
2071 struct bgp *bgp;
2072 struct peer *peer;
2073 struct peer_group *group;
2074 struct listnode *node, *nnode;
2075 struct bgp_filter *pfilter;
2076 struct bgp_filter *gfilter;
2077 int locked_and_added = 0;
2078
2079 bgp = vty->index;
2080
2081 peer = peer_and_group_lookup_vty (vty, peer_str);
2082 if ( ! peer )
2083 return CMD_WARNING;
2084
2085 /* If it is already a RS-Client, don't do anything. */
2086 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2087 return CMD_SUCCESS;
2088
2089 if ( ! peer_rsclient_active (peer) )
2090 {
2091 peer = peer_lock (peer); /* rsclient peer list reference */
2092 listnode_add_sort (bgp->rsclient, peer);
2093 locked_and_added = 1;
2094 }
2095
2096 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2097 if (ret < 0)
2098 {
2099 if (locked_and_added)
2100 {
2101 listnode_delete (bgp->rsclient, peer);
2102 peer_unlock (peer); /* rsclient peer list reference */
2103 }
2104
2105 return bgp_vty_return (vty, ret);
2106 }
2107
2108 peer->rib[afi][safi] = bgp_table_init (afi, safi);
2109 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
2110 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
2111 peer->rib[afi][safi]->owner = peer_lock (peer);
2112
2113 /* Check for existing 'network' and 'redistribute' routes. */
2114 bgp_check_local_routes_rsclient (peer, afi, safi);
2115
2116 /* Check for routes for peers configured with 'soft-reconfiguration'. */
2117 bgp_soft_reconfig_rsclient (peer, afi, safi);
2118
2119 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2120 {
2121 group = peer->group;
2122 gfilter = &peer->filter[afi][safi];
2123
2124 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
2125 {
2126 pfilter = &peer->filter[afi][safi];
2127
2128 /* Members of a non-RS-Client group should not be RS-Clients, as that
2129 is checked when the become part of the peer-group */
2130 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2131 if (ret < 0)
2132 return bgp_vty_return (vty, ret);
2133
2134 /* Make peer's RIB point to group's RIB. */
2135 peer->rib[afi][safi] = group->conf->rib[afi][safi];
2136
2137 /* Import policy. */
2138 if (pfilter->map[RMAP_IMPORT].name)
2139 free (pfilter->map[RMAP_IMPORT].name);
2140 if (gfilter->map[RMAP_IMPORT].name)
2141 {
2142 pfilter->map[RMAP_IMPORT].name = strdup (gfilter->map[RMAP_IMPORT].name);
2143 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
2144 }
2145 else
2146 {
2147 pfilter->map[RMAP_IMPORT].name = NULL;
2148 pfilter->map[RMAP_IMPORT].map =NULL;
2149 }
2150
2151 /* Export policy. */
2152 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
2153 {
2154 pfilter->map[RMAP_EXPORT].name = strdup (gfilter->map[RMAP_EXPORT].name);
2155 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
2156 }
2157 }
2158 }
2159 return CMD_SUCCESS;
2160 }
2161
2162 static int
2163 peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
2164 int afi, int safi)
2165 {
2166 int ret;
2167 struct bgp *bgp;
2168 struct peer *peer;
2169 struct peer_group *group;
2170 struct listnode *node, *nnode;
2171
2172 bgp = vty->index;
2173
2174 peer = peer_and_group_lookup_vty (vty, peer_str);
2175 if ( ! peer )
2176 return CMD_WARNING;
2177
2178 /* If it is not a RS-Client, don't do anything. */
2179 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
2180 return CMD_SUCCESS;
2181
2182 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
2183 {
2184 group = peer->group;
2185
2186 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
2187 {
2188 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2189 if (ret < 0)
2190 return bgp_vty_return (vty, ret);
2191
2192 peer->rib[afi][safi] = NULL;
2193 }
2194
2195 peer = group->conf;
2196 }
2197
2198 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
2199 if (ret < 0)
2200 return bgp_vty_return (vty, ret);
2201
2202 if ( ! peer_rsclient_active (peer) )
2203 {
2204 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
2205 listnode_delete (bgp->rsclient, peer);
2206 peer_unlock (peer); /* peer bgp rsclient reference */
2207 }
2208
2209 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
2210
2211 return CMD_SUCCESS;
2212 }
2213 \f
2214 /* neighbor route-server-client. */
2215 DEFUN (neighbor_route_server_client,
2216 neighbor_route_server_client_cmd,
2217 NEIGHBOR_CMD2 "route-server-client",
2218 NEIGHBOR_STR
2219 NEIGHBOR_ADDR_STR2
2220 "Configure a neighbor as Route Server client\n")
2221 {
2222 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
2223 bgp_node_safi(vty));
2224 }
2225
2226 DEFUN (no_neighbor_route_server_client,
2227 no_neighbor_route_server_client_cmd,
2228 NO_NEIGHBOR_CMD2 "route-server-client",
2229 NO_STR
2230 NEIGHBOR_STR
2231 NEIGHBOR_ADDR_STR2
2232 "Configure a neighbor as Route Server client\n")
2233 {
2234 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
2235 bgp_node_safi(vty));
2236 }
2237 \f
2238 DEFUN (neighbor_nexthop_local_unchanged,
2239 neighbor_nexthop_local_unchanged_cmd,
2240 NEIGHBOR_CMD2 "nexthop-local unchanged",
2241 NEIGHBOR_STR
2242 NEIGHBOR_ADDR_STR2
2243 "Configure treatment of outgoing link-local nexthop attribute\n"
2244 "Leave link-local nexthop unchanged for this peer\n")
2245 {
2246 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2247 bgp_node_safi (vty),
2248 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2249 }
2250 \f
2251 DEFUN (no_neighbor_nexthop_local_unchanged,
2252 no_neighbor_nexthop_local_unchanged_cmd,
2253 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
2254 NO_STR
2255 NEIGHBOR_STR
2256 NEIGHBOR_ADDR_STR2
2257 "Configure treatment of outgoing link-local-nexthop attribute\n"
2258 "Leave link-local nexthop unchanged for this peer\n")
2259 {
2260 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2261 bgp_node_safi (vty),
2262 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
2263 }
2264 \f
2265 DEFUN (neighbor_attr_unchanged,
2266 neighbor_attr_unchanged_cmd,
2267 NEIGHBOR_CMD2 "attribute-unchanged",
2268 NEIGHBOR_STR
2269 NEIGHBOR_ADDR_STR2
2270 "BGP attribute is propagated unchanged to this neighbor\n")
2271 {
2272 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2273 bgp_node_safi (vty),
2274 (PEER_FLAG_AS_PATH_UNCHANGED |
2275 PEER_FLAG_NEXTHOP_UNCHANGED |
2276 PEER_FLAG_MED_UNCHANGED));
2277 }
2278
2279 DEFUN (neighbor_attr_unchanged1,
2280 neighbor_attr_unchanged1_cmd,
2281 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2282 NEIGHBOR_STR
2283 NEIGHBOR_ADDR_STR2
2284 "BGP attribute is propagated unchanged to this neighbor\n"
2285 "As-path attribute\n"
2286 "Nexthop attribute\n"
2287 "Med attribute\n")
2288 {
2289 u_int16_t flags = 0;
2290
2291 if (strncmp (argv[1], "as-path", 1) == 0)
2292 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2293 else if (strncmp (argv[1], "next-hop", 1) == 0)
2294 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2295 else if (strncmp (argv[1], "med", 1) == 0)
2296 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2297
2298 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2299 bgp_node_safi (vty), flags);
2300 }
2301
2302 DEFUN (neighbor_attr_unchanged2,
2303 neighbor_attr_unchanged2_cmd,
2304 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2305 NEIGHBOR_STR
2306 NEIGHBOR_ADDR_STR2
2307 "BGP attribute is propagated unchanged to this neighbor\n"
2308 "As-path attribute\n"
2309 "Nexthop attribute\n"
2310 "Med attribute\n")
2311 {
2312 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2313
2314 if (strncmp (argv[1], "next-hop", 1) == 0)
2315 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2316 else if (strncmp (argv[1], "med", 1) == 0)
2317 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2318
2319 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2320 bgp_node_safi (vty), flags);
2321
2322 }
2323
2324 DEFUN (neighbor_attr_unchanged3,
2325 neighbor_attr_unchanged3_cmd,
2326 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2327 NEIGHBOR_STR
2328 NEIGHBOR_ADDR_STR2
2329 "BGP attribute is propagated unchanged to this neighbor\n"
2330 "Nexthop attribute\n"
2331 "As-path attribute\n"
2332 "Med attribute\n")
2333 {
2334 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2335
2336 if (strncmp (argv[1], "as-path", 1) == 0)
2337 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2338 else if (strncmp (argv[1], "med", 1) == 0)
2339 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2340
2341 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2342 bgp_node_safi (vty), flags);
2343 }
2344
2345 DEFUN (neighbor_attr_unchanged4,
2346 neighbor_attr_unchanged4_cmd,
2347 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2348 NEIGHBOR_STR
2349 NEIGHBOR_ADDR_STR2
2350 "BGP attribute is propagated unchanged to this neighbor\n"
2351 "Med attribute\n"
2352 "As-path attribute\n"
2353 "Nexthop attribute\n")
2354 {
2355 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2356
2357 if (strncmp (argv[1], "as-path", 1) == 0)
2358 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2359 else if (strncmp (argv[1], "next-hop", 1) == 0)
2360 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2361
2362 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2363 bgp_node_safi (vty), flags);
2364 }
2365
2366 ALIAS (neighbor_attr_unchanged,
2367 neighbor_attr_unchanged5_cmd,
2368 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2369 NEIGHBOR_STR
2370 NEIGHBOR_ADDR_STR2
2371 "BGP attribute is propagated unchanged to this neighbor\n"
2372 "As-path attribute\n"
2373 "Nexthop attribute\n"
2374 "Med attribute\n")
2375
2376 ALIAS (neighbor_attr_unchanged,
2377 neighbor_attr_unchanged6_cmd,
2378 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2379 NEIGHBOR_STR
2380 NEIGHBOR_ADDR_STR2
2381 "BGP attribute is propagated unchanged to this neighbor\n"
2382 "As-path attribute\n"
2383 "Med attribute\n"
2384 "Nexthop attribute\n")
2385
2386 ALIAS (neighbor_attr_unchanged,
2387 neighbor_attr_unchanged7_cmd,
2388 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2389 NEIGHBOR_STR
2390 NEIGHBOR_ADDR_STR2
2391 "BGP attribute is propagated unchanged to this neighbor\n"
2392 "Nexthop attribute\n"
2393 "Med attribute\n"
2394 "As-path attribute\n")
2395
2396 ALIAS (neighbor_attr_unchanged,
2397 neighbor_attr_unchanged8_cmd,
2398 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2399 NEIGHBOR_STR
2400 NEIGHBOR_ADDR_STR2
2401 "BGP attribute is propagated unchanged to this neighbor\n"
2402 "Nexthop attribute\n"
2403 "As-path attribute\n"
2404 "Med attribute\n")
2405
2406 ALIAS (neighbor_attr_unchanged,
2407 neighbor_attr_unchanged9_cmd,
2408 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2409 NEIGHBOR_STR
2410 NEIGHBOR_ADDR_STR2
2411 "BGP attribute is propagated unchanged to this neighbor\n"
2412 "Med attribute\n"
2413 "Nexthop attribute\n"
2414 "As-path attribute\n")
2415
2416 ALIAS (neighbor_attr_unchanged,
2417 neighbor_attr_unchanged10_cmd,
2418 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2419 NEIGHBOR_STR
2420 NEIGHBOR_ADDR_STR2
2421 "BGP attribute is propagated unchanged to this neighbor\n"
2422 "Med attribute\n"
2423 "As-path attribute\n"
2424 "Nexthop attribute\n")
2425
2426 DEFUN (no_neighbor_attr_unchanged,
2427 no_neighbor_attr_unchanged_cmd,
2428 NO_NEIGHBOR_CMD2 "attribute-unchanged",
2429 NO_STR
2430 NEIGHBOR_STR
2431 NEIGHBOR_ADDR_STR2
2432 "BGP attribute is propagated unchanged to this neighbor\n")
2433 {
2434 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2435 bgp_node_safi (vty),
2436 (PEER_FLAG_AS_PATH_UNCHANGED |
2437 PEER_FLAG_NEXTHOP_UNCHANGED |
2438 PEER_FLAG_MED_UNCHANGED));
2439 }
2440
2441 DEFUN (no_neighbor_attr_unchanged1,
2442 no_neighbor_attr_unchanged1_cmd,
2443 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
2444 NO_STR
2445 NEIGHBOR_STR
2446 NEIGHBOR_ADDR_STR2
2447 "BGP attribute is propagated unchanged to this neighbor\n"
2448 "As-path attribute\n"
2449 "Nexthop attribute\n"
2450 "Med attribute\n")
2451 {
2452 u_int16_t flags = 0;
2453
2454 if (strncmp (argv[1], "as-path", 1) == 0)
2455 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2456 else if (strncmp (argv[1], "next-hop", 1) == 0)
2457 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2458 else if (strncmp (argv[1], "med", 1) == 0)
2459 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2460
2461 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2462 bgp_node_safi (vty), flags);
2463 }
2464
2465 DEFUN (no_neighbor_attr_unchanged2,
2466 no_neighbor_attr_unchanged2_cmd,
2467 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
2468 NO_STR
2469 NEIGHBOR_STR
2470 NEIGHBOR_ADDR_STR2
2471 "BGP attribute is propagated unchanged to this neighbor\n"
2472 "As-path attribute\n"
2473 "Nexthop attribute\n"
2474 "Med attribute\n")
2475 {
2476 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
2477
2478 if (strncmp (argv[1], "next-hop", 1) == 0)
2479 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2480 else if (strncmp (argv[1], "med", 1) == 0)
2481 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2482
2483 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2484 bgp_node_safi (vty), flags);
2485 }
2486
2487 DEFUN (no_neighbor_attr_unchanged3,
2488 no_neighbor_attr_unchanged3_cmd,
2489 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
2490 NO_STR
2491 NEIGHBOR_STR
2492 NEIGHBOR_ADDR_STR2
2493 "BGP attribute is propagated unchanged to this neighbor\n"
2494 "Nexthop attribute\n"
2495 "As-path attribute\n"
2496 "Med attribute\n")
2497 {
2498 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
2499
2500 if (strncmp (argv[1], "as-path", 1) == 0)
2501 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2502 else if (strncmp (argv[1], "med", 1) == 0)
2503 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
2504
2505 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2506 bgp_node_safi (vty), flags);
2507 }
2508
2509 DEFUN (no_neighbor_attr_unchanged4,
2510 no_neighbor_attr_unchanged4_cmd,
2511 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
2512 NO_STR
2513 NEIGHBOR_STR
2514 NEIGHBOR_ADDR_STR2
2515 "BGP attribute is propagated unchanged to this neighbor\n"
2516 "Med attribute\n"
2517 "As-path attribute\n"
2518 "Nexthop attribute\n")
2519 {
2520 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
2521
2522 if (strncmp (argv[1], "as-path", 1) == 0)
2523 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
2524 else if (strncmp (argv[1], "next-hop", 1) == 0)
2525 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
2526
2527 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
2528 bgp_node_safi (vty), flags);
2529 }
2530
2531 ALIAS (no_neighbor_attr_unchanged,
2532 no_neighbor_attr_unchanged5_cmd,
2533 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
2534 NO_STR
2535 NEIGHBOR_STR
2536 NEIGHBOR_ADDR_STR2
2537 "BGP attribute is propagated unchanged to this neighbor\n"
2538 "As-path attribute\n"
2539 "Nexthop attribute\n"
2540 "Med attribute\n")
2541
2542 ALIAS (no_neighbor_attr_unchanged,
2543 no_neighbor_attr_unchanged6_cmd,
2544 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
2545 NO_STR
2546 NEIGHBOR_STR
2547 NEIGHBOR_ADDR_STR2
2548 "BGP attribute is propagated unchanged to this neighbor\n"
2549 "As-path attribute\n"
2550 "Med attribute\n"
2551 "Nexthop attribute\n")
2552
2553 ALIAS (no_neighbor_attr_unchanged,
2554 no_neighbor_attr_unchanged7_cmd,
2555 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
2556 NO_STR
2557 NEIGHBOR_STR
2558 NEIGHBOR_ADDR_STR2
2559 "BGP attribute is propagated unchanged to this neighbor\n"
2560 "Nexthop attribute\n"
2561 "Med attribute\n"
2562 "As-path attribute\n")
2563
2564 ALIAS (no_neighbor_attr_unchanged,
2565 no_neighbor_attr_unchanged8_cmd,
2566 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
2567 NO_STR
2568 NEIGHBOR_STR
2569 NEIGHBOR_ADDR_STR2
2570 "BGP attribute is propagated unchanged to this neighbor\n"
2571 "Nexthop attribute\n"
2572 "As-path attribute\n"
2573 "Med attribute\n")
2574
2575 ALIAS (no_neighbor_attr_unchanged,
2576 no_neighbor_attr_unchanged9_cmd,
2577 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
2578 NO_STR
2579 NEIGHBOR_STR
2580 NEIGHBOR_ADDR_STR2
2581 "BGP attribute is propagated unchanged to this neighbor\n"
2582 "Med attribute\n"
2583 "Nexthop attribute\n"
2584 "As-path attribute\n")
2585
2586 ALIAS (no_neighbor_attr_unchanged,
2587 no_neighbor_attr_unchanged10_cmd,
2588 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
2589 NO_STR
2590 NEIGHBOR_STR
2591 NEIGHBOR_ADDR_STR2
2592 "BGP attribute is propagated unchanged to this neighbor\n"
2593 "Med attribute\n"
2594 "As-path attribute\n"
2595 "Nexthop attribute\n")
2596
2597 /* For old version Zebra compatibility. */
2598 DEFUN_DEPRECATED (neighbor_transparent_as,
2599 neighbor_transparent_as_cmd,
2600 NEIGHBOR_CMD "transparent-as",
2601 NEIGHBOR_STR
2602 NEIGHBOR_ADDR_STR
2603 "Do not append my AS number even peer is EBGP peer\n")
2604 {
2605 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2606 bgp_node_safi (vty),
2607 PEER_FLAG_AS_PATH_UNCHANGED);
2608 }
2609
2610 DEFUN_DEPRECATED (neighbor_transparent_nexthop,
2611 neighbor_transparent_nexthop_cmd,
2612 NEIGHBOR_CMD "transparent-nexthop",
2613 NEIGHBOR_STR
2614 NEIGHBOR_ADDR_STR
2615 "Do not change nexthop even peer is EBGP peer\n")
2616 {
2617 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
2618 bgp_node_safi (vty),
2619 PEER_FLAG_NEXTHOP_UNCHANGED);
2620 }
2621 \f
2622 /* EBGP multihop configuration. */
2623 static int
2624 peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
2625 const char *ttl_str)
2626 {
2627 struct peer *peer;
2628 unsigned int ttl;
2629
2630 peer = peer_and_group_lookup_vty (vty, ip_str);
2631 if (! peer)
2632 return CMD_WARNING;
2633
2634 if (! ttl_str)
2635 ttl = TTL_MAX;
2636 else
2637 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
2638
2639 peer_ebgp_multihop_set (peer, ttl);
2640
2641 return CMD_SUCCESS;
2642 }
2643
2644 static int
2645 peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
2646 {
2647 struct peer *peer;
2648
2649 peer = peer_and_group_lookup_vty (vty, ip_str);
2650 if (! peer)
2651 return CMD_WARNING;
2652
2653 peer_ebgp_multihop_unset (peer);
2654
2655 return CMD_SUCCESS;
2656 }
2657
2658 /* neighbor ebgp-multihop. */
2659 DEFUN (neighbor_ebgp_multihop,
2660 neighbor_ebgp_multihop_cmd,
2661 NEIGHBOR_CMD2 "ebgp-multihop",
2662 NEIGHBOR_STR
2663 NEIGHBOR_ADDR_STR2
2664 "Allow EBGP neighbors not on directly connected networks\n")
2665 {
2666 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
2667 }
2668
2669 DEFUN (neighbor_ebgp_multihop_ttl,
2670 neighbor_ebgp_multihop_ttl_cmd,
2671 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2672 NEIGHBOR_STR
2673 NEIGHBOR_ADDR_STR2
2674 "Allow EBGP neighbors not on directly connected networks\n"
2675 "maximum hop count\n")
2676 {
2677 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
2678 }
2679
2680 DEFUN (no_neighbor_ebgp_multihop,
2681 no_neighbor_ebgp_multihop_cmd,
2682 NO_NEIGHBOR_CMD2 "ebgp-multihop",
2683 NO_STR
2684 NEIGHBOR_STR
2685 NEIGHBOR_ADDR_STR2
2686 "Allow EBGP neighbors not on directly connected networks\n")
2687 {
2688 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
2689 }
2690
2691 ALIAS (no_neighbor_ebgp_multihop,
2692 no_neighbor_ebgp_multihop_ttl_cmd,
2693 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
2694 NO_STR
2695 NEIGHBOR_STR
2696 NEIGHBOR_ADDR_STR2
2697 "Allow EBGP neighbors not on directly connected networks\n"
2698 "maximum hop count\n")
2699 \f
2700 /* disable-connected-check */
2701 DEFUN (neighbor_disable_connected_check,
2702 neighbor_disable_connected_check_cmd,
2703 NEIGHBOR_CMD2 "disable-connected-check",
2704 NEIGHBOR_STR
2705 NEIGHBOR_ADDR_STR2
2706 "one-hop away EBGP peer using loopback address\n")
2707 {
2708 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2709 }
2710
2711 DEFUN (no_neighbor_disable_connected_check,
2712 no_neighbor_disable_connected_check_cmd,
2713 NO_NEIGHBOR_CMD2 "disable-connected-check",
2714 NO_STR
2715 NEIGHBOR_STR
2716 NEIGHBOR_ADDR_STR2
2717 "one-hop away EBGP peer using loopback address\n")
2718 {
2719 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
2720 }
2721
2722 /* Enforce multihop. */
2723 ALIAS (neighbor_disable_connected_check,
2724 neighbor_enforce_multihop_cmd,
2725 NEIGHBOR_CMD2 "enforce-multihop",
2726 NEIGHBOR_STR
2727 NEIGHBOR_ADDR_STR2
2728 "Enforce EBGP neighbors perform multihop\n")
2729
2730 /* Enforce multihop. */
2731 ALIAS (no_neighbor_disable_connected_check,
2732 no_neighbor_enforce_multihop_cmd,
2733 NO_NEIGHBOR_CMD2 "enforce-multihop",
2734 NO_STR
2735 NEIGHBOR_STR
2736 NEIGHBOR_ADDR_STR2
2737 "Enforce EBGP neighbors perform multihop\n")
2738 \f
2739 DEFUN (neighbor_description,
2740 neighbor_description_cmd,
2741 NEIGHBOR_CMD2 "description .LINE",
2742 NEIGHBOR_STR
2743 NEIGHBOR_ADDR_STR2
2744 "Neighbor specific description\n"
2745 "Up to 80 characters describing this neighbor\n")
2746 {
2747 struct peer *peer;
2748 char *str;
2749
2750 peer = peer_and_group_lookup_vty (vty, argv[0]);
2751 if (! peer)
2752 return CMD_WARNING;
2753
2754 if (argc == 1)
2755 return CMD_SUCCESS;
2756
2757 str = argv_concat(argv, argc, 1);
2758
2759 peer_description_set (peer, str);
2760
2761 XFREE (MTYPE_TMP, str);
2762
2763 return CMD_SUCCESS;
2764 }
2765
2766 DEFUN (no_neighbor_description,
2767 no_neighbor_description_cmd,
2768 NO_NEIGHBOR_CMD2 "description",
2769 NO_STR
2770 NEIGHBOR_STR
2771 NEIGHBOR_ADDR_STR2
2772 "Neighbor specific description\n")
2773 {
2774 struct peer *peer;
2775
2776 peer = peer_and_group_lookup_vty (vty, argv[0]);
2777 if (! peer)
2778 return CMD_WARNING;
2779
2780 peer_description_unset (peer);
2781
2782 return CMD_SUCCESS;
2783 }
2784
2785 ALIAS (no_neighbor_description,
2786 no_neighbor_description_val_cmd,
2787 NO_NEIGHBOR_CMD2 "description .LINE",
2788 NO_STR
2789 NEIGHBOR_STR
2790 NEIGHBOR_ADDR_STR2
2791 "Neighbor specific description\n"
2792 "Up to 80 characters describing this neighbor\n")
2793 \f
2794 /* Neighbor update-source. */
2795 static int
2796 peer_update_source_vty (struct vty *vty, const char *peer_str,
2797 const char *source_str)
2798 {
2799 struct peer *peer;
2800 union sockunion *su;
2801
2802 peer = peer_and_group_lookup_vty (vty, peer_str);
2803 if (! peer)
2804 return CMD_WARNING;
2805
2806 if (source_str)
2807 {
2808 su = sockunion_str2su (source_str);
2809 if (su)
2810 {
2811 peer_update_source_addr_set (peer, su);
2812 sockunion_free (su);
2813 }
2814 else
2815 peer_update_source_if_set (peer, source_str);
2816 }
2817 else
2818 peer_update_source_unset (peer);
2819
2820 return CMD_SUCCESS;
2821 }
2822
2823 #define BGP_UPDATE_SOURCE_STR "(A.B.C.D|X:X::X:X)"
2824 #define BGP_UPDATE_SOURCE_HELP_STR \
2825 "IPv4 address\n" \
2826 "IPv6 address\n"
2827
2828 DEFUN (neighbor_update_source,
2829 neighbor_update_source_cmd,
2830 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_STR,
2831 NEIGHBOR_STR
2832 NEIGHBOR_ADDR_STR2
2833 "Source of routing updates\n"
2834 BGP_UPDATE_SOURCE_HELP_STR)
2835 {
2836 return peer_update_source_vty (vty, argv[0], argv[1]);
2837 }
2838
2839 DEFUN (no_neighbor_update_source,
2840 no_neighbor_update_source_cmd,
2841 NO_NEIGHBOR_CMD2 "update-source",
2842 NO_STR
2843 NEIGHBOR_STR
2844 NEIGHBOR_ADDR_STR2
2845 "Source of routing updates\n")
2846 {
2847 return peer_update_source_vty (vty, argv[0], NULL);
2848 }
2849 \f
2850 static int
2851 peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
2852 afi_t afi, safi_t safi,
2853 const char *rmap, int set)
2854 {
2855 int ret;
2856 struct peer *peer;
2857
2858 peer = peer_and_group_lookup_vty (vty, peer_str);
2859 if (! peer)
2860 return CMD_WARNING;
2861
2862 if (set)
2863 ret = peer_default_originate_set (peer, afi, safi, rmap);
2864 else
2865 ret = peer_default_originate_unset (peer, afi, safi);
2866
2867 return bgp_vty_return (vty, ret);
2868 }
2869
2870 /* neighbor default-originate. */
2871 DEFUN (neighbor_default_originate,
2872 neighbor_default_originate_cmd,
2873 NEIGHBOR_CMD2 "default-originate",
2874 NEIGHBOR_STR
2875 NEIGHBOR_ADDR_STR2
2876 "Originate default route to this neighbor\n")
2877 {
2878 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2879 bgp_node_safi (vty), NULL, 1);
2880 }
2881
2882 DEFUN (neighbor_default_originate_rmap,
2883 neighbor_default_originate_rmap_cmd,
2884 NEIGHBOR_CMD2 "default-originate route-map WORD",
2885 NEIGHBOR_STR
2886 NEIGHBOR_ADDR_STR2
2887 "Originate default route to this neighbor\n"
2888 "Route-map to specify criteria to originate default\n"
2889 "route-map name\n")
2890 {
2891 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2892 bgp_node_safi (vty), argv[1], 1);
2893 }
2894
2895 DEFUN (no_neighbor_default_originate,
2896 no_neighbor_default_originate_cmd,
2897 NO_NEIGHBOR_CMD2 "default-originate",
2898 NO_STR
2899 NEIGHBOR_STR
2900 NEIGHBOR_ADDR_STR2
2901 "Originate default route to this neighbor\n")
2902 {
2903 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
2904 bgp_node_safi (vty), NULL, 0);
2905 }
2906
2907 ALIAS (no_neighbor_default_originate,
2908 no_neighbor_default_originate_rmap_cmd,
2909 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
2910 NO_STR
2911 NEIGHBOR_STR
2912 NEIGHBOR_ADDR_STR2
2913 "Originate default route to this neighbor\n"
2914 "Route-map to specify criteria to originate default\n"
2915 "route-map name\n")
2916 \f
2917 /* Set neighbor's BGP port. */
2918 static int
2919 peer_port_vty (struct vty *vty, const char *ip_str, int afi,
2920 const char *port_str)
2921 {
2922 struct peer *peer;
2923 u_int16_t port;
2924 struct servent *sp;
2925
2926 peer = peer_lookup_vty (vty, ip_str);
2927 if (! peer)
2928 return CMD_WARNING;
2929
2930 if (! port_str)
2931 {
2932 sp = getservbyname ("bgp", "tcp");
2933 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
2934 }
2935 else
2936 {
2937 VTY_GET_INTEGER("port", port, port_str);
2938 }
2939
2940 peer_port_set (peer, port);
2941
2942 return CMD_SUCCESS;
2943 }
2944
2945 /* Set specified peer's BGP port. */
2946 DEFUN (neighbor_port,
2947 neighbor_port_cmd,
2948 NEIGHBOR_CMD "port <0-65535>",
2949 NEIGHBOR_STR
2950 NEIGHBOR_ADDR_STR
2951 "Neighbor's BGP port\n"
2952 "TCP port number\n")
2953 {
2954 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
2955 }
2956
2957 DEFUN (no_neighbor_port,
2958 no_neighbor_port_cmd,
2959 NO_NEIGHBOR_CMD "port",
2960 NO_STR
2961 NEIGHBOR_STR
2962 NEIGHBOR_ADDR_STR
2963 "Neighbor's BGP port\n")
2964 {
2965 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
2966 }
2967
2968 ALIAS (no_neighbor_port,
2969 no_neighbor_port_val_cmd,
2970 NO_NEIGHBOR_CMD "port <0-65535>",
2971 NO_STR
2972 NEIGHBOR_STR
2973 NEIGHBOR_ADDR_STR
2974 "Neighbor's BGP port\n"
2975 "TCP port number\n")
2976 \f
2977 /* neighbor weight. */
2978 static int
2979 peer_weight_set_vty (struct vty *vty, const char *ip_str,
2980 const char *weight_str)
2981 {
2982 int ret;
2983 struct peer *peer;
2984 unsigned long weight;
2985
2986 peer = peer_and_group_lookup_vty (vty, ip_str);
2987 if (! peer)
2988 return CMD_WARNING;
2989
2990 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
2991
2992 ret = peer_weight_set (peer, weight);
2993
2994 return CMD_SUCCESS;
2995 }
2996
2997 static int
2998 peer_weight_unset_vty (struct vty *vty, const char *ip_str)
2999 {
3000 struct peer *peer;
3001
3002 peer = peer_and_group_lookup_vty (vty, ip_str);
3003 if (! peer)
3004 return CMD_WARNING;
3005
3006 peer_weight_unset (peer);
3007
3008 return CMD_SUCCESS;
3009 }
3010
3011 DEFUN (neighbor_weight,
3012 neighbor_weight_cmd,
3013 NEIGHBOR_CMD2 "weight <0-65535>",
3014 NEIGHBOR_STR
3015 NEIGHBOR_ADDR_STR2
3016 "Set default weight for routes from this neighbor\n"
3017 "default weight\n")
3018 {
3019 return peer_weight_set_vty (vty, argv[0], argv[1]);
3020 }
3021
3022 DEFUN (no_neighbor_weight,
3023 no_neighbor_weight_cmd,
3024 NO_NEIGHBOR_CMD2 "weight",
3025 NO_STR
3026 NEIGHBOR_STR
3027 NEIGHBOR_ADDR_STR2
3028 "Set default weight for routes from this neighbor\n")
3029 {
3030 return peer_weight_unset_vty (vty, argv[0]);
3031 }
3032
3033 ALIAS (no_neighbor_weight,
3034 no_neighbor_weight_val_cmd,
3035 NO_NEIGHBOR_CMD2 "weight <0-65535>",
3036 NO_STR
3037 NEIGHBOR_STR
3038 NEIGHBOR_ADDR_STR2
3039 "Set default weight for routes from this neighbor\n"
3040 "default weight\n")
3041 \f
3042 /* Override capability negotiation. */
3043 DEFUN (neighbor_override_capability,
3044 neighbor_override_capability_cmd,
3045 NEIGHBOR_CMD2 "override-capability",
3046 NEIGHBOR_STR
3047 NEIGHBOR_ADDR_STR2
3048 "Override capability negotiation result\n")
3049 {
3050 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3051 }
3052
3053 DEFUN (no_neighbor_override_capability,
3054 no_neighbor_override_capability_cmd,
3055 NO_NEIGHBOR_CMD2 "override-capability",
3056 NO_STR
3057 NEIGHBOR_STR
3058 NEIGHBOR_ADDR_STR2
3059 "Override capability negotiation result\n")
3060 {
3061 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
3062 }
3063 \f
3064 DEFUN (neighbor_strict_capability,
3065 neighbor_strict_capability_cmd,
3066 NEIGHBOR_CMD "strict-capability-match",
3067 NEIGHBOR_STR
3068 NEIGHBOR_ADDR_STR
3069 "Strict capability negotiation match\n")
3070 {
3071 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3072 }
3073
3074 DEFUN (no_neighbor_strict_capability,
3075 no_neighbor_strict_capability_cmd,
3076 NO_NEIGHBOR_CMD "strict-capability-match",
3077 NO_STR
3078 NEIGHBOR_STR
3079 NEIGHBOR_ADDR_STR
3080 "Strict capability negotiation match\n")
3081 {
3082 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
3083 }
3084 \f
3085 static int
3086 peer_timers_set_vty (struct vty *vty, const char *ip_str,
3087 const char *keep_str, const char *hold_str)
3088 {
3089 int ret;
3090 struct peer *peer;
3091 u_int32_t keepalive;
3092 u_int32_t holdtime;
3093
3094 peer = peer_and_group_lookup_vty (vty, ip_str);
3095 if (! peer)
3096 return CMD_WARNING;
3097
3098 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
3099 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
3100
3101 ret = peer_timers_set (peer, keepalive, holdtime);
3102
3103 return bgp_vty_return (vty, ret);
3104 }
3105 \f
3106 static int
3107 peer_timers_unset_vty (struct vty *vty, const char *ip_str)
3108 {
3109 int ret;
3110 struct peer *peer;
3111
3112 peer = peer_lookup_vty (vty, ip_str);
3113 if (! peer)
3114 return CMD_WARNING;
3115
3116 ret = peer_timers_unset (peer);
3117
3118 return bgp_vty_return (vty, ret);
3119 }
3120
3121 DEFUN (neighbor_timers,
3122 neighbor_timers_cmd,
3123 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
3124 NEIGHBOR_STR
3125 NEIGHBOR_ADDR_STR2
3126 "BGP per neighbor timers\n"
3127 "Keepalive interval\n"
3128 "Holdtime\n")
3129 {
3130 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
3131 }
3132
3133 DEFUN (no_neighbor_timers,
3134 no_neighbor_timers_cmd,
3135 NO_NEIGHBOR_CMD2 "timers",
3136 NO_STR
3137 NEIGHBOR_STR
3138 NEIGHBOR_ADDR_STR2
3139 "BGP per neighbor timers\n")
3140 {
3141 return peer_timers_unset_vty (vty, argv[0]);
3142 }
3143 \f
3144 static int
3145 peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
3146 const char *time_str)
3147 {
3148 int ret;
3149 struct peer *peer;
3150 u_int32_t connect;
3151
3152 peer = peer_lookup_vty (vty, ip_str);
3153 if (! peer)
3154 return CMD_WARNING;
3155
3156 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
3157
3158 ret = peer_timers_connect_set (peer, connect);
3159
3160 return CMD_SUCCESS;
3161 }
3162
3163 static int
3164 peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
3165 {
3166 int ret;
3167 struct peer *peer;
3168
3169 peer = peer_and_group_lookup_vty (vty, ip_str);
3170 if (! peer)
3171 return CMD_WARNING;
3172
3173 ret = peer_timers_connect_unset (peer);
3174
3175 return CMD_SUCCESS;
3176 }
3177
3178 DEFUN (neighbor_timers_connect,
3179 neighbor_timers_connect_cmd,
3180 NEIGHBOR_CMD "timers connect <0-65535>",
3181 NEIGHBOR_STR
3182 NEIGHBOR_ADDR_STR
3183 "BGP per neighbor timers\n"
3184 "BGP connect timer\n"
3185 "Connect timer\n")
3186 {
3187 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
3188 }
3189
3190 DEFUN (no_neighbor_timers_connect,
3191 no_neighbor_timers_connect_cmd,
3192 NO_NEIGHBOR_CMD "timers connect",
3193 NO_STR
3194 NEIGHBOR_STR
3195 NEIGHBOR_ADDR_STR
3196 "BGP per neighbor timers\n"
3197 "BGP connect timer\n")
3198 {
3199 return peer_timers_connect_unset_vty (vty, argv[0]);
3200 }
3201
3202 ALIAS (no_neighbor_timers_connect,
3203 no_neighbor_timers_connect_val_cmd,
3204 NO_NEIGHBOR_CMD "timers connect <0-65535>",
3205 NO_STR
3206 NEIGHBOR_STR
3207 NEIGHBOR_ADDR_STR
3208 "BGP per neighbor timers\n"
3209 "BGP connect timer\n"
3210 "Connect timer\n")
3211 \f
3212 static int
3213 peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
3214 const char *time_str, int set)
3215 {
3216 int ret;
3217 struct peer *peer;
3218 u_int32_t routeadv = 0;
3219
3220 peer = peer_lookup_vty (vty, ip_str);
3221 if (! peer)
3222 return CMD_WARNING;
3223
3224 if (time_str)
3225 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
3226
3227 if (set)
3228 ret = peer_advertise_interval_set (peer, routeadv);
3229 else
3230 ret = peer_advertise_interval_unset (peer);
3231
3232 return CMD_SUCCESS;
3233 }
3234
3235 DEFUN (neighbor_advertise_interval,
3236 neighbor_advertise_interval_cmd,
3237 NEIGHBOR_CMD "advertisement-interval <0-600>",
3238 NEIGHBOR_STR
3239 NEIGHBOR_ADDR_STR
3240 "Minimum interval between sending BGP routing updates\n"
3241 "time in seconds\n")
3242 {
3243 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
3244 }
3245
3246 DEFUN (no_neighbor_advertise_interval,
3247 no_neighbor_advertise_interval_cmd,
3248 NO_NEIGHBOR_CMD "advertisement-interval",
3249 NO_STR
3250 NEIGHBOR_STR
3251 NEIGHBOR_ADDR_STR
3252 "Minimum interval between sending BGP routing updates\n")
3253 {
3254 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
3255 }
3256
3257 ALIAS (no_neighbor_advertise_interval,
3258 no_neighbor_advertise_interval_val_cmd,
3259 NO_NEIGHBOR_CMD "advertisement-interval <0-600>",
3260 NO_STR
3261 NEIGHBOR_STR
3262 NEIGHBOR_ADDR_STR
3263 "Minimum interval between sending BGP routing updates\n"
3264 "time in seconds\n")
3265 \f
3266 /* neighbor interface */
3267 static int
3268 peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
3269 {
3270 int ret;
3271 struct peer *peer;
3272
3273 peer = peer_lookup_vty (vty, ip_str);
3274 if (! peer)
3275 return CMD_WARNING;
3276
3277 if (str)
3278 ret = peer_interface_set (peer, str);
3279 else
3280 ret = peer_interface_unset (peer);
3281
3282 return CMD_SUCCESS;
3283 }
3284
3285 DEFUN (neighbor_interface,
3286 neighbor_interface_cmd,
3287 NEIGHBOR_CMD "interface WORD",
3288 NEIGHBOR_STR
3289 NEIGHBOR_ADDR_STR
3290 "Interface\n"
3291 "Interface name\n")
3292 {
3293 return peer_interface_vty (vty, argv[0], argv[1]);
3294 }
3295
3296 DEFUN (no_neighbor_interface,
3297 no_neighbor_interface_cmd,
3298 NO_NEIGHBOR_CMD "interface WORD",
3299 NO_STR
3300 NEIGHBOR_STR
3301 NEIGHBOR_ADDR_STR
3302 "Interface\n"
3303 "Interface name\n")
3304 {
3305 return peer_interface_vty (vty, argv[0], NULL);
3306 }
3307 \f
3308 /* Set distribute list to the peer. */
3309 static int
3310 peer_distribute_set_vty (struct vty *vty, const char *ip_str,
3311 afi_t afi, safi_t safi,
3312 const char *name_str, const char *direct_str)
3313 {
3314 int ret;
3315 struct peer *peer;
3316 int direct = FILTER_IN;
3317
3318 peer = peer_and_group_lookup_vty (vty, ip_str);
3319 if (! peer)
3320 return CMD_WARNING;
3321
3322 /* Check filter direction. */
3323 if (strncmp (direct_str, "i", 1) == 0)
3324 direct = FILTER_IN;
3325 else if (strncmp (direct_str, "o", 1) == 0)
3326 direct = FILTER_OUT;
3327
3328 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
3329
3330 return bgp_vty_return (vty, ret);
3331 }
3332
3333 static int
3334 peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3335 safi_t safi, const char *direct_str)
3336 {
3337 int ret;
3338 struct peer *peer;
3339 int direct = FILTER_IN;
3340
3341 peer = peer_and_group_lookup_vty (vty, ip_str);
3342 if (! peer)
3343 return CMD_WARNING;
3344
3345 /* Check filter direction. */
3346 if (strncmp (direct_str, "i", 1) == 0)
3347 direct = FILTER_IN;
3348 else if (strncmp (direct_str, "o", 1) == 0)
3349 direct = FILTER_OUT;
3350
3351 ret = peer_distribute_unset (peer, afi, safi, direct);
3352
3353 return bgp_vty_return (vty, ret);
3354 }
3355
3356 DEFUN (neighbor_distribute_list,
3357 neighbor_distribute_list_cmd,
3358 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3359 NEIGHBOR_STR
3360 NEIGHBOR_ADDR_STR2
3361 "Filter updates to/from this neighbor\n"
3362 "IP access-list number\n"
3363 "IP access-list number (expanded range)\n"
3364 "IP Access-list name\n"
3365 "Filter incoming updates\n"
3366 "Filter outgoing updates\n")
3367 {
3368 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
3369 bgp_node_safi (vty), argv[1], argv[2]);
3370 }
3371
3372 DEFUN (no_neighbor_distribute_list,
3373 no_neighbor_distribute_list_cmd,
3374 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
3375 NO_STR
3376 NEIGHBOR_STR
3377 NEIGHBOR_ADDR_STR2
3378 "Filter updates to/from this neighbor\n"
3379 "IP access-list number\n"
3380 "IP access-list number (expanded range)\n"
3381 "IP Access-list name\n"
3382 "Filter incoming updates\n"
3383 "Filter outgoing updates\n")
3384 {
3385 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
3386 bgp_node_safi (vty), argv[2]);
3387 }
3388 \f
3389 /* Set prefix list to the peer. */
3390 static int
3391 peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3392 safi_t safi, const char *name_str,
3393 const char *direct_str)
3394 {
3395 int ret;
3396 struct peer *peer;
3397 int direct = FILTER_IN;
3398
3399 peer = peer_and_group_lookup_vty (vty, ip_str);
3400 if (! peer)
3401 return CMD_WARNING;
3402
3403 /* Check filter direction. */
3404 if (strncmp (direct_str, "i", 1) == 0)
3405 direct = FILTER_IN;
3406 else if (strncmp (direct_str, "o", 1) == 0)
3407 direct = FILTER_OUT;
3408
3409 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
3410
3411 return bgp_vty_return (vty, ret);
3412 }
3413
3414 static int
3415 peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3416 safi_t safi, const char *direct_str)
3417 {
3418 int ret;
3419 struct peer *peer;
3420 int direct = FILTER_IN;
3421
3422 peer = peer_and_group_lookup_vty (vty, ip_str);
3423 if (! peer)
3424 return CMD_WARNING;
3425
3426 /* Check filter direction. */
3427 if (strncmp (direct_str, "i", 1) == 0)
3428 direct = FILTER_IN;
3429 else if (strncmp (direct_str, "o", 1) == 0)
3430 direct = FILTER_OUT;
3431
3432 ret = peer_prefix_list_unset (peer, afi, safi, direct);
3433
3434 return bgp_vty_return (vty, ret);
3435 }
3436
3437 DEFUN (neighbor_prefix_list,
3438 neighbor_prefix_list_cmd,
3439 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3440 NEIGHBOR_STR
3441 NEIGHBOR_ADDR_STR2
3442 "Filter updates to/from this neighbor\n"
3443 "Name of a prefix list\n"
3444 "Filter incoming updates\n"
3445 "Filter outgoing updates\n")
3446 {
3447 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
3448 bgp_node_safi (vty), argv[1], argv[2]);
3449 }
3450
3451 DEFUN (no_neighbor_prefix_list,
3452 no_neighbor_prefix_list_cmd,
3453 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
3454 NO_STR
3455 NEIGHBOR_STR
3456 NEIGHBOR_ADDR_STR2
3457 "Filter updates to/from this neighbor\n"
3458 "Name of a prefix list\n"
3459 "Filter incoming updates\n"
3460 "Filter outgoing updates\n")
3461 {
3462 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
3463 bgp_node_safi (vty), argv[2]);
3464 }
3465 \f
3466 static int
3467 peer_aslist_set_vty (struct vty *vty, const char *ip_str,
3468 afi_t afi, safi_t safi,
3469 const char *name_str, const char *direct_str)
3470 {
3471 int ret;
3472 struct peer *peer;
3473 int direct = FILTER_IN;
3474
3475 peer = peer_and_group_lookup_vty (vty, ip_str);
3476 if (! peer)
3477 return CMD_WARNING;
3478
3479 /* Check filter direction. */
3480 if (strncmp (direct_str, "i", 1) == 0)
3481 direct = FILTER_IN;
3482 else if (strncmp (direct_str, "o", 1) == 0)
3483 direct = FILTER_OUT;
3484
3485 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
3486
3487 return bgp_vty_return (vty, ret);
3488 }
3489
3490 static int
3491 peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
3492 afi_t afi, safi_t safi,
3493 const char *direct_str)
3494 {
3495 int ret;
3496 struct peer *peer;
3497 int direct = FILTER_IN;
3498
3499 peer = peer_and_group_lookup_vty (vty, ip_str);
3500 if (! peer)
3501 return CMD_WARNING;
3502
3503 /* Check filter direction. */
3504 if (strncmp (direct_str, "i", 1) == 0)
3505 direct = FILTER_IN;
3506 else if (strncmp (direct_str, "o", 1) == 0)
3507 direct = FILTER_OUT;
3508
3509 ret = peer_aslist_unset (peer, afi, safi, direct);
3510
3511 return bgp_vty_return (vty, ret);
3512 }
3513
3514 DEFUN (neighbor_filter_list,
3515 neighbor_filter_list_cmd,
3516 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3517 NEIGHBOR_STR
3518 NEIGHBOR_ADDR_STR2
3519 "Establish BGP filters\n"
3520 "AS path access-list name\n"
3521 "Filter incoming routes\n"
3522 "Filter outgoing routes\n")
3523 {
3524 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
3525 bgp_node_safi (vty), argv[1], argv[2]);
3526 }
3527
3528 DEFUN (no_neighbor_filter_list,
3529 no_neighbor_filter_list_cmd,
3530 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
3531 NO_STR
3532 NEIGHBOR_STR
3533 NEIGHBOR_ADDR_STR2
3534 "Establish BGP filters\n"
3535 "AS path access-list name\n"
3536 "Filter incoming routes\n"
3537 "Filter outgoing routes\n")
3538 {
3539 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
3540 bgp_node_safi (vty), argv[2]);
3541 }
3542 \f
3543 /* Set route-map to the peer. */
3544 static int
3545 peer_route_map_set_vty (struct vty *vty, const char *ip_str,
3546 afi_t afi, safi_t safi,
3547 const char *name_str, const char *direct_str)
3548 {
3549 int ret;
3550 struct peer *peer;
3551 int direct = RMAP_IN;
3552
3553 peer = peer_and_group_lookup_vty (vty, ip_str);
3554 if (! peer)
3555 return CMD_WARNING;
3556
3557 /* Check filter direction. */
3558 if (strncmp (direct_str, "in", 2) == 0)
3559 direct = RMAP_IN;
3560 else if (strncmp (direct_str, "o", 1) == 0)
3561 direct = RMAP_OUT;
3562 else if (strncmp (direct_str, "im", 2) == 0)
3563 direct = RMAP_IMPORT;
3564 else if (strncmp (direct_str, "e", 1) == 0)
3565 direct = RMAP_EXPORT;
3566
3567 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
3568
3569 return bgp_vty_return (vty, ret);
3570 }
3571
3572 static int
3573 peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3574 safi_t safi, const char *direct_str)
3575 {
3576 int ret;
3577 struct peer *peer;
3578 int direct = RMAP_IN;
3579
3580 peer = peer_and_group_lookup_vty (vty, ip_str);
3581 if (! peer)
3582 return CMD_WARNING;
3583
3584 /* Check filter direction. */
3585 if (strncmp (direct_str, "in", 2) == 0)
3586 direct = RMAP_IN;
3587 else if (strncmp (direct_str, "o", 1) == 0)
3588 direct = RMAP_OUT;
3589 else if (strncmp (direct_str, "im", 2) == 0)
3590 direct = RMAP_IMPORT;
3591 else if (strncmp (direct_str, "e", 1) == 0)
3592 direct = RMAP_EXPORT;
3593
3594 ret = peer_route_map_unset (peer, afi, safi, direct);
3595
3596 return bgp_vty_return (vty, ret);
3597 }
3598
3599 DEFUN (neighbor_route_map,
3600 neighbor_route_map_cmd,
3601 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
3602 NEIGHBOR_STR
3603 NEIGHBOR_ADDR_STR2
3604 "Apply route map to neighbor\n"
3605 "Name of route map\n"
3606 "Apply map to incoming routes\n"
3607 "Apply map to outbound routes\n"
3608 "Apply map to routes going into a Route-Server client's table\n"
3609 "Apply map to routes coming from a Route-Server client")
3610 {
3611 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3612 bgp_node_safi (vty), argv[1], argv[2]);
3613 }
3614
3615 DEFUN (no_neighbor_route_map,
3616 no_neighbor_route_map_cmd,
3617 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
3618 NO_STR
3619 NEIGHBOR_STR
3620 NEIGHBOR_ADDR_STR2
3621 "Apply route map to neighbor\n"
3622 "Name of route map\n"
3623 "Apply map to incoming routes\n"
3624 "Apply map to outbound routes\n"
3625 "Apply map to routes going into a Route-Server client's table\n"
3626 "Apply map to routes coming from a Route-Server client")
3627 {
3628 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3629 bgp_node_safi (vty), argv[2]);
3630 }
3631 \f
3632 /* Set unsuppress-map to the peer. */
3633 static int
3634 peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3635 safi_t safi, const char *name_str)
3636 {
3637 int ret;
3638 struct peer *peer;
3639
3640 peer = peer_and_group_lookup_vty (vty, ip_str);
3641 if (! peer)
3642 return CMD_WARNING;
3643
3644 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
3645
3646 return bgp_vty_return (vty, ret);
3647 }
3648
3649 /* Unset route-map from the peer. */
3650 static int
3651 peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3652 safi_t safi)
3653 {
3654 int ret;
3655 struct peer *peer;
3656
3657 peer = peer_and_group_lookup_vty (vty, ip_str);
3658 if (! peer)
3659 return CMD_WARNING;
3660
3661 ret = peer_unsuppress_map_unset (peer, afi, safi);
3662
3663 return bgp_vty_return (vty, ret);
3664 }
3665
3666 DEFUN (neighbor_unsuppress_map,
3667 neighbor_unsuppress_map_cmd,
3668 NEIGHBOR_CMD2 "unsuppress-map WORD",
3669 NEIGHBOR_STR
3670 NEIGHBOR_ADDR_STR2
3671 "Route-map to selectively unsuppress suppressed routes\n"
3672 "Name of route map\n")
3673 {
3674 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
3675 bgp_node_safi (vty), argv[1]);
3676 }
3677
3678 DEFUN (no_neighbor_unsuppress_map,
3679 no_neighbor_unsuppress_map_cmd,
3680 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
3681 NO_STR
3682 NEIGHBOR_STR
3683 NEIGHBOR_ADDR_STR2
3684 "Route-map to selectively unsuppress suppressed routes\n"
3685 "Name of route map\n")
3686 {
3687 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
3688 bgp_node_safi (vty));
3689 }
3690 \f
3691 static int
3692 peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
3693 safi_t safi, const char *num_str,
3694 const char *threshold_str, int warning,
3695 const char *restart_str)
3696 {
3697 int ret;
3698 struct peer *peer;
3699 u_int32_t max;
3700 u_char threshold;
3701 u_int16_t restart;
3702
3703 peer = peer_and_group_lookup_vty (vty, ip_str);
3704 if (! peer)
3705 return CMD_WARNING;
3706
3707 VTY_GET_INTEGER ("maxmum number", max, num_str);
3708 if (threshold_str)
3709 threshold = atoi (threshold_str);
3710 else
3711 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
3712
3713 if (restart_str)
3714 restart = atoi (restart_str);
3715 else
3716 restart = 0;
3717
3718 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
3719
3720 return bgp_vty_return (vty, ret);
3721 }
3722
3723 static int
3724 peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
3725 safi_t safi)
3726 {
3727 int ret;
3728 struct peer *peer;
3729
3730 peer = peer_and_group_lookup_vty (vty, ip_str);
3731 if (! peer)
3732 return CMD_WARNING;
3733
3734 ret = peer_maximum_prefix_unset (peer, afi, safi);
3735
3736 return bgp_vty_return (vty, ret);
3737 }
3738
3739 /* Maximum number of prefix configuration. prefix count is different
3740 for each peer configuration. So this configuration can be set for
3741 each peer configuration. */
3742 DEFUN (neighbor_maximum_prefix,
3743 neighbor_maximum_prefix_cmd,
3744 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3745 NEIGHBOR_STR
3746 NEIGHBOR_ADDR_STR2
3747 "Maximum number of prefix accept from this peer\n"
3748 "maximum no. of prefix limit\n")
3749 {
3750 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3751 bgp_node_safi (vty), argv[1], NULL, 0,
3752 NULL);
3753 }
3754
3755 DEFUN (neighbor_maximum_prefix_threshold,
3756 neighbor_maximum_prefix_threshold_cmd,
3757 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
3758 NEIGHBOR_STR
3759 NEIGHBOR_ADDR_STR2
3760 "Maximum number of prefix accept from this peer\n"
3761 "maximum no. of prefix limit\n"
3762 "Threshold value (%) at which to generate a warning msg\n")
3763 {
3764 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3765 bgp_node_safi (vty), argv[1], argv[2], 0,
3766 NULL);
3767 }
3768
3769 DEFUN (neighbor_maximum_prefix_warning,
3770 neighbor_maximum_prefix_warning_cmd,
3771 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3772 NEIGHBOR_STR
3773 NEIGHBOR_ADDR_STR2
3774 "Maximum number of prefix accept from this peer\n"
3775 "maximum no. of prefix limit\n"
3776 "Only give warning message when limit is exceeded\n")
3777 {
3778 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3779 bgp_node_safi (vty), argv[1], NULL, 1,
3780 NULL);
3781 }
3782
3783 DEFUN (neighbor_maximum_prefix_threshold_warning,
3784 neighbor_maximum_prefix_threshold_warning_cmd,
3785 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3786 NEIGHBOR_STR
3787 NEIGHBOR_ADDR_STR2
3788 "Maximum number of prefix accept from this peer\n"
3789 "maximum no. of prefix limit\n"
3790 "Threshold value (%) at which to generate a warning msg\n"
3791 "Only give warning message when limit is exceeded\n")
3792 {
3793 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3794 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
3795 }
3796
3797 DEFUN (neighbor_maximum_prefix_restart,
3798 neighbor_maximum_prefix_restart_cmd,
3799 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3800 NEIGHBOR_STR
3801 NEIGHBOR_ADDR_STR2
3802 "Maximum number of prefix accept from this peer\n"
3803 "maximum no. of prefix limit\n"
3804 "Restart bgp connection after limit is exceeded\n"
3805 "Restart interval in minutes")
3806 {
3807 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3808 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
3809 }
3810
3811 DEFUN (neighbor_maximum_prefix_threshold_restart,
3812 neighbor_maximum_prefix_threshold_restart_cmd,
3813 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3814 NEIGHBOR_STR
3815 NEIGHBOR_ADDR_STR2
3816 "Maximum number of prefix accept from this peer\n"
3817 "maximum no. of prefix limit\n"
3818 "Threshold value (%) at which to generate a warning msg\n"
3819 "Restart bgp connection after limit is exceeded\n"
3820 "Restart interval in minutes")
3821 {
3822 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
3823 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
3824 }
3825
3826 DEFUN (no_neighbor_maximum_prefix,
3827 no_neighbor_maximum_prefix_cmd,
3828 NO_NEIGHBOR_CMD2 "maximum-prefix",
3829 NO_STR
3830 NEIGHBOR_STR
3831 NEIGHBOR_ADDR_STR2
3832 "Maximum number of prefix accept from this peer\n")
3833 {
3834 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
3835 bgp_node_safi (vty));
3836 }
3837
3838 ALIAS (no_neighbor_maximum_prefix,
3839 no_neighbor_maximum_prefix_val_cmd,
3840 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
3841 NO_STR
3842 NEIGHBOR_STR
3843 NEIGHBOR_ADDR_STR2
3844 "Maximum number of prefix accept from this peer\n"
3845 "maximum no. of prefix limit\n")
3846
3847 ALIAS (no_neighbor_maximum_prefix,
3848 no_neighbor_maximum_prefix_threshold_cmd,
3849 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3850 NO_STR
3851 NEIGHBOR_STR
3852 NEIGHBOR_ADDR_STR2
3853 "Maximum number of prefix accept from this peer\n"
3854 "maximum no. of prefix limit\n"
3855 "Threshold value (%) at which to generate a warning msg\n")
3856
3857 ALIAS (no_neighbor_maximum_prefix,
3858 no_neighbor_maximum_prefix_warning_cmd,
3859 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
3860 NO_STR
3861 NEIGHBOR_STR
3862 NEIGHBOR_ADDR_STR2
3863 "Maximum number of prefix accept from this peer\n"
3864 "maximum no. of prefix limit\n"
3865 "Only give warning message when limit is exceeded\n")
3866
3867 ALIAS (no_neighbor_maximum_prefix,
3868 no_neighbor_maximum_prefix_threshold_warning_cmd,
3869 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
3870 NO_STR
3871 NEIGHBOR_STR
3872 NEIGHBOR_ADDR_STR2
3873 "Maximum number of prefix accept from this peer\n"
3874 "maximum no. of prefix limit\n"
3875 "Threshold value (%) at which to generate a warning msg\n"
3876 "Only give warning message when limit is exceeded\n")
3877
3878 ALIAS (no_neighbor_maximum_prefix,
3879 no_neighbor_maximum_prefix_restart_cmd,
3880 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
3881 NO_STR
3882 NEIGHBOR_STR
3883 NEIGHBOR_ADDR_STR2
3884 "Maximum number of prefix accept from this peer\n"
3885 "maximum no. of prefix limit\n"
3886 "Restart bgp connection after limit is exceeded\n"
3887 "Restart interval in minutes")
3888
3889 ALIAS (no_neighbor_maximum_prefix,
3890 no_neighbor_maximum_prefix_threshold_restart_cmd,
3891 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
3892 NO_STR
3893 NEIGHBOR_STR
3894 NEIGHBOR_ADDR_STR2
3895 "Maximum number of prefix accept from this peer\n"
3896 "maximum no. of prefix limit\n"
3897 "Threshold value (%) at which to generate a warning msg\n"
3898 "Restart bgp connection after limit is exceeded\n"
3899 "Restart interval in minutes")
3900 \f
3901 /* "neighbor allowas-in" */
3902 DEFUN (neighbor_allowas_in,
3903 neighbor_allowas_in_cmd,
3904 NEIGHBOR_CMD2 "allowas-in",
3905 NEIGHBOR_STR
3906 NEIGHBOR_ADDR_STR2
3907 "Accept as-path with my AS present in it\n")
3908 {
3909 int ret;
3910 struct peer *peer;
3911 unsigned int allow_num;
3912
3913 peer = peer_and_group_lookup_vty (vty, argv[0]);
3914 if (! peer)
3915 return CMD_WARNING;
3916
3917 if (argc == 1)
3918 allow_num = 3;
3919 else
3920 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
3921
3922 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
3923 allow_num);
3924
3925 return bgp_vty_return (vty, ret);
3926 }
3927
3928 ALIAS (neighbor_allowas_in,
3929 neighbor_allowas_in_arg_cmd,
3930 NEIGHBOR_CMD2 "allowas-in <1-10>",
3931 NEIGHBOR_STR
3932 NEIGHBOR_ADDR_STR2
3933 "Accept as-path with my AS present in it\n"
3934 "Number of occurances of AS number\n")
3935
3936 DEFUN (no_neighbor_allowas_in,
3937 no_neighbor_allowas_in_cmd,
3938 NO_NEIGHBOR_CMD2 "allowas-in",
3939 NO_STR
3940 NEIGHBOR_STR
3941 NEIGHBOR_ADDR_STR2
3942 "allow local ASN appears in aspath attribute\n")
3943 {
3944 int ret;
3945 struct peer *peer;
3946
3947 peer = peer_and_group_lookup_vty (vty, argv[0]);
3948 if (! peer)
3949 return CMD_WARNING;
3950
3951 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3952
3953 return bgp_vty_return (vty, ret);
3954 }
3955 \f
3956 /* Address family configuration. */
3957 DEFUN (address_family_ipv4,
3958 address_family_ipv4_cmd,
3959 "address-family ipv4",
3960 "Enter Address Family command mode\n"
3961 "Address family\n")
3962 {
3963 vty->node = BGP_IPV4_NODE;
3964 return CMD_SUCCESS;
3965 }
3966
3967 DEFUN (address_family_ipv4_safi,
3968 address_family_ipv4_safi_cmd,
3969 "address-family ipv4 (unicast|multicast)",
3970 "Enter Address Family command mode\n"
3971 "Address family\n"
3972 "Address Family modifier\n"
3973 "Address Family modifier\n")
3974 {
3975 if (strncmp (argv[0], "m", 1) == 0)
3976 vty->node = BGP_IPV4M_NODE;
3977 else
3978 vty->node = BGP_IPV4_NODE;
3979
3980 return CMD_SUCCESS;
3981 }
3982
3983 DEFUN (address_family_ipv6,
3984 address_family_ipv6_cmd,
3985 "address-family ipv6",
3986 "Enter Address Family command mode\n"
3987 "Address family\n")
3988 {
3989 vty->node = BGP_IPV6_NODE;
3990 return CMD_SUCCESS;
3991 }
3992
3993 DEFUN (address_family_ipv6_safi,
3994 address_family_ipv6_safi_cmd,
3995 "address-family ipv6 (unicast|multicast)",
3996 "Enter Address Family command mode\n"
3997 "Address family\n"
3998 "Address Family modifier\n"
3999 "Address Family modifier\n")
4000 {
4001 if (strncmp (argv[0], "m", 1) == 0)
4002 vty->node = BGP_IPV6M_NODE;
4003 else
4004 vty->node = BGP_IPV6_NODE;
4005
4006 return CMD_SUCCESS;
4007 }
4008
4009 DEFUN (address_family_vpnv4,
4010 address_family_vpnv4_cmd,
4011 "address-family vpnv4",
4012 "Enter Address Family command mode\n"
4013 "Address family\n")
4014 {
4015 vty->node = BGP_VPNV4_NODE;
4016 return CMD_SUCCESS;
4017 }
4018
4019 ALIAS (address_family_vpnv4,
4020 address_family_vpnv4_unicast_cmd,
4021 "address-family vpnv4 unicast",
4022 "Enter Address Family command mode\n"
4023 "Address family\n"
4024 "Address Family Modifier\n")
4025
4026 DEFUN (exit_address_family,
4027 exit_address_family_cmd,
4028 "exit-address-family",
4029 "Exit from Address Family configuration mode\n")
4030 {
4031 if (vty->node == BGP_IPV4_NODE
4032 || vty->node == BGP_IPV4M_NODE
4033 || vty->node == BGP_VPNV4_NODE
4034 || vty->node == BGP_IPV6_NODE
4035 || vty->node == BGP_IPV6M_NODE)
4036 vty->node = BGP_NODE;
4037 return CMD_SUCCESS;
4038 }
4039 \f
4040 /* BGP clear sort. */
4041 enum clear_sort
4042 {
4043 clear_all,
4044 clear_peer,
4045 clear_group,
4046 clear_external,
4047 clear_as
4048 };
4049
4050 static void
4051 bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
4052 safi_t safi, int error)
4053 {
4054 switch (error)
4055 {
4056 case BGP_ERR_AF_UNCONFIGURED:
4057 vty_out (vty,
4058 "%%BGP: Enable %s %s address family for the neighbor %s%s",
4059 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
4060 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
4061 peer->host, VTY_NEWLINE);
4062 break;
4063 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
4064 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);
4065 break;
4066 default:
4067 break;
4068 }
4069 }
4070
4071 /* `clear ip bgp' functions. */
4072 static int
4073 bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
4074 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
4075 {
4076 int ret;
4077 struct peer *peer;
4078 struct listnode *node, *nnode;
4079
4080 /* Clear all neighbors. */
4081 if (sort == clear_all)
4082 {
4083 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4084 {
4085 if (stype == BGP_CLEAR_SOFT_NONE)
4086 ret = peer_clear (peer);
4087 else
4088 ret = peer_clear_soft (peer, afi, safi, stype);
4089
4090 if (ret < 0)
4091 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4092 }
4093 return CMD_SUCCESS;
4094 }
4095
4096 /* Clear specified neighbors. */
4097 if (sort == clear_peer)
4098 {
4099 union sockunion su;
4100 int ret;
4101
4102 /* Make sockunion for lookup. */
4103 ret = str2sockunion (arg, &su);
4104 if (ret < 0)
4105 {
4106 vty_out (vty, "Malformed address: %s%s", arg, VTY_NEWLINE);
4107 return CMD_WARNING;
4108 }
4109 peer = peer_lookup (bgp, &su);
4110 if (! peer)
4111 {
4112 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
4113 return CMD_WARNING;
4114 }
4115
4116 if (stype == BGP_CLEAR_SOFT_NONE)
4117 ret = peer_clear (peer);
4118 else
4119 ret = peer_clear_soft (peer, afi, safi, stype);
4120
4121 if (ret < 0)
4122 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4123
4124 return CMD_SUCCESS;
4125 }
4126
4127 /* Clear all peer-group members. */
4128 if (sort == clear_group)
4129 {
4130 struct peer_group *group;
4131
4132 group = peer_group_lookup (bgp, arg);
4133 if (! group)
4134 {
4135 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
4136 return CMD_WARNING;
4137 }
4138
4139 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
4140 {
4141 if (stype == BGP_CLEAR_SOFT_NONE)
4142 {
4143 ret = peer_clear (peer);
4144 continue;
4145 }
4146
4147 if (! peer->af_group[afi][safi])
4148 continue;
4149
4150 ret = peer_clear_soft (peer, afi, safi, stype);
4151
4152 if (ret < 0)
4153 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4154 }
4155 return CMD_SUCCESS;
4156 }
4157
4158 if (sort == clear_external)
4159 {
4160 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4161 {
4162 if (peer_sort (peer) == BGP_PEER_IBGP)
4163 continue;
4164
4165 if (stype == BGP_CLEAR_SOFT_NONE)
4166 ret = peer_clear (peer);
4167 else
4168 ret = peer_clear_soft (peer, afi, safi, stype);
4169
4170 if (ret < 0)
4171 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4172 }
4173 return CMD_SUCCESS;
4174 }
4175
4176 if (sort == clear_as)
4177 {
4178 as_t as;
4179 unsigned long as_ul;
4180 int find = 0;
4181
4182 VTY_GET_LONG ("AS", as_ul, arg);
4183
4184 if (!as_ul)
4185 {
4186 vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
4187 return CMD_WARNING;
4188 }
4189 as = (as_t) as_ul;
4190
4191 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
4192 {
4193 if (peer->as != as)
4194 continue;
4195
4196 find = 1;
4197 if (stype == BGP_CLEAR_SOFT_NONE)
4198 ret = peer_clear (peer);
4199 else
4200 ret = peer_clear_soft (peer, afi, safi, stype);
4201
4202 if (ret < 0)
4203 bgp_clear_vty_error (vty, peer, afi, safi, ret);
4204 }
4205 if (! find)
4206 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
4207 VTY_NEWLINE);
4208 return CMD_SUCCESS;
4209 }
4210
4211 return CMD_SUCCESS;
4212 }
4213
4214 static int
4215 bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
4216 enum clear_sort sort, enum bgp_clear_type stype,
4217 const char *arg)
4218 {
4219 struct bgp *bgp;
4220
4221 /* BGP structure lookup. */
4222 if (name)
4223 {
4224 bgp = bgp_lookup_by_name (name);
4225 if (bgp == NULL)
4226 {
4227 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
4228 return CMD_WARNING;
4229 }
4230 }
4231 else
4232 {
4233 bgp = bgp_get_default ();
4234 if (bgp == NULL)
4235 {
4236 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4237 return CMD_WARNING;
4238 }
4239 }
4240
4241 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
4242 }
4243
4244 DEFUN (clear_ip_bgp_all,
4245 clear_ip_bgp_all_cmd,
4246 "clear ip bgp *",
4247 CLEAR_STR
4248 IP_STR
4249 BGP_STR
4250 "Clear all peers\n")
4251 {
4252 if (argc == 1)
4253 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4254
4255 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
4256 }
4257
4258 ALIAS (clear_ip_bgp_all,
4259 clear_bgp_all_cmd,
4260 "clear bgp *",
4261 CLEAR_STR
4262 BGP_STR
4263 "Clear all peers\n")
4264
4265 ALIAS (clear_ip_bgp_all,
4266 clear_bgp_ipv6_all_cmd,
4267 "clear bgp ipv6 *",
4268 CLEAR_STR
4269 BGP_STR
4270 "Address family\n"
4271 "Clear all peers\n")
4272
4273 ALIAS (clear_ip_bgp_all,
4274 clear_ip_bgp_instance_all_cmd,
4275 "clear ip bgp view WORD *",
4276 CLEAR_STR
4277 IP_STR
4278 BGP_STR
4279 "BGP view\n"
4280 "view name\n"
4281 "Clear all peers\n")
4282
4283 ALIAS (clear_ip_bgp_all,
4284 clear_bgp_instance_all_cmd,
4285 "clear bgp view WORD *",
4286 CLEAR_STR
4287 BGP_STR
4288 "BGP view\n"
4289 "view name\n"
4290 "Clear all peers\n")
4291
4292 DEFUN (clear_ip_bgp_peer,
4293 clear_ip_bgp_peer_cmd,
4294 "clear ip bgp (A.B.C.D|X:X::X:X)",
4295 CLEAR_STR
4296 IP_STR
4297 BGP_STR
4298 "BGP neighbor IP address to clear\n"
4299 "BGP IPv6 neighbor to clear\n")
4300 {
4301 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
4302 }
4303
4304 ALIAS (clear_ip_bgp_peer,
4305 clear_bgp_peer_cmd,
4306 "clear bgp (A.B.C.D|X:X::X:X)",
4307 CLEAR_STR
4308 BGP_STR
4309 "BGP neighbor address to clear\n"
4310 "BGP IPv6 neighbor to clear\n")
4311
4312 ALIAS (clear_ip_bgp_peer,
4313 clear_bgp_ipv6_peer_cmd,
4314 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
4315 CLEAR_STR
4316 BGP_STR
4317 "Address family\n"
4318 "BGP neighbor address to clear\n"
4319 "BGP IPv6 neighbor to clear\n")
4320
4321 DEFUN (clear_ip_bgp_peer_group,
4322 clear_ip_bgp_peer_group_cmd,
4323 "clear ip bgp peer-group WORD",
4324 CLEAR_STR
4325 IP_STR
4326 BGP_STR
4327 "Clear all members of peer-group\n"
4328 "BGP peer-group name\n")
4329 {
4330 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
4331 }
4332
4333 ALIAS (clear_ip_bgp_peer_group,
4334 clear_bgp_peer_group_cmd,
4335 "clear bgp peer-group WORD",
4336 CLEAR_STR
4337 BGP_STR
4338 "Clear all members of peer-group\n"
4339 "BGP peer-group name\n")
4340
4341 ALIAS (clear_ip_bgp_peer_group,
4342 clear_bgp_ipv6_peer_group_cmd,
4343 "clear bgp ipv6 peer-group WORD",
4344 CLEAR_STR
4345 BGP_STR
4346 "Address family\n"
4347 "Clear all members of peer-group\n"
4348 "BGP peer-group name\n")
4349
4350 DEFUN (clear_ip_bgp_external,
4351 clear_ip_bgp_external_cmd,
4352 "clear ip bgp external",
4353 CLEAR_STR
4354 IP_STR
4355 BGP_STR
4356 "Clear all external peers\n")
4357 {
4358 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
4359 }
4360
4361 ALIAS (clear_ip_bgp_external,
4362 clear_bgp_external_cmd,
4363 "clear bgp external",
4364 CLEAR_STR
4365 BGP_STR
4366 "Clear all external peers\n")
4367
4368 ALIAS (clear_ip_bgp_external,
4369 clear_bgp_ipv6_external_cmd,
4370 "clear bgp ipv6 external",
4371 CLEAR_STR
4372 BGP_STR
4373 "Address family\n"
4374 "Clear all external peers\n")
4375
4376 DEFUN (clear_ip_bgp_as,
4377 clear_ip_bgp_as_cmd,
4378 "clear ip bgp " CMD_AS_RANGE,
4379 CLEAR_STR
4380 IP_STR
4381 BGP_STR
4382 "Clear peers with the AS number\n")
4383 {
4384 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
4385 }
4386
4387 ALIAS (clear_ip_bgp_as,
4388 clear_bgp_as_cmd,
4389 "clear bgp " CMD_AS_RANGE,
4390 CLEAR_STR
4391 BGP_STR
4392 "Clear peers with the AS number\n")
4393
4394 ALIAS (clear_ip_bgp_as,
4395 clear_bgp_ipv6_as_cmd,
4396 "clear bgp ipv6 " CMD_AS_RANGE,
4397 CLEAR_STR
4398 BGP_STR
4399 "Address family\n"
4400 "Clear peers with the AS number\n")
4401 \f
4402 /* Outbound soft-reconfiguration */
4403 DEFUN (clear_ip_bgp_all_soft_out,
4404 clear_ip_bgp_all_soft_out_cmd,
4405 "clear ip bgp * soft out",
4406 CLEAR_STR
4407 IP_STR
4408 BGP_STR
4409 "Clear all peers\n"
4410 "Soft reconfig\n"
4411 "Soft reconfig outbound update\n")
4412 {
4413 if (argc == 1)
4414 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4415 BGP_CLEAR_SOFT_OUT, NULL);
4416
4417 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4418 BGP_CLEAR_SOFT_OUT, NULL);
4419 }
4420
4421 ALIAS (clear_ip_bgp_all_soft_out,
4422 clear_ip_bgp_all_out_cmd,
4423 "clear ip bgp * out",
4424 CLEAR_STR
4425 IP_STR
4426 BGP_STR
4427 "Clear all peers\n"
4428 "Soft reconfig outbound update\n")
4429
4430 ALIAS (clear_ip_bgp_all_soft_out,
4431 clear_ip_bgp_instance_all_soft_out_cmd,
4432 "clear ip bgp view WORD * soft out",
4433 CLEAR_STR
4434 IP_STR
4435 BGP_STR
4436 "BGP view\n"
4437 "view name\n"
4438 "Clear all peers\n"
4439 "Soft reconfig\n"
4440 "Soft reconfig outbound update\n")
4441
4442 DEFUN (clear_ip_bgp_all_ipv4_soft_out,
4443 clear_ip_bgp_all_ipv4_soft_out_cmd,
4444 "clear ip bgp * ipv4 (unicast|multicast) soft out",
4445 CLEAR_STR
4446 IP_STR
4447 BGP_STR
4448 "Clear all peers\n"
4449 "Address family\n"
4450 "Address Family modifier\n"
4451 "Address Family modifier\n"
4452 "Soft reconfig\n"
4453 "Soft reconfig outbound update\n")
4454 {
4455 if (strncmp (argv[0], "m", 1) == 0)
4456 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
4457 BGP_CLEAR_SOFT_OUT, NULL);
4458
4459 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
4460 BGP_CLEAR_SOFT_OUT, NULL);
4461 }
4462
4463 ALIAS (clear_ip_bgp_all_ipv4_soft_out,
4464 clear_ip_bgp_all_ipv4_out_cmd,
4465 "clear ip bgp * ipv4 (unicast|multicast) out",
4466 CLEAR_STR
4467 IP_STR
4468 BGP_STR
4469 "Clear all peers\n"
4470 "Address family\n"
4471 "Address Family modifier\n"
4472 "Address Family modifier\n"
4473 "Soft reconfig outbound update\n")
4474
4475 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
4476 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
4477 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
4478 CLEAR_STR
4479 IP_STR
4480 BGP_STR
4481 "BGP view\n"
4482 "view name\n"
4483 "Clear all peers\n"
4484 "Address family\n"
4485 "Address Family modifier\n"
4486 "Address Family modifier\n"
4487 "Soft reconfig outbound update\n")
4488 {
4489 if (strncmp (argv[1], "m", 1) == 0)
4490 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
4491 BGP_CLEAR_SOFT_OUT, NULL);
4492
4493 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
4494 BGP_CLEAR_SOFT_OUT, NULL);
4495 }
4496
4497 DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
4498 clear_ip_bgp_all_vpnv4_soft_out_cmd,
4499 "clear ip bgp * vpnv4 unicast soft out",
4500 CLEAR_STR
4501 IP_STR
4502 BGP_STR
4503 "Clear all peers\n"
4504 "Address family\n"
4505 "Address Family Modifier\n"
4506 "Soft reconfig\n"
4507 "Soft reconfig outbound update\n")
4508 {
4509 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
4510 BGP_CLEAR_SOFT_OUT, NULL);
4511 }
4512
4513 ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
4514 clear_ip_bgp_all_vpnv4_out_cmd,
4515 "clear ip bgp * vpnv4 unicast out",
4516 CLEAR_STR
4517 IP_STR
4518 BGP_STR
4519 "Clear all peers\n"
4520 "Address family\n"
4521 "Address Family Modifier\n"
4522 "Soft reconfig outbound update\n")
4523
4524 DEFUN (clear_bgp_all_soft_out,
4525 clear_bgp_all_soft_out_cmd,
4526 "clear bgp * soft out",
4527 CLEAR_STR
4528 BGP_STR
4529 "Clear all peers\n"
4530 "Soft reconfig\n"
4531 "Soft reconfig outbound update\n")
4532 {
4533 if (argc == 1)
4534 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
4535 BGP_CLEAR_SOFT_OUT, NULL);
4536
4537 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
4538 BGP_CLEAR_SOFT_OUT, NULL);
4539 }
4540
4541 ALIAS (clear_bgp_all_soft_out,
4542 clear_bgp_instance_all_soft_out_cmd,
4543 "clear bgp view WORD * soft out",
4544 CLEAR_STR
4545 BGP_STR
4546 "BGP view\n"
4547 "view name\n"
4548 "Clear all peers\n"
4549 "Soft reconfig\n"
4550 "Soft reconfig outbound update\n")
4551
4552 ALIAS (clear_bgp_all_soft_out,
4553 clear_bgp_all_out_cmd,
4554 "clear bgp * out",
4555 CLEAR_STR
4556 BGP_STR
4557 "Clear all peers\n"
4558 "Soft reconfig outbound update\n")
4559
4560 ALIAS (clear_bgp_all_soft_out,
4561 clear_bgp_ipv6_all_soft_out_cmd,
4562 "clear bgp ipv6 * soft out",
4563 CLEAR_STR
4564 BGP_STR
4565 "Address family\n"
4566 "Clear all peers\n"
4567 "Soft reconfig\n"
4568 "Soft reconfig outbound update\n")
4569
4570 ALIAS (clear_bgp_all_soft_out,
4571 clear_bgp_ipv6_all_out_cmd,
4572 "clear bgp ipv6 * out",
4573 CLEAR_STR
4574 BGP_STR
4575 "Address family\n"
4576 "Clear all peers\n"
4577 "Soft reconfig outbound update\n")
4578
4579 DEFUN (clear_ip_bgp_peer_soft_out,
4580 clear_ip_bgp_peer_soft_out_cmd,
4581 "clear ip bgp A.B.C.D soft out",
4582 CLEAR_STR
4583 IP_STR
4584 BGP_STR
4585 "BGP neighbor address to clear\n"
4586 "Soft reconfig\n"
4587 "Soft reconfig outbound update\n")
4588 {
4589 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4590 BGP_CLEAR_SOFT_OUT, argv[0]);
4591 }
4592
4593 ALIAS (clear_ip_bgp_peer_soft_out,
4594 clear_ip_bgp_peer_out_cmd,
4595 "clear ip bgp A.B.C.D out",
4596 CLEAR_STR
4597 IP_STR
4598 BGP_STR
4599 "BGP neighbor address to clear\n"
4600 "Soft reconfig outbound update\n")
4601
4602 DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
4603 clear_ip_bgp_peer_ipv4_soft_out_cmd,
4604 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
4605 CLEAR_STR
4606 IP_STR
4607 BGP_STR
4608 "BGP neighbor address to clear\n"
4609 "Address family\n"
4610 "Address Family modifier\n"
4611 "Address Family modifier\n"
4612 "Soft reconfig\n"
4613 "Soft reconfig outbound update\n")
4614 {
4615 if (strncmp (argv[1], "m", 1) == 0)
4616 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
4617 BGP_CLEAR_SOFT_OUT, argv[0]);
4618
4619 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
4620 BGP_CLEAR_SOFT_OUT, argv[0]);
4621 }
4622
4623 ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
4624 clear_ip_bgp_peer_ipv4_out_cmd,
4625 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
4626 CLEAR_STR
4627 IP_STR
4628 BGP_STR
4629 "BGP neighbor address to clear\n"
4630 "Address family\n"
4631 "Address Family modifier\n"
4632 "Address Family modifier\n"
4633 "Soft reconfig outbound update\n")
4634
4635 DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
4636 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
4637 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
4638 CLEAR_STR
4639 IP_STR
4640 BGP_STR
4641 "BGP neighbor address to clear\n"
4642 "Address family\n"
4643 "Address Family Modifier\n"
4644 "Soft reconfig\n"
4645 "Soft reconfig outbound update\n")
4646 {
4647 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
4648 BGP_CLEAR_SOFT_OUT, argv[0]);
4649 }
4650
4651 ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
4652 clear_ip_bgp_peer_vpnv4_out_cmd,
4653 "clear ip bgp A.B.C.D vpnv4 unicast out",
4654 CLEAR_STR
4655 IP_STR
4656 BGP_STR
4657 "BGP neighbor address to clear\n"
4658 "Address family\n"
4659 "Address Family Modifier\n"
4660 "Soft reconfig outbound update\n")
4661
4662 DEFUN (clear_bgp_peer_soft_out,
4663 clear_bgp_peer_soft_out_cmd,
4664 "clear bgp (A.B.C.D|X:X::X:X) soft out",
4665 CLEAR_STR
4666 BGP_STR
4667 "BGP neighbor address to clear\n"
4668 "BGP IPv6 neighbor to clear\n"
4669 "Soft reconfig\n"
4670 "Soft reconfig outbound update\n")
4671 {
4672 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
4673 BGP_CLEAR_SOFT_OUT, argv[0]);
4674 }
4675
4676 ALIAS (clear_bgp_peer_soft_out,
4677 clear_bgp_ipv6_peer_soft_out_cmd,
4678 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
4679 CLEAR_STR
4680 BGP_STR
4681 "Address family\n"
4682 "BGP neighbor address to clear\n"
4683 "BGP IPv6 neighbor to clear\n"
4684 "Soft reconfig\n"
4685 "Soft reconfig outbound update\n")
4686
4687 ALIAS (clear_bgp_peer_soft_out,
4688 clear_bgp_peer_out_cmd,
4689 "clear bgp (A.B.C.D|X:X::X:X) out",
4690 CLEAR_STR
4691 BGP_STR
4692 "BGP neighbor address to clear\n"
4693 "BGP IPv6 neighbor to clear\n"
4694 "Soft reconfig outbound update\n")
4695
4696 ALIAS (clear_bgp_peer_soft_out,
4697 clear_bgp_ipv6_peer_out_cmd,
4698 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
4699 CLEAR_STR
4700 BGP_STR
4701 "Address family\n"
4702 "BGP neighbor address to clear\n"
4703 "BGP IPv6 neighbor to clear\n"
4704 "Soft reconfig outbound update\n")
4705
4706 DEFUN (clear_ip_bgp_peer_group_soft_out,
4707 clear_ip_bgp_peer_group_soft_out_cmd,
4708 "clear ip bgp peer-group WORD soft out",
4709 CLEAR_STR
4710 IP_STR
4711 BGP_STR
4712 "Clear all members of peer-group\n"
4713 "BGP peer-group name\n"
4714 "Soft reconfig\n"
4715 "Soft reconfig outbound update\n")
4716 {
4717 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4718 BGP_CLEAR_SOFT_OUT, argv[0]);
4719 }
4720
4721 ALIAS (clear_ip_bgp_peer_group_soft_out,
4722 clear_ip_bgp_peer_group_out_cmd,
4723 "clear ip bgp peer-group WORD out",
4724 CLEAR_STR
4725 IP_STR
4726 BGP_STR
4727 "Clear all members of peer-group\n"
4728 "BGP peer-group name\n"
4729 "Soft reconfig outbound update\n")
4730
4731 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
4732 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
4733 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
4734 CLEAR_STR
4735 IP_STR
4736 BGP_STR
4737 "Clear all members of peer-group\n"
4738 "BGP peer-group name\n"
4739 "Address family\n"
4740 "Address Family modifier\n"
4741 "Address Family modifier\n"
4742 "Soft reconfig\n"
4743 "Soft reconfig outbound update\n")
4744 {
4745 if (strncmp (argv[1], "m", 1) == 0)
4746 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
4747 BGP_CLEAR_SOFT_OUT, argv[0]);
4748
4749 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
4750 BGP_CLEAR_SOFT_OUT, argv[0]);
4751 }
4752
4753 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
4754 clear_ip_bgp_peer_group_ipv4_out_cmd,
4755 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
4756 CLEAR_STR
4757 IP_STR
4758 BGP_STR
4759 "Clear all members of peer-group\n"
4760 "BGP peer-group name\n"
4761 "Address family\n"
4762 "Address Family modifier\n"
4763 "Address Family modifier\n"
4764 "Soft reconfig outbound update\n")
4765
4766 DEFUN (clear_bgp_peer_group_soft_out,
4767 clear_bgp_peer_group_soft_out_cmd,
4768 "clear bgp peer-group WORD soft out",
4769 CLEAR_STR
4770 BGP_STR
4771 "Clear all members of peer-group\n"
4772 "BGP peer-group name\n"
4773 "Soft reconfig\n"
4774 "Soft reconfig outbound update\n")
4775 {
4776 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
4777 BGP_CLEAR_SOFT_OUT, argv[0]);
4778 }
4779
4780 ALIAS (clear_bgp_peer_group_soft_out,
4781 clear_bgp_ipv6_peer_group_soft_out_cmd,
4782 "clear bgp ipv6 peer-group WORD soft out",
4783 CLEAR_STR
4784 BGP_STR
4785 "Address family\n"
4786 "Clear all members of peer-group\n"
4787 "BGP peer-group name\n"
4788 "Soft reconfig\n"
4789 "Soft reconfig outbound update\n")
4790
4791 ALIAS (clear_bgp_peer_group_soft_out,
4792 clear_bgp_peer_group_out_cmd,
4793 "clear bgp peer-group WORD out",
4794 CLEAR_STR
4795 BGP_STR
4796 "Clear all members of peer-group\n"
4797 "BGP peer-group name\n"
4798 "Soft reconfig outbound update\n")
4799
4800 ALIAS (clear_bgp_peer_group_soft_out,
4801 clear_bgp_ipv6_peer_group_out_cmd,
4802 "clear bgp ipv6 peer-group WORD out",
4803 CLEAR_STR
4804 BGP_STR
4805 "Address family\n"
4806 "Clear all members of peer-group\n"
4807 "BGP peer-group name\n"
4808 "Soft reconfig outbound update\n")
4809
4810 DEFUN (clear_ip_bgp_external_soft_out,
4811 clear_ip_bgp_external_soft_out_cmd,
4812 "clear ip bgp external soft out",
4813 CLEAR_STR
4814 IP_STR
4815 BGP_STR
4816 "Clear all external peers\n"
4817 "Soft reconfig\n"
4818 "Soft reconfig outbound update\n")
4819 {
4820 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4821 BGP_CLEAR_SOFT_OUT, NULL);
4822 }
4823
4824 ALIAS (clear_ip_bgp_external_soft_out,
4825 clear_ip_bgp_external_out_cmd,
4826 "clear ip bgp external out",
4827 CLEAR_STR
4828 IP_STR
4829 BGP_STR
4830 "Clear all external peers\n"
4831 "Soft reconfig outbound update\n")
4832
4833 DEFUN (clear_ip_bgp_external_ipv4_soft_out,
4834 clear_ip_bgp_external_ipv4_soft_out_cmd,
4835 "clear ip bgp external ipv4 (unicast|multicast) soft out",
4836 CLEAR_STR
4837 IP_STR
4838 BGP_STR
4839 "Clear all external peers\n"
4840 "Address family\n"
4841 "Address Family modifier\n"
4842 "Address Family modifier\n"
4843 "Soft reconfig\n"
4844 "Soft reconfig outbound update\n")
4845 {
4846 if (strncmp (argv[0], "m", 1) == 0)
4847 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
4848 BGP_CLEAR_SOFT_OUT, NULL);
4849
4850 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
4851 BGP_CLEAR_SOFT_OUT, NULL);
4852 }
4853
4854 ALIAS (clear_ip_bgp_external_ipv4_soft_out,
4855 clear_ip_bgp_external_ipv4_out_cmd,
4856 "clear ip bgp external ipv4 (unicast|multicast) out",
4857 CLEAR_STR
4858 IP_STR
4859 BGP_STR
4860 "Clear all external peers\n"
4861 "Address family\n"
4862 "Address Family modifier\n"
4863 "Address Family modifier\n"
4864 "Soft reconfig outbound update\n")
4865
4866 DEFUN (clear_bgp_external_soft_out,
4867 clear_bgp_external_soft_out_cmd,
4868 "clear bgp external soft out",
4869 CLEAR_STR
4870 BGP_STR
4871 "Clear all external peers\n"
4872 "Soft reconfig\n"
4873 "Soft reconfig outbound update\n")
4874 {
4875 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
4876 BGP_CLEAR_SOFT_OUT, NULL);
4877 }
4878
4879 ALIAS (clear_bgp_external_soft_out,
4880 clear_bgp_ipv6_external_soft_out_cmd,
4881 "clear bgp ipv6 external soft out",
4882 CLEAR_STR
4883 BGP_STR
4884 "Address family\n"
4885 "Clear all external peers\n"
4886 "Soft reconfig\n"
4887 "Soft reconfig outbound update\n")
4888
4889 ALIAS (clear_bgp_external_soft_out,
4890 clear_bgp_external_out_cmd,
4891 "clear bgp external out",
4892 CLEAR_STR
4893 BGP_STR
4894 "Clear all external peers\n"
4895 "Soft reconfig outbound update\n")
4896
4897 ALIAS (clear_bgp_external_soft_out,
4898 clear_bgp_ipv6_external_out_cmd,
4899 "clear bgp ipv6 external WORD out",
4900 CLEAR_STR
4901 BGP_STR
4902 "Address family\n"
4903 "Clear all external peers\n"
4904 "Soft reconfig outbound update\n")
4905
4906 DEFUN (clear_ip_bgp_as_soft_out,
4907 clear_ip_bgp_as_soft_out_cmd,
4908 "clear ip bgp " CMD_AS_RANGE " soft out",
4909 CLEAR_STR
4910 IP_STR
4911 BGP_STR
4912 "Clear peers with the AS number\n"
4913 "Soft reconfig\n"
4914 "Soft reconfig outbound update\n")
4915 {
4916 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4917 BGP_CLEAR_SOFT_OUT, argv[0]);
4918 }
4919
4920 ALIAS (clear_ip_bgp_as_soft_out,
4921 clear_ip_bgp_as_out_cmd,
4922 "clear ip bgp " CMD_AS_RANGE " out",
4923 CLEAR_STR
4924 IP_STR
4925 BGP_STR
4926 "Clear peers with the AS number\n"
4927 "Soft reconfig outbound update\n")
4928
4929 DEFUN (clear_ip_bgp_as_ipv4_soft_out,
4930 clear_ip_bgp_as_ipv4_soft_out_cmd,
4931 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
4932 CLEAR_STR
4933 IP_STR
4934 BGP_STR
4935 "Clear peers with the AS number\n"
4936 "Address family\n"
4937 "Address Family modifier\n"
4938 "Address Family modifier\n"
4939 "Soft reconfig\n"
4940 "Soft reconfig outbound update\n")
4941 {
4942 if (strncmp (argv[1], "m", 1) == 0)
4943 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
4944 BGP_CLEAR_SOFT_OUT, argv[0]);
4945
4946 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
4947 BGP_CLEAR_SOFT_OUT, argv[0]);
4948 }
4949
4950 ALIAS (clear_ip_bgp_as_ipv4_soft_out,
4951 clear_ip_bgp_as_ipv4_out_cmd,
4952 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
4953 CLEAR_STR
4954 IP_STR
4955 BGP_STR
4956 "Clear peers with the AS number\n"
4957 "Address family\n"
4958 "Address Family modifier\n"
4959 "Address Family modifier\n"
4960 "Soft reconfig outbound update\n")
4961
4962 DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
4963 clear_ip_bgp_as_vpnv4_soft_out_cmd,
4964 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
4965 CLEAR_STR
4966 IP_STR
4967 BGP_STR
4968 "Clear peers with the AS number\n"
4969 "Address family\n"
4970 "Address Family modifier\n"
4971 "Soft reconfig\n"
4972 "Soft reconfig outbound update\n")
4973 {
4974 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
4975 BGP_CLEAR_SOFT_OUT, argv[0]);
4976 }
4977
4978 ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
4979 clear_ip_bgp_as_vpnv4_out_cmd,
4980 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
4981 CLEAR_STR
4982 IP_STR
4983 BGP_STR
4984 "Clear peers with the AS number\n"
4985 "Address family\n"
4986 "Address Family modifier\n"
4987 "Soft reconfig outbound update\n")
4988
4989 DEFUN (clear_bgp_as_soft_out,
4990 clear_bgp_as_soft_out_cmd,
4991 "clear bgp " CMD_AS_RANGE " soft out",
4992 CLEAR_STR
4993 BGP_STR
4994 "Clear peers with the AS number\n"
4995 "Soft reconfig\n"
4996 "Soft reconfig outbound update\n")
4997 {
4998 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
4999 BGP_CLEAR_SOFT_OUT, argv[0]);
5000 }
5001
5002 ALIAS (clear_bgp_as_soft_out,
5003 clear_bgp_ipv6_as_soft_out_cmd,
5004 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
5005 CLEAR_STR
5006 BGP_STR
5007 "Address family\n"
5008 "Clear peers with the AS number\n"
5009 "Soft reconfig\n"
5010 "Soft reconfig outbound update\n")
5011
5012 ALIAS (clear_bgp_as_soft_out,
5013 clear_bgp_as_out_cmd,
5014 "clear bgp " CMD_AS_RANGE " out",
5015 CLEAR_STR
5016 BGP_STR
5017 "Clear peers with the AS number\n"
5018 "Soft reconfig outbound update\n")
5019
5020 ALIAS (clear_bgp_as_soft_out,
5021 clear_bgp_ipv6_as_out_cmd,
5022 "clear bgp ipv6 " CMD_AS_RANGE " out",
5023 CLEAR_STR
5024 BGP_STR
5025 "Address family\n"
5026 "Clear peers with the AS number\n"
5027 "Soft reconfig outbound update\n")
5028 \f
5029 /* Inbound soft-reconfiguration */
5030 DEFUN (clear_ip_bgp_all_soft_in,
5031 clear_ip_bgp_all_soft_in_cmd,
5032 "clear ip bgp * soft in",
5033 CLEAR_STR
5034 IP_STR
5035 BGP_STR
5036 "Clear all peers\n"
5037 "Soft reconfig\n"
5038 "Soft reconfig inbound update\n")
5039 {
5040 if (argc == 1)
5041 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5042 BGP_CLEAR_SOFT_IN, NULL);
5043
5044 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5045 BGP_CLEAR_SOFT_IN, NULL);
5046 }
5047
5048 ALIAS (clear_ip_bgp_all_soft_in,
5049 clear_ip_bgp_instance_all_soft_in_cmd,
5050 "clear ip bgp view WORD * soft in",
5051 CLEAR_STR
5052 IP_STR
5053 BGP_STR
5054 "BGP view\n"
5055 "view name\n"
5056 "Clear all peers\n"
5057 "Soft reconfig\n"
5058 "Soft reconfig inbound update\n")
5059
5060 ALIAS (clear_ip_bgp_all_soft_in,
5061 clear_ip_bgp_all_in_cmd,
5062 "clear ip bgp * in",
5063 CLEAR_STR
5064 IP_STR
5065 BGP_STR
5066 "Clear all peers\n"
5067 "Soft reconfig inbound update\n")
5068
5069 DEFUN (clear_ip_bgp_all_in_prefix_filter,
5070 clear_ip_bgp_all_in_prefix_filter_cmd,
5071 "clear ip bgp * in prefix-filter",
5072 CLEAR_STR
5073 IP_STR
5074 BGP_STR
5075 "Clear all peers\n"
5076 "Soft reconfig inbound update\n"
5077 "Push out prefix-list ORF and do inbound soft reconfig\n")
5078 {
5079 if (argc== 1)
5080 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5081 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5082
5083 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5084 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5085 }
5086
5087 ALIAS (clear_ip_bgp_all_in_prefix_filter,
5088 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
5089 "clear ip bgp view WORD * in prefix-filter",
5090 CLEAR_STR
5091 IP_STR
5092 BGP_STR
5093 "BGP view\n"
5094 "view name\n"
5095 "Clear all peers\n"
5096 "Soft reconfig inbound update\n"
5097 "Push out prefix-list ORF and do inbound soft reconfig\n")
5098
5099
5100 DEFUN (clear_ip_bgp_all_ipv4_soft_in,
5101 clear_ip_bgp_all_ipv4_soft_in_cmd,
5102 "clear ip bgp * ipv4 (unicast|multicast) soft in",
5103 CLEAR_STR
5104 IP_STR
5105 BGP_STR
5106 "Clear all peers\n"
5107 "Address family\n"
5108 "Address Family modifier\n"
5109 "Address Family modifier\n"
5110 "Soft reconfig\n"
5111 "Soft reconfig inbound update\n")
5112 {
5113 if (strncmp (argv[0], "m", 1) == 0)
5114 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5115 BGP_CLEAR_SOFT_IN, NULL);
5116
5117 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5118 BGP_CLEAR_SOFT_IN, NULL);
5119 }
5120
5121 ALIAS (clear_ip_bgp_all_ipv4_soft_in,
5122 clear_ip_bgp_all_ipv4_in_cmd,
5123 "clear ip bgp * ipv4 (unicast|multicast) in",
5124 CLEAR_STR
5125 IP_STR
5126 BGP_STR
5127 "Clear all peers\n"
5128 "Address family\n"
5129 "Address Family modifier\n"
5130 "Address Family modifier\n"
5131 "Soft reconfig inbound update\n")
5132
5133 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
5134 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
5135 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
5136 CLEAR_STR
5137 IP_STR
5138 BGP_STR
5139 "BGP view\n"
5140 "view name\n"
5141 "Clear all peers\n"
5142 "Address family\n"
5143 "Address Family modifier\n"
5144 "Address Family modifier\n"
5145 "Soft reconfig\n"
5146 "Soft reconfig inbound update\n")
5147 {
5148 if (strncmp (argv[1], "m", 1) == 0)
5149 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5150 BGP_CLEAR_SOFT_IN, NULL);
5151
5152 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5153 BGP_CLEAR_SOFT_IN, NULL);
5154 }
5155
5156 DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
5157 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
5158 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
5159 CLEAR_STR
5160 IP_STR
5161 BGP_STR
5162 "Clear all peers\n"
5163 "Address family\n"
5164 "Address Family modifier\n"
5165 "Address Family modifier\n"
5166 "Soft reconfig inbound update\n"
5167 "Push out prefix-list ORF and do inbound soft reconfig\n")
5168 {
5169 if (strncmp (argv[0], "m", 1) == 0)
5170 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
5171 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5172
5173 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
5174 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5175 }
5176
5177 DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
5178 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
5179 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
5180 CLEAR_STR
5181 IP_STR
5182 BGP_STR
5183 "Clear all peers\n"
5184 "Address family\n"
5185 "Address Family modifier\n"
5186 "Address Family modifier\n"
5187 "Soft reconfig inbound update\n"
5188 "Push out prefix-list ORF and do inbound soft reconfig\n")
5189 {
5190 if (strncmp (argv[1], "m", 1) == 0)
5191 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
5192 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5193
5194 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
5195 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5196 }
5197
5198 DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
5199 clear_ip_bgp_all_vpnv4_soft_in_cmd,
5200 "clear ip bgp * vpnv4 unicast soft in",
5201 CLEAR_STR
5202 IP_STR
5203 BGP_STR
5204 "Clear all peers\n"
5205 "Address family\n"
5206 "Address Family Modifier\n"
5207 "Soft reconfig\n"
5208 "Soft reconfig inbound update\n")
5209 {
5210 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
5211 BGP_CLEAR_SOFT_IN, NULL);
5212 }
5213
5214 ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
5215 clear_ip_bgp_all_vpnv4_in_cmd,
5216 "clear ip bgp * vpnv4 unicast in",
5217 CLEAR_STR
5218 IP_STR
5219 BGP_STR
5220 "Clear all peers\n"
5221 "Address family\n"
5222 "Address Family Modifier\n"
5223 "Soft reconfig inbound update\n")
5224
5225 DEFUN (clear_bgp_all_soft_in,
5226 clear_bgp_all_soft_in_cmd,
5227 "clear bgp * soft in",
5228 CLEAR_STR
5229 BGP_STR
5230 "Clear all peers\n"
5231 "Soft reconfig\n"
5232 "Soft reconfig inbound update\n")
5233 {
5234 if (argc == 1)
5235 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
5236 BGP_CLEAR_SOFT_IN, NULL);
5237
5238 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5239 BGP_CLEAR_SOFT_IN, NULL);
5240 }
5241
5242 ALIAS (clear_bgp_all_soft_in,
5243 clear_bgp_instance_all_soft_in_cmd,
5244 "clear bgp view WORD * soft in",
5245 CLEAR_STR
5246 BGP_STR
5247 "BGP view\n"
5248 "view name\n"
5249 "Clear all peers\n"
5250 "Soft reconfig\n"
5251 "Soft reconfig inbound update\n")
5252
5253 ALIAS (clear_bgp_all_soft_in,
5254 clear_bgp_ipv6_all_soft_in_cmd,
5255 "clear bgp ipv6 * soft in",
5256 CLEAR_STR
5257 BGP_STR
5258 "Address family\n"
5259 "Clear all peers\n"
5260 "Soft reconfig\n"
5261 "Soft reconfig inbound update\n")
5262
5263 ALIAS (clear_bgp_all_soft_in,
5264 clear_bgp_all_in_cmd,
5265 "clear bgp * in",
5266 CLEAR_STR
5267 BGP_STR
5268 "Clear all peers\n"
5269 "Soft reconfig inbound update\n")
5270
5271 ALIAS (clear_bgp_all_soft_in,
5272 clear_bgp_ipv6_all_in_cmd,
5273 "clear bgp ipv6 * in",
5274 CLEAR_STR
5275 BGP_STR
5276 "Address family\n"
5277 "Clear all peers\n"
5278 "Soft reconfig inbound update\n")
5279
5280 DEFUN (clear_bgp_all_in_prefix_filter,
5281 clear_bgp_all_in_prefix_filter_cmd,
5282 "clear bgp * in prefix-filter",
5283 CLEAR_STR
5284 BGP_STR
5285 "Clear all peers\n"
5286 "Soft reconfig inbound update\n"
5287 "Push out prefix-list ORF and do inbound soft reconfig\n")
5288 {
5289 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
5290 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5291 }
5292
5293 ALIAS (clear_bgp_all_in_prefix_filter,
5294 clear_bgp_ipv6_all_in_prefix_filter_cmd,
5295 "clear bgp ipv6 * in prefix-filter",
5296 CLEAR_STR
5297 BGP_STR
5298 "Address family\n"
5299 "Clear all peers\n"
5300 "Soft reconfig inbound update\n"
5301 "Push out prefix-list ORF and do inbound soft reconfig\n")
5302
5303 DEFUN (clear_ip_bgp_peer_soft_in,
5304 clear_ip_bgp_peer_soft_in_cmd,
5305 "clear ip bgp A.B.C.D soft in",
5306 CLEAR_STR
5307 IP_STR
5308 BGP_STR
5309 "BGP neighbor address to clear\n"
5310 "Soft reconfig\n"
5311 "Soft reconfig inbound update\n")
5312 {
5313 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5314 BGP_CLEAR_SOFT_IN, argv[0]);
5315 }
5316
5317 ALIAS (clear_ip_bgp_peer_soft_in,
5318 clear_ip_bgp_peer_in_cmd,
5319 "clear ip bgp A.B.C.D in",
5320 CLEAR_STR
5321 IP_STR
5322 BGP_STR
5323 "BGP neighbor address to clear\n"
5324 "Soft reconfig inbound update\n")
5325
5326 DEFUN (clear_ip_bgp_peer_in_prefix_filter,
5327 clear_ip_bgp_peer_in_prefix_filter_cmd,
5328 "clear ip bgp A.B.C.D in prefix-filter",
5329 CLEAR_STR
5330 IP_STR
5331 BGP_STR
5332 "BGP neighbor address to clear\n"
5333 "Soft reconfig inbound update\n"
5334 "Push out the existing ORF prefix-list\n")
5335 {
5336 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5337 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5338 }
5339
5340 DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
5341 clear_ip_bgp_peer_ipv4_soft_in_cmd,
5342 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
5343 CLEAR_STR
5344 IP_STR
5345 BGP_STR
5346 "BGP neighbor address to clear\n"
5347 "Address family\n"
5348 "Address Family modifier\n"
5349 "Address Family modifier\n"
5350 "Soft reconfig\n"
5351 "Soft reconfig inbound update\n")
5352 {
5353 if (strncmp (argv[1], "m", 1) == 0)
5354 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5355 BGP_CLEAR_SOFT_IN, argv[0]);
5356
5357 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5358 BGP_CLEAR_SOFT_IN, argv[0]);
5359 }
5360
5361 ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
5362 clear_ip_bgp_peer_ipv4_in_cmd,
5363 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
5364 CLEAR_STR
5365 IP_STR
5366 BGP_STR
5367 "BGP neighbor address to clear\n"
5368 "Address family\n"
5369 "Address Family modifier\n"
5370 "Address Family modifier\n"
5371 "Soft reconfig inbound update\n")
5372
5373 DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
5374 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
5375 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in prefix-filter",
5376 CLEAR_STR
5377 IP_STR
5378 BGP_STR
5379 "BGP neighbor address to clear\n"
5380 "Address family\n"
5381 "Address Family modifier\n"
5382 "Address Family modifier\n"
5383 "Soft reconfig inbound update\n"
5384 "Push out the existing ORF prefix-list\n")
5385 {
5386 if (strncmp (argv[1], "m", 1) == 0)
5387 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
5388 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5389
5390 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
5391 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5392 }
5393
5394 DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
5395 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
5396 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
5397 CLEAR_STR
5398 IP_STR
5399 BGP_STR
5400 "BGP neighbor address to clear\n"
5401 "Address family\n"
5402 "Address Family Modifier\n"
5403 "Soft reconfig\n"
5404 "Soft reconfig inbound update\n")
5405 {
5406 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
5407 BGP_CLEAR_SOFT_IN, argv[0]);
5408 }
5409
5410 ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
5411 clear_ip_bgp_peer_vpnv4_in_cmd,
5412 "clear ip bgp A.B.C.D vpnv4 unicast in",
5413 CLEAR_STR
5414 IP_STR
5415 BGP_STR
5416 "BGP neighbor address to clear\n"
5417 "Address family\n"
5418 "Address Family Modifier\n"
5419 "Soft reconfig inbound update\n")
5420
5421 DEFUN (clear_bgp_peer_soft_in,
5422 clear_bgp_peer_soft_in_cmd,
5423 "clear bgp (A.B.C.D|X:X::X:X) soft in",
5424 CLEAR_STR
5425 BGP_STR
5426 "BGP neighbor address to clear\n"
5427 "BGP IPv6 neighbor to clear\n"
5428 "Soft reconfig\n"
5429 "Soft reconfig inbound update\n")
5430 {
5431 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5432 BGP_CLEAR_SOFT_IN, argv[0]);
5433 }
5434
5435 ALIAS (clear_bgp_peer_soft_in,
5436 clear_bgp_ipv6_peer_soft_in_cmd,
5437 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
5438 CLEAR_STR
5439 BGP_STR
5440 "Address family\n"
5441 "BGP neighbor address to clear\n"
5442 "BGP IPv6 neighbor to clear\n"
5443 "Soft reconfig\n"
5444 "Soft reconfig inbound update\n")
5445
5446 ALIAS (clear_bgp_peer_soft_in,
5447 clear_bgp_peer_in_cmd,
5448 "clear bgp (A.B.C.D|X:X::X:X) in",
5449 CLEAR_STR
5450 BGP_STR
5451 "BGP neighbor address to clear\n"
5452 "BGP IPv6 neighbor to clear\n"
5453 "Soft reconfig inbound update\n")
5454
5455 ALIAS (clear_bgp_peer_soft_in,
5456 clear_bgp_ipv6_peer_in_cmd,
5457 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
5458 CLEAR_STR
5459 BGP_STR
5460 "Address family\n"
5461 "BGP neighbor address to clear\n"
5462 "BGP IPv6 neighbor to clear\n"
5463 "Soft reconfig inbound update\n")
5464
5465 DEFUN (clear_bgp_peer_in_prefix_filter,
5466 clear_bgp_peer_in_prefix_filter_cmd,
5467 "clear bgp (A.B.C.D|X:X::X:X) in prefix-filter",
5468 CLEAR_STR
5469 BGP_STR
5470 "BGP neighbor address to clear\n"
5471 "BGP IPv6 neighbor to clear\n"
5472 "Soft reconfig inbound update\n"
5473 "Push out the existing ORF prefix-list\n")
5474 {
5475 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
5476 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5477 }
5478
5479 ALIAS (clear_bgp_peer_in_prefix_filter,
5480 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
5481 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in prefix-filter",
5482 CLEAR_STR
5483 BGP_STR
5484 "Address family\n"
5485 "BGP neighbor address to clear\n"
5486 "BGP IPv6 neighbor to clear\n"
5487 "Soft reconfig inbound update\n"
5488 "Push out the existing ORF prefix-list\n")
5489
5490 DEFUN (clear_ip_bgp_peer_group_soft_in,
5491 clear_ip_bgp_peer_group_soft_in_cmd,
5492 "clear ip bgp peer-group WORD soft in",
5493 CLEAR_STR
5494 IP_STR
5495 BGP_STR
5496 "Clear all members of peer-group\n"
5497 "BGP peer-group name\n"
5498 "Soft reconfig\n"
5499 "Soft reconfig inbound update\n")
5500 {
5501 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5502 BGP_CLEAR_SOFT_IN, argv[0]);
5503 }
5504
5505 ALIAS (clear_ip_bgp_peer_group_soft_in,
5506 clear_ip_bgp_peer_group_in_cmd,
5507 "clear ip bgp peer-group WORD in",
5508 CLEAR_STR
5509 IP_STR
5510 BGP_STR
5511 "Clear all members of peer-group\n"
5512 "BGP peer-group name\n"
5513 "Soft reconfig inbound update\n")
5514
5515 DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
5516 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
5517 "clear ip bgp peer-group WORD in prefix-filter",
5518 CLEAR_STR
5519 IP_STR
5520 BGP_STR
5521 "Clear all members of peer-group\n"
5522 "BGP peer-group name\n"
5523 "Soft reconfig inbound update\n"
5524 "Push out prefix-list ORF and do inbound soft reconfig\n")
5525 {
5526 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5527 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5528 }
5529
5530 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
5531 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
5532 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
5533 CLEAR_STR
5534 IP_STR
5535 BGP_STR
5536 "Clear all members of peer-group\n"
5537 "BGP peer-group name\n"
5538 "Address family\n"
5539 "Address Family modifier\n"
5540 "Address Family modifier\n"
5541 "Soft reconfig\n"
5542 "Soft reconfig inbound update\n")
5543 {
5544 if (strncmp (argv[1], "m", 1) == 0)
5545 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5546 BGP_CLEAR_SOFT_IN, argv[0]);
5547
5548 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5549 BGP_CLEAR_SOFT_IN, argv[0]);
5550 }
5551
5552 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
5553 clear_ip_bgp_peer_group_ipv4_in_cmd,
5554 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
5555 CLEAR_STR
5556 IP_STR
5557 BGP_STR
5558 "Clear all members of peer-group\n"
5559 "BGP peer-group name\n"
5560 "Address family\n"
5561 "Address Family modifier\n"
5562 "Address Family modifier\n"
5563 "Soft reconfig inbound update\n")
5564
5565 DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
5566 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
5567 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
5568 CLEAR_STR
5569 IP_STR
5570 BGP_STR
5571 "Clear all members of peer-group\n"
5572 "BGP peer-group name\n"
5573 "Address family\n"
5574 "Address Family modifier\n"
5575 "Address Family modifier\n"
5576 "Soft reconfig inbound update\n"
5577 "Push out prefix-list ORF and do inbound soft reconfig\n")
5578 {
5579 if (strncmp (argv[1], "m", 1) == 0)
5580 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
5581 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5582
5583 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
5584 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5585 }
5586
5587 DEFUN (clear_bgp_peer_group_soft_in,
5588 clear_bgp_peer_group_soft_in_cmd,
5589 "clear bgp peer-group WORD soft in",
5590 CLEAR_STR
5591 BGP_STR
5592 "Clear all members of peer-group\n"
5593 "BGP peer-group name\n"
5594 "Soft reconfig\n"
5595 "Soft reconfig inbound update\n")
5596 {
5597 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5598 BGP_CLEAR_SOFT_IN, argv[0]);
5599 }
5600
5601 ALIAS (clear_bgp_peer_group_soft_in,
5602 clear_bgp_ipv6_peer_group_soft_in_cmd,
5603 "clear bgp ipv6 peer-group WORD soft in",
5604 CLEAR_STR
5605 BGP_STR
5606 "Address family\n"
5607 "Clear all members of peer-group\n"
5608 "BGP peer-group name\n"
5609 "Soft reconfig\n"
5610 "Soft reconfig inbound update\n")
5611
5612 ALIAS (clear_bgp_peer_group_soft_in,
5613 clear_bgp_peer_group_in_cmd,
5614 "clear bgp peer-group WORD in",
5615 CLEAR_STR
5616 BGP_STR
5617 "Clear all members of peer-group\n"
5618 "BGP peer-group name\n"
5619 "Soft reconfig inbound update\n")
5620
5621 ALIAS (clear_bgp_peer_group_soft_in,
5622 clear_bgp_ipv6_peer_group_in_cmd,
5623 "clear bgp ipv6 peer-group WORD in",
5624 CLEAR_STR
5625 BGP_STR
5626 "Address family\n"
5627 "Clear all members of peer-group\n"
5628 "BGP peer-group name\n"
5629 "Soft reconfig inbound update\n")
5630
5631 DEFUN (clear_bgp_peer_group_in_prefix_filter,
5632 clear_bgp_peer_group_in_prefix_filter_cmd,
5633 "clear bgp peer-group WORD in prefix-filter",
5634 CLEAR_STR
5635 BGP_STR
5636 "Clear all members of peer-group\n"
5637 "BGP peer-group name\n"
5638 "Soft reconfig inbound update\n"
5639 "Push out prefix-list ORF and do inbound soft reconfig\n")
5640 {
5641 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
5642 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5643 }
5644
5645 ALIAS (clear_bgp_peer_group_in_prefix_filter,
5646 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
5647 "clear bgp ipv6 peer-group WORD in prefix-filter",
5648 CLEAR_STR
5649 BGP_STR
5650 "Address family\n"
5651 "Clear all members of peer-group\n"
5652 "BGP peer-group name\n"
5653 "Soft reconfig inbound update\n"
5654 "Push out prefix-list ORF and do inbound soft reconfig\n")
5655
5656 DEFUN (clear_ip_bgp_external_soft_in,
5657 clear_ip_bgp_external_soft_in_cmd,
5658 "clear ip bgp external soft in",
5659 CLEAR_STR
5660 IP_STR
5661 BGP_STR
5662 "Clear all external peers\n"
5663 "Soft reconfig\n"
5664 "Soft reconfig inbound update\n")
5665 {
5666 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5667 BGP_CLEAR_SOFT_IN, NULL);
5668 }
5669
5670 ALIAS (clear_ip_bgp_external_soft_in,
5671 clear_ip_bgp_external_in_cmd,
5672 "clear ip bgp external in",
5673 CLEAR_STR
5674 IP_STR
5675 BGP_STR
5676 "Clear all external peers\n"
5677 "Soft reconfig inbound update\n")
5678
5679 DEFUN (clear_ip_bgp_external_in_prefix_filter,
5680 clear_ip_bgp_external_in_prefix_filter_cmd,
5681 "clear ip bgp external in prefix-filter",
5682 CLEAR_STR
5683 IP_STR
5684 BGP_STR
5685 "Clear all external peers\n"
5686 "Soft reconfig inbound update\n"
5687 "Push out prefix-list ORF and do inbound soft reconfig\n")
5688 {
5689 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5690 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5691 }
5692
5693 DEFUN (clear_ip_bgp_external_ipv4_soft_in,
5694 clear_ip_bgp_external_ipv4_soft_in_cmd,
5695 "clear ip bgp external ipv4 (unicast|multicast) soft in",
5696 CLEAR_STR
5697 IP_STR
5698 BGP_STR
5699 "Clear all external peers\n"
5700 "Address family\n"
5701 "Address Family modifier\n"
5702 "Address Family modifier\n"
5703 "Soft reconfig\n"
5704 "Soft reconfig inbound update\n")
5705 {
5706 if (strncmp (argv[0], "m", 1) == 0)
5707 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5708 BGP_CLEAR_SOFT_IN, NULL);
5709
5710 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5711 BGP_CLEAR_SOFT_IN, NULL);
5712 }
5713
5714 ALIAS (clear_ip_bgp_external_ipv4_soft_in,
5715 clear_ip_bgp_external_ipv4_in_cmd,
5716 "clear ip bgp external ipv4 (unicast|multicast) in",
5717 CLEAR_STR
5718 IP_STR
5719 BGP_STR
5720 "Clear all external peers\n"
5721 "Address family\n"
5722 "Address Family modifier\n"
5723 "Address Family modifier\n"
5724 "Soft reconfig inbound update\n")
5725
5726 DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
5727 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
5728 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
5729 CLEAR_STR
5730 IP_STR
5731 BGP_STR
5732 "Clear all external peers\n"
5733 "Address family\n"
5734 "Address Family modifier\n"
5735 "Address Family modifier\n"
5736 "Soft reconfig inbound update\n"
5737 "Push out prefix-list ORF and do inbound soft reconfig\n")
5738 {
5739 if (strncmp (argv[0], "m", 1) == 0)
5740 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
5741 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5742
5743 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
5744 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5745 }
5746
5747 DEFUN (clear_bgp_external_soft_in,
5748 clear_bgp_external_soft_in_cmd,
5749 "clear bgp external soft in",
5750 CLEAR_STR
5751 BGP_STR
5752 "Clear all external peers\n"
5753 "Soft reconfig\n"
5754 "Soft reconfig inbound update\n")
5755 {
5756 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5757 BGP_CLEAR_SOFT_IN, NULL);
5758 }
5759
5760 ALIAS (clear_bgp_external_soft_in,
5761 clear_bgp_ipv6_external_soft_in_cmd,
5762 "clear bgp ipv6 external soft in",
5763 CLEAR_STR
5764 BGP_STR
5765 "Address family\n"
5766 "Clear all external peers\n"
5767 "Soft reconfig\n"
5768 "Soft reconfig inbound update\n")
5769
5770 ALIAS (clear_bgp_external_soft_in,
5771 clear_bgp_external_in_cmd,
5772 "clear bgp external in",
5773 CLEAR_STR
5774 BGP_STR
5775 "Clear all external peers\n"
5776 "Soft reconfig inbound update\n")
5777
5778 ALIAS (clear_bgp_external_soft_in,
5779 clear_bgp_ipv6_external_in_cmd,
5780 "clear bgp ipv6 external WORD in",
5781 CLEAR_STR
5782 BGP_STR
5783 "Address family\n"
5784 "Clear all external peers\n"
5785 "Soft reconfig inbound update\n")
5786
5787 DEFUN (clear_bgp_external_in_prefix_filter,
5788 clear_bgp_external_in_prefix_filter_cmd,
5789 "clear bgp external in prefix-filter",
5790 CLEAR_STR
5791 BGP_STR
5792 "Clear all external peers\n"
5793 "Soft reconfig inbound update\n"
5794 "Push out prefix-list ORF and do inbound soft reconfig\n")
5795 {
5796 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
5797 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
5798 }
5799
5800 ALIAS (clear_bgp_external_in_prefix_filter,
5801 clear_bgp_ipv6_external_in_prefix_filter_cmd,
5802 "clear bgp ipv6 external in prefix-filter",
5803 CLEAR_STR
5804 BGP_STR
5805 "Address family\n"
5806 "Clear all external peers\n"
5807 "Soft reconfig inbound update\n"
5808 "Push out prefix-list ORF and do inbound soft reconfig\n")
5809
5810 DEFUN (clear_ip_bgp_as_soft_in,
5811 clear_ip_bgp_as_soft_in_cmd,
5812 "clear ip bgp " CMD_AS_RANGE " soft in",
5813 CLEAR_STR
5814 IP_STR
5815 BGP_STR
5816 "Clear peers with the AS number\n"
5817 "Soft reconfig\n"
5818 "Soft reconfig inbound update\n")
5819 {
5820 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5821 BGP_CLEAR_SOFT_IN, argv[0]);
5822 }
5823
5824 ALIAS (clear_ip_bgp_as_soft_in,
5825 clear_ip_bgp_as_in_cmd,
5826 "clear ip bgp " CMD_AS_RANGE " in",
5827 CLEAR_STR
5828 IP_STR
5829 BGP_STR
5830 "Clear peers with the AS number\n"
5831 "Soft reconfig inbound update\n")
5832
5833 DEFUN (clear_ip_bgp_as_in_prefix_filter,
5834 clear_ip_bgp_as_in_prefix_filter_cmd,
5835 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
5836 CLEAR_STR
5837 IP_STR
5838 BGP_STR
5839 "Clear peers with the AS number\n"
5840 "Soft reconfig inbound update\n"
5841 "Push out prefix-list ORF and do inbound soft reconfig\n")
5842 {
5843 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5844 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5845 }
5846
5847 DEFUN (clear_ip_bgp_as_ipv4_soft_in,
5848 clear_ip_bgp_as_ipv4_soft_in_cmd,
5849 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
5850 CLEAR_STR
5851 IP_STR
5852 BGP_STR
5853 "Clear peers with the AS number\n"
5854 "Address family\n"
5855 "Address Family modifier\n"
5856 "Address Family modifier\n"
5857 "Soft reconfig\n"
5858 "Soft reconfig inbound update\n")
5859 {
5860 if (strncmp (argv[1], "m", 1) == 0)
5861 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5862 BGP_CLEAR_SOFT_IN, argv[0]);
5863
5864 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5865 BGP_CLEAR_SOFT_IN, argv[0]);
5866 }
5867
5868 ALIAS (clear_ip_bgp_as_ipv4_soft_in,
5869 clear_ip_bgp_as_ipv4_in_cmd,
5870 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
5871 CLEAR_STR
5872 IP_STR
5873 BGP_STR
5874 "Clear peers with the AS number\n"
5875 "Address family\n"
5876 "Address Family modifier\n"
5877 "Address Family modifier\n"
5878 "Soft reconfig inbound update\n")
5879
5880 DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
5881 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
5882 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
5883 CLEAR_STR
5884 IP_STR
5885 BGP_STR
5886 "Clear peers with the AS number\n"
5887 "Address family\n"
5888 "Address Family modifier\n"
5889 "Address Family modifier\n"
5890 "Soft reconfig inbound update\n"
5891 "Push out prefix-list ORF and do inbound soft reconfig\n")
5892 {
5893 if (strncmp (argv[1], "m", 1) == 0)
5894 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
5895 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5896
5897 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
5898 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5899 }
5900
5901 DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
5902 clear_ip_bgp_as_vpnv4_soft_in_cmd,
5903 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
5904 CLEAR_STR
5905 IP_STR
5906 BGP_STR
5907 "Clear peers with the AS number\n"
5908 "Address family\n"
5909 "Address Family modifier\n"
5910 "Soft reconfig\n"
5911 "Soft reconfig inbound update\n")
5912 {
5913 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
5914 BGP_CLEAR_SOFT_IN, argv[0]);
5915 }
5916
5917 ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
5918 clear_ip_bgp_as_vpnv4_in_cmd,
5919 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
5920 CLEAR_STR
5921 IP_STR
5922 BGP_STR
5923 "Clear peers with the AS number\n"
5924 "Address family\n"
5925 "Address Family modifier\n"
5926 "Soft reconfig inbound update\n")
5927
5928 DEFUN (clear_bgp_as_soft_in,
5929 clear_bgp_as_soft_in_cmd,
5930 "clear bgp " CMD_AS_RANGE " soft in",
5931 CLEAR_STR
5932 BGP_STR
5933 "Clear peers with the AS number\n"
5934 "Soft reconfig\n"
5935 "Soft reconfig inbound update\n")
5936 {
5937 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5938 BGP_CLEAR_SOFT_IN, argv[0]);
5939 }
5940
5941 ALIAS (clear_bgp_as_soft_in,
5942 clear_bgp_ipv6_as_soft_in_cmd,
5943 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
5944 CLEAR_STR
5945 BGP_STR
5946 "Address family\n"
5947 "Clear peers with the AS number\n"
5948 "Soft reconfig\n"
5949 "Soft reconfig inbound update\n")
5950
5951 ALIAS (clear_bgp_as_soft_in,
5952 clear_bgp_as_in_cmd,
5953 "clear bgp " CMD_AS_RANGE " in",
5954 CLEAR_STR
5955 BGP_STR
5956 "Clear peers with the AS number\n"
5957 "Soft reconfig inbound update\n")
5958
5959 ALIAS (clear_bgp_as_soft_in,
5960 clear_bgp_ipv6_as_in_cmd,
5961 "clear bgp ipv6 " CMD_AS_RANGE " in",
5962 CLEAR_STR
5963 BGP_STR
5964 "Address family\n"
5965 "Clear peers with the AS number\n"
5966 "Soft reconfig inbound update\n")
5967
5968 DEFUN (clear_bgp_as_in_prefix_filter,
5969 clear_bgp_as_in_prefix_filter_cmd,
5970 "clear bgp " CMD_AS_RANGE " in prefix-filter",
5971 CLEAR_STR
5972 BGP_STR
5973 "Clear peers with the AS number\n"
5974 "Soft reconfig inbound update\n"
5975 "Push out prefix-list ORF and do inbound soft reconfig\n")
5976 {
5977 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
5978 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
5979 }
5980
5981 ALIAS (clear_bgp_as_in_prefix_filter,
5982 clear_bgp_ipv6_as_in_prefix_filter_cmd,
5983 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
5984 CLEAR_STR
5985 BGP_STR
5986 "Address family\n"
5987 "Clear peers with the AS number\n"
5988 "Soft reconfig inbound update\n"
5989 "Push out prefix-list ORF and do inbound soft reconfig\n")
5990 \f
5991 /* Both soft-reconfiguration */
5992 DEFUN (clear_ip_bgp_all_soft,
5993 clear_ip_bgp_all_soft_cmd,
5994 "clear ip bgp * soft",
5995 CLEAR_STR
5996 IP_STR
5997 BGP_STR
5998 "Clear all peers\n"
5999 "Soft reconfig\n")
6000 {
6001 if (argc == 1)
6002 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6003 BGP_CLEAR_SOFT_BOTH, NULL);
6004
6005 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6006 BGP_CLEAR_SOFT_BOTH, NULL);
6007 }
6008
6009 ALIAS (clear_ip_bgp_all_soft,
6010 clear_ip_bgp_instance_all_soft_cmd,
6011 "clear ip bgp view WORD * soft",
6012 CLEAR_STR
6013 IP_STR
6014 BGP_STR
6015 "BGP view\n"
6016 "view name\n"
6017 "Clear all peers\n"
6018 "Soft reconfig\n")
6019
6020
6021 DEFUN (clear_ip_bgp_all_ipv4_soft,
6022 clear_ip_bgp_all_ipv4_soft_cmd,
6023 "clear ip bgp * ipv4 (unicast|multicast) soft",
6024 CLEAR_STR
6025 IP_STR
6026 BGP_STR
6027 "Clear all peers\n"
6028 "Address family\n"
6029 "Address Family Modifier\n"
6030 "Address Family Modifier\n"
6031 "Soft reconfig\n")
6032 {
6033 if (strncmp (argv[0], "m", 1) == 0)
6034 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6035 BGP_CLEAR_SOFT_BOTH, NULL);
6036
6037 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6038 BGP_CLEAR_SOFT_BOTH, NULL);
6039 }
6040
6041 DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
6042 clear_ip_bgp_instance_all_ipv4_soft_cmd,
6043 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
6044 CLEAR_STR
6045 IP_STR
6046 BGP_STR
6047 "BGP view\n"
6048 "view name\n"
6049 "Clear all peers\n"
6050 "Address family\n"
6051 "Address Family Modifier\n"
6052 "Address Family Modifier\n"
6053 "Soft reconfig\n")
6054 {
6055 if (strncmp (argv[1], "m", 1) == 0)
6056 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6057 BGP_CLEAR_SOFT_BOTH, NULL);
6058
6059 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6060 BGP_CLEAR_SOFT_BOTH, NULL);
6061 }
6062
6063 DEFUN (clear_ip_bgp_all_vpnv4_soft,
6064 clear_ip_bgp_all_vpnv4_soft_cmd,
6065 "clear ip bgp * vpnv4 unicast soft",
6066 CLEAR_STR
6067 IP_STR
6068 BGP_STR
6069 "Clear all peers\n"
6070 "Address family\n"
6071 "Address Family Modifier\n"
6072 "Soft reconfig\n")
6073 {
6074 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6075 BGP_CLEAR_SOFT_BOTH, argv[0]);
6076 }
6077
6078 DEFUN (clear_bgp_all_soft,
6079 clear_bgp_all_soft_cmd,
6080 "clear bgp * soft",
6081 CLEAR_STR
6082 BGP_STR
6083 "Clear all peers\n"
6084 "Soft reconfig\n")
6085 {
6086 if (argc == 1)
6087 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6088 BGP_CLEAR_SOFT_BOTH, argv[0]);
6089
6090 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6091 BGP_CLEAR_SOFT_BOTH, argv[0]);
6092 }
6093
6094 ALIAS (clear_bgp_all_soft,
6095 clear_bgp_instance_all_soft_cmd,
6096 "clear bgp view WORD * soft",
6097 CLEAR_STR
6098 BGP_STR
6099 "BGP view\n"
6100 "view name\n"
6101 "Clear all peers\n"
6102 "Soft reconfig\n")
6103
6104 ALIAS (clear_bgp_all_soft,
6105 clear_bgp_ipv6_all_soft_cmd,
6106 "clear bgp ipv6 * soft",
6107 CLEAR_STR
6108 BGP_STR
6109 "Address family\n"
6110 "Clear all peers\n"
6111 "Soft reconfig\n")
6112
6113 DEFUN (clear_ip_bgp_peer_soft,
6114 clear_ip_bgp_peer_soft_cmd,
6115 "clear ip bgp A.B.C.D soft",
6116 CLEAR_STR
6117 IP_STR
6118 BGP_STR
6119 "BGP neighbor address to clear\n"
6120 "Soft reconfig\n")
6121 {
6122 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6123 BGP_CLEAR_SOFT_BOTH, argv[0]);
6124 }
6125
6126 DEFUN (clear_ip_bgp_peer_ipv4_soft,
6127 clear_ip_bgp_peer_ipv4_soft_cmd,
6128 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6129 CLEAR_STR
6130 IP_STR
6131 BGP_STR
6132 "BGP neighbor address to clear\n"
6133 "Address family\n"
6134 "Address Family Modifier\n"
6135 "Address Family Modifier\n"
6136 "Soft reconfig\n")
6137 {
6138 if (strncmp (argv[1], "m", 1) == 0)
6139 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6140 BGP_CLEAR_SOFT_BOTH, argv[0]);
6141
6142 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6143 BGP_CLEAR_SOFT_BOTH, argv[0]);
6144 }
6145
6146 DEFUN (clear_ip_bgp_peer_vpnv4_soft,
6147 clear_ip_bgp_peer_vpnv4_soft_cmd,
6148 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6149 CLEAR_STR
6150 IP_STR
6151 BGP_STR
6152 "BGP neighbor address to clear\n"
6153 "Address family\n"
6154 "Address Family Modifier\n"
6155 "Soft reconfig\n")
6156 {
6157 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6158 BGP_CLEAR_SOFT_BOTH, argv[0]);
6159 }
6160
6161 DEFUN (clear_bgp_peer_soft,
6162 clear_bgp_peer_soft_cmd,
6163 "clear bgp (A.B.C.D|X:X::X:X) soft",
6164 CLEAR_STR
6165 BGP_STR
6166 "BGP neighbor address to clear\n"
6167 "BGP IPv6 neighbor to clear\n"
6168 "Soft reconfig\n")
6169 {
6170 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6171 BGP_CLEAR_SOFT_BOTH, argv[0]);
6172 }
6173
6174 ALIAS (clear_bgp_peer_soft,
6175 clear_bgp_ipv6_peer_soft_cmd,
6176 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
6177 CLEAR_STR
6178 BGP_STR
6179 "Address family\n"
6180 "BGP neighbor address to clear\n"
6181 "BGP IPv6 neighbor to clear\n"
6182 "Soft reconfig\n")
6183
6184 DEFUN (clear_ip_bgp_peer_group_soft,
6185 clear_ip_bgp_peer_group_soft_cmd,
6186 "clear ip bgp peer-group WORD soft",
6187 CLEAR_STR
6188 IP_STR
6189 BGP_STR
6190 "Clear all members of peer-group\n"
6191 "BGP peer-group name\n"
6192 "Soft reconfig\n")
6193 {
6194 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6195 BGP_CLEAR_SOFT_BOTH, argv[0]);
6196 }
6197
6198 DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
6199 clear_ip_bgp_peer_group_ipv4_soft_cmd,
6200 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
6201 CLEAR_STR
6202 IP_STR
6203 BGP_STR
6204 "Clear all members of peer-group\n"
6205 "BGP peer-group name\n"
6206 "Address family\n"
6207 "Address Family modifier\n"
6208 "Address Family modifier\n"
6209 "Soft reconfig\n")
6210 {
6211 if (strncmp (argv[1], "m", 1) == 0)
6212 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6213 BGP_CLEAR_SOFT_BOTH, argv[0]);
6214
6215 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6216 BGP_CLEAR_SOFT_BOTH, argv[0]);
6217 }
6218
6219 DEFUN (clear_bgp_peer_group_soft,
6220 clear_bgp_peer_group_soft_cmd,
6221 "clear bgp peer-group WORD soft",
6222 CLEAR_STR
6223 BGP_STR
6224 "Clear all members of peer-group\n"
6225 "BGP peer-group name\n"
6226 "Soft reconfig\n")
6227 {
6228 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6229 BGP_CLEAR_SOFT_BOTH, argv[0]);
6230 }
6231
6232 ALIAS (clear_bgp_peer_group_soft,
6233 clear_bgp_ipv6_peer_group_soft_cmd,
6234 "clear bgp ipv6 peer-group WORD soft",
6235 CLEAR_STR
6236 BGP_STR
6237 "Address family\n"
6238 "Clear all members of peer-group\n"
6239 "BGP peer-group name\n"
6240 "Soft reconfig\n")
6241
6242 DEFUN (clear_ip_bgp_external_soft,
6243 clear_ip_bgp_external_soft_cmd,
6244 "clear ip bgp external soft",
6245 CLEAR_STR
6246 IP_STR
6247 BGP_STR
6248 "Clear all external peers\n"
6249 "Soft reconfig\n")
6250 {
6251 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6252 BGP_CLEAR_SOFT_BOTH, NULL);
6253 }
6254
6255 DEFUN (clear_ip_bgp_external_ipv4_soft,
6256 clear_ip_bgp_external_ipv4_soft_cmd,
6257 "clear ip bgp external ipv4 (unicast|multicast) soft",
6258 CLEAR_STR
6259 IP_STR
6260 BGP_STR
6261 "Clear all external peers\n"
6262 "Address family\n"
6263 "Address Family modifier\n"
6264 "Address Family modifier\n"
6265 "Soft reconfig\n")
6266 {
6267 if (strncmp (argv[0], "m", 1) == 0)
6268 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6269 BGP_CLEAR_SOFT_BOTH, NULL);
6270
6271 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6272 BGP_CLEAR_SOFT_BOTH, NULL);
6273 }
6274
6275 DEFUN (clear_bgp_external_soft,
6276 clear_bgp_external_soft_cmd,
6277 "clear bgp external soft",
6278 CLEAR_STR
6279 BGP_STR
6280 "Clear all external peers\n"
6281 "Soft reconfig\n")
6282 {
6283 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6284 BGP_CLEAR_SOFT_BOTH, NULL);
6285 }
6286
6287 ALIAS (clear_bgp_external_soft,
6288 clear_bgp_ipv6_external_soft_cmd,
6289 "clear bgp ipv6 external soft",
6290 CLEAR_STR
6291 BGP_STR
6292 "Address family\n"
6293 "Clear all external peers\n"
6294 "Soft reconfig\n")
6295
6296 DEFUN (clear_ip_bgp_as_soft,
6297 clear_ip_bgp_as_soft_cmd,
6298 "clear ip bgp " CMD_AS_RANGE " soft",
6299 CLEAR_STR
6300 IP_STR
6301 BGP_STR
6302 "Clear peers with the AS number\n"
6303 "Soft reconfig\n")
6304 {
6305 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6306 BGP_CLEAR_SOFT_BOTH, argv[0]);
6307 }
6308
6309 DEFUN (clear_ip_bgp_as_ipv4_soft,
6310 clear_ip_bgp_as_ipv4_soft_cmd,
6311 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
6312 CLEAR_STR
6313 IP_STR
6314 BGP_STR
6315 "Clear peers with the AS number\n"
6316 "Address family\n"
6317 "Address Family Modifier\n"
6318 "Address Family Modifier\n"
6319 "Soft reconfig\n")
6320 {
6321 if (strncmp (argv[1], "m", 1) == 0)
6322 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6323 BGP_CLEAR_SOFT_BOTH, argv[0]);
6324
6325 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
6326 BGP_CLEAR_SOFT_BOTH, argv[0]);
6327 }
6328
6329 DEFUN (clear_ip_bgp_as_vpnv4_soft,
6330 clear_ip_bgp_as_vpnv4_soft_cmd,
6331 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
6332 CLEAR_STR
6333 IP_STR
6334 BGP_STR
6335 "Clear peers with the AS number\n"
6336 "Address family\n"
6337 "Address Family Modifier\n"
6338 "Soft reconfig\n")
6339 {
6340 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6341 BGP_CLEAR_SOFT_BOTH, argv[0]);
6342 }
6343
6344 DEFUN (clear_bgp_as_soft,
6345 clear_bgp_as_soft_cmd,
6346 "clear bgp " CMD_AS_RANGE " soft",
6347 CLEAR_STR
6348 BGP_STR
6349 "Clear peers with the AS number\n"
6350 "Soft reconfig\n")
6351 {
6352 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6353 BGP_CLEAR_SOFT_BOTH, argv[0]);
6354 }
6355
6356 ALIAS (clear_bgp_as_soft,
6357 clear_bgp_ipv6_as_soft_cmd,
6358 "clear bgp ipv6 " CMD_AS_RANGE " soft",
6359 CLEAR_STR
6360 BGP_STR
6361 "Address family\n"
6362 "Clear peers with the AS number\n"
6363 "Soft reconfig\n")
6364 \f
6365 /* RS-client soft reconfiguration. */
6366 #ifdef HAVE_IPV6
6367 DEFUN (clear_bgp_all_rsclient,
6368 clear_bgp_all_rsclient_cmd,
6369 "clear bgp * rsclient",
6370 CLEAR_STR
6371 BGP_STR
6372 "Clear all peers\n"
6373 "Soft reconfig for rsclient RIB\n")
6374 {
6375 if (argc == 1)
6376 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6377 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6378
6379 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6380 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6381 }
6382
6383 ALIAS (clear_bgp_all_rsclient,
6384 clear_bgp_ipv6_all_rsclient_cmd,
6385 "clear bgp ipv6 * rsclient",
6386 CLEAR_STR
6387 BGP_STR
6388 "Address family\n"
6389 "Clear all peers\n"
6390 "Soft reconfig for rsclient RIB\n")
6391
6392 ALIAS (clear_bgp_all_rsclient,
6393 clear_bgp_instance_all_rsclient_cmd,
6394 "clear bgp view WORD * rsclient",
6395 CLEAR_STR
6396 BGP_STR
6397 "BGP view\n"
6398 "view name\n"
6399 "Clear all peers\n"
6400 "Soft reconfig for rsclient RIB\n")
6401
6402 ALIAS (clear_bgp_all_rsclient,
6403 clear_bgp_ipv6_instance_all_rsclient_cmd,
6404 "clear bgp ipv6 view WORD * rsclient",
6405 CLEAR_STR
6406 BGP_STR
6407 "Address family\n"
6408 "BGP view\n"
6409 "view name\n"
6410 "Clear all peers\n"
6411 "Soft reconfig for rsclient RIB\n")
6412 #endif /* HAVE_IPV6 */
6413
6414 DEFUN (clear_ip_bgp_all_rsclient,
6415 clear_ip_bgp_all_rsclient_cmd,
6416 "clear ip bgp * rsclient",
6417 CLEAR_STR
6418 IP_STR
6419 BGP_STR
6420 "Clear all peers\n"
6421 "Soft reconfig for rsclient RIB\n")
6422 {
6423 if (argc == 1)
6424 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6425 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6426
6427 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6428 BGP_CLEAR_SOFT_RSCLIENT, NULL);
6429 }
6430
6431 ALIAS (clear_ip_bgp_all_rsclient,
6432 clear_ip_bgp_instance_all_rsclient_cmd,
6433 "clear ip bgp view WORD * rsclient",
6434 CLEAR_STR
6435 IP_STR
6436 BGP_STR
6437 "BGP view\n"
6438 "view name\n"
6439 "Clear all peers\n"
6440 "Soft reconfig for rsclient RIB\n")
6441
6442 #ifdef HAVE_IPV6
6443 DEFUN (clear_bgp_peer_rsclient,
6444 clear_bgp_peer_rsclient_cmd,
6445 "clear bgp (A.B.C.D|X:X::X:X) rsclient",
6446 CLEAR_STR
6447 BGP_STR
6448 "BGP neighbor IP address to clear\n"
6449 "BGP IPv6 neighbor to clear\n"
6450 "Soft reconfig for rsclient RIB\n")
6451 {
6452 if (argc == 2)
6453 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
6454 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6455
6456 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6457 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6458 }
6459
6460 ALIAS (clear_bgp_peer_rsclient,
6461 clear_bgp_ipv6_peer_rsclient_cmd,
6462 "clear bgp ipv6 (A.B.C.D|X:X::X:X) rsclient",
6463 CLEAR_STR
6464 BGP_STR
6465 "Address family\n"
6466 "BGP neighbor IP address to clear\n"
6467 "BGP IPv6 neighbor to clear\n"
6468 "Soft reconfig for rsclient RIB\n")
6469
6470 ALIAS (clear_bgp_peer_rsclient,
6471 clear_bgp_instance_peer_rsclient_cmd,
6472 "clear bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6473 CLEAR_STR
6474 BGP_STR
6475 "BGP view\n"
6476 "view name\n"
6477 "BGP neighbor IP address to clear\n"
6478 "BGP IPv6 neighbor to clear\n"
6479 "Soft reconfig for rsclient RIB\n")
6480
6481 ALIAS (clear_bgp_peer_rsclient,
6482 clear_bgp_ipv6_instance_peer_rsclient_cmd,
6483 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X) rsclient",
6484 CLEAR_STR
6485 BGP_STR
6486 "Address family\n"
6487 "BGP view\n"
6488 "view name\n"
6489 "BGP neighbor IP address to clear\n"
6490 "BGP IPv6 neighbor to clear\n"
6491 "Soft reconfig for rsclient RIB\n")
6492 #endif /* HAVE_IPV6 */
6493
6494 DEFUN (clear_ip_bgp_peer_rsclient,
6495 clear_ip_bgp_peer_rsclient_cmd,
6496 "clear ip bgp (A.B.C.D|X:X::X:X) rsclient",
6497 CLEAR_STR
6498 IP_STR
6499 BGP_STR
6500 "BGP neighbor IP address to clear\n"
6501 "BGP IPv6 neighbor to clear\n"
6502 "Soft reconfig for rsclient RIB\n")
6503 {
6504 if (argc == 2)
6505 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
6506 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
6507
6508 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6509 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
6510 }
6511
6512 ALIAS (clear_ip_bgp_peer_rsclient,
6513 clear_ip_bgp_instance_peer_rsclient_cmd,
6514 "clear ip bgp view WORD (A.B.C.D|X:X::X:X) rsclient",
6515 CLEAR_STR
6516 IP_STR
6517 BGP_STR
6518 "BGP view\n"
6519 "view name\n"
6520 "BGP neighbor IP address to clear\n"
6521 "BGP IPv6 neighbor to clear\n"
6522 "Soft reconfig for rsclient RIB\n")
6523
6524 DEFUN (show_bgp_views,
6525 show_bgp_views_cmd,
6526 "show bgp views",
6527 SHOW_STR
6528 BGP_STR
6529 "Show the defined BGP views\n")
6530 {
6531 struct list *inst = bm->bgp;
6532 struct listnode *node;
6533 struct bgp *bgp;
6534
6535 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6536 {
6537 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
6538 return CMD_WARNING;
6539 }
6540
6541 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6542 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6543 vty_out (vty, "\t%s (AS%u)%s",
6544 bgp->name ? bgp->name : "(null)",
6545 bgp->as, VTY_NEWLINE);
6546
6547 return CMD_SUCCESS;
6548 }
6549
6550 DEFUN (show_bgp_memory,
6551 show_bgp_memory_cmd,
6552 "show bgp memory",
6553 SHOW_STR
6554 BGP_STR
6555 "Global BGP memory statistics\n")
6556 {
6557 char memstrbuf[MTYPE_MEMSTR_LEN];
6558 unsigned long count;
6559
6560 /* RIB related usage stats */
6561 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6562 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6563 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6564 count * sizeof (struct bgp_node)),
6565 VTY_NEWLINE);
6566
6567 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6568 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6569 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6570 count * sizeof (struct bgp_info)),
6571 VTY_NEWLINE);
6572 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6573 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6574 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6575 count * sizeof (struct bgp_info_extra)),
6576 VTY_NEWLINE);
6577
6578 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6579 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6580 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6581 count * sizeof (struct bgp_static)),
6582 VTY_NEWLINE);
6583
6584 /* Adj-In/Out */
6585 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6586 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6587 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6588 count * sizeof (struct bgp_adj_in)),
6589 VTY_NEWLINE);
6590 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6591 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6592 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6593 count * sizeof (struct bgp_adj_out)),
6594 VTY_NEWLINE);
6595
6596 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6597 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6598 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6599 count * sizeof (struct bgp_nexthop_cache)),
6600 VTY_NEWLINE);
6601
6602 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6603 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6604 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6605 count * sizeof (struct bgp_damp_info)),
6606 VTY_NEWLINE);
6607
6608 /* Attributes */
6609 count = attr_count();
6610 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6611 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6612 count * sizeof(struct attr)),
6613 VTY_NEWLINE);
6614 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
6615 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6616 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6617 count * sizeof(struct attr_extra)),
6618 VTY_NEWLINE);
6619
6620 if ((count = attr_unknown_count()))
6621 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
6622
6623 /* AS_PATH attributes */
6624 count = aspath_count ();
6625 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6626 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6627 count * sizeof (struct aspath)),
6628 VTY_NEWLINE);
6629
6630 count = mtype_stats_alloc (MTYPE_AS_SEG);
6631 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6632 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6633 count * sizeof (struct assegment)),
6634 VTY_NEWLINE);
6635
6636 /* Other attributes */
6637 if ((count = community_count ()))
6638 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6639 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6640 count * sizeof (struct community)),
6641 VTY_NEWLINE);
6642 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6643 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6644 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6645 count * sizeof (struct ecommunity)),
6646 VTY_NEWLINE);
6647
6648 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6649 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6650 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6651 count * sizeof (struct cluster_list)),
6652 VTY_NEWLINE);
6653
6654 /* Peer related usage */
6655 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6656 vty_out (vty, "%ld peers, using %s of memory%s", count,
6657 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6658 count * sizeof (struct peer)),
6659 VTY_NEWLINE);
6660
6661 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
6662 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6663 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6664 count * sizeof (struct peer_group)),
6665 VTY_NEWLINE);
6666
6667 /* Other */
6668 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6669 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6670 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6671 count * sizeof (struct hash)),
6672 VTY_NEWLINE);
6673 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6674 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6675 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6676 count * sizeof (struct hash_backet)),
6677 VTY_NEWLINE);
6678 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6679 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6680 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6681 count * sizeof (regex_t)),
6682 VTY_NEWLINE);
6683 return CMD_SUCCESS;
6684 }
6685
6686 /* Show BGP peer's summary information. */
6687 static int
6688 bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
6689 {
6690 struct peer *peer;
6691 struct listnode *node, *nnode;
6692 unsigned int count = 0;
6693 char timebuf[BGP_UPTIME_LEN];
6694 int len;
6695
6696 /* Header string for each address family. */
6697 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
6698
6699 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
6700 {
6701 if (peer->afc[afi][safi])
6702 {
6703 if (!count)
6704 {
6705 unsigned long ents;
6706 char memstrbuf[MTYPE_MEMSTR_LEN];
6707
6708 /* Usage summary and header */
6709 vty_out (vty,
6710 "BGP router identifier %s, local AS number %u%s",
6711 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
6712
6713 ents = bgp_table_count (bgp->rib[afi][safi]);
6714 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
6715 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6716 ents * sizeof (struct bgp_node)),
6717 VTY_NEWLINE);
6718
6719 /* Peer related usage */
6720 ents = listcount (bgp->peer);
6721 vty_out (vty, "Peers %ld, using %s of memory%s",
6722 ents,
6723 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6724 ents * sizeof (struct peer)),
6725 VTY_NEWLINE);
6726
6727 if ((ents = listcount (bgp->rsclient)))
6728 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
6729 ents,
6730 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6731 ents * sizeof (struct peer)),
6732 VTY_NEWLINE);
6733
6734 if ((ents = listcount (bgp->group)))
6735 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
6736 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6737 ents * sizeof (struct peer_group)),
6738 VTY_NEWLINE);
6739
6740 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
6741 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
6742 vty_out (vty, "%s", VTY_NEWLINE);
6743 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6744 }
6745
6746 count++;
6747
6748 len = vty_out (vty, "%s", peer->host);
6749 len = 16 - len;
6750 if (len < 1)
6751 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
6752 else
6753 vty_out (vty, "%*s", len, " ");
6754
6755 vty_out (vty, "4 ");
6756
6757 vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
6758 peer->as,
6759 peer->open_in + peer->update_in + peer->keepalive_in
6760 + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
6761 peer->open_out + peer->update_out + peer->keepalive_out
6762 + peer->notify_out + peer->refresh_out
6763 + peer->dynamic_cap_out,
6764 0, 0, (unsigned long) peer->obuf->count);
6765
6766 vty_out (vty, "%8s",
6767 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
6768
6769 if (peer->status == Established)
6770 {
6771 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
6772 }
6773 else
6774 {
6775 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
6776 vty_out (vty, " Idle (Admin)");
6777 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
6778 vty_out (vty, " Idle (PfxCt)");
6779 else
6780 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
6781 }
6782
6783 vty_out (vty, "%s", VTY_NEWLINE);
6784 }
6785 }
6786
6787 if (count)
6788 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
6789 count, VTY_NEWLINE);
6790 else
6791 vty_out (vty, "No %s neighbor is configured%s",
6792 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
6793 return CMD_SUCCESS;
6794 }
6795
6796 static int
6797 bgp_show_summary_vty (struct vty *vty, const char *name,
6798 afi_t afi, safi_t safi)
6799 {
6800 struct bgp *bgp;
6801
6802 if (name)
6803 {
6804 bgp = bgp_lookup_by_name (name);
6805
6806 if (! bgp)
6807 {
6808 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
6809 return CMD_WARNING;
6810 }
6811
6812 bgp_show_summary (vty, bgp, afi, safi);
6813 return CMD_SUCCESS;
6814 }
6815
6816 bgp = bgp_get_default ();
6817
6818 if (bgp)
6819 bgp_show_summary (vty, bgp, afi, safi);
6820
6821 return CMD_SUCCESS;
6822 }
6823
6824 /* `show ip bgp summary' commands. */
6825 DEFUN (show_ip_bgp_summary,
6826 show_ip_bgp_summary_cmd,
6827 "show ip bgp summary",
6828 SHOW_STR
6829 IP_STR
6830 BGP_STR
6831 "Summary of BGP neighbor status\n")
6832 {
6833 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6834 }
6835
6836 DEFUN (show_ip_bgp_instance_summary,
6837 show_ip_bgp_instance_summary_cmd,
6838 "show ip bgp view WORD summary",
6839 SHOW_STR
6840 IP_STR
6841 BGP_STR
6842 "BGP view\n"
6843 "View name\n"
6844 "Summary of BGP neighbor status\n")
6845 {
6846 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6847 }
6848
6849 DEFUN (show_ip_bgp_ipv4_summary,
6850 show_ip_bgp_ipv4_summary_cmd,
6851 "show ip bgp ipv4 (unicast|multicast) summary",
6852 SHOW_STR
6853 IP_STR
6854 BGP_STR
6855 "Address family\n"
6856 "Address Family modifier\n"
6857 "Address Family modifier\n"
6858 "Summary of BGP neighbor status\n")
6859 {
6860 if (strncmp (argv[0], "m", 1) == 0)
6861 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
6862
6863 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
6864 }
6865
6866 DEFUN (show_ip_bgp_instance_ipv4_summary,
6867 show_ip_bgp_instance_ipv4_summary_cmd,
6868 "show ip bgp view WORD ipv4 (unicast|multicast) summary",
6869 SHOW_STR
6870 IP_STR
6871 BGP_STR
6872 "BGP view\n"
6873 "View name\n"
6874 "Address family\n"
6875 "Address Family modifier\n"
6876 "Address Family modifier\n"
6877 "Summary of BGP neighbor status\n")
6878 {
6879 if (strncmp (argv[1], "m", 1) == 0)
6880 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
6881 else
6882 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
6883 }
6884
6885 DEFUN (show_ip_bgp_vpnv4_all_summary,
6886 show_ip_bgp_vpnv4_all_summary_cmd,
6887 "show ip bgp vpnv4 all summary",
6888 SHOW_STR
6889 IP_STR
6890 BGP_STR
6891 "Display VPNv4 NLRI specific information\n"
6892 "Display information about all VPNv4 NLRIs\n"
6893 "Summary of BGP neighbor status\n")
6894 {
6895 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6896 }
6897
6898 DEFUN (show_ip_bgp_vpnv4_rd_summary,
6899 show_ip_bgp_vpnv4_rd_summary_cmd,
6900 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
6901 SHOW_STR
6902 IP_STR
6903 BGP_STR
6904 "Display VPNv4 NLRI specific information\n"
6905 "Display information for a route distinguisher\n"
6906 "VPN Route Distinguisher\n"
6907 "Summary of BGP neighbor status\n")
6908 {
6909 int ret;
6910 struct prefix_rd prd;
6911
6912 ret = str2prefix_rd (argv[0], &prd);
6913 if (! ret)
6914 {
6915 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6916 return CMD_WARNING;
6917 }
6918
6919 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN);
6920 }
6921
6922 #ifdef HAVE_IPV6
6923 DEFUN (show_bgp_summary,
6924 show_bgp_summary_cmd,
6925 "show bgp summary",
6926 SHOW_STR
6927 BGP_STR
6928 "Summary of BGP neighbor status\n")
6929 {
6930 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6931 }
6932
6933 DEFUN (show_bgp_instance_summary,
6934 show_bgp_instance_summary_cmd,
6935 "show bgp view WORD summary",
6936 SHOW_STR
6937 BGP_STR
6938 "BGP view\n"
6939 "View name\n"
6940 "Summary of BGP neighbor status\n")
6941 {
6942 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
6943 }
6944
6945 ALIAS (show_bgp_summary,
6946 show_bgp_ipv6_summary_cmd,
6947 "show bgp ipv6 summary",
6948 SHOW_STR
6949 BGP_STR
6950 "Address family\n"
6951 "Summary of BGP neighbor status\n")
6952
6953 ALIAS (show_bgp_instance_summary,
6954 show_bgp_instance_ipv6_summary_cmd,
6955 "show bgp view WORD ipv6 summary",
6956 SHOW_STR
6957 BGP_STR
6958 "BGP view\n"
6959 "View name\n"
6960 "Address family\n"
6961 "Summary of BGP neighbor status\n")
6962
6963 /* old command */
6964 DEFUN (show_ipv6_bgp_summary,
6965 show_ipv6_bgp_summary_cmd,
6966 "show ipv6 bgp summary",
6967 SHOW_STR
6968 IPV6_STR
6969 BGP_STR
6970 "Summary of BGP neighbor status\n")
6971 {
6972 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
6973 }
6974
6975 /* old command */
6976 DEFUN (show_ipv6_mbgp_summary,
6977 show_ipv6_mbgp_summary_cmd,
6978 "show ipv6 mbgp summary",
6979 SHOW_STR
6980 IPV6_STR
6981 MBGP_STR
6982 "Summary of BGP neighbor status\n")
6983 {
6984 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
6985 }
6986 #endif /* HAVE_IPV6 */
6987 \f
6988 const char *
6989 afi_safi_print (afi_t afi, safi_t safi)
6990 {
6991 if (afi == AFI_IP && safi == SAFI_UNICAST)
6992 return "IPv4 Unicast";
6993 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
6994 return "IPv4 Multicast";
6995 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
6996 return "VPNv4 Unicast";
6997 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
6998 return "IPv6 Unicast";
6999 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7000 return "IPv6 Multicast";
7001 else
7002 return "Unknown";
7003 }
7004
7005 /* Show BGP peer's information. */
7006 enum show_type
7007 {
7008 show_all,
7009 show_peer
7010 };
7011
7012 static void
7013 bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p,
7014 afi_t afi, safi_t safi,
7015 u_int16_t adv_smcap, u_int16_t adv_rmcap,
7016 u_int16_t rcv_smcap, u_int16_t rcv_rmcap)
7017 {
7018 /* Send-Mode */
7019 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7020 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7021 {
7022 vty_out (vty, " Send-mode: ");
7023 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7024 vty_out (vty, "advertised");
7025 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7026 vty_out (vty, "%sreceived",
7027 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7028 ", " : "");
7029 vty_out (vty, "%s", VTY_NEWLINE);
7030 }
7031
7032 /* Receive-Mode */
7033 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7034 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7035 {
7036 vty_out (vty, " Receive-mode: ");
7037 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7038 vty_out (vty, "advertised");
7039 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7040 vty_out (vty, "%sreceived",
7041 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7042 ", " : "");
7043 vty_out (vty, "%s", VTY_NEWLINE);
7044 }
7045 }
7046
7047 static void
7048 bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
7049 {
7050 struct bgp_filter *filter;
7051 char orf_pfx_name[BUFSIZ];
7052 int orf_pfx_count;
7053
7054 filter = &p->filter[afi][safi];
7055
7056 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
7057 VTY_NEWLINE);
7058
7059 if (p->af_group[afi][safi])
7060 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7061
7062 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7063 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7064 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7065 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7066 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7067 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7068 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7069
7070 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7071 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7072 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7073 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7074 {
7075 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7076 ORF_TYPE_PREFIX, VTY_NEWLINE);
7077 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7078 PEER_CAP_ORF_PREFIX_SM_ADV,
7079 PEER_CAP_ORF_PREFIX_RM_ADV,
7080 PEER_CAP_ORF_PREFIX_SM_RCV,
7081 PEER_CAP_ORF_PREFIX_RM_RCV);
7082 }
7083 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7084 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7085 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7086 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7087 {
7088 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7089 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7090 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7091 PEER_CAP_ORF_PREFIX_SM_ADV,
7092 PEER_CAP_ORF_PREFIX_RM_ADV,
7093 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7094 PEER_CAP_ORF_PREFIX_RM_OLD_RCV);
7095 }
7096
7097 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7098 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name);
7099
7100 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7101 || orf_pfx_count)
7102 {
7103 vty_out (vty, " Outbound Route Filter (ORF):");
7104 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7105 vty_out (vty, " sent;");
7106 if (orf_pfx_count)
7107 vty_out (vty, " received (%d entries)", orf_pfx_count);
7108 vty_out (vty, "%s", VTY_NEWLINE);
7109 }
7110 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7111 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7112
7113 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7114 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7115 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7116 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7117 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7118 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7119 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7120 vty_out (vty, " Private AS number removed from updates to this neighbor%s", VTY_NEWLINE);
7121 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF))
7122 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7123 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7124 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7125 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7126 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7127 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7128 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7129 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7130 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7131 {
7132 vty_out (vty, " Community attribute sent to this neighbor");
7133 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7134 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7135 vty_out (vty, "(both)%s", VTY_NEWLINE);
7136 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7137 vty_out (vty, "(extended)%s", VTY_NEWLINE);
7138 else
7139 vty_out (vty, "(standard)%s", VTY_NEWLINE);
7140 }
7141 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7142 {
7143 vty_out (vty, " Default information originate,");
7144
7145 if (p->default_rmap[afi][safi].name)
7146 vty_out (vty, " default route-map %s%s,",
7147 p->default_rmap[afi][safi].map ? "*" : "",
7148 p->default_rmap[afi][safi].name);
7149 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
7150 vty_out (vty, " default sent%s", VTY_NEWLINE);
7151 else
7152 vty_out (vty, " default not sent%s", VTY_NEWLINE);
7153 }
7154
7155 if (filter->plist[FILTER_IN].name
7156 || filter->dlist[FILTER_IN].name
7157 || filter->aslist[FILTER_IN].name
7158 || filter->map[RMAP_IN].name)
7159 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
7160 if (filter->plist[FILTER_OUT].name
7161 || filter->dlist[FILTER_OUT].name
7162 || filter->aslist[FILTER_OUT].name
7163 || filter->map[RMAP_OUT].name
7164 || filter->usmap.name)
7165 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
7166 if (filter->map[RMAP_IMPORT].name)
7167 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
7168 if (filter->map[RMAP_EXPORT].name)
7169 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
7170
7171 /* prefix-list */
7172 if (filter->plist[FILTER_IN].name)
7173 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
7174 filter->plist[FILTER_IN].plist ? "*" : "",
7175 filter->plist[FILTER_IN].name,
7176 VTY_NEWLINE);
7177 if (filter->plist[FILTER_OUT].name)
7178 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
7179 filter->plist[FILTER_OUT].plist ? "*" : "",
7180 filter->plist[FILTER_OUT].name,
7181 VTY_NEWLINE);
7182
7183 /* distribute-list */
7184 if (filter->dlist[FILTER_IN].name)
7185 vty_out (vty, " Incoming update network filter list is %s%s%s",
7186 filter->dlist[FILTER_IN].alist ? "*" : "",
7187 filter->dlist[FILTER_IN].name,
7188 VTY_NEWLINE);
7189 if (filter->dlist[FILTER_OUT].name)
7190 vty_out (vty, " Outgoing update network filter list is %s%s%s",
7191 filter->dlist[FILTER_OUT].alist ? "*" : "",
7192 filter->dlist[FILTER_OUT].name,
7193 VTY_NEWLINE);
7194
7195 /* filter-list. */
7196 if (filter->aslist[FILTER_IN].name)
7197 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
7198 filter->aslist[FILTER_IN].aslist ? "*" : "",
7199 filter->aslist[FILTER_IN].name,
7200 VTY_NEWLINE);
7201 if (filter->aslist[FILTER_OUT].name)
7202 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
7203 filter->aslist[FILTER_OUT].aslist ? "*" : "",
7204 filter->aslist[FILTER_OUT].name,
7205 VTY_NEWLINE);
7206
7207 /* route-map. */
7208 if (filter->map[RMAP_IN].name)
7209 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
7210 filter->map[RMAP_IN].map ? "*" : "",
7211 filter->map[RMAP_IN].name,
7212 VTY_NEWLINE);
7213 if (filter->map[RMAP_OUT].name)
7214 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
7215 filter->map[RMAP_OUT].map ? "*" : "",
7216 filter->map[RMAP_OUT].name,
7217 VTY_NEWLINE);
7218 if (filter->map[RMAP_IMPORT].name)
7219 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
7220 filter->map[RMAP_IMPORT].map ? "*" : "",
7221 filter->map[RMAP_IMPORT].name,
7222 VTY_NEWLINE);
7223 if (filter->map[RMAP_EXPORT].name)
7224 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
7225 filter->map[RMAP_EXPORT].map ? "*" : "",
7226 filter->map[RMAP_EXPORT].name,
7227 VTY_NEWLINE);
7228
7229 /* unsuppress-map */
7230 if (filter->usmap.name)
7231 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
7232 filter->usmap.map ? "*" : "",
7233 filter->usmap.name, VTY_NEWLINE);
7234
7235 /* Receive prefix count */
7236 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
7237
7238 /* Maximum prefix */
7239 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7240 {
7241 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
7242 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
7243 ? " (warning-only)" : "", VTY_NEWLINE);
7244 vty_out (vty, " Threshold for warning message %d%%",
7245 p->pmax_threshold[afi][safi]);
7246 if (p->pmax_restart[afi][safi])
7247 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
7248 vty_out (vty, "%s", VTY_NEWLINE);
7249 }
7250
7251 vty_out (vty, "%s", VTY_NEWLINE);
7252 }
7253
7254 static void
7255 bgp_show_peer (struct vty *vty, struct peer *p)
7256 {
7257 struct bgp *bgp;
7258 char buf1[BUFSIZ];
7259 char timebuf[BGP_UPTIME_LEN];
7260 afi_t afi;
7261 safi_t safi;
7262
7263 bgp = p->bgp;
7264
7265 /* Configured IP address. */
7266 vty_out (vty, "BGP neighbor is %s, ", p->host);
7267 vty_out (vty, "remote AS %u, ", p->as);
7268 vty_out (vty, "local AS %u%s, ",
7269 p->change_local_as ? p->change_local_as : p->local_as,
7270 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
7271 " no-prepend" : "");
7272 vty_out (vty, "%s link%s",
7273 p->as == p->local_as ? "internal" : "external",
7274 VTY_NEWLINE);
7275
7276 /* Description. */
7277 if (p->desc)
7278 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
7279
7280 /* Peer-group */
7281 if (p->group)
7282 vty_out (vty, " Member of peer-group %s for session parameters%s",
7283 p->group->name, VTY_NEWLINE);
7284
7285 /* Administrative shutdown. */
7286 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
7287 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
7288
7289 /* BGP Version. */
7290 vty_out (vty, " BGP version 4");
7291 vty_out (vty, ", remote router ID %s%s",
7292 inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
7293 VTY_NEWLINE);
7294
7295 /* Confederation */
7296 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
7297 && bgp_confederation_peers_check (bgp, p->as))
7298 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
7299
7300 /* Status. */
7301 vty_out (vty, " BGP state = %s",
7302 LOOKUP (bgp_status_msg, p->status));
7303 if (p->status == Established)
7304 vty_out (vty, ", up for %8s",
7305 peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
7306 else if (p->status == Active)
7307 {
7308 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
7309 vty_out (vty, " (passive)");
7310 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
7311 vty_out (vty, " (NSF passive)");
7312 }
7313 vty_out (vty, "%s", VTY_NEWLINE);
7314
7315 /* read timer */
7316 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
7317
7318 /* Configured timer values. */
7319 vty_out (vty, ", hold time is %d, keepalive interval is %d seconds%s",
7320 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
7321 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
7322 {
7323 vty_out (vty, " Configured hold time is %d", p->holdtime);
7324 vty_out (vty, ", keepalive interval is %d seconds%s",
7325 p->keepalive, VTY_NEWLINE);
7326 }
7327
7328 /* Capability. */
7329 if (p->status == Established)
7330 {
7331 if (p->cap
7332 || p->afc_adv[AFI_IP][SAFI_UNICAST]
7333 || p->afc_recv[AFI_IP][SAFI_UNICAST]
7334 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
7335 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
7336 #ifdef HAVE_IPV6
7337 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
7338 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
7339 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
7340 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
7341 #endif /* HAVE_IPV6 */
7342 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
7343 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
7344 {
7345 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
7346
7347 /* AS4 */
7348 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
7349 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7350 {
7351 vty_out (vty, " 4 Byte AS:");
7352 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
7353 vty_out (vty, " advertised");
7354 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
7355 vty_out (vty, " %sreceived",
7356 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
7357 vty_out (vty, "%s", VTY_NEWLINE);
7358 }
7359 /* Dynamic */
7360 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
7361 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7362 {
7363 vty_out (vty, " Dynamic:");
7364 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
7365 vty_out (vty, " advertised");
7366 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
7367 vty_out (vty, " %sreceived",
7368 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
7369 vty_out (vty, "%s", VTY_NEWLINE);
7370 }
7371
7372 /* Route Refresh */
7373 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
7374 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7375 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7376 {
7377 vty_out (vty, " Route refresh:");
7378 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
7379 vty_out (vty, " advertised");
7380 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
7381 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
7382 vty_out (vty, " %sreceived(%s)",
7383 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
7384 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
7385 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
7386 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
7387
7388 vty_out (vty, "%s", VTY_NEWLINE);
7389 }
7390
7391 /* Multiprotocol Extensions */
7392 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7393 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7394 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
7395 {
7396 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
7397 if (p->afc_adv[afi][safi])
7398 vty_out (vty, " advertised");
7399 if (p->afc_recv[afi][safi])
7400 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
7401 vty_out (vty, "%s", VTY_NEWLINE);
7402 }
7403
7404 /* Gracefull Restart */
7405 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7406 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
7407 {
7408 vty_out (vty, " Graceful Restart Capabilty:");
7409 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
7410 vty_out (vty, " advertised");
7411 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7412 vty_out (vty, " %sreceived",
7413 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
7414 vty_out (vty, "%s", VTY_NEWLINE);
7415
7416 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
7417 {
7418 int restart_af_count = 0;
7419
7420 vty_out (vty, " Remote Restart timer is %d seconds%s",
7421 p->v_gr_restart, VTY_NEWLINE);
7422 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
7423
7424 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7425 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7426 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
7427 {
7428 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
7429 afi_safi_print (afi, safi),
7430 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
7431 "preserved" : "not preserved");
7432 restart_af_count++;
7433 }
7434 if (! restart_af_count)
7435 vty_out (vty, "none");
7436 vty_out (vty, "%s", VTY_NEWLINE);
7437 }
7438 }
7439 }
7440 }
7441
7442 /* graceful restart information */
7443 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
7444 || p->t_gr_restart
7445 || p->t_gr_stale)
7446 {
7447 int eor_send_af_count = 0;
7448 int eor_receive_af_count = 0;
7449
7450 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
7451 if (p->status == Established)
7452 {
7453 vty_out (vty, " End-of-RIB send: ");
7454 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7455 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7456 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
7457 {
7458 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
7459 afi_safi_print (afi, safi));
7460 eor_send_af_count++;
7461 }
7462 vty_out (vty, "%s", VTY_NEWLINE);
7463
7464 vty_out (vty, " End-of-RIB received: ");
7465 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7466 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7467 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
7468 {
7469 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
7470 afi_safi_print (afi, safi));
7471 eor_receive_af_count++;
7472 }
7473 vty_out (vty, "%s", VTY_NEWLINE);
7474 }
7475
7476 if (p->t_gr_restart)
7477 vty_out (vty, " The remaining time of restart timer is %ld%s",
7478 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
7479
7480 if (p->t_gr_stale)
7481 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
7482 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
7483 }
7484
7485 /* Packet counts. */
7486 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
7487 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
7488 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
7489 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
7490 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
7491 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
7492 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
7493 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
7494 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
7495 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
7496 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
7497 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
7498 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
7499 p->dynamic_cap_in, VTY_NEWLINE);
7500
7501 /* advertisement-interval */
7502 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
7503 p->v_routeadv, VTY_NEWLINE);
7504
7505 /* Update-source. */
7506 if (p->update_if || p->update_source)
7507 {
7508 vty_out (vty, " Update source is ");
7509 if (p->update_if)
7510 vty_out (vty, "%s", p->update_if);
7511 else if (p->update_source)
7512 vty_out (vty, "%s",
7513 sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
7514 vty_out (vty, "%s", VTY_NEWLINE);
7515 }
7516
7517 /* Default weight */
7518 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
7519 vty_out (vty, " Default weight %d%s", p->weight,
7520 VTY_NEWLINE);
7521
7522 vty_out (vty, "%s", VTY_NEWLINE);
7523
7524 /* Address Family Information */
7525 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
7526 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
7527 if (p->afc[afi][safi])
7528 bgp_show_peer_afi (vty, p, afi, safi);
7529
7530 vty_out (vty, " Connections established %d; dropped %d%s",
7531 p->established, p->dropped,
7532 VTY_NEWLINE);
7533
7534 if (! p->dropped)
7535 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
7536 else
7537 vty_out (vty, " Last reset %s, due to %s%s",
7538 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN),
7539 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
7540
7541 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7542 {
7543 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
7544
7545 if (p->t_pmax_restart)
7546 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
7547 p->host, thread_timer_remain_second (p->t_pmax_restart),
7548 VTY_NEWLINE);
7549 else
7550 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7551 p->host, VTY_NEWLINE);
7552 }
7553
7554 /* EBGP Multihop */
7555 if (peer_sort (p) != BGP_PEER_IBGP && p->ttl > 1)
7556 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
7557 p->ttl, VTY_NEWLINE);
7558
7559 /* Local address. */
7560 if (p->su_local)
7561 {
7562 vty_out (vty, "Local host: %s, Local port: %d%s",
7563 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
7564 ntohs (p->su_local->sin.sin_port),
7565 VTY_NEWLINE);
7566 }
7567
7568 /* Remote address. */
7569 if (p->su_remote)
7570 {
7571 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
7572 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
7573 ntohs (p->su_remote->sin.sin_port),
7574 VTY_NEWLINE);
7575 }
7576
7577 /* Nexthop display. */
7578 if (p->su_local)
7579 {
7580 vty_out (vty, "Nexthop: %s%s",
7581 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
7582 VTY_NEWLINE);
7583 #ifdef HAVE_IPV6
7584 vty_out (vty, "Nexthop global: %s%s",
7585 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
7586 VTY_NEWLINE);
7587 vty_out (vty, "Nexthop local: %s%s",
7588 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
7589 VTY_NEWLINE);
7590 vty_out (vty, "BGP connection: %s%s",
7591 p->shared_network ? "shared network" : "non shared network",
7592 VTY_NEWLINE);
7593 #endif /* HAVE_IPV6 */
7594 }
7595
7596 /* Timer information. */
7597 if (p->t_start)
7598 vty_out (vty, "Next start timer due in %ld seconds%s",
7599 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
7600 if (p->t_connect)
7601 vty_out (vty, "Next connect timer due in %ld seconds%s",
7602 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
7603
7604 vty_out (vty, "Read thread: %s Write thread: %s%s",
7605 p->t_read ? "on" : "off",
7606 p->t_write ? "on" : "off",
7607 VTY_NEWLINE);
7608
7609 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
7610 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
7611 bgp_capability_vty_out (vty, p);
7612
7613 vty_out (vty, "%s", VTY_NEWLINE);
7614 }
7615
7616 static int
7617 bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
7618 enum show_type type, union sockunion *su)
7619 {
7620 struct listnode *node, *nnode;
7621 struct peer *peer;
7622 int find = 0;
7623
7624 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
7625 {
7626 switch (type)
7627 {
7628 case show_all:
7629 bgp_show_peer (vty, peer);
7630 break;
7631 case show_peer:
7632 if (sockunion_same (&peer->su, su))
7633 {
7634 find = 1;
7635 bgp_show_peer (vty, peer);
7636 }
7637 break;
7638 }
7639 }
7640
7641 if (type == show_peer && ! find)
7642 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
7643
7644 return CMD_SUCCESS;
7645 }
7646
7647 static int
7648 bgp_show_neighbor_vty (struct vty *vty, const char *name,
7649 enum show_type type, const char *ip_str)
7650 {
7651 int ret;
7652 struct bgp *bgp;
7653 union sockunion su;
7654
7655 if (ip_str)
7656 {
7657 ret = str2sockunion (ip_str, &su);
7658 if (ret < 0)
7659 {
7660 vty_out (vty, "%% Malformed address: %s%s", ip_str, VTY_NEWLINE);
7661 return CMD_WARNING;
7662 }
7663 }
7664
7665 if (name)
7666 {
7667 bgp = bgp_lookup_by_name (name);
7668
7669 if (! bgp)
7670 {
7671 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7672 return CMD_WARNING;
7673 }
7674
7675 bgp_show_neighbor (vty, bgp, type, &su);
7676
7677 return CMD_SUCCESS;
7678 }
7679
7680 bgp = bgp_get_default ();
7681
7682 if (bgp)
7683 bgp_show_neighbor (vty, bgp, type, &su);
7684
7685 return CMD_SUCCESS;
7686 }
7687
7688 /* "show ip bgp neighbors" commands. */
7689 DEFUN (show_ip_bgp_neighbors,
7690 show_ip_bgp_neighbors_cmd,
7691 "show ip bgp neighbors",
7692 SHOW_STR
7693 IP_STR
7694 BGP_STR
7695 "Detailed information on TCP and BGP neighbor connections\n")
7696 {
7697 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL);
7698 }
7699
7700 ALIAS (show_ip_bgp_neighbors,
7701 show_ip_bgp_ipv4_neighbors_cmd,
7702 "show ip bgp ipv4 (unicast|multicast) neighbors",
7703 SHOW_STR
7704 IP_STR
7705 BGP_STR
7706 "Address family\n"
7707 "Address Family modifier\n"
7708 "Address Family modifier\n"
7709 "Detailed information on TCP and BGP neighbor connections\n")
7710
7711 ALIAS (show_ip_bgp_neighbors,
7712 show_ip_bgp_vpnv4_all_neighbors_cmd,
7713 "show ip bgp vpnv4 all neighbors",
7714 SHOW_STR
7715 IP_STR
7716 BGP_STR
7717 "Display VPNv4 NLRI specific information\n"
7718 "Display information about all VPNv4 NLRIs\n"
7719 "Detailed information on TCP and BGP neighbor connections\n")
7720
7721 ALIAS (show_ip_bgp_neighbors,
7722 show_ip_bgp_vpnv4_rd_neighbors_cmd,
7723 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7724 SHOW_STR
7725 IP_STR
7726 BGP_STR
7727 "Display VPNv4 NLRI specific information\n"
7728 "Display information for a route distinguisher\n"
7729 "VPN Route Distinguisher\n"
7730 "Detailed information on TCP and BGP neighbor connections\n")
7731
7732 ALIAS (show_ip_bgp_neighbors,
7733 show_bgp_neighbors_cmd,
7734 "show bgp neighbors",
7735 SHOW_STR
7736 BGP_STR
7737 "Detailed information on TCP and BGP neighbor connections\n")
7738
7739 ALIAS (show_ip_bgp_neighbors,
7740 show_bgp_ipv6_neighbors_cmd,
7741 "show bgp ipv6 neighbors",
7742 SHOW_STR
7743 BGP_STR
7744 "Address family\n"
7745 "Detailed information on TCP and BGP neighbor connections\n")
7746
7747 DEFUN (show_ip_bgp_neighbors_peer,
7748 show_ip_bgp_neighbors_peer_cmd,
7749 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7750 SHOW_STR
7751 IP_STR
7752 BGP_STR
7753 "Detailed information on TCP and BGP neighbor connections\n"
7754 "Neighbor to display information about\n"
7755 "Neighbor to display information about\n")
7756 {
7757 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 1]);
7758 }
7759
7760 ALIAS (show_ip_bgp_neighbors_peer,
7761 show_ip_bgp_ipv4_neighbors_peer_cmd,
7762 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7763 SHOW_STR
7764 IP_STR
7765 BGP_STR
7766 "Address family\n"
7767 "Address Family modifier\n"
7768 "Address Family modifier\n"
7769 "Detailed information on TCP and BGP neighbor connections\n"
7770 "Neighbor to display information about\n"
7771 "Neighbor to display information about\n")
7772
7773 ALIAS (show_ip_bgp_neighbors_peer,
7774 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
7775 "show ip bgp vpnv4 all neighbors A.B.C.D",
7776 SHOW_STR
7777 IP_STR
7778 BGP_STR
7779 "Display VPNv4 NLRI specific information\n"
7780 "Display information about all VPNv4 NLRIs\n"
7781 "Detailed information on TCP and BGP neighbor connections\n"
7782 "Neighbor to display information about\n")
7783
7784 ALIAS (show_ip_bgp_neighbors_peer,
7785 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
7786 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
7787 SHOW_STR
7788 IP_STR
7789 BGP_STR
7790 "Display VPNv4 NLRI specific information\n"
7791 "Display information about all VPNv4 NLRIs\n"
7792 "Detailed information on TCP and BGP neighbor connections\n"
7793 "Neighbor to display information about\n")
7794
7795 ALIAS (show_ip_bgp_neighbors_peer,
7796 show_bgp_neighbors_peer_cmd,
7797 "show bgp neighbors (A.B.C.D|X:X::X:X)",
7798 SHOW_STR
7799 BGP_STR
7800 "Detailed information on TCP and BGP neighbor connections\n"
7801 "Neighbor to display information about\n"
7802 "Neighbor to display information about\n")
7803
7804 ALIAS (show_ip_bgp_neighbors_peer,
7805 show_bgp_ipv6_neighbors_peer_cmd,
7806 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
7807 SHOW_STR
7808 BGP_STR
7809 "Address family\n"
7810 "Detailed information on TCP and BGP neighbor connections\n"
7811 "Neighbor to display information about\n"
7812 "Neighbor to display information about\n")
7813
7814 DEFUN (show_ip_bgp_instance_neighbors,
7815 show_ip_bgp_instance_neighbors_cmd,
7816 "show ip bgp view WORD neighbors",
7817 SHOW_STR
7818 IP_STR
7819 BGP_STR
7820 "BGP view\n"
7821 "View name\n"
7822 "Detailed information on TCP and BGP neighbor connections\n")
7823 {
7824 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
7825 }
7826
7827 ALIAS (show_ip_bgp_instance_neighbors,
7828 show_bgp_instance_neighbors_cmd,
7829 "show bgp view WORD neighbors",
7830 SHOW_STR
7831 BGP_STR
7832 "BGP view\n"
7833 "View name\n"
7834 "Detailed information on TCP and BGP neighbor connections\n")
7835
7836 ALIAS (show_ip_bgp_instance_neighbors,
7837 show_bgp_instance_ipv6_neighbors_cmd,
7838 "show bgp view WORD ipv6 neighbors",
7839 SHOW_STR
7840 BGP_STR
7841 "BGP view\n"
7842 "View name\n"
7843 "Address family\n"
7844 "Detailed information on TCP and BGP neighbor connections\n")
7845
7846 DEFUN (show_ip_bgp_instance_neighbors_peer,
7847 show_ip_bgp_instance_neighbors_peer_cmd,
7848 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7849 SHOW_STR
7850 IP_STR
7851 BGP_STR
7852 "BGP view\n"
7853 "View name\n"
7854 "Detailed information on TCP and BGP neighbor connections\n"
7855 "Neighbor to display information about\n"
7856 "Neighbor to display information about\n")
7857 {
7858 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
7859 }
7860
7861 ALIAS (show_ip_bgp_instance_neighbors_peer,
7862 show_bgp_instance_neighbors_peer_cmd,
7863 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
7864 SHOW_STR
7865 BGP_STR
7866 "BGP view\n"
7867 "View name\n"
7868 "Detailed information on TCP and BGP neighbor connections\n"
7869 "Neighbor to display information about\n"
7870 "Neighbor to display information about\n")
7871
7872 ALIAS (show_ip_bgp_instance_neighbors_peer,
7873 show_bgp_instance_ipv6_neighbors_peer_cmd,
7874 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
7875 SHOW_STR
7876 BGP_STR
7877 "BGP view\n"
7878 "View name\n"
7879 "Address family\n"
7880 "Detailed information on TCP and BGP neighbor connections\n"
7881 "Neighbor to display information about\n"
7882 "Neighbor to display information about\n")
7883 \f
7884 /* Show BGP's AS paths internal data. There are both `show ip bgp
7885 paths' and `show ip mbgp paths'. Those functions results are the
7886 same.*/
7887 DEFUN (show_ip_bgp_paths,
7888 show_ip_bgp_paths_cmd,
7889 "show ip bgp paths",
7890 SHOW_STR
7891 IP_STR
7892 BGP_STR
7893 "Path information\n")
7894 {
7895 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
7896 aspath_print_all_vty (vty);
7897 return CMD_SUCCESS;
7898 }
7899
7900 DEFUN (show_ip_bgp_ipv4_paths,
7901 show_ip_bgp_ipv4_paths_cmd,
7902 "show ip bgp ipv4 (unicast|multicast) paths",
7903 SHOW_STR
7904 IP_STR
7905 BGP_STR
7906 "Address family\n"
7907 "Address Family modifier\n"
7908 "Address Family modifier\n"
7909 "Path information\n")
7910 {
7911 vty_out (vty, "Address Refcnt Path\r\n");
7912 aspath_print_all_vty (vty);
7913
7914 return CMD_SUCCESS;
7915 }
7916 \f
7917 #include "hash.h"
7918
7919 static void
7920 community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
7921 {
7922 struct community *com;
7923
7924 com = (struct community *) backet->data;
7925 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
7926 community_str (com), VTY_NEWLINE);
7927 }
7928
7929 /* Show BGP's community internal data. */
7930 DEFUN (show_ip_bgp_community_info,
7931 show_ip_bgp_community_info_cmd,
7932 "show ip bgp community-info",
7933 SHOW_STR
7934 IP_STR
7935 BGP_STR
7936 "List all bgp community information\n")
7937 {
7938 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
7939
7940 hash_iterate (community_hash (),
7941 (void (*) (struct hash_backet *, void *))
7942 community_show_all_iterator,
7943 vty);
7944
7945 return CMD_SUCCESS;
7946 }
7947
7948 DEFUN (show_ip_bgp_attr_info,
7949 show_ip_bgp_attr_info_cmd,
7950 "show ip bgp attribute-info",
7951 SHOW_STR
7952 IP_STR
7953 BGP_STR
7954 "List all bgp attribute information\n")
7955 {
7956 attr_show_all (vty);
7957 return CMD_SUCCESS;
7958 }
7959 \f
7960 static int
7961 bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
7962 afi_t afi, safi_t safi)
7963 {
7964 char timebuf[BGP_UPTIME_LEN];
7965 char rmbuf[14];
7966 const char *rmname;
7967 struct peer *peer;
7968 struct listnode *node, *nnode;
7969 int len;
7970 int count = 0;
7971
7972 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
7973 {
7974 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
7975 {
7976 count++;
7977 bgp_write_rsclient_summary (vty, peer, afi, safi);
7978 }
7979 return count;
7980 }
7981
7982 len = vty_out (vty, "%s", rsclient->host);
7983 len = 16 - len;
7984
7985 if (len < 1)
7986 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
7987 else
7988 vty_out (vty, "%*s", len, " ");
7989
7990 vty_out (vty, "4 ");
7991
7992 vty_out (vty, "%11d ", rsclient->as);
7993
7994 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
7995 if ( rmname && strlen (rmname) > 13 )
7996 {
7997 sprintf (rmbuf, "%13s", "...");
7998 rmname = strncpy (rmbuf, rmname, 10);
7999 }
8000 else if (! rmname)
8001 rmname = "<none>";
8002 vty_out (vty, " %13s ", rmname);
8003
8004 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
8005 if ( rmname && strlen (rmname) > 13 )
8006 {
8007 sprintf (rmbuf, "%13s", "...");
8008 rmname = strncpy (rmbuf, rmname, 10);
8009 }
8010 else if (! rmname)
8011 rmname = "<none>";
8012 vty_out (vty, " %13s ", rmname);
8013
8014 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN));
8015
8016 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
8017 vty_out (vty, " Idle (Admin)");
8018 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8019 vty_out (vty, " Idle (PfxCt)");
8020 else
8021 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
8022
8023 vty_out (vty, "%s", VTY_NEWLINE);
8024
8025 return 1;
8026 }
8027
8028 static int
8029 bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
8030 afi_t afi, safi_t safi)
8031 {
8032 struct peer *peer;
8033 struct listnode *node, *nnode;
8034 int count = 0;
8035
8036 /* Header string for each address family. */
8037 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
8038
8039 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
8040 {
8041 if (peer->afc[afi][safi] &&
8042 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
8043 {
8044 if (! count)
8045 {
8046 vty_out (vty,
8047 "Route Server's BGP router identifier %s%s",
8048 inet_ntoa (bgp->router_id), VTY_NEWLINE);
8049 vty_out (vty,
8050 "Route Server's local AS number %u%s", bgp->as,
8051 VTY_NEWLINE);
8052
8053 vty_out (vty, "%s", VTY_NEWLINE);
8054 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8055 }
8056
8057 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
8058 }
8059 }
8060
8061 if (count)
8062 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
8063 count, VTY_NEWLINE);
8064 else
8065 vty_out (vty, "No %s Route Server Client is configured%s",
8066 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8067
8068 return CMD_SUCCESS;
8069 }
8070
8071 static int
8072 bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
8073 afi_t afi, safi_t safi)
8074 {
8075 struct bgp *bgp;
8076
8077 if (name)
8078 {
8079 bgp = bgp_lookup_by_name (name);
8080
8081 if (! bgp)
8082 {
8083 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8084 return CMD_WARNING;
8085 }
8086
8087 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8088 return CMD_SUCCESS;
8089 }
8090
8091 bgp = bgp_get_default ();
8092
8093 if (bgp)
8094 bgp_show_rsclient_summary (vty, bgp, afi, safi);
8095
8096 return CMD_SUCCESS;
8097 }
8098
8099 /* 'show bgp rsclient' commands. */
8100 DEFUN (show_ip_bgp_rsclient_summary,
8101 show_ip_bgp_rsclient_summary_cmd,
8102 "show ip bgp rsclient summary",
8103 SHOW_STR
8104 IP_STR
8105 BGP_STR
8106 "Information about Route Server Clients\n"
8107 "Summary of all Route Server Clients\n")
8108 {
8109 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8110 }
8111
8112 DEFUN (show_ip_bgp_instance_rsclient_summary,
8113 show_ip_bgp_instance_rsclient_summary_cmd,
8114 "show ip bgp view WORD rsclient summary",
8115 SHOW_STR
8116 IP_STR
8117 BGP_STR
8118 "BGP view\n"
8119 "View name\n"
8120 "Information about Route Server Clients\n"
8121 "Summary of all Route Server Clients\n")
8122 {
8123 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8124 }
8125
8126 DEFUN (show_ip_bgp_ipv4_rsclient_summary,
8127 show_ip_bgp_ipv4_rsclient_summary_cmd,
8128 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
8129 SHOW_STR
8130 IP_STR
8131 BGP_STR
8132 "Address family\n"
8133 "Address Family modifier\n"
8134 "Address Family modifier\n"
8135 "Information about Route Server Clients\n"
8136 "Summary of all Route Server Clients\n")
8137 {
8138 if (strncmp (argv[0], "m", 1) == 0)
8139 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
8140
8141 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
8142 }
8143
8144 DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
8145 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
8146 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
8147 SHOW_STR
8148 IP_STR
8149 BGP_STR
8150 "BGP view\n"
8151 "View name\n"
8152 "Address family\n"
8153 "Address Family modifier\n"
8154 "Address Family modifier\n"
8155 "Information about Route Server Clients\n"
8156 "Summary of all Route Server Clients\n")
8157 {
8158 if (strncmp (argv[1], "m", 1) == 0)
8159 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
8160
8161 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
8162 }
8163
8164 #ifdef HAVE_IPV6
8165 DEFUN (show_bgp_rsclient_summary,
8166 show_bgp_rsclient_summary_cmd,
8167 "show bgp rsclient summary",
8168 SHOW_STR
8169 BGP_STR
8170 "Information about Route Server Clients\n"
8171 "Summary of all Route Server Clients\n")
8172 {
8173 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
8174 }
8175
8176 DEFUN (show_bgp_instance_rsclient_summary,
8177 show_bgp_instance_rsclient_summary_cmd,
8178 "show bgp view WORD rsclient summary",
8179 SHOW_STR
8180 BGP_STR
8181 "BGP view\n"
8182 "View name\n"
8183 "Information about Route Server Clients\n"
8184 "Summary of all Route Server Clients\n")
8185 {
8186 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
8187 }
8188
8189 ALIAS (show_bgp_rsclient_summary,
8190 show_bgp_ipv6_rsclient_summary_cmd,
8191 "show bgp ipv6 rsclient summary",
8192 SHOW_STR
8193 BGP_STR
8194 "Address family\n"
8195 "Information about Route Server Clients\n"
8196 "Summary of all Route Server Clients\n")
8197
8198 ALIAS (show_bgp_instance_rsclient_summary,
8199 show_bgp_instance_ipv6_rsclient_summary_cmd,
8200 "show bgp view WORD ipv6 rsclient summary",
8201 SHOW_STR
8202 BGP_STR
8203 "BGP view\n"
8204 "View name\n"
8205 "Address family\n"
8206 "Information about Route Server Clients\n"
8207 "Summary of all Route Server Clients\n")
8208 #endif /* HAVE IPV6 */
8209 \f
8210 /* Redistribute VTY commands. */
8211
8212 /* Utility function to convert user input route type string to route
8213 type. */
8214 static int
8215 bgp_str2route_type (int afi, const char *str)
8216 {
8217 if (! str)
8218 return 0;
8219
8220 if (afi == AFI_IP)
8221 {
8222 if (strncmp (str, "k", 1) == 0)
8223 return ZEBRA_ROUTE_KERNEL;
8224 else if (strncmp (str, "c", 1) == 0)
8225 return ZEBRA_ROUTE_CONNECT;
8226 else if (strncmp (str, "s", 1) == 0)
8227 return ZEBRA_ROUTE_STATIC;
8228 else if (strncmp (str, "r", 1) == 0)
8229 return ZEBRA_ROUTE_RIP;
8230 else if (strncmp (str, "o", 1) == 0)
8231 return ZEBRA_ROUTE_OSPF;
8232 }
8233 if (afi == AFI_IP6)
8234 {
8235 if (strncmp (str, "k", 1) == 0)
8236 return ZEBRA_ROUTE_KERNEL;
8237 else if (strncmp (str, "c", 1) == 0)
8238 return ZEBRA_ROUTE_CONNECT;
8239 else if (strncmp (str, "s", 1) == 0)
8240 return ZEBRA_ROUTE_STATIC;
8241 else if (strncmp (str, "r", 1) == 0)
8242 return ZEBRA_ROUTE_RIPNG;
8243 else if (strncmp (str, "o", 1) == 0)
8244 return ZEBRA_ROUTE_OSPF6;
8245 }
8246 return 0;
8247 }
8248
8249 DEFUN (bgp_redistribute_ipv4,
8250 bgp_redistribute_ipv4_cmd,
8251 "redistribute (connected|kernel|ospf|rip|static)",
8252 "Redistribute information from another routing protocol\n"
8253 "Connected\n"
8254 "Kernel routes\n"
8255 "Open Shurtest Path First (OSPF)\n"
8256 "Routing Information Protocol (RIP)\n"
8257 "Static routes\n")
8258 {
8259 int type;
8260
8261 type = bgp_str2route_type (AFI_IP, argv[0]);
8262 if (! type)
8263 {
8264 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8265 return CMD_WARNING;
8266 }
8267 return bgp_redistribute_set (vty->index, AFI_IP, type);
8268 }
8269
8270 DEFUN (bgp_redistribute_ipv4_rmap,
8271 bgp_redistribute_ipv4_rmap_cmd,
8272 "redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8273 "Redistribute information from another routing protocol\n"
8274 "Connected\n"
8275 "Kernel routes\n"
8276 "Open Shurtest Path First (OSPF)\n"
8277 "Routing Information Protocol (RIP)\n"
8278 "Static routes\n"
8279 "Route map reference\n"
8280 "Pointer to route-map entries\n")
8281 {
8282 int type;
8283
8284 type = bgp_str2route_type (AFI_IP, argv[0]);
8285 if (! type)
8286 {
8287 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8288 return CMD_WARNING;
8289 }
8290
8291 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8292 return bgp_redistribute_set (vty->index, AFI_IP, type);
8293 }
8294
8295 DEFUN (bgp_redistribute_ipv4_metric,
8296 bgp_redistribute_ipv4_metric_cmd,
8297 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8298 "Redistribute information from another routing protocol\n"
8299 "Connected\n"
8300 "Kernel routes\n"
8301 "Open Shurtest Path First (OSPF)\n"
8302 "Routing Information Protocol (RIP)\n"
8303 "Static routes\n"
8304 "Metric for redistributed routes\n"
8305 "Default metric\n")
8306 {
8307 int type;
8308 u_int32_t metric;
8309
8310 type = bgp_str2route_type (AFI_IP, argv[0]);
8311 if (! type)
8312 {
8313 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8314 return CMD_WARNING;
8315 }
8316 VTY_GET_INTEGER ("metric", metric, argv[1]);
8317
8318 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8319 return bgp_redistribute_set (vty->index, AFI_IP, type);
8320 }
8321
8322 DEFUN (bgp_redistribute_ipv4_rmap_metric,
8323 bgp_redistribute_ipv4_rmap_metric_cmd,
8324 "redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8325 "Redistribute information from another routing protocol\n"
8326 "Connected\n"
8327 "Kernel routes\n"
8328 "Open Shurtest Path First (OSPF)\n"
8329 "Routing Information Protocol (RIP)\n"
8330 "Static routes\n"
8331 "Route map reference\n"
8332 "Pointer to route-map entries\n"
8333 "Metric for redistributed routes\n"
8334 "Default metric\n")
8335 {
8336 int type;
8337 u_int32_t metric;
8338
8339 type = bgp_str2route_type (AFI_IP, argv[0]);
8340 if (! type)
8341 {
8342 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8343 return CMD_WARNING;
8344 }
8345 VTY_GET_INTEGER ("metric", metric, argv[2]);
8346
8347 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
8348 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8349 return bgp_redistribute_set (vty->index, AFI_IP, type);
8350 }
8351
8352 DEFUN (bgp_redistribute_ipv4_metric_rmap,
8353 bgp_redistribute_ipv4_metric_rmap_cmd,
8354 "redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8355 "Redistribute information from another routing protocol\n"
8356 "Connected\n"
8357 "Kernel routes\n"
8358 "Open Shurtest Path First (OSPF)\n"
8359 "Routing Information Protocol (RIP)\n"
8360 "Static routes\n"
8361 "Metric for redistributed routes\n"
8362 "Default metric\n"
8363 "Route map reference\n"
8364 "Pointer to route-map entries\n")
8365 {
8366 int type;
8367 u_int32_t metric;
8368
8369 type = bgp_str2route_type (AFI_IP, argv[0]);
8370 if (! type)
8371 {
8372 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8373 return CMD_WARNING;
8374 }
8375 VTY_GET_INTEGER ("metric", metric, argv[1]);
8376
8377 bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
8378 bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[2]);
8379 return bgp_redistribute_set (vty->index, AFI_IP, type);
8380 }
8381
8382 DEFUN (no_bgp_redistribute_ipv4,
8383 no_bgp_redistribute_ipv4_cmd,
8384 "no redistribute (connected|kernel|ospf|rip|static)",
8385 NO_STR
8386 "Redistribute information from another routing protocol\n"
8387 "Connected\n"
8388 "Kernel routes\n"
8389 "Open Shurtest Path First (OSPF)\n"
8390 "Routing Information Protocol (RIP)\n"
8391 "Static routes\n")
8392 {
8393 int type;
8394
8395 type = bgp_str2route_type (AFI_IP, argv[0]);
8396 if (! type)
8397 {
8398 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8399 return CMD_WARNING;
8400 }
8401
8402 return bgp_redistribute_unset (vty->index, AFI_IP, type);
8403 }
8404
8405 DEFUN (no_bgp_redistribute_ipv4_rmap,
8406 no_bgp_redistribute_ipv4_rmap_cmd,
8407 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD",
8408 NO_STR
8409 "Redistribute information from another routing protocol\n"
8410 "Connected\n"
8411 "Kernel routes\n"
8412 "Open Shurtest Path First (OSPF)\n"
8413 "Routing Information Protocol (RIP)\n"
8414 "Static routes\n"
8415 "Route map reference\n"
8416 "Pointer to route-map entries\n")
8417 {
8418 int type;
8419
8420 type = bgp_str2route_type (AFI_IP, argv[0]);
8421 if (! type)
8422 {
8423 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8424 return CMD_WARNING;
8425 }
8426
8427 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8428 return CMD_SUCCESS;
8429 }
8430
8431 DEFUN (no_bgp_redistribute_ipv4_metric,
8432 no_bgp_redistribute_ipv4_metric_cmd,
8433 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295>",
8434 NO_STR
8435 "Redistribute information from another routing protocol\n"
8436 "Connected\n"
8437 "Kernel routes\n"
8438 "Open Shurtest Path First (OSPF)\n"
8439 "Routing Information Protocol (RIP)\n"
8440 "Static routes\n"
8441 "Metric for redistributed routes\n"
8442 "Default metric\n")
8443 {
8444 int type;
8445
8446 type = bgp_str2route_type (AFI_IP, argv[0]);
8447 if (! type)
8448 {
8449 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8450 return CMD_WARNING;
8451 }
8452
8453 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8454 return CMD_SUCCESS;
8455 }
8456
8457 DEFUN (no_bgp_redistribute_ipv4_rmap_metric,
8458 no_bgp_redistribute_ipv4_rmap_metric_cmd,
8459 "no redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
8460 NO_STR
8461 "Redistribute information from another routing protocol\n"
8462 "Connected\n"
8463 "Kernel routes\n"
8464 "Open Shurtest Path First (OSPF)\n"
8465 "Routing Information Protocol (RIP)\n"
8466 "Static routes\n"
8467 "Route map reference\n"
8468 "Pointer to route-map entries\n"
8469 "Metric for redistributed routes\n"
8470 "Default metric\n")
8471 {
8472 int type;
8473
8474 type = bgp_str2route_type (AFI_IP, argv[0]);
8475 if (! type)
8476 {
8477 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8478 return CMD_WARNING;
8479 }
8480
8481 bgp_redistribute_metric_unset (vty->index, AFI_IP, type);
8482 bgp_redistribute_routemap_unset (vty->index, AFI_IP, type);
8483 return CMD_SUCCESS;
8484 }
8485
8486 ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
8487 no_bgp_redistribute_ipv4_metric_rmap_cmd,
8488 "no redistribute (connected|kernel|ospf|rip|static) metric <0-4294967295> route-map WORD",
8489 NO_STR
8490 "Redistribute information from another routing protocol\n"
8491 "Connected\n"
8492 "Kernel routes\n"
8493 "Open Shurtest Path First (OSPF)\n"
8494 "Routing Information Protocol (RIP)\n"
8495 "Static routes\n"
8496 "Metric for redistributed routes\n"
8497 "Default metric\n"
8498 "Route map reference\n"
8499 "Pointer to route-map entries\n")
8500 \f
8501 #ifdef HAVE_IPV6
8502 DEFUN (bgp_redistribute_ipv6,
8503 bgp_redistribute_ipv6_cmd,
8504 "redistribute (connected|kernel|ospf6|ripng|static)",
8505 "Redistribute information from another routing protocol\n"
8506 "Connected\n"
8507 "Kernel routes\n"
8508 "Open Shurtest Path First (OSPFv3)\n"
8509 "Routing Information Protocol (RIPng)\n"
8510 "Static routes\n")
8511 {
8512 int type;
8513
8514 type = bgp_str2route_type (AFI_IP6, argv[0]);
8515 if (! type)
8516 {
8517 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8518 return CMD_WARNING;
8519 }
8520
8521 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8522 }
8523
8524 DEFUN (bgp_redistribute_ipv6_rmap,
8525 bgp_redistribute_ipv6_rmap_cmd,
8526 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8527 "Redistribute information from another routing protocol\n"
8528 "Connected\n"
8529 "Kernel routes\n"
8530 "Open Shurtest Path First (OSPFv3)\n"
8531 "Routing Information Protocol (RIPng)\n"
8532 "Static routes\n"
8533 "Route map reference\n"
8534 "Pointer to route-map entries\n")
8535 {
8536 int type;
8537
8538 type = bgp_str2route_type (AFI_IP6, argv[0]);
8539 if (! type)
8540 {
8541 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8542 return CMD_WARNING;
8543 }
8544
8545 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8546 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8547 }
8548
8549 DEFUN (bgp_redistribute_ipv6_metric,
8550 bgp_redistribute_ipv6_metric_cmd,
8551 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8552 "Redistribute information from another routing protocol\n"
8553 "Connected\n"
8554 "Kernel routes\n"
8555 "Open Shurtest Path First (OSPFv3)\n"
8556 "Routing Information Protocol (RIPng)\n"
8557 "Static routes\n"
8558 "Metric for redistributed routes\n"
8559 "Default metric\n")
8560 {
8561 int type;
8562 u_int32_t metric;
8563
8564 type = bgp_str2route_type (AFI_IP6, argv[0]);
8565 if (! type)
8566 {
8567 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8568 return CMD_WARNING;
8569 }
8570 VTY_GET_INTEGER ("metric", metric, argv[1]);
8571
8572 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8573 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8574 }
8575
8576 DEFUN (bgp_redistribute_ipv6_rmap_metric,
8577 bgp_redistribute_ipv6_rmap_metric_cmd,
8578 "redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8579 "Redistribute information from another routing protocol\n"
8580 "Connected\n"
8581 "Kernel routes\n"
8582 "Open Shurtest Path First (OSPFv3)\n"
8583 "Routing Information Protocol (RIPng)\n"
8584 "Static routes\n"
8585 "Route map reference\n"
8586 "Pointer to route-map entries\n"
8587 "Metric for redistributed routes\n"
8588 "Default metric\n")
8589 {
8590 int type;
8591 u_int32_t metric;
8592
8593 type = bgp_str2route_type (AFI_IP6, argv[0]);
8594 if (! type)
8595 {
8596 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8597 return CMD_WARNING;
8598 }
8599 VTY_GET_INTEGER ("metric", metric, argv[2]);
8600
8601 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[1]);
8602 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8603 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8604 }
8605
8606 DEFUN (bgp_redistribute_ipv6_metric_rmap,
8607 bgp_redistribute_ipv6_metric_rmap_cmd,
8608 "redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8609 "Redistribute information from another routing protocol\n"
8610 "Connected\n"
8611 "Kernel routes\n"
8612 "Open Shurtest Path First (OSPFv3)\n"
8613 "Routing Information Protocol (RIPng)\n"
8614 "Static routes\n"
8615 "Metric for redistributed routes\n"
8616 "Default metric\n"
8617 "Route map reference\n"
8618 "Pointer to route-map entries\n")
8619 {
8620 int type;
8621 u_int32_t metric;
8622
8623 type = bgp_str2route_type (AFI_IP6, argv[0]);
8624 if (! type)
8625 {
8626 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8627 return CMD_WARNING;
8628 }
8629 VTY_GET_INTEGER ("metric", metric, argv[1]);
8630
8631 bgp_redistribute_metric_set (vty->index, AFI_IP6, type, metric);
8632 bgp_redistribute_rmap_set (vty->index, AFI_IP6, type, argv[2]);
8633 return bgp_redistribute_set (vty->index, AFI_IP6, type);
8634 }
8635
8636 DEFUN (no_bgp_redistribute_ipv6,
8637 no_bgp_redistribute_ipv6_cmd,
8638 "no redistribute (connected|kernel|ospf6|ripng|static)",
8639 NO_STR
8640 "Redistribute information from another routing protocol\n"
8641 "Connected\n"
8642 "Kernel routes\n"
8643 "Open Shurtest Path First (OSPFv3)\n"
8644 "Routing Information Protocol (RIPng)\n"
8645 "Static routes\n")
8646 {
8647 int type;
8648
8649 type = bgp_str2route_type (AFI_IP6, argv[0]);
8650 if (! type)
8651 {
8652 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8653 return CMD_WARNING;
8654 }
8655
8656 return bgp_redistribute_unset (vty->index, AFI_IP6, type);
8657 }
8658
8659 DEFUN (no_bgp_redistribute_ipv6_rmap,
8660 no_bgp_redistribute_ipv6_rmap_cmd,
8661 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD",
8662 NO_STR
8663 "Redistribute information from another routing protocol\n"
8664 "Connected\n"
8665 "Kernel routes\n"
8666 "Open Shurtest Path First (OSPFv3)\n"
8667 "Routing Information Protocol (RIPng)\n"
8668 "Static routes\n"
8669 "Route map reference\n"
8670 "Pointer to route-map entries\n")
8671 {
8672 int type;
8673
8674 type = bgp_str2route_type (AFI_IP6, argv[0]);
8675 if (! type)
8676 {
8677 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8678 return CMD_WARNING;
8679 }
8680
8681 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8682 return CMD_SUCCESS;
8683 }
8684
8685 DEFUN (no_bgp_redistribute_ipv6_metric,
8686 no_bgp_redistribute_ipv6_metric_cmd,
8687 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295>",
8688 NO_STR
8689 "Redistribute information from another routing protocol\n"
8690 "Connected\n"
8691 "Kernel routes\n"
8692 "Open Shurtest Path First (OSPFv3)\n"
8693 "Routing Information Protocol (RIPng)\n"
8694 "Static routes\n"
8695 "Metric for redistributed routes\n"
8696 "Default metric\n")
8697 {
8698 int type;
8699
8700 type = bgp_str2route_type (AFI_IP6, argv[0]);
8701 if (! type)
8702 {
8703 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8704 return CMD_WARNING;
8705 }
8706
8707 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8708 return CMD_SUCCESS;
8709 }
8710
8711 DEFUN (no_bgp_redistribute_ipv6_rmap_metric,
8712 no_bgp_redistribute_ipv6_rmap_metric_cmd,
8713 "no redistribute (connected|kernel|ospf6|ripng|static) route-map WORD metric <0-4294967295>",
8714 NO_STR
8715 "Redistribute information from another routing protocol\n"
8716 "Connected\n"
8717 "Kernel routes\n"
8718 "Open Shurtest Path First (OSPFv3)\n"
8719 "Routing Information Protocol (RIPng)\n"
8720 "Static routes\n"
8721 "Route map reference\n"
8722 "Pointer to route-map entries\n"
8723 "Metric for redistributed routes\n"
8724 "Default metric\n")
8725 {
8726 int type;
8727
8728 type = bgp_str2route_type (AFI_IP6, argv[0]);
8729 if (! type)
8730 {
8731 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
8732 return CMD_WARNING;
8733 }
8734
8735 bgp_redistribute_metric_unset (vty->index, AFI_IP6, type);
8736 bgp_redistribute_routemap_unset (vty->index, AFI_IP6, type);
8737 return CMD_SUCCESS;
8738 }
8739
8740 ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
8741 no_bgp_redistribute_ipv6_metric_rmap_cmd,
8742 "no redistribute (connected|kernel|ospf6|ripng|static) metric <0-4294967295> route-map WORD",
8743 NO_STR
8744 "Redistribute information from another routing protocol\n"
8745 "Connected\n"
8746 "Kernel routes\n"
8747 "Open Shurtest Path First (OSPFv3)\n"
8748 "Routing Information Protocol (RIPng)\n"
8749 "Static routes\n"
8750 "Metric for redistributed routes\n"
8751 "Default metric\n"
8752 "Route map reference\n"
8753 "Pointer to route-map entries\n")
8754 #endif /* HAVE_IPV6 */
8755 \f
8756 int
8757 bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
8758 safi_t safi, int *write)
8759 {
8760 int i;
8761
8762 /* Unicast redistribution only. */
8763 if (safi != SAFI_UNICAST)
8764 return 0;
8765
8766 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
8767 {
8768 /* Redistribute BGP does not make sense. */
8769 if (bgp->redist[afi][i] && i != ZEBRA_ROUTE_BGP)
8770 {
8771 /* Display "address-family" when it is not yet diplayed. */
8772 bgp_config_write_family_header (vty, afi, safi, write);
8773
8774 /* "redistribute" configuration. */
8775 vty_out (vty, " redistribute %s", zebra_route_string(i));
8776
8777 if (bgp->redist_metric_flag[afi][i])
8778 vty_out (vty, " metric %d", bgp->redist_metric[afi][i]);
8779
8780 if (bgp->rmap[afi][i].name)
8781 vty_out (vty, " route-map %s", bgp->rmap[afi][i].name);
8782
8783 vty_out (vty, "%s", VTY_NEWLINE);
8784 }
8785 }
8786 return *write;
8787 }
8788 \f
8789 /* BGP node structure. */
8790 static struct cmd_node bgp_node =
8791 {
8792 BGP_NODE,
8793 "%s(config-router)# ",
8794 1,
8795 };
8796
8797 static struct cmd_node bgp_ipv4_unicast_node =
8798 {
8799 BGP_IPV4_NODE,
8800 "%s(config-router-af)# ",
8801 1,
8802 };
8803
8804 static struct cmd_node bgp_ipv4_multicast_node =
8805 {
8806 BGP_IPV4M_NODE,
8807 "%s(config-router-af)# ",
8808 1,
8809 };
8810
8811 static struct cmd_node bgp_ipv6_unicast_node =
8812 {
8813 BGP_IPV6_NODE,
8814 "%s(config-router-af)# ",
8815 1,
8816 };
8817
8818 static struct cmd_node bgp_ipv6_multicast_node =
8819 {
8820 BGP_IPV6M_NODE,
8821 "%s(config-router-af)# ",
8822 1,
8823 };
8824
8825 static struct cmd_node bgp_vpnv4_node =
8826 {
8827 BGP_VPNV4_NODE,
8828 "%s(config-router-af)# ",
8829 1
8830 };
8831 \f
8832 static void community_list_vty (void);
8833
8834 void
8835 bgp_vty_init (void)
8836 {
8837 /* Install bgp top node. */
8838 install_node (&bgp_node, bgp_config_write);
8839 install_node (&bgp_ipv4_unicast_node, NULL);
8840 install_node (&bgp_ipv4_multicast_node, NULL);
8841 install_node (&bgp_ipv6_unicast_node, NULL);
8842 install_node (&bgp_ipv6_multicast_node, NULL);
8843 install_node (&bgp_vpnv4_node, NULL);
8844
8845 /* Install default VTY commands to new nodes. */
8846 install_default (BGP_NODE);
8847 install_default (BGP_IPV4_NODE);
8848 install_default (BGP_IPV4M_NODE);
8849 install_default (BGP_IPV6_NODE);
8850 install_default (BGP_IPV6M_NODE);
8851 install_default (BGP_VPNV4_NODE);
8852
8853 /* "bgp multiple-instance" commands. */
8854 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
8855 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
8856
8857 /* "bgp config-type" commands. */
8858 install_element (CONFIG_NODE, &bgp_config_type_cmd);
8859 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
8860
8861 /* Dummy commands (Currently not supported) */
8862 install_element (BGP_NODE, &no_synchronization_cmd);
8863 install_element (BGP_NODE, &no_auto_summary_cmd);
8864
8865 /* "router bgp" commands. */
8866 install_element (CONFIG_NODE, &router_bgp_cmd);
8867 install_element (CONFIG_NODE, &router_bgp_view_cmd);
8868
8869 /* "no router bgp" commands. */
8870 install_element (CONFIG_NODE, &no_router_bgp_cmd);
8871 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
8872
8873 /* "bgp router-id" commands. */
8874 install_element (BGP_NODE, &bgp_router_id_cmd);
8875 install_element (BGP_NODE, &no_bgp_router_id_cmd);
8876 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
8877
8878 /* "bgp cluster-id" commands. */
8879 install_element (BGP_NODE, &bgp_cluster_id_cmd);
8880 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
8881 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
8882 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
8883
8884 /* "bgp confederation" commands. */
8885 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
8886 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
8887 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
8888
8889 /* "bgp confederation peers" commands. */
8890 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
8891 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
8892
8893 /* "timers bgp" commands. */
8894 install_element (BGP_NODE, &bgp_timers_cmd);
8895 install_element (BGP_NODE, &no_bgp_timers_cmd);
8896 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
8897
8898 /* "bgp client-to-client reflection" commands */
8899 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
8900 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
8901
8902 /* "bgp always-compare-med" commands */
8903 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
8904 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
8905
8906 /* "bgp deterministic-med" commands */
8907 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
8908 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
8909
8910 /* "bgp graceful-restart" commands */
8911 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
8912 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
8913 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
8914 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
8915 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
8916
8917 /* "bgp fast-external-failover" commands */
8918 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
8919 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
8920
8921 /* "bgp enforce-first-as" commands */
8922 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
8923 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
8924
8925 /* "bgp bestpath compare-routerid" commands */
8926 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
8927 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
8928
8929 /* "bgp bestpath as-path ignore" commands */
8930 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
8931 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
8932
8933 /* "bgp bestpath as-path confed" commands */
8934 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
8935 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
8936
8937 /* "bgp log-neighbor-changes" commands */
8938 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
8939 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
8940
8941 /* "bgp bestpath med" commands */
8942 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
8943 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
8944 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
8945 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
8946 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
8947 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
8948
8949 /* "no bgp default ipv4-unicast" commands. */
8950 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
8951 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
8952
8953 /* "bgp network import-check" commands. */
8954 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8955 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
8956
8957 /* "bgp default local-preference" commands. */
8958 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
8959 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
8960 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
8961
8962 /* "neighbor remote-as" commands. */
8963 install_element (BGP_NODE, &neighbor_remote_as_cmd);
8964 install_element (BGP_NODE, &no_neighbor_cmd);
8965 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
8966
8967 /* "neighbor peer-group" commands. */
8968 install_element (BGP_NODE, &neighbor_peer_group_cmd);
8969 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
8970 install_element (BGP_NODE, &no_neighbor_peer_group_remote_as_cmd);
8971
8972 /* "neighbor local-as" commands. */
8973 install_element (BGP_NODE, &neighbor_local_as_cmd);
8974 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
8975 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
8976 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
8977 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
8978
8979 /* "neighbor password" commands. */
8980 install_element (BGP_NODE, &neighbor_password_cmd);
8981 install_element (BGP_NODE, &no_neighbor_password_cmd);
8982
8983 /* "neighbor activate" commands. */
8984 install_element (BGP_NODE, &neighbor_activate_cmd);
8985 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
8986 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
8987 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
8988 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
8989 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8990
8991 /* "no neighbor activate" commands. */
8992 install_element (BGP_NODE, &no_neighbor_activate_cmd);
8993 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
8994 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
8995 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
8996 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
8997 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8998
8999 /* "neighbor peer-group set" commands. */
9000 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
9001 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
9002 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
9003 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
9004 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
9005 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
9006
9007 /* "no neighbor peer-group unset" commands. */
9008 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
9009 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
9010 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
9011 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
9012 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
9013 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
9014
9015 /* "neighbor softreconfiguration inbound" commands.*/
9016 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
9017 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
9018 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
9019 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
9020 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
9021 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
9022 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
9023 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
9024 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
9025 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
9026 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
9027 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
9028
9029 /* "neighbor attribute-unchanged" commands. */
9030 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
9031 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
9032 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
9033 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
9034 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
9035 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
9036 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
9037 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
9038 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
9039 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
9040 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
9041 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
9042 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
9043 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
9044 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
9045 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
9046 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
9047 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
9048 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
9049 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
9050 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
9051 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
9052 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
9053 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
9054 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
9055 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
9056 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
9057 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
9058 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
9059 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
9060 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
9061 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
9062 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
9063 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
9064 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9065 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9066 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9067 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9068 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9069 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9070 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9071 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9072 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9073 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9074 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
9075 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
9076 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
9077 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
9078 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
9079 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
9080 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
9081 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
9082 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
9083 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
9084 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
9085 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
9086 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
9087 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
9088 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
9089 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
9090 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
9091 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
9092 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
9093 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
9094 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
9095 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
9096 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
9097 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
9098 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
9099 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
9100 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
9101 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
9102 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
9103 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
9104 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
9105 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
9106 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
9107 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
9108 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
9109 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
9110 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
9111 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
9112 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
9113 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
9114 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
9115 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
9116 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
9117 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
9118 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
9119 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
9120 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
9121 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
9122 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
9123 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
9124 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
9125 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
9126 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
9127 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
9128 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
9129 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
9130 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
9131 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
9132 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
9133 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
9134 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
9135 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
9136 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
9137 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
9138 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
9139 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
9140 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
9141 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
9142 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
9143 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
9144 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
9145 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
9146 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
9147 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
9148 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
9149 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
9150 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
9151 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
9152 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
9153 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
9154 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
9155 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
9156 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
9157 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
9158 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
9159 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
9160 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
9161 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
9162
9163 /* "nexthop-local unchanged" commands */
9164 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
9165 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
9166
9167 /* "transparent-as" and "transparent-nexthop" for old version
9168 compatibility. */
9169 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
9170 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
9171
9172 /* "neighbor next-hop-self" commands. */
9173 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
9174 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
9175 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
9176 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
9177 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
9178 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
9179 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
9180 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
9181 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
9182 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
9183 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
9184 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
9185
9186 /* "neighbor remove-private-AS" commands. */
9187 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
9188 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
9189 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
9190 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
9191 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
9192 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
9193 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
9194 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
9195 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
9196 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
9197 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
9198 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
9199
9200 /* "neighbor send-community" commands.*/
9201 install_element (BGP_NODE, &neighbor_send_community_cmd);
9202 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
9203 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
9204 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
9205 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
9206 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
9207 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
9208 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
9209 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
9210 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
9211 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
9212 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
9213 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
9214 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
9215 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
9216 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
9217 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
9218 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
9219 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
9220 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
9221 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
9222 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
9223 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
9224 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
9225
9226 /* "neighbor route-reflector" commands.*/
9227 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
9228 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
9229 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
9230 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
9231 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
9232 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
9233 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
9234 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
9235 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
9236 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
9237 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
9238 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
9239
9240 /* "neighbor route-server" commands.*/
9241 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
9242 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
9243 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
9244 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
9245 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
9246 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
9247 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
9248 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
9249 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
9250 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
9251 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
9252 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
9253
9254 /* "neighbor passive" commands. */
9255 install_element (BGP_NODE, &neighbor_passive_cmd);
9256 install_element (BGP_NODE, &no_neighbor_passive_cmd);
9257
9258 /* "neighbor shutdown" commands. */
9259 install_element (BGP_NODE, &neighbor_shutdown_cmd);
9260 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
9261
9262 /* Deprecated "neighbor capability route-refresh" commands.*/
9263 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
9264 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
9265
9266 /* "neighbor capability orf prefix-list" commands.*/
9267 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
9268 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
9269 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
9270 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
9271 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
9272 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9273 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
9274 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
9275 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
9276 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
9277
9278 /* "neighbor capability dynamic" commands.*/
9279 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
9280 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
9281
9282 /* "neighbor dont-capability-negotiate" commands. */
9283 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
9284 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
9285
9286 /* "neighbor ebgp-multihop" commands. */
9287 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
9288 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
9289 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
9290 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
9291
9292 /* "neighbor disable-connected-check" commands. */
9293 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
9294 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
9295 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
9296 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
9297
9298 /* "neighbor description" commands. */
9299 install_element (BGP_NODE, &neighbor_description_cmd);
9300 install_element (BGP_NODE, &no_neighbor_description_cmd);
9301 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
9302
9303 /* "neighbor update-source" commands. "*/
9304 install_element (BGP_NODE, &neighbor_update_source_cmd);
9305 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
9306
9307 /* "neighbor default-originate" commands. */
9308 install_element (BGP_NODE, &neighbor_default_originate_cmd);
9309 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
9310 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
9311 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
9312 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
9313 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
9314 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
9315 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
9316 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
9317 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
9318 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
9319 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
9320 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
9321 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
9322 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
9323 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
9324 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
9325 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
9326 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
9327 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
9328
9329 /* "neighbor port" commands. */
9330 install_element (BGP_NODE, &neighbor_port_cmd);
9331 install_element (BGP_NODE, &no_neighbor_port_cmd);
9332 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
9333
9334 /* "neighbor weight" commands. */
9335 install_element (BGP_NODE, &neighbor_weight_cmd);
9336 install_element (BGP_NODE, &no_neighbor_weight_cmd);
9337 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
9338
9339 /* "neighbor override-capability" commands. */
9340 install_element (BGP_NODE, &neighbor_override_capability_cmd);
9341 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
9342
9343 /* "neighbor strict-capability-match" commands. */
9344 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
9345 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
9346
9347 /* "neighbor timers" commands. */
9348 install_element (BGP_NODE, &neighbor_timers_cmd);
9349 install_element (BGP_NODE, &no_neighbor_timers_cmd);
9350
9351 /* "neighbor timers connect" commands. */
9352 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
9353 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
9354 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
9355
9356 /* "neighbor advertisement-interval" commands. */
9357 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
9358 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
9359 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
9360
9361 /* "neighbor version" commands. */
9362 install_element (BGP_NODE, &neighbor_version_cmd);
9363
9364 /* "neighbor interface" commands. */
9365 install_element (BGP_NODE, &neighbor_interface_cmd);
9366 install_element (BGP_NODE, &no_neighbor_interface_cmd);
9367
9368 /* "neighbor distribute" commands. */
9369 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
9370 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
9371 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
9372 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
9373 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
9374 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
9375 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
9376 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
9377 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
9378 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
9379 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
9380 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
9381
9382 /* "neighbor prefix-list" commands. */
9383 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
9384 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
9385 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
9386 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
9387 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
9388 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
9389 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
9390 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
9391 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
9392 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
9393 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
9394 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
9395
9396 /* "neighbor filter-list" commands. */
9397 install_element (BGP_NODE, &neighbor_filter_list_cmd);
9398 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
9399 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
9400 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
9401 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
9402 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
9403 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
9404 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
9405 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
9406 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
9407 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
9408 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
9409
9410 /* "neighbor route-map" commands. */
9411 install_element (BGP_NODE, &neighbor_route_map_cmd);
9412 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
9413 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
9414 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
9415 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
9416 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
9417 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
9418 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
9419 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
9420 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
9421 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
9422 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
9423
9424 /* "neighbor unsuppress-map" commands. */
9425 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
9426 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
9427 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
9428 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
9429 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
9430 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
9431 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
9432 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
9433 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
9434 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
9435 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
9436 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
9437
9438 /* "neighbor maximum-prefix" commands. */
9439 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
9440 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
9441 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
9442 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9443 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
9444 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9445 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
9446 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
9447 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9448 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9449 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9450 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9451 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9452 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
9453 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
9454 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
9455 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9456 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9457 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9458 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
9459 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
9460 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9461 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9462 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9463 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9464 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9465 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
9466 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9467 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
9468 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9469 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
9470 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9471 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
9472 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9473 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9474 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9475 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9476 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9477 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9478 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
9479 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
9480 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
9481 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9482 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
9483 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9484 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
9485 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
9486 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9487 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9488 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9489 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9490 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9491 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
9492 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
9493 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
9494 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9495 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
9496 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9497 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
9498 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
9499 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9500 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9501 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9502 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9503 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9504 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
9505 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
9506 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
9507 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
9508 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
9509 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
9510 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
9511 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
9512 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
9513 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
9514 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
9515 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
9516 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
9517
9518 /* "neighbor allowas-in" */
9519 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
9520 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
9521 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
9522 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
9523 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
9524 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
9525 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
9526 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
9527 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
9528 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
9529 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
9530 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
9531 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
9532 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
9533 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
9534 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
9535 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
9536 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
9537
9538 /* address-family commands. */
9539 install_element (BGP_NODE, &address_family_ipv4_cmd);
9540 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
9541 #ifdef HAVE_IPV6
9542 install_element (BGP_NODE, &address_family_ipv6_cmd);
9543 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
9544 #endif /* HAVE_IPV6 */
9545 install_element (BGP_NODE, &address_family_vpnv4_cmd);
9546 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
9547
9548 /* "exit-address-family" command. */
9549 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
9550 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
9551 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
9552 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
9553 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
9554
9555 /* "clear ip bgp commands" */
9556 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
9557 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
9558 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
9559 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
9560 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
9561 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
9562 #ifdef HAVE_IPV6
9563 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
9564 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
9565 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
9566 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
9567 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
9568 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
9569 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
9570 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
9571 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
9572 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
9573 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
9574 #endif /* HAVE_IPV6 */
9575
9576 /* "clear ip bgp neighbor soft in" */
9577 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
9578 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
9579 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
9580 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
9581 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
9582 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
9583 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
9584 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
9585 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
9586 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
9587 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
9588 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
9589 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
9590 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
9591 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
9592 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
9593 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
9594 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
9595 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
9596 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
9597 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
9598 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
9599 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
9600 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
9601 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
9602 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
9603 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
9604 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
9605 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
9606 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
9607 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
9608 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
9609 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
9610 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
9611 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
9612 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
9613 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
9614 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
9615 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
9616 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
9617 #ifdef HAVE_IPV6
9618 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
9619 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
9620 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
9621 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
9622 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
9623 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
9624 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
9625 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
9626 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
9627 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
9628 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
9629 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
9630 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
9631 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
9632 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
9633 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
9634 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
9635 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
9636 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
9637 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
9638 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
9639 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
9640 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
9641 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
9642 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
9643 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
9644 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
9645 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
9646 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
9647 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
9648 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
9649 #endif /* HAVE_IPV6 */
9650
9651 /* "clear ip bgp neighbor soft out" */
9652 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
9653 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
9654 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
9655 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
9656 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
9657 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
9658 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
9659 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
9660 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
9661 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
9662 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
9663 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
9664 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
9665 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
9666 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
9667 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
9668 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
9669 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
9670 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
9671 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
9672 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
9673 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
9674 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
9675 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
9676 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
9677 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
9678 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
9679 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
9680 #ifdef HAVE_IPV6
9681 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
9682 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
9683 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
9684 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
9685 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
9686 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
9687 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
9688 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
9689 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
9690 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
9691 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
9692 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
9693 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
9694 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
9695 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
9696 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
9697 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
9698 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
9699 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
9700 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
9701 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
9702 #endif /* HAVE_IPV6 */
9703
9704 /* "clear ip bgp neighbor soft" */
9705 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
9706 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
9707 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
9708 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
9709 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
9710 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
9711 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
9712 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
9713 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
9714 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
9715 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
9716 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
9717 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
9718 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
9719 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
9720 #ifdef HAVE_IPV6
9721 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
9722 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
9723 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
9724 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
9725 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
9726 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
9727 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
9728 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
9729 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
9730 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
9731 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
9732 #endif /* HAVE_IPV6 */
9733
9734 /* "clear ip bgp neighbor rsclient" */
9735 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
9736 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
9737 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
9738 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
9739 #ifdef HAVE_IPV6
9740 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
9741 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
9742 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
9743 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
9744 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
9745 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
9746 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
9747 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
9748 #endif /* HAVE_IPV6 */
9749
9750 /* "show ip bgp summary" commands. */
9751 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
9752 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
9753 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
9754 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9755 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9756 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9757 #ifdef HAVE_IPV6
9758 install_element (VIEW_NODE, &show_bgp_summary_cmd);
9759 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
9760 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
9761 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
9762 #endif /* HAVE_IPV6 */
9763 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
9764 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
9765 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
9766 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9767 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9768 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9769 #ifdef HAVE_IPV6
9770 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
9771 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
9772 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
9773 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
9774 #endif /* HAVE_IPV6 */
9775 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
9776 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
9777 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
9778 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
9779 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
9780 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
9781 #ifdef HAVE_IPV6
9782 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
9783 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
9784 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
9785 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
9786 #endif /* HAVE_IPV6 */
9787
9788 /* "show ip bgp neighbors" commands. */
9789 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
9790 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9791 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
9792 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9793 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9794 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9795 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9796 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9797 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
9798 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9799 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
9800 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9801 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9802 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9803 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9804 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
9805 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
9806 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
9807 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
9808 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
9809 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
9810 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
9811 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
9812 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
9813 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
9814
9815 #ifdef HAVE_IPV6
9816 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
9817 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
9818 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
9819 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
9820 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
9821 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9822 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
9823 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
9824 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
9825 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
9826 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
9827 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
9828 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
9829 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
9830 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
9831 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
9832 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
9833 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
9834 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
9835 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
9836
9837 /* Old commands. */
9838 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
9839 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
9840 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
9841 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
9842 #endif /* HAVE_IPV6 */
9843
9844 /* "show ip bgp rsclient" commands. */
9845 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
9846 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9847 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9848 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9849 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
9850 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9851 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9852 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9853 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
9854 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
9855 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
9856 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
9857
9858 #ifdef HAVE_IPV6
9859 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
9860 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9861 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
9862 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9863 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
9864 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9865 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
9866 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9867 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
9868 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
9869 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
9870 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
9871 #endif /* HAVE_IPV6 */
9872
9873 /* "show ip bgp paths" commands. */
9874 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
9875 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
9876 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
9877 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
9878
9879 /* "show ip bgp community" commands. */
9880 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
9881 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
9882
9883 /* "show ip bgp attribute-info" commands. */
9884 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
9885 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
9886
9887 /* "redistribute" commands. */
9888 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
9889 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
9890 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
9891 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
9892 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
9893 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
9894 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
9895 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
9896 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
9897 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
9898 #ifdef HAVE_IPV6
9899 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
9900 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
9901 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
9902 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
9903 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
9904 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
9905 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
9906 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
9907 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
9908 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
9909 #endif /* HAVE_IPV6 */
9910
9911 /* "show bgp memory" commands. */
9912 install_element (VIEW_NODE, &show_bgp_memory_cmd);
9913 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
9914 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
9915
9916 /* "show bgp views" commands. */
9917 install_element (VIEW_NODE, &show_bgp_views_cmd);
9918 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
9919 install_element (ENABLE_NODE, &show_bgp_views_cmd);
9920
9921 /* Community-list. */
9922 community_list_vty ();
9923 }
9924 \f
9925 #include "memory.h"
9926 #include "bgp_regex.h"
9927 #include "bgp_clist.h"
9928 #include "bgp_ecommunity.h"
9929
9930 /* VTY functions. */
9931
9932 /* Direction value to string conversion. */
9933 static const char *
9934 community_direct_str (int direct)
9935 {
9936 switch (direct)
9937 {
9938 case COMMUNITY_DENY:
9939 return "deny";
9940 case COMMUNITY_PERMIT:
9941 return "permit";
9942 default:
9943 return "unknown";
9944 }
9945 }
9946
9947 /* Display error string. */
9948 static void
9949 community_list_perror (struct vty *vty, int ret)
9950 {
9951 switch (ret)
9952 {
9953 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
9954 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
9955 break;
9956 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
9957 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
9958 break;
9959 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
9960 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
9961 break;
9962 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
9963 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
9964 break;
9965 }
9966 }
9967
9968 /* VTY interface for community_set() function. */
9969 static int
9970 community_list_set_vty (struct vty *vty, int argc, const char **argv,
9971 int style, int reject_all_digit_name)
9972 {
9973 int ret;
9974 int direct;
9975 char *str;
9976
9977 /* Check the list type. */
9978 if (strncmp (argv[1], "p", 1) == 0)
9979 direct = COMMUNITY_PERMIT;
9980 else if (strncmp (argv[1], "d", 1) == 0)
9981 direct = COMMUNITY_DENY;
9982 else
9983 {
9984 vty_out (vty, "%% Matching condition must be permit or deny%s",
9985 VTY_NEWLINE);
9986 return CMD_WARNING;
9987 }
9988
9989 /* All digit name check. */
9990 if (reject_all_digit_name && all_digit (argv[0]))
9991 {
9992 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
9993 return CMD_WARNING;
9994 }
9995
9996 /* Concat community string argument. */
9997 if (argc > 1)
9998 str = argv_concat (argv, argc, 2);
9999 else
10000 str = NULL;
10001
10002 /* When community_list_set() return nevetive value, it means
10003 malformed community string. */
10004 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
10005
10006 /* Free temporary community list string allocated by
10007 argv_concat(). */
10008 if (str)
10009 XFREE (MTYPE_TMP, str);
10010
10011 if (ret < 0)
10012 {
10013 /* Display error string. */
10014 community_list_perror (vty, ret);
10015 return CMD_WARNING;
10016 }
10017
10018 return CMD_SUCCESS;
10019 }
10020
10021 /* Communiyt-list entry delete. */
10022 static int
10023 community_list_unset_vty (struct vty *vty, int argc, const char **argv,
10024 int style)
10025 {
10026 int ret;
10027 int direct = 0;
10028 char *str = NULL;
10029
10030 if (argc > 1)
10031 {
10032 /* Check the list direct. */
10033 if (strncmp (argv[1], "p", 1) == 0)
10034 direct = COMMUNITY_PERMIT;
10035 else if (strncmp (argv[1], "d", 1) == 0)
10036 direct = COMMUNITY_DENY;
10037 else
10038 {
10039 vty_out (vty, "%% Matching condition must be permit or deny%s",
10040 VTY_NEWLINE);
10041 return CMD_WARNING;
10042 }
10043
10044 /* Concat community string argument. */
10045 str = argv_concat (argv, argc, 2);
10046 }
10047
10048 /* Unset community list. */
10049 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
10050
10051 /* Free temporary community list string allocated by
10052 argv_concat(). */
10053 if (str)
10054 XFREE (MTYPE_TMP, str);
10055
10056 if (ret < 0)
10057 {
10058 community_list_perror (vty, ret);
10059 return CMD_WARNING;
10060 }
10061
10062 return CMD_SUCCESS;
10063 }
10064
10065 /* "community-list" keyword help string. */
10066 #define COMMUNITY_LIST_STR "Add a community list entry\n"
10067 #define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
10068
10069 DEFUN (ip_community_list_standard,
10070 ip_community_list_standard_cmd,
10071 "ip community-list <1-99> (deny|permit) .AA:NN",
10072 IP_STR
10073 COMMUNITY_LIST_STR
10074 "Community list number (standard)\n"
10075 "Specify community to reject\n"
10076 "Specify community to accept\n"
10077 COMMUNITY_VAL_STR)
10078 {
10079 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
10080 }
10081
10082 ALIAS (ip_community_list_standard,
10083 ip_community_list_standard2_cmd,
10084 "ip community-list <1-99> (deny|permit)",
10085 IP_STR
10086 COMMUNITY_LIST_STR
10087 "Community list number (standard)\n"
10088 "Specify community to reject\n"
10089 "Specify community to accept\n")
10090
10091 DEFUN (ip_community_list_expanded,
10092 ip_community_list_expanded_cmd,
10093 "ip community-list <100-500> (deny|permit) .LINE",
10094 IP_STR
10095 COMMUNITY_LIST_STR
10096 "Community list number (expanded)\n"
10097 "Specify community to reject\n"
10098 "Specify community to accept\n"
10099 "An ordered list as a regular-expression\n")
10100 {
10101 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
10102 }
10103
10104 DEFUN (ip_community_list_name_standard,
10105 ip_community_list_name_standard_cmd,
10106 "ip community-list standard WORD (deny|permit) .AA:NN",
10107 IP_STR
10108 COMMUNITY_LIST_STR
10109 "Add a standard community-list entry\n"
10110 "Community list name\n"
10111 "Specify community to reject\n"
10112 "Specify community to accept\n"
10113 COMMUNITY_VAL_STR)
10114 {
10115 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
10116 }
10117
10118 ALIAS (ip_community_list_name_standard,
10119 ip_community_list_name_standard2_cmd,
10120 "ip community-list standard WORD (deny|permit)",
10121 IP_STR
10122 COMMUNITY_LIST_STR
10123 "Add a standard community-list entry\n"
10124 "Community list name\n"
10125 "Specify community to reject\n"
10126 "Specify community to accept\n")
10127
10128 DEFUN (ip_community_list_name_expanded,
10129 ip_community_list_name_expanded_cmd,
10130 "ip community-list expanded WORD (deny|permit) .LINE",
10131 IP_STR
10132 COMMUNITY_LIST_STR
10133 "Add an expanded community-list entry\n"
10134 "Community list name\n"
10135 "Specify community to reject\n"
10136 "Specify community to accept\n"
10137 "An ordered list as a regular-expression\n")
10138 {
10139 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
10140 }
10141
10142 DEFUN (no_ip_community_list_standard_all,
10143 no_ip_community_list_standard_all_cmd,
10144 "no ip community-list <1-99>",
10145 NO_STR
10146 IP_STR
10147 COMMUNITY_LIST_STR
10148 "Community list number (standard)\n")
10149 {
10150 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10151 }
10152
10153 DEFUN (no_ip_community_list_expanded_all,
10154 no_ip_community_list_expanded_all_cmd,
10155 "no ip community-list <100-500>",
10156 NO_STR
10157 IP_STR
10158 COMMUNITY_LIST_STR
10159 "Community list number (expanded)\n")
10160 {
10161 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10162 }
10163
10164 DEFUN (no_ip_community_list_name_standard_all,
10165 no_ip_community_list_name_standard_all_cmd,
10166 "no ip community-list standard WORD",
10167 NO_STR
10168 IP_STR
10169 COMMUNITY_LIST_STR
10170 "Add a standard community-list entry\n"
10171 "Community list name\n")
10172 {
10173 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10174 }
10175
10176 DEFUN (no_ip_community_list_name_expanded_all,
10177 no_ip_community_list_name_expanded_all_cmd,
10178 "no ip community-list expanded WORD",
10179 NO_STR
10180 IP_STR
10181 COMMUNITY_LIST_STR
10182 "Add an expanded community-list entry\n"
10183 "Community list name\n")
10184 {
10185 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10186 }
10187
10188 DEFUN (no_ip_community_list_standard,
10189 no_ip_community_list_standard_cmd,
10190 "no ip community-list <1-99> (deny|permit) .AA:NN",
10191 NO_STR
10192 IP_STR
10193 COMMUNITY_LIST_STR
10194 "Community list number (standard)\n"
10195 "Specify community to reject\n"
10196 "Specify community to accept\n"
10197 COMMUNITY_VAL_STR)
10198 {
10199 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10200 }
10201
10202 DEFUN (no_ip_community_list_expanded,
10203 no_ip_community_list_expanded_cmd,
10204 "no ip community-list <100-500> (deny|permit) .LINE",
10205 NO_STR
10206 IP_STR
10207 COMMUNITY_LIST_STR
10208 "Community list number (expanded)\n"
10209 "Specify community to reject\n"
10210 "Specify community to accept\n"
10211 "An ordered list as a regular-expression\n")
10212 {
10213 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10214 }
10215
10216 DEFUN (no_ip_community_list_name_standard,
10217 no_ip_community_list_name_standard_cmd,
10218 "no ip community-list standard WORD (deny|permit) .AA:NN",
10219 NO_STR
10220 IP_STR
10221 COMMUNITY_LIST_STR
10222 "Specify a standard community-list\n"
10223 "Community list name\n"
10224 "Specify community to reject\n"
10225 "Specify community to accept\n"
10226 COMMUNITY_VAL_STR)
10227 {
10228 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
10229 }
10230
10231 DEFUN (no_ip_community_list_name_expanded,
10232 no_ip_community_list_name_expanded_cmd,
10233 "no ip community-list expanded WORD (deny|permit) .LINE",
10234 NO_STR
10235 IP_STR
10236 COMMUNITY_LIST_STR
10237 "Specify an expanded community-list\n"
10238 "Community list name\n"
10239 "Specify community to reject\n"
10240 "Specify community to accept\n"
10241 "An ordered list as a regular-expression\n")
10242 {
10243 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
10244 }
10245
10246 static void
10247 community_list_show (struct vty *vty, struct community_list *list)
10248 {
10249 struct community_entry *entry;
10250
10251 for (entry = list->head; entry; entry = entry->next)
10252 {
10253 if (entry == list->head)
10254 {
10255 if (all_digit (list->name))
10256 vty_out (vty, "Community %s list %s%s",
10257 entry->style == COMMUNITY_LIST_STANDARD ?
10258 "standard" : "(expanded) access",
10259 list->name, VTY_NEWLINE);
10260 else
10261 vty_out (vty, "Named Community %s list %s%s",
10262 entry->style == COMMUNITY_LIST_STANDARD ?
10263 "standard" : "expanded",
10264 list->name, VTY_NEWLINE);
10265 }
10266 if (entry->any)
10267 vty_out (vty, " %s%s",
10268 community_direct_str (entry->direct), VTY_NEWLINE);
10269 else
10270 vty_out (vty, " %s %s%s",
10271 community_direct_str (entry->direct),
10272 entry->style == COMMUNITY_LIST_STANDARD
10273 ? community_str (entry->u.com) : entry->config,
10274 VTY_NEWLINE);
10275 }
10276 }
10277
10278 DEFUN (show_ip_community_list,
10279 show_ip_community_list_cmd,
10280 "show ip community-list",
10281 SHOW_STR
10282 IP_STR
10283 "List community-list\n")
10284 {
10285 struct community_list *list;
10286 struct community_list_master *cm;
10287
10288 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
10289 if (! cm)
10290 return CMD_SUCCESS;
10291
10292 for (list = cm->num.head; list; list = list->next)
10293 community_list_show (vty, list);
10294
10295 for (list = cm->str.head; list; list = list->next)
10296 community_list_show (vty, list);
10297
10298 return CMD_SUCCESS;
10299 }
10300
10301 DEFUN (show_ip_community_list_arg,
10302 show_ip_community_list_arg_cmd,
10303 "show ip community-list (<1-500>|WORD)",
10304 SHOW_STR
10305 IP_STR
10306 "List community-list\n"
10307 "Community-list number\n"
10308 "Community-list name\n")
10309 {
10310 struct community_list *list;
10311
10312 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
10313 if (! list)
10314 {
10315 vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
10316 return CMD_WARNING;
10317 }
10318
10319 community_list_show (vty, list);
10320
10321 return CMD_SUCCESS;
10322 }
10323 \f
10324 static int
10325 extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
10326 int style, int reject_all_digit_name)
10327 {
10328 int ret;
10329 int direct;
10330 char *str;
10331
10332 /* Check the list type. */
10333 if (strncmp (argv[1], "p", 1) == 0)
10334 direct = COMMUNITY_PERMIT;
10335 else if (strncmp (argv[1], "d", 1) == 0)
10336 direct = COMMUNITY_DENY;
10337 else
10338 {
10339 vty_out (vty, "%% Matching condition must be permit or deny%s",
10340 VTY_NEWLINE);
10341 return CMD_WARNING;
10342 }
10343
10344 /* All digit name check. */
10345 if (reject_all_digit_name && all_digit (argv[0]))
10346 {
10347 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
10348 return CMD_WARNING;
10349 }
10350
10351 /* Concat community string argument. */
10352 if (argc > 1)
10353 str = argv_concat (argv, argc, 2);
10354 else
10355 str = NULL;
10356
10357 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
10358
10359 /* Free temporary community list string allocated by
10360 argv_concat(). */
10361 if (str)
10362 XFREE (MTYPE_TMP, str);
10363
10364 if (ret < 0)
10365 {
10366 community_list_perror (vty, ret);
10367 return CMD_WARNING;
10368 }
10369 return CMD_SUCCESS;
10370 }
10371
10372 static int
10373 extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
10374 int style)
10375 {
10376 int ret;
10377 int direct = 0;
10378 char *str = NULL;
10379
10380 if (argc > 1)
10381 {
10382 /* Check the list direct. */
10383 if (strncmp (argv[1], "p", 1) == 0)
10384 direct = COMMUNITY_PERMIT;
10385 else if (strncmp (argv[1], "d", 1) == 0)
10386 direct = COMMUNITY_DENY;
10387 else
10388 {
10389 vty_out (vty, "%% Matching condition must be permit or deny%s",
10390 VTY_NEWLINE);
10391 return CMD_WARNING;
10392 }
10393
10394 /* Concat community string argument. */
10395 str = argv_concat (argv, argc, 2);
10396 }
10397
10398 /* Unset community list. */
10399 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
10400
10401 /* Free temporary community list string allocated by
10402 argv_concat(). */
10403 if (str)
10404 XFREE (MTYPE_TMP, str);
10405
10406 if (ret < 0)
10407 {
10408 community_list_perror (vty, ret);
10409 return CMD_WARNING;
10410 }
10411
10412 return CMD_SUCCESS;
10413 }
10414
10415 /* "extcommunity-list" keyword help string. */
10416 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
10417 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
10418
10419 DEFUN (ip_extcommunity_list_standard,
10420 ip_extcommunity_list_standard_cmd,
10421 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10422 IP_STR
10423 EXTCOMMUNITY_LIST_STR
10424 "Extended Community list number (standard)\n"
10425 "Specify community to reject\n"
10426 "Specify community to accept\n"
10427 EXTCOMMUNITY_VAL_STR)
10428 {
10429 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
10430 }
10431
10432 ALIAS (ip_extcommunity_list_standard,
10433 ip_extcommunity_list_standard2_cmd,
10434 "ip extcommunity-list <1-99> (deny|permit)",
10435 IP_STR
10436 EXTCOMMUNITY_LIST_STR
10437 "Extended Community list number (standard)\n"
10438 "Specify community to reject\n"
10439 "Specify community to accept\n")
10440
10441 DEFUN (ip_extcommunity_list_expanded,
10442 ip_extcommunity_list_expanded_cmd,
10443 "ip extcommunity-list <100-500> (deny|permit) .LINE",
10444 IP_STR
10445 EXTCOMMUNITY_LIST_STR
10446 "Extended Community list number (expanded)\n"
10447 "Specify community to reject\n"
10448 "Specify community to accept\n"
10449 "An ordered list as a regular-expression\n")
10450 {
10451 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
10452 }
10453
10454 DEFUN (ip_extcommunity_list_name_standard,
10455 ip_extcommunity_list_name_standard_cmd,
10456 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10457 IP_STR
10458 EXTCOMMUNITY_LIST_STR
10459 "Specify standard extcommunity-list\n"
10460 "Extended Community list name\n"
10461 "Specify community to reject\n"
10462 "Specify community to accept\n"
10463 EXTCOMMUNITY_VAL_STR)
10464 {
10465 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
10466 }
10467
10468 ALIAS (ip_extcommunity_list_name_standard,
10469 ip_extcommunity_list_name_standard2_cmd,
10470 "ip extcommunity-list standard WORD (deny|permit)",
10471 IP_STR
10472 EXTCOMMUNITY_LIST_STR
10473 "Specify standard extcommunity-list\n"
10474 "Extended Community list name\n"
10475 "Specify community to reject\n"
10476 "Specify community to accept\n")
10477
10478 DEFUN (ip_extcommunity_list_name_expanded,
10479 ip_extcommunity_list_name_expanded_cmd,
10480 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
10481 IP_STR
10482 EXTCOMMUNITY_LIST_STR
10483 "Specify expanded extcommunity-list\n"
10484 "Extended Community list name\n"
10485 "Specify community to reject\n"
10486 "Specify community to accept\n"
10487 "An ordered list as a regular-expression\n")
10488 {
10489 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
10490 }
10491
10492 DEFUN (no_ip_extcommunity_list_standard_all,
10493 no_ip_extcommunity_list_standard_all_cmd,
10494 "no ip extcommunity-list <1-99>",
10495 NO_STR
10496 IP_STR
10497 EXTCOMMUNITY_LIST_STR
10498 "Extended Community list number (standard)\n")
10499 {
10500 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10501 }
10502
10503 DEFUN (no_ip_extcommunity_list_expanded_all,
10504 no_ip_extcommunity_list_expanded_all_cmd,
10505 "no ip extcommunity-list <100-500>",
10506 NO_STR
10507 IP_STR
10508 EXTCOMMUNITY_LIST_STR
10509 "Extended Community list number (expanded)\n")
10510 {
10511 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10512 }
10513
10514 DEFUN (no_ip_extcommunity_list_name_standard_all,
10515 no_ip_extcommunity_list_name_standard_all_cmd,
10516 "no ip extcommunity-list standard WORD",
10517 NO_STR
10518 IP_STR
10519 EXTCOMMUNITY_LIST_STR
10520 "Specify standard extcommunity-list\n"
10521 "Extended Community list name\n")
10522 {
10523 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10524 }
10525
10526 DEFUN (no_ip_extcommunity_list_name_expanded_all,
10527 no_ip_extcommunity_list_name_expanded_all_cmd,
10528 "no ip extcommunity-list expanded WORD",
10529 NO_STR
10530 IP_STR
10531 EXTCOMMUNITY_LIST_STR
10532 "Specify expanded extcommunity-list\n"
10533 "Extended Community list name\n")
10534 {
10535 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10536 }
10537
10538 DEFUN (no_ip_extcommunity_list_standard,
10539 no_ip_extcommunity_list_standard_cmd,
10540 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
10541 NO_STR
10542 IP_STR
10543 EXTCOMMUNITY_LIST_STR
10544 "Extended Community list number (standard)\n"
10545 "Specify community to reject\n"
10546 "Specify community to accept\n"
10547 EXTCOMMUNITY_VAL_STR)
10548 {
10549 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10550 }
10551
10552 DEFUN (no_ip_extcommunity_list_expanded,
10553 no_ip_extcommunity_list_expanded_cmd,
10554 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
10555 NO_STR
10556 IP_STR
10557 EXTCOMMUNITY_LIST_STR
10558 "Extended Community list number (expanded)\n"
10559 "Specify community to reject\n"
10560 "Specify community to accept\n"
10561 "An ordered list as a regular-expression\n")
10562 {
10563 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10564 }
10565
10566 DEFUN (no_ip_extcommunity_list_name_standard,
10567 no_ip_extcommunity_list_name_standard_cmd,
10568 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
10569 NO_STR
10570 IP_STR
10571 EXTCOMMUNITY_LIST_STR
10572 "Specify standard extcommunity-list\n"
10573 "Extended Community list name\n"
10574 "Specify community to reject\n"
10575 "Specify community to accept\n"
10576 EXTCOMMUNITY_VAL_STR)
10577 {
10578 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
10579 }
10580
10581 DEFUN (no_ip_extcommunity_list_name_expanded,
10582 no_ip_extcommunity_list_name_expanded_cmd,
10583 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
10584 NO_STR
10585 IP_STR
10586 EXTCOMMUNITY_LIST_STR
10587 "Specify expanded extcommunity-list\n"
10588 "Community list name\n"
10589 "Specify community to reject\n"
10590 "Specify community to accept\n"
10591 "An ordered list as a regular-expression\n")
10592 {
10593 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
10594 }
10595
10596 static void
10597 extcommunity_list_show (struct vty *vty, struct community_list *list)
10598 {
10599 struct community_entry *entry;
10600
10601 for (entry = list->head; entry; entry = entry->next)
10602 {
10603 if (entry == list->head)
10604 {
10605 if (all_digit (list->name))
10606 vty_out (vty, "Extended community %s list %s%s",
10607 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10608 "standard" : "(expanded) access",
10609 list->name, VTY_NEWLINE);
10610 else
10611 vty_out (vty, "Named extended community %s list %s%s",
10612 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10613 "standard" : "expanded",
10614 list->name, VTY_NEWLINE);
10615 }
10616 if (entry->any)
10617 vty_out (vty, " %s%s",
10618 community_direct_str (entry->direct), VTY_NEWLINE);
10619 else
10620 vty_out (vty, " %s %s%s",
10621 community_direct_str (entry->direct),
10622 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
10623 entry->u.ecom->str : entry->config,
10624 VTY_NEWLINE);
10625 }
10626 }
10627
10628 DEFUN (show_ip_extcommunity_list,
10629 show_ip_extcommunity_list_cmd,
10630 "show ip extcommunity-list",
10631 SHOW_STR
10632 IP_STR
10633 "List extended-community list\n")
10634 {
10635 struct community_list *list;
10636 struct community_list_master *cm;
10637
10638 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
10639 if (! cm)
10640 return CMD_SUCCESS;
10641
10642 for (list = cm->num.head; list; list = list->next)
10643 extcommunity_list_show (vty, list);
10644
10645 for (list = cm->str.head; list; list = list->next)
10646 extcommunity_list_show (vty, list);
10647
10648 return CMD_SUCCESS;
10649 }
10650
10651 DEFUN (show_ip_extcommunity_list_arg,
10652 show_ip_extcommunity_list_arg_cmd,
10653 "show ip extcommunity-list (<1-500>|WORD)",
10654 SHOW_STR
10655 IP_STR
10656 "List extended-community list\n"
10657 "Extcommunity-list number\n"
10658 "Extcommunity-list name\n")
10659 {
10660 struct community_list *list;
10661
10662 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
10663 if (! list)
10664 {
10665 vty_out (vty, "%% Can't find extcommunit-list%s", VTY_NEWLINE);
10666 return CMD_WARNING;
10667 }
10668
10669 extcommunity_list_show (vty, list);
10670
10671 return CMD_SUCCESS;
10672 }
10673 \f
10674 /* Return configuration string of community-list entry. */
10675 static const char *
10676 community_list_config_str (struct community_entry *entry)
10677 {
10678 const char *str;
10679
10680 if (entry->any)
10681 str = "";
10682 else
10683 {
10684 if (entry->style == COMMUNITY_LIST_STANDARD)
10685 str = community_str (entry->u.com);
10686 else
10687 str = entry->config;
10688 }
10689 return str;
10690 }
10691
10692 /* Display community-list and extcommunity-list configuration. */
10693 static int
10694 community_list_config_write (struct vty *vty)
10695 {
10696 struct community_list *list;
10697 struct community_entry *entry;
10698 struct community_list_master *cm;
10699 int write = 0;
10700
10701 /* Community-list. */
10702 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
10703
10704 for (list = cm->num.head; list; list = list->next)
10705 for (entry = list->head; entry; entry = entry->next)
10706 {
10707 vty_out (vty, "ip community-list %s %s %s%s",
10708 list->name, community_direct_str (entry->direct),
10709 community_list_config_str (entry),
10710 VTY_NEWLINE);
10711 write++;
10712 }
10713 for (list = cm->str.head; list; list = list->next)
10714 for (entry = list->head; entry; entry = entry->next)
10715 {
10716 vty_out (vty, "ip community-list %s %s %s %s%s",
10717 entry->style == COMMUNITY_LIST_STANDARD
10718 ? "standard" : "expanded",
10719 list->name, community_direct_str (entry->direct),
10720 community_list_config_str (entry),
10721 VTY_NEWLINE);
10722 write++;
10723 }
10724
10725 /* Extcommunity-list. */
10726 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
10727
10728 for (list = cm->num.head; list; list = list->next)
10729 for (entry = list->head; entry; entry = entry->next)
10730 {
10731 vty_out (vty, "ip extcommunity-list %s %s %s%s",
10732 list->name, community_direct_str (entry->direct),
10733 community_list_config_str (entry), VTY_NEWLINE);
10734 write++;
10735 }
10736 for (list = cm->str.head; list; list = list->next)
10737 for (entry = list->head; entry; entry = entry->next)
10738 {
10739 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
10740 entry->style == EXTCOMMUNITY_LIST_STANDARD
10741 ? "standard" : "expanded",
10742 list->name, community_direct_str (entry->direct),
10743 community_list_config_str (entry), VTY_NEWLINE);
10744 write++;
10745 }
10746 return write;
10747 }
10748
10749 static struct cmd_node community_list_node =
10750 {
10751 COMMUNITY_LIST_NODE,
10752 "",
10753 1 /* Export to vtysh. */
10754 };
10755
10756 static void
10757 community_list_vty (void)
10758 {
10759 install_node (&community_list_node, community_list_config_write);
10760
10761 /* Community-list. */
10762 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
10763 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
10764 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
10765 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
10766 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
10767 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
10768 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
10769 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
10770 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
10771 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
10772 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
10773 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
10774 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
10775 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
10776 install_element (VIEW_NODE, &show_ip_community_list_cmd);
10777 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
10778 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
10779 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
10780
10781 /* Extcommunity-list. */
10782 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
10783 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
10784 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
10785 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
10786 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
10787 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
10788 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
10789 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
10790 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
10791 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
10792 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
10793 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
10794 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
10795 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
10796 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
10797 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
10798 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
10799 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
10800 }