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