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