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