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