]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
Fix arm compilation failures of sockunion_hash issues
[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
856ca177 23#include "lib/json.h"
718e3744 24#include "command.h"
25#include "prefix.h"
26#include "plist.h"
27#include "buffer.h"
28#include "linklist.h"
29#include "stream.h"
30#include "thread.h"
31#include "log.h"
3b8b1855 32#include "memory.h"
4bf6a362 33#include "hash.h"
3f9c7369 34#include "queue.h"
718e3744 35
36#include "bgpd/bgpd.h"
4bf6a362 37#include "bgpd/bgp_advertise.h"
718e3744 38#include "bgpd/bgp_attr.h"
39#include "bgpd/bgp_aspath.h"
40#include "bgpd/bgp_community.h"
4bf6a362
PJ
41#include "bgpd/bgp_ecommunity.h"
42#include "bgpd/bgp_damp.h"
718e3744 43#include "bgpd/bgp_debug.h"
e0701b79 44#include "bgpd/bgp_fsm.h"
718e3744 45#include "bgpd/bgp_mplsvpn.h"
4bf6a362 46#include "bgpd/bgp_nexthop.h"
718e3744 47#include "bgpd/bgp_open.h"
4bf6a362 48#include "bgpd/bgp_regex.h"
718e3744 49#include "bgpd/bgp_route.h"
50#include "bgpd/bgp_zebra.h"
fee0f4c6 51#include "bgpd/bgp_table.h"
94f2b392 52#include "bgpd/bgp_vty.h"
165b5fff 53#include "bgpd/bgp_mpath.h"
cb1faec9 54#include "bgpd/bgp_packet.h"
3f9c7369 55#include "bgpd/bgp_updgrp.h"
c43ed2e4 56#include "bgpd/bgp_bfd.h"
718e3744 57
18a6dce6 58extern struct in_addr router_id_zebra;
59
718e3744 60/* Utility function to get address family from current node. */
61afi_t
62bgp_node_afi (struct vty *vty)
63{
25ffbdc1 64 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 65 return AFI_IP6;
66 return AFI_IP;
67}
68
69/* Utility function to get subsequent address family from current
70 node. */
71safi_t
72bgp_node_safi (struct vty *vty)
73{
74 if (vty->node == BGP_VPNV4_NODE)
75 return SAFI_MPLS_VPN;
25ffbdc1 76 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
718e3744 77 return SAFI_MULTICAST;
78 return SAFI_UNICAST;
79}
80
94f2b392 81static int
718e3744 82peer_address_self_check (union sockunion *su)
83{
84 struct interface *ifp = NULL;
85
86 if (su->sa.sa_family == AF_INET)
87 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr);
88#ifdef HAVE_IPV6
89 else if (su->sa.sa_family == AF_INET6)
f2345335
DS
90 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
91 su->sin6.sin6_scope_id);
718e3744 92#endif /* HAVE IPV6 */
93
94 if (ifp)
95 return 1;
96
97 return 0;
98}
99
100/* Utility function for looking up peer from VTY. */
f14e6fdb
DS
101/* This is used only for configuration, so disallow if attempted on
102 * a dynamic neighbor.
103 */
94f2b392 104static struct peer *
fd79ac91 105peer_lookup_vty (struct vty *vty, const char *ip_str)
718e3744 106{
107 int ret;
108 struct bgp *bgp;
109 union sockunion su;
110 struct peer *peer;
111
112 bgp = vty->index;
113
114 ret = str2sockunion (ip_str, &su);
115 if (ret < 0)
116 {
a80beece
DS
117 peer = peer_lookup_by_conf_if (bgp, ip_str);
118 if (!peer)
119 {
c744aa9f
DS
120 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
121 return NULL;
a80beece 122 }
718e3744 123 }
a80beece 124 else
718e3744 125 {
a80beece
DS
126 peer = peer_lookup (bgp, &su);
127 if (! peer)
128 {
129 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
130 VTY_NEWLINE);
131 return NULL;
132 }
f14e6fdb
DS
133 if (peer_dynamic_neighbor (peer))
134 {
135 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
136 VTY_NEWLINE);
137 return NULL;
138 }
139
718e3744 140 }
141 return peer;
142}
143
144/* Utility function for looking up peer or peer group. */
f14e6fdb
DS
145/* This is used only for configuration, so disallow if attempted on
146 * a dynamic neighbor.
147 */
c43ed2e4 148struct peer *
fd79ac91 149peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
718e3744 150{
151 int ret;
152 struct bgp *bgp;
153 union sockunion su;
f14e6fdb
DS
154 struct peer *peer = NULL;
155 struct peer_group *group = NULL;
718e3744 156
157 bgp = vty->index;
158
159 ret = str2sockunion (peer_str, &su);
160 if (ret == 0)
161 {
f14e6fdb 162 /* IP address, locate peer. */
718e3744 163 peer = peer_lookup (bgp, &su);
718e3744 164 }
165 else
166 {
f14e6fdb 167 /* Not IP, could match either peer configured on interface or a group. */
a80beece 168 peer = peer_lookup_by_conf_if (bgp, peer_str);
f14e6fdb
DS
169 if (!peer)
170 group = peer_group_lookup (bgp, peer_str);
171 }
a80beece 172
f14e6fdb
DS
173 if (peer)
174 {
175 if (peer_dynamic_neighbor (peer))
176 {
177 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
178 VTY_NEWLINE);
179 return NULL;
180 }
181
182 return peer;
718e3744 183 }
184
f14e6fdb
DS
185 if (group)
186 return group->conf;
187
718e3744 188 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
189 VTY_NEWLINE);
190
191 return NULL;
192}
193
c43ed2e4 194int
718e3744 195bgp_vty_return (struct vty *vty, int ret)
196{
fd79ac91 197 const char *str = NULL;
718e3744 198
199 switch (ret)
200 {
201 case BGP_ERR_INVALID_VALUE:
202 str = "Invalid value";
203 break;
204 case BGP_ERR_INVALID_FLAG:
205 str = "Invalid flag";
206 break;
207 case BGP_ERR_PEER_INACTIVE:
208 str = "Activate the neighbor for the address family first";
209 break;
210 case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER:
211 str = "Invalid command for a peer-group member";
212 break;
213 case BGP_ERR_PEER_GROUP_SHUTDOWN:
214 str = "Peer-group has been shutdown. Activate the peer-group first";
215 break;
216 case BGP_ERR_PEER_GROUP_HAS_THE_FLAG:
217 str = "This peer is a peer-group member. Please change peer-group configuration";
218 break;
219 case BGP_ERR_PEER_FLAG_CONFLICT:
220 str = "Can't set override-capability and strict-capability-match at the same time";
221 break;
222 case BGP_ERR_PEER_GROUP_MEMBER_EXISTS:
223 str = "No activate for peergroup can be given only if peer-group has no members";
224 break;
225 case BGP_ERR_PEER_BELONGS_TO_GROUP:
226 str = "No activate for an individual peer-group member is invalid";
227 break;
228 case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED:
229 str = "Activate the peer-group for the address family first";
230 break;
231 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
232 str = "Specify remote-as or peer-group remote AS first";
233 break;
234 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
235 str = "Cannot change the peer-group. Deconfigure first";
236 break;
237 case BGP_ERR_PEER_GROUP_MISMATCH:
238 str = "Cannot have different peer-group for the neighbor";
239 break;
240 case BGP_ERR_PEER_FILTER_CONFLICT:
241 str = "Prefix/distribute list can not co-exist";
242 break;
243 case BGP_ERR_NOT_INTERNAL_PEER:
244 str = "Invalid command. Not an internal neighbor";
245 break;
246 case BGP_ERR_REMOVE_PRIVATE_AS:
5000f21c 247 str = "remove-private-AS cannot be configured for IBGP peers";
718e3744 248 break;
249 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
250 str = "Local-AS allowed only for EBGP peers";
251 break;
252 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
253 str = "Cannot have local-as same as BGP AS number";
254 break;
0df7c91f
PJ
255 case BGP_ERR_TCPSIG_FAILED:
256 str = "Error while applying TCP-Sig to session(s)";
257 break;
fa411a21
NH
258 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
259 str = "ebgp-multihop and ttl-security cannot be configured together";
260 break;
f5a4827d
SH
261 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
262 str = "ttl-security only allowed for EBGP peers";
263 break;
c7122e14
DS
264 case BGP_ERR_AS_OVERRIDE:
265 str = "as-override cannot be configured for IBGP peers";
266 break;
f14e6fdb
DS
267 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
268 str = "Invalid limit for number of dynamic neighbors";
269 break;
270 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
271 str = "Dynamic neighbor listen range already exists";
272 break;
273 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
274 str = "Operation not allowed on a dynamic neighbor";
275 break;
718e3744 276 }
277 if (str)
278 {
279 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
280 return CMD_WARNING;
281 }
282 return CMD_SUCCESS;
283}
284
7aafcaca
DS
285/* BGP clear sort. */
286enum clear_sort
287{
288 clear_all,
289 clear_peer,
290 clear_group,
291 clear_external,
292 clear_as
293};
294
295/* Force a bestpath recalculation for all prefixes. This is used
296 * when 'bgp bestpath' commands are entered.
297 */
298static void
299bgp_recalculate_all_bestpaths (struct bgp *bgp)
300{
301 afi_t afi;
302 safi_t safi;
303 struct bgp_node *rn;
304
305 for (afi = AFI_IP; afi < AFI_MAX; afi++)
306 {
307 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
308 {
309 for (rn = bgp_table_top (bgp->rib[afi][safi]); rn; rn = bgp_route_next (rn))
310 {
311 bgp_process (bgp, rn, afi, safi);
312 }
313 }
314 }
315}
316
317static void
318bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
319 safi_t safi, int error)
320{
321 switch (error)
322 {
323 case BGP_ERR_AF_UNCONFIGURED:
324 vty_out (vty,
325 "%%BGP: Enable %s %s address family for the neighbor %s%s",
326 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
327 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
328 peer->host, VTY_NEWLINE);
329 break;
330 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
331 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);
332 break;
333 default:
334 break;
335 }
336}
337
338/* `clear ip bgp' functions. */
339static int
340bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
341 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
342{
343 int ret;
344 struct peer *peer;
345 struct listnode *node, *nnode;
346
347 /* Clear all neighbors. */
348 /*
349 * Pass along pointer to next node to peer_clear() when walking all nodes
350 * on the BGP instance as that may get freed if it is a doppelganger
351 */
352 if (sort == clear_all)
353 {
354 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
355 {
356 if (stype == BGP_CLEAR_SOFT_NONE)
357 ret = peer_clear (peer, &nnode);
358 else if (peer->afc[afi][safi])
359 ret = peer_clear_soft (peer, afi, safi, stype);
360 else
361 ret = 0;
362
363 if (ret < 0)
364 bgp_clear_vty_error (vty, peer, afi, safi, ret);
365 }
366
367 /* This is to apply read-only mode on this clear. */
368 if (stype == BGP_CLEAR_SOFT_NONE)
369 bgp->update_delay_over = 0;
370
371 return CMD_SUCCESS;
372 }
373
374 /* Clear specified neighbors. */
375 if (sort == clear_peer)
376 {
377 union sockunion su;
378 int ret;
379
380 /* Make sockunion for lookup. */
381 ret = str2sockunion (arg, &su);
382 if (ret < 0)
383 {
384 peer = peer_lookup_by_conf_if (bgp, arg);
385 if (!peer)
386 {
c744aa9f
DS
387 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
388 return CMD_WARNING;
7aafcaca
DS
389 }
390 }
391 else
392 {
393 peer = peer_lookup (bgp, &su);
394 if (! peer)
395 {
396 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
397 return CMD_WARNING;
398 }
399 }
400
401 if (stype == BGP_CLEAR_SOFT_NONE)
402 ret = peer_clear (peer, NULL);
403 else
404 ret = peer_clear_soft (peer, afi, safi, stype);
405
406 if (ret < 0)
407 bgp_clear_vty_error (vty, peer, afi, safi, ret);
408
409 return CMD_SUCCESS;
410 }
411
412 /* Clear all peer-group members. */
413 if (sort == clear_group)
414 {
415 struct peer_group *group;
416
417 group = peer_group_lookup (bgp, arg);
418 if (! group)
419 {
420 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
421 return CMD_WARNING;
422 }
423
424 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
425 {
426 if (stype == BGP_CLEAR_SOFT_NONE)
427 {
428 ret = peer_clear (peer, NULL);
429 continue;
430 }
431
432 if (! peer->af_group[afi][safi])
433 continue;
434
435 ret = peer_clear_soft (peer, afi, safi, stype);
436
437 if (ret < 0)
438 bgp_clear_vty_error (vty, peer, afi, safi, ret);
439 }
440 return CMD_SUCCESS;
441 }
442
443 if (sort == clear_external)
444 {
445 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
446 {
447 if (peer->sort == BGP_PEER_IBGP)
448 continue;
449
450 if (stype == BGP_CLEAR_SOFT_NONE)
451 ret = peer_clear (peer, &nnode);
452 else
453 ret = peer_clear_soft (peer, afi, safi, stype);
454
455 if (ret < 0)
456 bgp_clear_vty_error (vty, peer, afi, safi, ret);
457 }
458 return CMD_SUCCESS;
459 }
460
461 if (sort == clear_as)
462 {
463 as_t as;
464 int find = 0;
465
466 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
467
468 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
469 {
470 if (peer->as != as)
471 continue;
472
473 find = 1;
474 if (stype == BGP_CLEAR_SOFT_NONE)
475 ret = peer_clear (peer, &nnode);
476 else
477 ret = peer_clear_soft (peer, afi, safi, stype);
478
479 if (ret < 0)
480 bgp_clear_vty_error (vty, peer, afi, safi, ret);
481 }
482 if (! find)
483 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
484 VTY_NEWLINE);
485 return CMD_SUCCESS;
486 }
487
488 return CMD_SUCCESS;
489}
490
491static int
492bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
493 enum clear_sort sort, enum bgp_clear_type stype,
494 const char *arg)
495{
496 struct bgp *bgp;
497
498 /* BGP structure lookup. */
499 if (name)
500 {
501 bgp = bgp_lookup_by_name (name);
502 if (bgp == NULL)
503 {
504 vty_out (vty, "Can't find BGP view %s%s", name, VTY_NEWLINE);
505 return CMD_WARNING;
506 }
507 }
508 else
509 {
510 bgp = bgp_get_default ();
511 if (bgp == NULL)
512 {
513 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
514 return CMD_WARNING;
515 }
516 }
517
518 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
519}
520
521/* clear soft inbound */
522static void
523bgp_clear_star_soft_in (struct vty *vty)
524{
525 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
526 BGP_CLEAR_SOFT_IN, NULL);
527#ifdef HAVE_IPV6
528 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
529 BGP_CLEAR_SOFT_IN, NULL);
530#endif /* HAVE_IPV6 */
531}
532
533/* clear soft outbound */
534static void
535bgp_clear_star_soft_out (struct vty *vty)
536{
537 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
538 BGP_CLEAR_SOFT_OUT, NULL);
539#ifdef HAVE_IPV6
540 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
541 BGP_CLEAR_SOFT_OUT, NULL);
542#endif /* HAVE_IPV6 */
543}
544
545
718e3744 546/* BGP global configuration. */
547
548DEFUN (bgp_multiple_instance_func,
549 bgp_multiple_instance_cmd,
550 "bgp multiple-instance",
551 BGP_STR
552 "Enable bgp multiple instance\n")
553{
554 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
555 return CMD_SUCCESS;
556}
557
558DEFUN (no_bgp_multiple_instance,
559 no_bgp_multiple_instance_cmd,
560 "no bgp multiple-instance",
561 NO_STR
562 BGP_STR
563 "BGP multiple instance\n")
564{
565 int ret;
566
567 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
568 if (ret < 0)
569 {
570 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
571 return CMD_WARNING;
572 }
573 return CMD_SUCCESS;
574}
575
576DEFUN (bgp_config_type,
577 bgp_config_type_cmd,
578 "bgp config-type (cisco|zebra)",
579 BGP_STR
580 "Configuration type\n"
581 "cisco\n"
582 "zebra\n")
583{
584 if (strncmp (argv[0], "c", 1) == 0)
585 bgp_option_set (BGP_OPT_CONFIG_CISCO);
586 else
587 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
588
589 return CMD_SUCCESS;
590}
591
592DEFUN (no_bgp_config_type,
593 no_bgp_config_type_cmd,
594 "no bgp config-type",
595 NO_STR
596 BGP_STR
597 "Display configuration type\n")
598{
599 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
600 return CMD_SUCCESS;
601}
602
603DEFUN (no_synchronization,
604 no_synchronization_cmd,
605 "no synchronization",
606 NO_STR
607 "Perform IGP synchronization\n")
608{
609 return CMD_SUCCESS;
610}
611
612DEFUN (no_auto_summary,
613 no_auto_summary_cmd,
614 "no auto-summary",
615 NO_STR
616 "Enable automatic network number summarization\n")
617{
618 return CMD_SUCCESS;
619}
3d515fd9 620
621DEFUN_DEPRECATED (neighbor_version,
622 neighbor_version_cmd,
623 NEIGHBOR_CMD "version (4|4-)",
624 NEIGHBOR_STR
625 NEIGHBOR_ADDR_STR
626 "Set the BGP version to match a neighbor\n"
627 "Neighbor's BGP version\n")
628{
629 return CMD_SUCCESS;
630}
6b0655a2 631
718e3744 632/* "router bgp" commands. */
633DEFUN (router_bgp,
634 router_bgp_cmd,
320da874 635 "router bgp " CMD_AS_RANGE,
718e3744 636 ROUTER_STR
637 BGP_STR
638 AS_STR)
639{
640 int ret;
641 as_t as;
642 struct bgp *bgp;
fd79ac91 643 const char *name = NULL;
718e3744 644
0b2aa3a0 645 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 646
647 if (argc == 2)
648 name = argv[1];
649
650 ret = bgp_get (&bgp, &as, name);
651 switch (ret)
652 {
653 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
654 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
655 VTY_NEWLINE);
656 return CMD_WARNING;
718e3744 657 case BGP_ERR_AS_MISMATCH:
aea339f7 658 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
718e3744 659 return CMD_WARNING;
718e3744 660 case BGP_ERR_INSTANCE_MISMATCH:
661 vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
aea339f7 662 vty_out (vty, "BGP instance is already running; AS is %u%s",
718e3744 663 as, VTY_NEWLINE);
664 return CMD_WARNING;
718e3744 665 }
666
667 vty->node = BGP_NODE;
668 vty->index = bgp;
669
670 return CMD_SUCCESS;
671}
672
673ALIAS (router_bgp,
674 router_bgp_view_cmd,
320da874 675 "router bgp " CMD_AS_RANGE " view WORD",
718e3744 676 ROUTER_STR
677 BGP_STR
678 AS_STR
679 "BGP view\n"
680 "view name\n")
6b0655a2 681
718e3744 682/* "no router bgp" commands. */
683DEFUN (no_router_bgp,
684 no_router_bgp_cmd,
320da874 685 "no router bgp " CMD_AS_RANGE,
718e3744 686 NO_STR
687 ROUTER_STR
688 BGP_STR
689 AS_STR)
690{
691 as_t as;
692 struct bgp *bgp;
fd79ac91 693 const char *name = NULL;
718e3744 694
0b2aa3a0 695 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 696
697 if (argc == 2)
698 name = argv[1];
699
700 /* Lookup bgp structure. */
701 bgp = bgp_lookup (as, name);
702 if (! bgp)
703 {
704 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
705 return CMD_WARNING;
706 }
707
708 bgp_delete (bgp);
709
710 return CMD_SUCCESS;
711}
712
713ALIAS (no_router_bgp,
714 no_router_bgp_view_cmd,
320da874 715 "no router bgp " CMD_AS_RANGE " view WORD",
718e3744 716 NO_STR
717 ROUTER_STR
718 BGP_STR
719 AS_STR
720 "BGP view\n"
721 "view name\n")
6b0655a2 722
718e3744 723/* BGP router-id. */
724
725DEFUN (bgp_router_id,
726 bgp_router_id_cmd,
727 "bgp router-id A.B.C.D",
728 BGP_STR
729 "Override configured router identifier\n"
730 "Manually configured router identifier\n")
731{
732 int ret;
733 struct in_addr id;
734 struct bgp *bgp;
735
736 bgp = vty->index;
737
738 ret = inet_aton (argv[0], &id);
739 if (! ret)
740 {
741 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
742 return CMD_WARNING;
743 }
744
18a6dce6 745 bgp->router_id_static = id;
718e3744 746 bgp_router_id_set (bgp, &id);
747
748 return CMD_SUCCESS;
749}
750
751DEFUN (no_bgp_router_id,
752 no_bgp_router_id_cmd,
753 "no bgp router-id",
754 NO_STR
755 BGP_STR
756 "Override configured router identifier\n")
757{
758 int ret;
759 struct in_addr id;
760 struct bgp *bgp;
761
762 bgp = vty->index;
763
764 if (argc == 1)
765 {
766 ret = inet_aton (argv[0], &id);
767 if (! ret)
768 {
769 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
770 return CMD_WARNING;
771 }
772
18a6dce6 773 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
718e3744 774 {
775 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
776 return CMD_WARNING;
777 }
778 }
779
18a6dce6 780 bgp->router_id_static.s_addr = 0;
781 bgp_router_id_set (bgp, &router_id_zebra);
718e3744 782
783 return CMD_SUCCESS;
784}
785
786ALIAS (no_bgp_router_id,
787 no_bgp_router_id_val_cmd,
788 "no bgp router-id A.B.C.D",
789 NO_STR
790 BGP_STR
791 "Override configured router identifier\n"
792 "Manually configured router identifier\n")
6b0655a2 793
718e3744 794/* BGP Cluster ID. */
795
796DEFUN (bgp_cluster_id,
797 bgp_cluster_id_cmd,
798 "bgp cluster-id A.B.C.D",
799 BGP_STR
800 "Configure Route-Reflector Cluster-id\n"
801 "Route-Reflector Cluster-id in IP address format\n")
802{
803 int ret;
804 struct bgp *bgp;
805 struct in_addr cluster;
806
807 bgp = vty->index;
808
809 ret = inet_aton (argv[0], &cluster);
810 if (! ret)
811 {
812 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
813 return CMD_WARNING;
814 }
815
816 bgp_cluster_id_set (bgp, &cluster);
7aafcaca 817 bgp_clear_star_soft_out (vty);
718e3744 818
819 return CMD_SUCCESS;
820}
821
822ALIAS (bgp_cluster_id,
823 bgp_cluster_id32_cmd,
824 "bgp cluster-id <1-4294967295>",
825 BGP_STR
826 "Configure Route-Reflector Cluster-id\n"
827 "Route-Reflector Cluster-id as 32 bit quantity\n")
828
829DEFUN (no_bgp_cluster_id,
830 no_bgp_cluster_id_cmd,
831 "no bgp cluster-id",
832 NO_STR
833 BGP_STR
834 "Configure Route-Reflector Cluster-id\n")
835{
836 int ret;
837 struct bgp *bgp;
838 struct in_addr cluster;
839
840 bgp = vty->index;
841
842 if (argc == 1)
843 {
844 ret = inet_aton (argv[0], &cluster);
845 if (! ret)
846 {
847 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
848 return CMD_WARNING;
849 }
850 }
851
852 bgp_cluster_id_unset (bgp);
7aafcaca 853 bgp_clear_star_soft_out (vty);
718e3744 854
855 return CMD_SUCCESS;
856}
857
858ALIAS (no_bgp_cluster_id,
859 no_bgp_cluster_id_arg_cmd,
860 "no bgp cluster-id A.B.C.D",
861 NO_STR
862 BGP_STR
863 "Configure Route-Reflector Cluster-id\n"
864 "Route-Reflector Cluster-id in IP address format\n")
6b0655a2 865
718e3744 866DEFUN (bgp_confederation_identifier,
867 bgp_confederation_identifier_cmd,
320da874 868 "bgp confederation identifier " CMD_AS_RANGE,
718e3744 869 "BGP specific commands\n"
870 "AS confederation parameters\n"
871 "AS number\n"
872 "Set routing domain confederation AS\n")
873{
874 struct bgp *bgp;
875 as_t as;
876
877 bgp = vty->index;
878
0b2aa3a0 879 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
718e3744 880
881 bgp_confederation_id_set (bgp, as);
882
883 return CMD_SUCCESS;
884}
885
886DEFUN (no_bgp_confederation_identifier,
887 no_bgp_confederation_identifier_cmd,
888 "no bgp confederation identifier",
889 NO_STR
890 "BGP specific commands\n"
891 "AS confederation parameters\n"
892 "AS number\n")
893{
894 struct bgp *bgp;
718e3744 895
896 bgp = vty->index;
897
718e3744 898 bgp_confederation_id_unset (bgp);
899
900 return CMD_SUCCESS;
901}
902
903ALIAS (no_bgp_confederation_identifier,
904 no_bgp_confederation_identifier_arg_cmd,
320da874 905 "no bgp confederation identifier " CMD_AS_RANGE,
718e3744 906 NO_STR
907 "BGP specific commands\n"
908 "AS confederation parameters\n"
909 "AS number\n"
910 "Set routing domain confederation AS\n")
6b0655a2 911
718e3744 912DEFUN (bgp_confederation_peers,
913 bgp_confederation_peers_cmd,
320da874 914 "bgp confederation peers ." CMD_AS_RANGE,
718e3744 915 "BGP specific commands\n"
916 "AS confederation parameters\n"
917 "Peer ASs in BGP confederation\n"
918 AS_STR)
919{
920 struct bgp *bgp;
921 as_t as;
922 int i;
923
924 bgp = vty->index;
925
926 for (i = 0; i < argc; i++)
927 {
0b2aa3a0 928 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
718e3744 929
930 if (bgp->as == as)
931 {
932 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
933 VTY_NEWLINE);
934 continue;
935 }
936
937 bgp_confederation_peers_add (bgp, as);
938 }
939 return CMD_SUCCESS;
940}
941
942DEFUN (no_bgp_confederation_peers,
943 no_bgp_confederation_peers_cmd,
320da874 944 "no bgp confederation peers ." CMD_AS_RANGE,
718e3744 945 NO_STR
946 "BGP specific commands\n"
947 "AS confederation parameters\n"
948 "Peer ASs in BGP confederation\n"
949 AS_STR)
950{
951 struct bgp *bgp;
952 as_t as;
953 int i;
954
955 bgp = vty->index;
956
957 for (i = 0; i < argc; i++)
958 {
0b2aa3a0
PJ
959 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
960
718e3744 961 bgp_confederation_peers_remove (bgp, as);
962 }
963 return CMD_SUCCESS;
964}
6b0655a2 965
5e242b0d
DS
966/**
967 * Central routine for maximum-paths configuration.
968 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
969 * @set: 1 for setting values, 0 for removing the max-paths config.
970 */
ffd0c037
DS
971static int
972bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
5e242b0d 973 u_int16_t options, int set)
165b5fff
JB
974{
975 struct bgp *bgp;
ffd0c037 976 u_int16_t maxpaths = 0;
165b5fff 977 int ret;
5e242b0d
DS
978 afi_t afi;
979 safi_t safi;
165b5fff
JB
980
981 bgp = vty->index;
5e242b0d
DS
982 afi = bgp_node_afi (vty);
983 safi = bgp_node_safi (vty);
165b5fff 984
5e242b0d
DS
985 if (set)
986 {
73ac8160
DS
987 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
988 BGP_MAXIMUM_MAXPATHS);
5e242b0d
DS
989 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
990 options);
991 }
992 else
993 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
165b5fff 994
165b5fff
JB
995 if (ret < 0)
996 {
997 vty_out (vty,
5e242b0d
DS
998 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
999 (set == 1) ? "" : "un",
1000 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1001 maxpaths, afi, safi, VTY_NEWLINE);
165b5fff
JB
1002 return CMD_WARNING;
1003 }
1004
7aafcaca
DS
1005 bgp_recalculate_all_bestpaths (bgp);
1006
165b5fff
JB
1007 return CMD_SUCCESS;
1008}
1009
abc920f8
DS
1010DEFUN (bgp_maxmed_admin,
1011 bgp_maxmed_admin_cmd,
1012 "bgp max-med administrative ",
1013 BGP_STR
1014 "Advertise routes with max-med\n"
1015 "Administratively applied, for an indefinite period\n")
1016{
1017 struct bgp *bgp;
1018
1019 bgp = vty->index;
1020
1021 bgp->v_maxmed_admin = 1;
1022 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1023
1024 bgp_maxmed_update(bgp);
1025
1026 return CMD_SUCCESS;
1027}
1028
1029DEFUN (bgp_maxmed_admin_medv,
1030 bgp_maxmed_admin_medv_cmd,
1031 "bgp max-med administrative <0-4294967294>",
1032 BGP_STR
1033 "Advertise routes with max-med\n"
1034 "Administratively applied, for an indefinite period\n"
1035 "Max MED value to be used\n")
1036{
1037 struct bgp *bgp;
1038
1039 bgp = vty->index;
1040
1041 bgp->v_maxmed_admin = 1;
1042 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]);
1043
1044 bgp_maxmed_update(bgp);
1045
1046 return CMD_SUCCESS;
1047}
1048
1049DEFUN (no_bgp_maxmed_admin,
1050 no_bgp_maxmed_admin_cmd,
1051 "no bgp max-med administrative",
1052 NO_STR
1053 BGP_STR
1054 "Advertise routes with max-med\n"
1055 "Administratively applied, for an indefinite period\n")
1056{
1057 struct bgp *bgp;
1058
1059 bgp = vty->index;
1060
1061 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1062 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1063
1064 bgp_maxmed_update(bgp);
1065
1066 return CMD_SUCCESS;
1067}
1068
1069ALIAS (no_bgp_maxmed_admin,
1070 no_bgp_maxmed_admin_medv_cmd,
1071 "no bgp max-med administrative <0-4294967294>",
1072 NO_STR
1073 BGP_STR
1074 "Advertise routes with max-med\n"
1075 "Administratively applied, for an indefinite period\n"
1076 "Max MED value to be used\n")
1077
1078
1079DEFUN (bgp_maxmed_onstartup,
1080 bgp_maxmed_onstartup_cmd,
1081 "bgp max-med on-startup <5-86400>",
1082 BGP_STR
1083 "Advertise routes with max-med\n"
1084 "Effective on a startup\n"
1085 "Time (seconds) period for max-med\n")
1086{
1087 struct bgp *bgp;
1088
1089 bgp = vty->index;
1090
1091 if (argc != 1)
1092 {
1093 vty_out (vty, "%% Must supply max-med on-startup period");
1094 return CMD_WARNING;
1095 }
1096
1097 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1098 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1099
1100 bgp_maxmed_update(bgp);
1101
1102 return CMD_SUCCESS;
1103}
1104
1105DEFUN (bgp_maxmed_onstartup_medv,
1106 bgp_maxmed_onstartup_medv_cmd,
1107 "bgp max-med on-startup <5-86400> <0-4294967294>",
1108 BGP_STR
1109 "Advertise routes with max-med\n"
1110 "Effective on a startup\n"
1111 "Time (seconds) period for max-med\n"
1112 "Max MED value to be used\n")
1113{
1114 struct bgp *bgp;
1115
1116 bgp = vty->index;
1117
1118 if (argc != 2)
1119 {
1120 vty_out (vty, "%% Must supply max-med on-startup period and med value");
1121 return CMD_WARNING;
1122 }
1123
1124 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1125 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]);
1126
1127 bgp_maxmed_update(bgp);
1128
1129 return CMD_SUCCESS;
1130}
1131
1132DEFUN (no_bgp_maxmed_onstartup,
1133 no_bgp_maxmed_onstartup_cmd,
1134 "no bgp max-med on-startup",
1135 NO_STR
1136 BGP_STR
1137 "Advertise routes with max-med\n"
1138 "Effective on a startup\n")
1139{
1140 struct bgp *bgp;
1141
1142 bgp = vty->index;
1143
1144 /* Cancel max-med onstartup if its on */
1145 if (bgp->t_maxmed_onstartup)
1146 {
1147 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1148 bgp->maxmed_onstartup_over = 1;
1149 }
1150
1151 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1152 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1153
1154 bgp_maxmed_update(bgp);
1155
1156 return CMD_SUCCESS;
1157}
1158
1159ALIAS (no_bgp_maxmed_onstartup,
1160 no_bgp_maxmed_onstartup_period_cmd,
1161 "no bgp max-med on-startup <5-86400>",
1162 NO_STR
1163 BGP_STR
1164 "Advertise routes with max-med\n"
1165 "Effective on a startup\n"
1166 "Time (seconds) period for max-med\n")
1167
1168ALIAS (no_bgp_maxmed_onstartup,
1169 no_bgp_maxmed_onstartup_period_medv_cmd,
1170 "no bgp max-med on-startup <5-86400> <0-4294967294>",
1171 NO_STR
1172 BGP_STR
1173 "Advertise routes with max-med\n"
1174 "Effective on a startup\n"
1175 "Time (seconds) period for max-med\n"
1176 "Max MED value to be used\n")
1177
f188f2c4
DS
1178static int
1179bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1180 const char *wait)
1181{
1182 struct bgp *bgp;
1183 u_int16_t update_delay;
1184 u_int16_t establish_wait;
1185
1186
1187 bgp = vty->index;
1188
1189 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1190 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1191
1192 if (!wait) /* update-delay <delay> */
1193 {
1194 bgp->v_update_delay = update_delay;
1195 bgp->v_establish_wait = bgp->v_update_delay;
1196 return CMD_SUCCESS;
1197 }
1198
1199 /* update-delay <delay> <establish-wait> */
1200 establish_wait = atoi (wait);
1201 if (update_delay < establish_wait)
1202 {
1203 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1204 VTY_NEWLINE);
1205 return CMD_WARNING;
1206 }
1207
1208 bgp->v_update_delay = update_delay;
1209 bgp->v_establish_wait = establish_wait;
1210
1211 return CMD_SUCCESS;
1212}
1213
1214static int
1215bgp_update_delay_deconfig_vty (struct vty *vty)
1216{
1217 struct bgp *bgp;
1218
1219 bgp = vty->index;
1220
1221 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1222 bgp->v_establish_wait = bgp->v_update_delay;
1223
1224 return CMD_SUCCESS;
1225}
1226
1227int
1228bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1229{
1230 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1231 {
1232 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1233 if (bgp->v_update_delay != bgp->v_establish_wait)
1234 vty_out (vty, " %d", bgp->v_establish_wait);
1235 vty_out (vty, "%s", VTY_NEWLINE);
1236 }
1237
1238 return 0;
1239}
1240
1241
1242/* Update-delay configuration */
1243DEFUN (bgp_update_delay,
1244 bgp_update_delay_cmd,
1245 "update-delay <0-3600>",
1246 "Force initial delay for best-path and updates\n"
1247 "Seconds\n")
1248{
1249 return bgp_update_delay_config_vty(vty, argv[0], NULL);
1250}
1251
1252DEFUN (bgp_update_delay_establish_wait,
1253 bgp_update_delay_establish_wait_cmd,
1254 "update-delay <0-3600> <1-3600>",
1255 "Force initial delay for best-path and updates\n"
1256 "Seconds\n"
1257 "Wait for peers to be established\n"
1258 "Seconds\n")
1259{
1260 return bgp_update_delay_config_vty(vty, argv[0], argv[1]);
1261}
1262
1263/* Update-delay deconfiguration */
1264DEFUN (no_bgp_update_delay,
1265 no_bgp_update_delay_cmd,
1266 "no update-delay <0-3600>",
1267 "Force initial delay for best-path and updates\n"
1268 "Seconds\n")
1269{
1270 return bgp_update_delay_deconfig_vty(vty);
1271}
1272
1273ALIAS (no_bgp_update_delay,
1274 no_bgp_update_delay_establish_wait_cmd,
1275 "no update-delay <0-3600> <1-3600>",
1276 "Force initial delay for best-path and updates\n"
1277 "Seconds\n"
1278 "Wait for peers to be established\n"
1279 "Seconds\n")
5e242b0d 1280
ffd0c037
DS
1281static int
1282bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
cb1faec9
DS
1283{
1284 struct bgp *bgp;
cb1faec9
DS
1285
1286 bgp = vty->index;
1287
1288 if (set)
1289 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
1290 1, 4294967295);
1291 else
1292 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1293
1294 return CMD_SUCCESS;
1295}
1296
1297int
1298bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1299{
1300 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1301 vty_out (vty, " write-quanta %d%s",
1302 bgp->wpkt_quanta, VTY_NEWLINE);
1303
1304 return 0;
1305}
1306
1307
1308/* Update-delay configuration */
1309DEFUN (bgp_wpkt_quanta,
1310 bgp_wpkt_quanta_cmd,
1311 "write-quanta <1-4294967295>",
1312 "How many packets to write to peer socket per run\n"
1313 "Number of packets\n")
1314{
1315 return bgp_wpkt_quanta_config_vty(vty, argv[0], 1);
1316}
1317
1318/* Update-delay deconfiguration */
1319DEFUN (no_bgp_wpkt_quanta,
1320 no_bgp_wpkt_quanta_cmd,
1321 "no write-quanta <1-4294967295>",
1322 "How many packets to write to peer socket per run\n"
1323 "Number of packets\n")
1324{
1325 return bgp_wpkt_quanta_config_vty(vty, argv[0], 0);
1326}
1327
ffd0c037 1328static int
3f9c7369
DS
1329bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1330{
1331 struct bgp *bgp;
1332
1333 bgp = vty->index;
1334
1335 if (set)
1336 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1337 0, 4294967295);
1338 else
1339 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1340
1341 return CMD_SUCCESS;
1342}
1343
1344int
1345bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1346{
1347 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1348 vty_out (vty, " coalesce-time %d%s",
1349 bgp->coalesce_time, VTY_NEWLINE);
1350
1351 return 0;
1352}
1353
1354
1355DEFUN (bgp_coalesce_time,
1356 bgp_coalesce_time_cmd,
1357 "coalesce-time <0-4294967295>",
1358 "Subgroup coalesce timer\n"
1359 "Subgroup coalesce timer value (in ms)\n")
1360{
1361 return bgp_coalesce_config_vty(vty, argv[0], 1);
1362}
1363
1364DEFUN (no_bgp_coalesce_time,
1365 no_bgp_coalesce_time_cmd,
1366 "no coalesce-time <0-4294967295>",
1367 "Subgroup coalesce timer\n"
1368 "Subgroup coalesce timer value (in ms)\n")
1369{
1370 return bgp_coalesce_config_vty(vty, argv[0], 0);
1371}
1372
5e242b0d
DS
1373/* Maximum-paths configuration */
1374DEFUN (bgp_maxpaths,
1375 bgp_maxpaths_cmd,
1376 "maximum-paths <1-255>",
1377 "Forward packets over multiple paths\n"
1378 "Number of paths\n")
1379{
1380 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1);
1381}
1382
165b5fff
JB
1383DEFUN (bgp_maxpaths_ibgp,
1384 bgp_maxpaths_ibgp_cmd,
1385 "maximum-paths ibgp <1-255>",
1386 "Forward packets over multiple paths\n"
1387 "iBGP-multipath\n"
1388 "Number of paths\n")
1389{
5e242b0d
DS
1390 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1);
1391}
165b5fff 1392
5e242b0d
DS
1393DEFUN (bgp_maxpaths_ibgp_cluster,
1394 bgp_maxpaths_ibgp_cluster_cmd,
1395 "maximum-paths ibgp <1-255> equal-cluster-length",
1396 "Forward packets over multiple paths\n"
1397 "iBGP-multipath\n"
1398 "Number of paths\n"
1399 "Match the cluster length\n")
1400{
1401 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0],
1402 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
165b5fff
JB
1403}
1404
1405DEFUN (no_bgp_maxpaths,
1406 no_bgp_maxpaths_cmd,
1407 "no maximum-paths",
1408 NO_STR
1409 "Forward packets over multiple paths\n"
1410 "Number of paths\n")
1411{
5e242b0d 1412 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
165b5fff
JB
1413}
1414
1415ALIAS (no_bgp_maxpaths,
1416 no_bgp_maxpaths_arg_cmd,
1417 "no maximum-paths <1-255>",
1418 NO_STR
1419 "Forward packets over multiple paths\n"
1420 "Number of paths\n")
1421
1422DEFUN (no_bgp_maxpaths_ibgp,
1423 no_bgp_maxpaths_ibgp_cmd,
1424 "no maximum-paths ibgp",
1425 NO_STR
1426 "Forward packets over multiple paths\n"
1427 "iBGP-multipath\n"
1428 "Number of paths\n")
1429{
5e242b0d 1430 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
165b5fff
JB
1431}
1432
1433ALIAS (no_bgp_maxpaths_ibgp,
1434 no_bgp_maxpaths_ibgp_arg_cmd,
1435 "no maximum-paths ibgp <1-255>",
1436 NO_STR
1437 "Forward packets over multiple paths\n"
1438 "iBGP-multipath\n"
1439 "Number of paths\n")
1440
5e242b0d
DS
1441ALIAS (no_bgp_maxpaths_ibgp,
1442 no_bgp_maxpaths_ibgp_cluster_cmd,
1443 "no maximum-paths ibgp <1-255> equal-cluster-length",
1444 NO_STR
1445 "Forward packets over multiple paths\n"
1446 "iBGP-multipath\n"
1447 "Number of paths\n"
1448 "Match the cluster length\n")
1449
165b5fff
JB
1450int
1451bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1452 safi_t safi, int *write)
1453{
1454 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != BGP_DEFAULT_MAXPATHS)
1455 {
1456 bgp_config_write_family_header (vty, afi, safi, write);
1457 vty_out (vty, " maximum-paths %d%s",
1458 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1459 }
1460
1461 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != BGP_DEFAULT_MAXPATHS)
1462 {
1463 bgp_config_write_family_header (vty, afi, safi, write);
5e242b0d
DS
1464 vty_out (vty, " maximum-paths ibgp %d",
1465 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1466 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1467 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1468 vty_out (vty, " equal-cluster-length");
1469 vty_out (vty, "%s", VTY_NEWLINE);
165b5fff
JB
1470 }
1471
1472 return 0;
1473}
6b0655a2 1474
718e3744 1475/* BGP timers. */
1476
1477DEFUN (bgp_timers,
1478 bgp_timers_cmd,
1479 "timers bgp <0-65535> <0-65535>",
1480 "Adjust routing timers\n"
1481 "BGP timers\n"
1482 "Keepalive interval\n"
1483 "Holdtime\n")
1484{
1485 struct bgp *bgp;
1486 unsigned long keepalive = 0;
1487 unsigned long holdtime = 0;
1488
1489 bgp = vty->index;
1490
1491 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
1492 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
1493
1494 /* Holdtime value check. */
1495 if (holdtime < 3 && holdtime != 0)
1496 {
1497 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1498 VTY_NEWLINE);
1499 return CMD_WARNING;
1500 }
1501
1502 bgp_timers_set (bgp, keepalive, holdtime);
1503
1504 return CMD_SUCCESS;
1505}
1506
1507DEFUN (no_bgp_timers,
1508 no_bgp_timers_cmd,
1509 "no timers bgp",
1510 NO_STR
1511 "Adjust routing timers\n"
1512 "BGP timers\n")
1513{
1514 struct bgp *bgp;
1515
1516 bgp = vty->index;
1517 bgp_timers_unset (bgp);
1518
1519 return CMD_SUCCESS;
1520}
1521
1522ALIAS (no_bgp_timers,
1523 no_bgp_timers_arg_cmd,
1524 "no timers bgp <0-65535> <0-65535>",
1525 NO_STR
1526 "Adjust routing timers\n"
1527 "BGP timers\n"
1528 "Keepalive interval\n"
1529 "Holdtime\n")
6b0655a2 1530
718e3744 1531DEFUN (bgp_client_to_client_reflection,
1532 bgp_client_to_client_reflection_cmd,
1533 "bgp client-to-client reflection",
1534 "BGP specific commands\n"
1535 "Configure client to client route reflection\n"
1536 "reflection of routes allowed\n")
1537{
1538 struct bgp *bgp;
1539
1540 bgp = vty->index;
1541 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
7aafcaca
DS
1542 bgp_clear_star_soft_out (vty);
1543
718e3744 1544 return CMD_SUCCESS;
1545}
1546
1547DEFUN (no_bgp_client_to_client_reflection,
1548 no_bgp_client_to_client_reflection_cmd,
1549 "no bgp client-to-client reflection",
1550 NO_STR
1551 "BGP specific commands\n"
1552 "Configure client to client route reflection\n"
1553 "reflection of routes allowed\n")
1554{
1555 struct bgp *bgp;
1556
1557 bgp = vty->index;
1558 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
7aafcaca
DS
1559 bgp_clear_star_soft_out (vty);
1560
718e3744 1561 return CMD_SUCCESS;
1562}
1563
1564/* "bgp always-compare-med" configuration. */
1565DEFUN (bgp_always_compare_med,
1566 bgp_always_compare_med_cmd,
1567 "bgp always-compare-med",
1568 "BGP specific commands\n"
1569 "Allow comparing MED from different neighbors\n")
1570{
1571 struct bgp *bgp;
1572
1573 bgp = vty->index;
1574 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1575 bgp_recalculate_all_bestpaths (bgp);
1576
718e3744 1577 return CMD_SUCCESS;
1578}
1579
1580DEFUN (no_bgp_always_compare_med,
1581 no_bgp_always_compare_med_cmd,
1582 "no bgp always-compare-med",
1583 NO_STR
1584 "BGP specific commands\n"
1585 "Allow comparing MED from different neighbors\n")
1586{
1587 struct bgp *bgp;
1588
1589 bgp = vty->index;
1590 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1591 bgp_recalculate_all_bestpaths (bgp);
1592
718e3744 1593 return CMD_SUCCESS;
1594}
6b0655a2 1595
718e3744 1596/* "bgp deterministic-med" configuration. */
1597DEFUN (bgp_deterministic_med,
1598 bgp_deterministic_med_cmd,
1599 "bgp deterministic-med",
1600 "BGP specific commands\n"
1601 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1602{
1603 struct bgp *bgp;
1604
1605 bgp = vty->index;
1606 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
7aafcaca
DS
1607 bgp_recalculate_all_bestpaths (bgp);
1608
718e3744 1609 return CMD_SUCCESS;
1610}
1611
1612DEFUN (no_bgp_deterministic_med,
1613 no_bgp_deterministic_med_cmd,
1614 "no bgp deterministic-med",
1615 NO_STR
1616 "BGP specific commands\n"
1617 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1618{
1619 struct bgp *bgp;
1620
1621 bgp = vty->index;
1622 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
7aafcaca
DS
1623 bgp_recalculate_all_bestpaths (bgp);
1624
718e3744 1625 return CMD_SUCCESS;
1626}
538621f2 1627
1628/* "bgp graceful-restart" configuration. */
1629DEFUN (bgp_graceful_restart,
1630 bgp_graceful_restart_cmd,
1631 "bgp graceful-restart",
1632 "BGP specific commands\n"
1633 "Graceful restart capability parameters\n")
1634{
1635 struct bgp *bgp;
1636
1637 bgp = vty->index;
1638 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1639 return CMD_SUCCESS;
1640}
1641
1642DEFUN (no_bgp_graceful_restart,
1643 no_bgp_graceful_restart_cmd,
1644 "no bgp graceful-restart",
1645 NO_STR
1646 "BGP specific commands\n"
1647 "Graceful restart capability parameters\n")
1648{
1649 struct bgp *bgp;
1650
1651 bgp = vty->index;
1652 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1653 return CMD_SUCCESS;
1654}
1655
93406d87 1656DEFUN (bgp_graceful_restart_stalepath_time,
1657 bgp_graceful_restart_stalepath_time_cmd,
1658 "bgp graceful-restart stalepath-time <1-3600>",
1659 "BGP specific commands\n"
1660 "Graceful restart capability parameters\n"
1661 "Set the max time to hold onto restarting peer's stale paths\n"
1662 "Delay value (seconds)\n")
1663{
1664 struct bgp *bgp;
1665 u_int32_t stalepath;
1666
1667 bgp = vty->index;
1668 if (! bgp)
1669 return CMD_WARNING;
1670
1671 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1672 bgp->stalepath_time = stalepath;
1673 return CMD_SUCCESS;
1674}
1675
1676DEFUN (no_bgp_graceful_restart_stalepath_time,
1677 no_bgp_graceful_restart_stalepath_time_cmd,
1678 "no bgp graceful-restart stalepath-time",
1679 NO_STR
1680 "BGP specific commands\n"
1681 "Graceful restart capability parameters\n"
1682 "Set the max time to hold onto restarting peer's stale paths\n")
1683{
1684 struct bgp *bgp;
1685
1686 bgp = vty->index;
1687 if (! bgp)
1688 return CMD_WARNING;
1689
1690 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1691 return CMD_SUCCESS;
1692}
1693
1694ALIAS (no_bgp_graceful_restart_stalepath_time,
1695 no_bgp_graceful_restart_stalepath_time_val_cmd,
1696 "no bgp graceful-restart stalepath-time <1-3600>",
1697 NO_STR
1698 "BGP specific commands\n"
1699 "Graceful restart capability parameters\n"
1700 "Set the max time to hold onto restarting peer's stale paths\n"
1701 "Delay value (seconds)\n")
1702
718e3744 1703/* "bgp fast-external-failover" configuration. */
1704DEFUN (bgp_fast_external_failover,
1705 bgp_fast_external_failover_cmd,
1706 "bgp fast-external-failover",
1707 BGP_STR
1708 "Immediately reset session if a link to a directly connected external peer goes down\n")
1709{
1710 struct bgp *bgp;
1711
1712 bgp = vty->index;
1713 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1714 return CMD_SUCCESS;
1715}
1716
1717DEFUN (no_bgp_fast_external_failover,
1718 no_bgp_fast_external_failover_cmd,
1719 "no bgp fast-external-failover",
1720 NO_STR
1721 BGP_STR
1722 "Immediately reset session if a link to a directly connected external peer goes down\n")
1723{
1724 struct bgp *bgp;
1725
1726 bgp = vty->index;
1727 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1728 return CMD_SUCCESS;
1729}
6b0655a2 1730
718e3744 1731/* "bgp enforce-first-as" configuration. */
1732DEFUN (bgp_enforce_first_as,
1733 bgp_enforce_first_as_cmd,
1734 "bgp enforce-first-as",
1735 BGP_STR
1736 "Enforce the first AS for EBGP routes\n")
1737{
1738 struct bgp *bgp;
1739
1740 bgp = vty->index;
1741 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
7aafcaca
DS
1742 bgp_clear_star_soft_in (vty);
1743
718e3744 1744 return CMD_SUCCESS;
1745}
1746
1747DEFUN (no_bgp_enforce_first_as,
1748 no_bgp_enforce_first_as_cmd,
1749 "no bgp enforce-first-as",
1750 NO_STR
1751 BGP_STR
1752 "Enforce the first AS for EBGP routes\n")
1753{
1754 struct bgp *bgp;
1755
1756 bgp = vty->index;
1757 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
7aafcaca
DS
1758 bgp_clear_star_soft_in (vty);
1759
718e3744 1760 return CMD_SUCCESS;
1761}
6b0655a2 1762
718e3744 1763/* "bgp bestpath compare-routerid" configuration. */
1764DEFUN (bgp_bestpath_compare_router_id,
1765 bgp_bestpath_compare_router_id_cmd,
1766 "bgp bestpath compare-routerid",
1767 "BGP specific commands\n"
1768 "Change the default bestpath selection\n"
1769 "Compare router-id for identical EBGP paths\n")
1770{
1771 struct bgp *bgp;
1772
1773 bgp = vty->index;
1774 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1775 bgp_recalculate_all_bestpaths (bgp);
1776
718e3744 1777 return CMD_SUCCESS;
1778}
1779
1780DEFUN (no_bgp_bestpath_compare_router_id,
1781 no_bgp_bestpath_compare_router_id_cmd,
1782 "no bgp bestpath compare-routerid",
1783 NO_STR
1784 "BGP specific commands\n"
1785 "Change the default bestpath selection\n"
1786 "Compare router-id for identical EBGP paths\n")
1787{
1788 struct bgp *bgp;
1789
1790 bgp = vty->index;
1791 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
1792 bgp_recalculate_all_bestpaths (bgp);
1793
718e3744 1794 return CMD_SUCCESS;
1795}
6b0655a2 1796
718e3744 1797/* "bgp bestpath as-path ignore" configuration. */
1798DEFUN (bgp_bestpath_aspath_ignore,
1799 bgp_bestpath_aspath_ignore_cmd,
1800 "bgp bestpath as-path ignore",
1801 "BGP specific commands\n"
1802 "Change the default bestpath selection\n"
1803 "AS-path attribute\n"
1804 "Ignore as-path length in selecting a route\n")
1805{
1806 struct bgp *bgp;
1807
1808 bgp = vty->index;
1809 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1810 bgp_recalculate_all_bestpaths (bgp);
1811
718e3744 1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN (no_bgp_bestpath_aspath_ignore,
1816 no_bgp_bestpath_aspath_ignore_cmd,
1817 "no bgp bestpath as-path ignore",
1818 NO_STR
1819 "BGP specific commands\n"
1820 "Change the default bestpath selection\n"
1821 "AS-path attribute\n"
1822 "Ignore as-path length in selecting a route\n")
1823{
1824 struct bgp *bgp;
1825
1826 bgp = vty->index;
1827 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
1828 bgp_recalculate_all_bestpaths (bgp);
1829
718e3744 1830 return CMD_SUCCESS;
1831}
6b0655a2 1832
6811845b 1833/* "bgp bestpath as-path confed" configuration. */
1834DEFUN (bgp_bestpath_aspath_confed,
1835 bgp_bestpath_aspath_confed_cmd,
1836 "bgp bestpath as-path confed",
1837 "BGP specific commands\n"
1838 "Change the default bestpath selection\n"
1839 "AS-path attribute\n"
1840 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1841{
1842 struct bgp *bgp;
1843
1844 bgp = vty->index;
1845 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1846 bgp_recalculate_all_bestpaths (bgp);
1847
6811845b 1848 return CMD_SUCCESS;
1849}
1850
1851DEFUN (no_bgp_bestpath_aspath_confed,
1852 no_bgp_bestpath_aspath_confed_cmd,
1853 "no bgp bestpath as-path confed",
1854 NO_STR
1855 "BGP specific commands\n"
1856 "Change the default bestpath selection\n"
1857 "AS-path attribute\n"
1858 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1859{
1860 struct bgp *bgp;
1861
1862 bgp = vty->index;
1863 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
1864 bgp_recalculate_all_bestpaths (bgp);
1865
6811845b 1866 return CMD_SUCCESS;
1867}
6b0655a2 1868
2fdd455c
PM
1869/* "bgp bestpath as-path multipath-relax" configuration. */
1870DEFUN (bgp_bestpath_aspath_multipath_relax,
1871 bgp_bestpath_aspath_multipath_relax_cmd,
1872 "bgp bestpath as-path multipath-relax",
1873 "BGP specific commands\n"
1874 "Change the default bestpath selection\n"
1875 "AS-path attribute\n"
1876 "Allow load sharing across routes that have different AS paths (but same length)\n")
1877{
1878 struct bgp *bgp;
1879
1880 bgp = vty->index;
1881 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
16fc1eec 1882 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
7aafcaca
DS
1883 bgp_recalculate_all_bestpaths (bgp);
1884
2fdd455c
PM
1885 return CMD_SUCCESS;
1886}
1887
1888DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1889 no_bgp_bestpath_aspath_multipath_relax_cmd,
1890 "no bgp bestpath as-path multipath-relax",
1891 NO_STR
1892 "BGP specific commands\n"
1893 "Change the default bestpath selection\n"
1894 "AS-path attribute\n"
1895 "Allow load sharing across routes that have different AS paths (but same length)\n")
1896{
1897 struct bgp *bgp;
1898
1899 bgp = vty->index;
1900 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
16fc1eec 1901 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
7aafcaca
DS
1902 bgp_recalculate_all_bestpaths (bgp);
1903
16fc1eec
DS
1904 return CMD_SUCCESS;
1905}
1906
1907/* "bgp bestpath as-path multipath-relax no-as-set" configuration. */
1908DEFUN (bgp_bestpath_aspath_multipath_relax_no_as_set,
1909 bgp_bestpath_aspath_multipath_relax_no_as_set_cmd,
1910 "bgp bestpath as-path multipath-relax no-as-set",
1911 "BGP specific commands\n"
1912 "Change the default bestpath selection\n"
1913 "AS-path attribute\n"
1914 "Allow load sharing across routes that have different AS paths (but same length)\n"
1915 "Do not generate an AS_SET\n")
1916{
1917 struct bgp *bgp;
1918
1919 bgp = vty->index;
1920 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1921 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
7aafcaca
DS
1922 bgp_recalculate_all_bestpaths (bgp);
1923
16fc1eec
DS
1924 return CMD_SUCCESS;
1925}
1926
1927DEFUN (no_bgp_bestpath_aspath_multipath_relax_no_as_set,
1928 no_bgp_bestpath_aspath_multipath_relax_no_as_set_cmd,
1929 "no bgp bestpath as-path multipath-relax no-as-set",
1930 NO_STR
1931 "BGP specific commands\n"
1932 "Change the default bestpath selection\n"
1933 "AS-path attribute\n"
1934 "Allow load sharing across routes that have different AS paths (but same length)\n"
1935 "Do not generate an AS_SET\n")
1936{
1937 struct bgp *bgp;
1938
1939 bgp = vty->index;
1940 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1941 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_NO_AS_SET);
7aafcaca
DS
1942 bgp_recalculate_all_bestpaths (bgp);
1943
2fdd455c
PM
1944 return CMD_SUCCESS;
1945}
6b0655a2 1946
848973c7 1947/* "bgp log-neighbor-changes" configuration. */
1948DEFUN (bgp_log_neighbor_changes,
1949 bgp_log_neighbor_changes_cmd,
1950 "bgp log-neighbor-changes",
1951 "BGP specific commands\n"
1952 "Log neighbor up/down and reset reason\n")
1953{
1954 struct bgp *bgp;
1955
1956 bgp = vty->index;
1957 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1958 return CMD_SUCCESS;
1959}
1960
1961DEFUN (no_bgp_log_neighbor_changes,
1962 no_bgp_log_neighbor_changes_cmd,
1963 "no bgp log-neighbor-changes",
1964 NO_STR
1965 "BGP specific commands\n"
1966 "Log neighbor up/down and reset reason\n")
1967{
1968 struct bgp *bgp;
1969
1970 bgp = vty->index;
1971 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1972 return CMD_SUCCESS;
1973}
6b0655a2 1974
718e3744 1975/* "bgp bestpath med" configuration. */
1976DEFUN (bgp_bestpath_med,
1977 bgp_bestpath_med_cmd,
1978 "bgp bestpath med (confed|missing-as-worst)",
1979 "BGP specific commands\n"
1980 "Change the default bestpath selection\n"
1981 "MED attribute\n"
1982 "Compare MED among confederation paths\n"
1983 "Treat missing MED as the least preferred one\n")
1984{
1985 struct bgp *bgp;
1986
1987 bgp = vty->index;
1988
1989 if (strncmp (argv[0], "confed", 1) == 0)
1990 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
1991 else
1992 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
1993
7aafcaca
DS
1994 bgp_recalculate_all_bestpaths (bgp);
1995
718e3744 1996 return CMD_SUCCESS;
1997}
1998
1999DEFUN (bgp_bestpath_med2,
2000 bgp_bestpath_med2_cmd,
2001 "bgp bestpath med confed missing-as-worst",
2002 "BGP specific commands\n"
2003 "Change the default bestpath selection\n"
2004 "MED attribute\n"
2005 "Compare MED among confederation paths\n"
2006 "Treat missing MED as the least preferred one\n")
2007{
2008 struct bgp *bgp;
2009
2010 bgp = vty->index;
2011 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2012 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2013 bgp_recalculate_all_bestpaths (bgp);
2014
718e3744 2015 return CMD_SUCCESS;
2016}
2017
2018ALIAS (bgp_bestpath_med2,
2019 bgp_bestpath_med3_cmd,
2020 "bgp bestpath med missing-as-worst confed",
2021 "BGP specific commands\n"
2022 "Change the default bestpath selection\n"
2023 "MED attribute\n"
2024 "Treat missing MED as the least preferred one\n"
2025 "Compare MED among confederation paths\n")
2026
2027DEFUN (no_bgp_bestpath_med,
2028 no_bgp_bestpath_med_cmd,
2029 "no bgp bestpath med (confed|missing-as-worst)",
2030 NO_STR
2031 "BGP specific commands\n"
2032 "Change the default bestpath selection\n"
2033 "MED attribute\n"
2034 "Compare MED among confederation paths\n"
2035 "Treat missing MED as the least preferred one\n")
2036{
2037 struct bgp *bgp;
2038
2039 bgp = vty->index;
2040
2041 if (strncmp (argv[0], "confed", 1) == 0)
2042 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2043 else
2044 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2045
7aafcaca
DS
2046 bgp_recalculate_all_bestpaths (bgp);
2047
718e3744 2048 return CMD_SUCCESS;
2049}
2050
2051DEFUN (no_bgp_bestpath_med2,
2052 no_bgp_bestpath_med2_cmd,
2053 "no bgp bestpath med confed missing-as-worst",
2054 NO_STR
2055 "BGP specific commands\n"
2056 "Change the default bestpath selection\n"
2057 "MED attribute\n"
2058 "Compare MED among confederation paths\n"
2059 "Treat missing MED as the least preferred one\n")
2060{
2061 struct bgp *bgp;
2062
2063 bgp = vty->index;
2064 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2065 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
7aafcaca
DS
2066 bgp_recalculate_all_bestpaths (bgp);
2067
718e3744 2068 return CMD_SUCCESS;
2069}
2070
2071ALIAS (no_bgp_bestpath_med2,
2072 no_bgp_bestpath_med3_cmd,
2073 "no bgp bestpath med missing-as-worst confed",
2074 NO_STR
2075 "BGP specific commands\n"
2076 "Change the default bestpath selection\n"
2077 "MED attribute\n"
2078 "Treat missing MED as the least preferred one\n"
2079 "Compare MED among confederation paths\n")
6b0655a2 2080
718e3744 2081/* "no bgp default ipv4-unicast". */
2082DEFUN (no_bgp_default_ipv4_unicast,
2083 no_bgp_default_ipv4_unicast_cmd,
2084 "no bgp default ipv4-unicast",
2085 NO_STR
2086 "BGP specific commands\n"
2087 "Configure BGP defaults\n"
2088 "Activate ipv4-unicast for a peer by default\n")
2089{
2090 struct bgp *bgp;
2091
2092 bgp = vty->index;
2093 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2094 return CMD_SUCCESS;
2095}
2096
2097DEFUN (bgp_default_ipv4_unicast,
2098 bgp_default_ipv4_unicast_cmd,
2099 "bgp default ipv4-unicast",
2100 "BGP specific commands\n"
2101 "Configure BGP defaults\n"
2102 "Activate ipv4-unicast for a peer by default\n")
2103{
2104 struct bgp *bgp;
2105
2106 bgp = vty->index;
2107 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2108 return CMD_SUCCESS;
2109}
6b0655a2 2110
718e3744 2111/* "bgp import-check" configuration. */
2112DEFUN (bgp_network_import_check,
2113 bgp_network_import_check_cmd,
078430f6 2114 "bgp network import-check {exact}",
718e3744 2115 "BGP specific commands\n"
2116 "BGP network command\n"
078430f6
DS
2117 "Check BGP network route exists in IGP\n"
2118 "Match route precisely")
718e3744 2119{
2120 struct bgp *bgp;
078430f6 2121 int trigger = 0;
718e3744 2122
2123 bgp = vty->index;
078430f6
DS
2124 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2125 {
2126 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
2127 trigger = 1;
2128 }
2129
2130 if (argv[0] != NULL)
2131 {
2132 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK_EXACT_MATCH))
2133 {
2134 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK_EXACT_MATCH);
2135 trigger = 1;
2136 }
2137 }
2138 else if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK_EXACT_MATCH))
2139 {
2140 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK_EXACT_MATCH);
2141 trigger = 1;
2142 }
2143
2144 if (trigger)
2145 bgp_static_redo_import_check(bgp);
2146
718e3744 2147 return CMD_SUCCESS;
2148}
2149
2150DEFUN (no_bgp_network_import_check,
2151 no_bgp_network_import_check_cmd,
078430f6 2152 "no bgp network import-check {exact}",
718e3744 2153 NO_STR
2154 "BGP specific commands\n"
2155 "BGP network command\n"
2156 "Check BGP network route exists in IGP\n")
2157{
2158 struct bgp *bgp;
2159
2160 bgp = vty->index;
078430f6
DS
2161 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2162 {
2163 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
2164 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK_EXACT_MATCH);
2165 bgp_static_redo_import_check(bgp);
2166 }
718e3744 2167 return CMD_SUCCESS;
2168}
6b0655a2 2169
718e3744 2170DEFUN (bgp_default_local_preference,
2171 bgp_default_local_preference_cmd,
2172 "bgp default local-preference <0-4294967295>",
2173 "BGP specific commands\n"
2174 "Configure BGP defaults\n"
2175 "local preference (higher=more preferred)\n"
2176 "Configure default local preference value\n")
2177{
2178 struct bgp *bgp;
2179 u_int32_t local_pref;
2180
2181 bgp = vty->index;
2182
2183 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
2184
2185 bgp_default_local_preference_set (bgp, local_pref);
7aafcaca 2186 bgp_clear_star_soft_in (vty);
718e3744 2187
2188 return CMD_SUCCESS;
2189}
2190
2191DEFUN (no_bgp_default_local_preference,
2192 no_bgp_default_local_preference_cmd,
2193 "no bgp default local-preference",
2194 NO_STR
2195 "BGP specific commands\n"
2196 "Configure BGP defaults\n"
2197 "local preference (higher=more preferred)\n")
2198{
2199 struct bgp *bgp;
2200
2201 bgp = vty->index;
2202 bgp_default_local_preference_unset (bgp);
7aafcaca
DS
2203 bgp_clear_star_soft_in (vty);
2204
718e3744 2205 return CMD_SUCCESS;
2206}
2207
2208ALIAS (no_bgp_default_local_preference,
2209 no_bgp_default_local_preference_val_cmd,
2210 "no bgp default local-preference <0-4294967295>",
2211 NO_STR
2212 "BGP specific commands\n"
2213 "Configure BGP defaults\n"
2214 "local preference (higher=more preferred)\n"
2215 "Configure default local preference value\n")
6b0655a2 2216
3f9c7369
DS
2217DEFUN (bgp_default_subgroup_pkt_queue_max,
2218 bgp_default_subgroup_pkt_queue_max_cmd,
2219 "bgp default subgroup-pkt-queue-max <20-100>",
2220 "BGP specific commands\n"
2221 "Configure BGP defaults\n"
2222 "subgroup-pkt-queue-max\n"
2223 "Configure subgroup packet queue max\n")
8bd9d948 2224{
3f9c7369
DS
2225 struct bgp *bgp;
2226 u_int32_t max_size;
8bd9d948 2227
3f9c7369
DS
2228 bgp = vty->index;
2229
2230 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]);
2231
2232 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2233
2234 return CMD_SUCCESS;
2235}
2236
2237DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2238 no_bgp_default_subgroup_pkt_queue_max_cmd,
2239 "no bgp default subgroup-pkt-queue-max",
2240 NO_STR
2241 "BGP specific commands\n"
2242 "Configure BGP defaults\n"
2243 "subgroup-pkt-queue-max\n")
2244{
2245 struct bgp *bgp;
2246
2247 bgp = vty->index;
2248 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2249 return CMD_SUCCESS;
8bd9d948
DS
2250}
2251
2252DEFUN (bgp_rr_allow_outbound_policy,
2253 bgp_rr_allow_outbound_policy_cmd,
2254 "bgp route-reflector allow-outbound-policy",
2255 "BGP specific commands\n"
2256 "Allow modifications made by out route-map\n"
2257 "on ibgp neighbors\n")
2258{
2259 struct bgp *bgp;
8bd9d948
DS
2260
2261 bgp = vty->index;
2262
2263 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2264 {
2265 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2266 update_group_announce_rrclients(bgp);
7aafcaca 2267 bgp_clear_star_soft_out (vty);
8bd9d948
DS
2268 }
2269
2270 return CMD_SUCCESS;
2271}
2272
2273DEFUN (no_bgp_rr_allow_outbound_policy,
2274 no_bgp_rr_allow_outbound_policy_cmd,
2275 "no bgp route-reflector allow-outbound-policy",
2276 NO_STR
2277 "BGP specific commands\n"
2278 "Allow modifications made by out route-map\n"
2279 "on ibgp neighbors\n")
2280{
2281 struct bgp *bgp;
8bd9d948
DS
2282
2283 bgp = vty->index;
2284
2285 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2286 {
2287 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2288 update_group_announce_rrclients(bgp);
7aafcaca 2289 bgp_clear_star_soft_out (vty);
8bd9d948
DS
2290 }
2291
2292 return CMD_SUCCESS;
2293}
2294
f14e6fdb
DS
2295DEFUN (bgp_listen_limit,
2296 bgp_listen_limit_cmd,
2297 "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2298 "BGP specific commands\n"
2299 "Configure BGP defaults\n"
2300 "maximum number of BGP Dynamic Neighbors that can be created\n"
2301 "Configure Dynamic Neighbors listen limit value\n")
2302{
2303 struct bgp *bgp;
2304 int listen_limit;
2305
2306 bgp = vty->index;
2307
2308 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0],
2309 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2310 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2311
2312 bgp_listen_limit_set (bgp, listen_limit);
2313
2314 return CMD_SUCCESS;
2315}
2316
2317DEFUN (no_bgp_listen_limit,
2318 no_bgp_listen_limit_cmd,
2319 "no bgp listen limit",
2320 "BGP specific commands\n"
2321 "Configure BGP defaults\n"
2322 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2323 "Configure Dynamic Neighbors listen limit value to default\n")
2324{
2325 struct bgp *bgp;
2326
2327 bgp = vty->index;
2328 bgp_listen_limit_unset (bgp);
2329 return CMD_SUCCESS;
2330}
2331
2332
2333DEFUN (bgp_listen_range,
2334 bgp_listen_range_cmd,
2335 LISTEN_RANGE_CMD "peer-group WORD" ,
2336 "BGP specific commands\n"
2337 "Configure BGP Dynamic Neighbors\n"
2338 "add a listening range for Dynamic Neighbors\n"
2339 LISTEN_RANGE_ADDR_STR)
2340{
2341 struct bgp *bgp;
2342 struct prefix range;
2343 struct peer_group *group;
2344 afi_t afi;
2345 int ret;
2346
2347 bgp = vty->index;
2348
2349 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2350
2351 /* Convert IP prefix string to struct prefix. */
2352 ret = str2prefix (argv[0], &range);
2353 if (! ret)
2354 {
2355 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2356 return CMD_WARNING;
2357 }
2358
2359 afi = family2afi(range.family);
2360
2361#ifdef HAVE_IPV6
2362 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2363 {
2364 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2365 VTY_NEWLINE);
2366 return CMD_WARNING;
2367 }
2368#endif /* HAVE_IPV6 */
2369
2370 apply_mask (&range);
2371
2372
2373 group = peer_group_lookup (bgp, argv[1]);
2374 if (! group)
2375 {
2376 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2377 return CMD_WARNING;
2378 }
2379
2380 ret = peer_group_listen_range_add(group, &range);
2381 return bgp_vty_return (vty, ret);
2382}
2383
2384DEFUN (no_bgp_listen_range,
2385 no_bgp_listen_range_cmd,
2386 "no bgp listen range A.B.C.D/M peer-group WORD" ,
2387 "BGP specific commands\n"
2388 "Configure BGP defaults\n"
2389 "delete a listening range for Dynamic Neighbors\n"
2390 "Remove Dynamic Neighbors listening range\n")
2391{
2392 struct bgp *bgp;
2393 struct prefix range;
2394 struct peer_group *group;
2395 afi_t afi;
2396 int ret;
2397
2398 bgp = vty->index;
2399
2400 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2401
2402 /* Convert IP prefix string to struct prefix. */
2403 ret = str2prefix (argv[0], &range);
2404 if (! ret)
2405 {
2406 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2407 return CMD_WARNING;
2408 }
2409
2410 afi = family2afi(range.family);
2411
2412#ifdef HAVE_IPV6
2413 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2414 {
2415 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2416 VTY_NEWLINE);
2417 return CMD_WARNING;
2418 }
2419#endif /* HAVE_IPV6 */
2420
2421 apply_mask (&range);
2422
2423
2424 group = peer_group_lookup (bgp, argv[1]);
2425 if (! group)
2426 {
2427 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2428 return CMD_WARNING;
2429 }
2430
2431 ret = peer_group_listen_range_del(group, &range);
2432 return bgp_vty_return (vty, ret);
2433}
2434
2435int
2436bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2437{
2438 struct peer_group *group;
2439 struct listnode *node, *nnode, *rnode, *nrnode;
2440 struct prefix *range;
2441 afi_t afi;
2442 char buf[128];
2443
2444 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2445 vty_out (vty, " bgp listen limit %d%s",
2446 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2447
2448 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2449 {
2450 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2451 {
2452 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2453 {
2454 prefix2str(range, buf, sizeof(buf));
2455 vty_out(vty, " bgp listen range %s peer-group %s%s",
2456 buf, group->name, VTY_NEWLINE);
2457 }
2458 }
2459 }
2460
2461 return 0;
2462}
2463
2464
907f92c8
DS
2465DEFUN (bgp_disable_connected_route_check,
2466 bgp_disable_connected_route_check_cmd,
2467 "bgp disable-ebgp-connected-route-check",
2468 "BGP specific commands\n"
2469 "Disable checking if nexthop is connected on ebgp sessions\n")
2470{
2471 struct bgp *bgp;
2472
2473 bgp = vty->index;
2474 bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
7aafcaca
DS
2475 bgp_clear_star_soft_in (vty);
2476
907f92c8
DS
2477 return CMD_SUCCESS;
2478}
2479
2480DEFUN (no_bgp_disable_connected_route_check,
2481 no_bgp_disable_connected_route_check_cmd,
2482 "no bgp disable-ebgp-connected-route-check",
2483 NO_STR
2484 "BGP specific commands\n"
2485 "Disable checking if nexthop is connected on ebgp sessions\n")
2486{
2487 struct bgp *bgp;
2488
2489 bgp = vty->index;
2490 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
7aafcaca
DS
2491 bgp_clear_star_soft_in (vty);
2492
907f92c8
DS
2493 return CMD_SUCCESS;
2494}
2495
2496
718e3744 2497static int
fd79ac91 2498peer_remote_as_vty (struct vty *vty, const char *peer_str,
2499 const char *as_str, afi_t afi, safi_t safi)
718e3744 2500{
2501 int ret;
2502 struct bgp *bgp;
2503 as_t as;
0299c004 2504 int as_type = AS_SPECIFIED;
718e3744 2505 union sockunion su;
2506
2507 bgp = vty->index;
2508
0299c004
DS
2509 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2510 {
2511 as = 0;
2512 as_type = AS_INTERNAL;
2513 }
2514 else if (strncmp(as_str, "external", strlen("external")) == 0)
2515 {
2516 as = 0;
2517 as_type = AS_EXTERNAL;
2518 }
2519 else
2520 {
2521 /* Get AS number. */
2522 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2523 }
718e3744 2524
2525 /* If peer is peer group, call proper function. */
2526 ret = str2sockunion (peer_str, &su);
2527 if (ret < 0)
2528 {
a80beece 2529 /* Check for peer by interface */
0299c004 2530 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
718e3744 2531 if (ret < 0)
a80beece 2532 {
0299c004 2533 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
a80beece
DS
2534 if (ret < 0)
2535 {
2536 vty_out (vty, "%% Create the peer-group or interface first%s",
2537 VTY_NEWLINE);
2538 return CMD_WARNING;
2539 }
2540 return CMD_SUCCESS;
2541 }
718e3744 2542 }
a80beece 2543 else
718e3744 2544 {
a80beece
DS
2545 if (peer_address_self_check (&su))
2546 {
2547 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2548 VTY_NEWLINE);
2549 return CMD_WARNING;
2550 }
0299c004 2551 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
718e3744 2552 }
2553
718e3744 2554 /* This peer belongs to peer group. */
2555 switch (ret)
2556 {
2557 case BGP_ERR_PEER_GROUP_MEMBER:
aea339f7 2558 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
718e3744 2559 return CMD_WARNING;
718e3744 2560 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
aea339f7 2561 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 2562 return CMD_WARNING;
718e3744 2563 }
2564 return bgp_vty_return (vty, ret);
2565}
2566
2567DEFUN (neighbor_remote_as,
2568 neighbor_remote_as_cmd,
0299c004 2569 NEIGHBOR_CMD2 "remote-as (" CMD_AS_RANGE "|external|internal)",
718e3744 2570 NEIGHBOR_STR
2571 NEIGHBOR_ADDR_STR2
2572 "Specify a BGP neighbor\n"
2573 AS_STR)
2574{
2575 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
2576}
6b0655a2 2577
a80beece
DS
2578DEFUN (neighbor_interface_config,
2579 neighbor_interface_config_cmd,
8ffedcea 2580 "neighbor WORD interface {v6only}",
a80beece
DS
2581 NEIGHBOR_STR
2582 "Interface name or neighbor tag\n"
8ffedcea
DS
2583 "Enable BGP on interface\n"
2584 "Enable BGP with v6 link-local only\n")
a80beece
DS
2585{
2586 struct bgp *bgp;
2587 struct peer *peer;
2588 struct peer_group *group;
2589
2590 bgp = vty->index;
2591 group = peer_group_lookup (bgp, argv[0]);
2592 if (group)
2593 {
2594 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2595 return CMD_WARNING;
2596 }
2597
8ffedcea
DS
2598 if (argv[1] != NULL)
2599 peer = peer_conf_interface_get (bgp, argv[0], AFI_IP, SAFI_UNICAST, 1);
2600 else
2601 peer = peer_conf_interface_get (bgp, argv[0], AFI_IP, SAFI_UNICAST, 0);
a80beece
DS
2602 if (!peer)
2603 return CMD_WARNING;
2604
2605 return CMD_SUCCESS;
2606}
2607
2608
718e3744 2609DEFUN (neighbor_peer_group,
2610 neighbor_peer_group_cmd,
2611 "neighbor WORD peer-group",
2612 NEIGHBOR_STR
a80beece 2613 "Interface name or neighbor tag\n"
718e3744 2614 "Configure peer-group\n")
2615{
2616 struct bgp *bgp;
a80beece 2617 struct peer *peer;
718e3744 2618 struct peer_group *group;
2619
2620 bgp = vty->index;
a80beece
DS
2621 peer = peer_lookup_by_conf_if (bgp, argv[0]);
2622 if (peer)
2623 {
2624 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2625 return CMD_WARNING;
2626 }
718e3744 2627
2628 group = peer_group_get (bgp, argv[0]);
2629 if (! group)
2630 return CMD_WARNING;
2631
2632 return CMD_SUCCESS;
2633}
2634
2635DEFUN (no_neighbor,
2636 no_neighbor_cmd,
2637 NO_NEIGHBOR_CMD2,
2638 NO_STR
2639 NEIGHBOR_STR
2640 NEIGHBOR_ADDR_STR2)
2641{
2642 int ret;
2643 union sockunion su;
2644 struct peer_group *group;
2645 struct peer *peer;
1ff9a340 2646 struct peer *other;
718e3744 2647
2648 ret = str2sockunion (argv[0], &su);
2649 if (ret < 0)
2650 {
a80beece
DS
2651 /* look up for neighbor by interface name config. */
2652 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2653 if (peer)
2654 {
2655 peer_delete (peer);
2656 return CMD_SUCCESS;
2657 }
2658
718e3744 2659 group = peer_group_lookup (vty->index, argv[0]);
2660 if (group)
2661 peer_group_delete (group);
2662 else
2663 {
2664 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2665 return CMD_WARNING;
2666 }
2667 }
2668 else
2669 {
2670 peer = peer_lookup (vty->index, &su);
2671 if (peer)
1ff9a340 2672 {
f14e6fdb
DS
2673 if (peer_dynamic_neighbor (peer))
2674 {
2675 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2676 VTY_NEWLINE);
2677 return CMD_WARNING;
2678 }
2679
1ff9a340
DS
2680 other = peer->doppelganger;
2681 peer_delete (peer);
2682 if (other && other->status != Deleted)
2683 peer_delete(other);
2684 }
718e3744 2685 }
2686
2687 return CMD_SUCCESS;
2688}
2689
2690ALIAS (no_neighbor,
2691 no_neighbor_remote_as_cmd,
0299c004 2692 NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)",
718e3744 2693 NO_STR
2694 NEIGHBOR_STR
2695 NEIGHBOR_ADDR_STR
2696 "Specify a BGP neighbor\n"
2697 AS_STR)
2698
a80beece
DS
2699DEFUN (no_neighbor_interface_config,
2700 no_neighbor_interface_config_cmd,
c8a96aef 2701 "no neighbor WORD interface {v6only}",
a80beece
DS
2702 NO_STR
2703 NEIGHBOR_STR
2704 "Interface name\n"
2705 "Configure BGP on interface\n")
2706{
2707 struct peer *peer;
2708
2709 /* look up for neighbor by interface name config. */
2710 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2711 if (peer)
2712 {
2713 peer_delete (peer);
2714 }
2715 else
2716 {
2717 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
2718 return CMD_WARNING;
2719 }
2720 return CMD_SUCCESS;
2721}
2722
718e3744 2723DEFUN (no_neighbor_peer_group,
2724 no_neighbor_peer_group_cmd,
2725 "no neighbor WORD peer-group",
2726 NO_STR
2727 NEIGHBOR_STR
2728 "Neighbor tag\n"
2729 "Configure peer-group\n")
2730{
2731 struct peer_group *group;
2732
2733 group = peer_group_lookup (vty->index, argv[0]);
2734 if (group)
2735 peer_group_delete (group);
2736 else
2737 {
2738 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2739 return CMD_WARNING;
2740 }
2741 return CMD_SUCCESS;
2742}
2743
a80beece
DS
2744DEFUN (no_neighbor_interface_peer_group_remote_as,
2745 no_neighbor_interface_peer_group_remote_as_cmd,
0299c004 2746 "no neighbor WORD remote-as (" CMD_AS_RANGE "|internal|external)",
718e3744 2747 NO_STR
2748 NEIGHBOR_STR
a80beece 2749 "Interface name or neighbor tag\n"
718e3744 2750 "Specify a BGP neighbor\n"
2751 AS_STR)
2752{
2753 struct peer_group *group;
a80beece
DS
2754 struct peer *peer;
2755
2756 /* look up for neighbor by interface name config. */
2757 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2758 if (peer)
2759 {
0299c004 2760 peer_as_change (peer, 0, AS_SPECIFIED);
a80beece
DS
2761 return CMD_SUCCESS;
2762 }
718e3744 2763
2764 group = peer_group_lookup (vty->index, argv[0]);
2765 if (group)
2766 peer_group_remote_as_delete (group);
2767 else
2768 {
a80beece 2769 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
718e3744 2770 return CMD_WARNING;
2771 }
2772 return CMD_SUCCESS;
2773}
6b0655a2 2774
718e3744 2775DEFUN (neighbor_local_as,
2776 neighbor_local_as_cmd,
320da874 2777 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 2778 NEIGHBOR_STR
2779 NEIGHBOR_ADDR_STR2
2780 "Specify a local-as number\n"
2781 "AS number used as local AS\n")
2782{
2783 struct peer *peer;
2784 int ret;
2785
2786 peer = peer_and_group_lookup_vty (vty, argv[0]);
2787 if (! peer)
2788 return CMD_WARNING;
2789
9d3f9705 2790 ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
718e3744 2791 return bgp_vty_return (vty, ret);
2792}
2793
2794DEFUN (neighbor_local_as_no_prepend,
2795 neighbor_local_as_no_prepend_cmd,
320da874 2796 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 2797 NEIGHBOR_STR
2798 NEIGHBOR_ADDR_STR2
2799 "Specify a local-as number\n"
2800 "AS number used as local AS\n"
2801 "Do not prepend local-as to updates from ebgp peers\n")
2802{
2803 struct peer *peer;
2804 int ret;
2805
2806 peer = peer_and_group_lookup_vty (vty, argv[0]);
2807 if (! peer)
2808 return CMD_WARNING;
2809
9d3f9705 2810 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
718e3744 2811 return bgp_vty_return (vty, ret);
2812}
2813
9d3f9705
AC
2814DEFUN (neighbor_local_as_no_prepend_replace_as,
2815 neighbor_local_as_no_prepend_replace_as_cmd,
2816 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
2817 NEIGHBOR_STR
2818 NEIGHBOR_ADDR_STR2
2819 "Specify a local-as number\n"
2820 "AS number used as local AS\n"
2821 "Do not prepend local-as to updates from ebgp peers\n"
2822 "Do not prepend local-as to updates from ibgp peers\n")
2823{
2824 struct peer *peer;
2825 int ret;
2826
2827 peer = peer_and_group_lookup_vty (vty, argv[0]);
2828 if (! peer)
2829 return CMD_WARNING;
2830
2831 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
2832 return bgp_vty_return (vty, ret);
2833}
2834
2835
718e3744 2836DEFUN (no_neighbor_local_as,
2837 no_neighbor_local_as_cmd,
2838 NO_NEIGHBOR_CMD2 "local-as",
2839 NO_STR
2840 NEIGHBOR_STR
2841 NEIGHBOR_ADDR_STR2
2842 "Specify a local-as number\n")
2843{
2844 struct peer *peer;
2845 int ret;
2846
2847 peer = peer_and_group_lookup_vty (vty, argv[0]);
2848 if (! peer)
2849 return CMD_WARNING;
2850
2851 ret = peer_local_as_unset (peer);
2852 return bgp_vty_return (vty, ret);
2853}
2854
2855ALIAS (no_neighbor_local_as,
2856 no_neighbor_local_as_val_cmd,
320da874 2857 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
718e3744 2858 NO_STR
2859 NEIGHBOR_STR
2860 NEIGHBOR_ADDR_STR2
2861 "Specify a local-as number\n"
2862 "AS number used as local AS\n")
2863
2864ALIAS (no_neighbor_local_as,
2865 no_neighbor_local_as_val2_cmd,
320da874 2866 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
718e3744 2867 NO_STR
2868 NEIGHBOR_STR
2869 NEIGHBOR_ADDR_STR2
2870 "Specify a local-as number\n"
2871 "AS number used as local AS\n"
2872 "Do not prepend local-as to updates from ebgp peers\n")
9d3f9705
AC
2873
2874ALIAS (no_neighbor_local_as,
2875 no_neighbor_local_as_val3_cmd,
2876 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
2877 NO_STR
2878 NEIGHBOR_STR
2879 NEIGHBOR_ADDR_STR2
2880 "Specify a local-as number\n"
2881 "AS number used as local AS\n"
2882 "Do not prepend local-as to updates from ebgp peers\n"
2883 "Do not prepend local-as to updates from ibgp peers\n")
6b0655a2 2884
3f9c7369
DS
2885DEFUN (neighbor_solo,
2886 neighbor_solo_cmd,
2887 NEIGHBOR_CMD2 "solo",
2888 NEIGHBOR_STR
2889 NEIGHBOR_ADDR_STR2
2890 "Solo peer - part of its own update group\n")
2891{
2892 struct peer *peer;
2893 int ret;
2894
2895 peer = peer_and_group_lookup_vty (vty, argv[0]);
2896 if (! peer)
2897 return CMD_WARNING;
2898
2899 ret = update_group_adjust_soloness(peer, 1);
2900 return bgp_vty_return (vty, ret);
2901}
2902
2903DEFUN (no_neighbor_solo,
2904 no_neighbor_solo_cmd,
2905 NO_NEIGHBOR_CMD2 "solo",
2906 NO_STR
2907 NEIGHBOR_STR
2908 NEIGHBOR_ADDR_STR2
2909 "Solo peer - part of its own update group\n")
2910{
2911 struct peer *peer;
2912 int ret;
2913
2914 peer = peer_and_group_lookup_vty (vty, argv[0]);
2915 if (! peer)
2916 return CMD_WARNING;
2917
2918 ret = update_group_adjust_soloness(peer, 0);
2919 return bgp_vty_return (vty, ret);
2920}
2921
0df7c91f
PJ
2922DEFUN (neighbor_password,
2923 neighbor_password_cmd,
2924 NEIGHBOR_CMD2 "password LINE",
2925 NEIGHBOR_STR
2926 NEIGHBOR_ADDR_STR2
2927 "Set a password\n"
2928 "The password\n")
2929{
2930 struct peer *peer;
2931 int ret;
2932
2933 peer = peer_and_group_lookup_vty (vty, argv[0]);
2934 if (! peer)
2935 return CMD_WARNING;
2936
2937 ret = peer_password_set (peer, argv[1]);
2938 return bgp_vty_return (vty, ret);
2939}
2940
2941DEFUN (no_neighbor_password,
2942 no_neighbor_password_cmd,
2943 NO_NEIGHBOR_CMD2 "password",
2944 NO_STR
2945 NEIGHBOR_STR
2946 NEIGHBOR_ADDR_STR2
2947 "Set a password\n")
2948{
2949 struct peer *peer;
2950 int ret;
2951
2952 peer = peer_and_group_lookup_vty (vty, argv[0]);
2953 if (! peer)
2954 return CMD_WARNING;
2955
2956 ret = peer_password_unset (peer);
2957 return bgp_vty_return (vty, ret);
2958}
6b0655a2 2959
718e3744 2960DEFUN (neighbor_activate,
2961 neighbor_activate_cmd,
2962 NEIGHBOR_CMD2 "activate",
2963 NEIGHBOR_STR
2964 NEIGHBOR_ADDR_STR2
2965 "Enable the Address Family for this Neighbor\n")
2966{
2967 struct peer *peer;
2968
2969 peer = peer_and_group_lookup_vty (vty, argv[0]);
2970 if (! peer)
2971 return CMD_WARNING;
2972
2973 peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
2974
2975 return CMD_SUCCESS;
2976}
2977
2978DEFUN (no_neighbor_activate,
2979 no_neighbor_activate_cmd,
2980 NO_NEIGHBOR_CMD2 "activate",
2981 NO_STR
2982 NEIGHBOR_STR
2983 NEIGHBOR_ADDR_STR2
2984 "Enable the Address Family for this Neighbor\n")
2985{
2986 int ret;
2987 struct peer *peer;
2988
2989 /* Lookup peer. */
2990 peer = peer_and_group_lookup_vty (vty, argv[0]);
2991 if (! peer)
2992 return CMD_WARNING;
2993
2994 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
2995
2996 return bgp_vty_return (vty, ret);
2997}
6b0655a2 2998
718e3744 2999DEFUN (neighbor_set_peer_group,
3000 neighbor_set_peer_group_cmd,
a80beece 3001 NEIGHBOR_CMD2 "peer-group WORD",
718e3744 3002 NEIGHBOR_STR
a80beece 3003 NEIGHBOR_ADDR_STR2
718e3744 3004 "Member of the peer-group\n"
3005 "peer-group name\n")
3006{
3007 int ret;
3008 as_t as;
3009 union sockunion su;
3010 struct bgp *bgp;
a80beece 3011 struct peer *peer;
718e3744 3012 struct peer_group *group;
3013
3014 bgp = vty->index;
a80beece 3015 peer = NULL;
718e3744 3016
3017 ret = str2sockunion (argv[0], &su);
3018 if (ret < 0)
3019 {
a80beece
DS
3020 peer = peer_lookup_by_conf_if (bgp, argv[0]);
3021 if (!peer)
3022 {
3023 vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE);
3024 return CMD_WARNING;
3025 }
3026 }
3027 else
3028 {
3029 if (peer_address_self_check (&su))
3030 {
3031 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3032 VTY_NEWLINE);
3033 return CMD_WARNING;
3034 }
f14e6fdb
DS
3035
3036 /* Disallow for dynamic neighbor. */
3037 peer = peer_lookup (bgp, &su);
3038 if (peer && peer_dynamic_neighbor (peer))
3039 {
3040 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3041 VTY_NEWLINE);
3042 return CMD_WARNING;
3043 }
718e3744 3044 }
3045
3046 group = peer_group_lookup (bgp, argv[1]);
3047 if (! group)
3048 {
3049 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3050 return CMD_WARNING;
3051 }
3052
a80beece 3053 ret = peer_group_bind (bgp, &su, peer, group, bgp_node_afi (vty),
718e3744 3054 bgp_node_safi (vty), &as);
3055
3056 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3057 {
aea339f7 3058 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 3059 return CMD_WARNING;
3060 }
3061
3062 return bgp_vty_return (vty, ret);
3063}
3064
3065DEFUN (no_neighbor_set_peer_group,
3066 no_neighbor_set_peer_group_cmd,
a80beece 3067 NO_NEIGHBOR_CMD2 "peer-group WORD",
718e3744 3068 NO_STR
3069 NEIGHBOR_STR
a80beece 3070 NEIGHBOR_ADDR_STR2
718e3744 3071 "Member of the peer-group\n"
3072 "peer-group name\n")
3073{
3074 int ret;
3075 struct bgp *bgp;
3076 struct peer *peer;
3077 struct peer_group *group;
3078
3079 bgp = vty->index;
3080
3081 peer = peer_lookup_vty (vty, argv[0]);
3082 if (! peer)
3083 return CMD_WARNING;
3084
3085 group = peer_group_lookup (bgp, argv[1]);
3086 if (! group)
3087 {
3088 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3089 return CMD_WARNING;
3090 }
3091
3092 ret = peer_group_unbind (bgp, peer, group, bgp_node_afi (vty),
3093 bgp_node_safi (vty));
3094
3095 return bgp_vty_return (vty, ret);
3096}
6b0655a2 3097
94f2b392 3098static int
fd79ac91 3099peer_flag_modify_vty (struct vty *vty, const char *ip_str,
3100 u_int16_t flag, int set)
718e3744 3101{
3102 int ret;
3103 struct peer *peer;
3104
3105 peer = peer_and_group_lookup_vty (vty, ip_str);
3106 if (! peer)
3107 return CMD_WARNING;
3108
3109 if (set)
3110 ret = peer_flag_set (peer, flag);
3111 else
3112 ret = peer_flag_unset (peer, flag);
3113
3114 return bgp_vty_return (vty, ret);
3115}
3116
94f2b392 3117static int
fd79ac91 3118peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3119{
3120 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3121}
3122
94f2b392 3123static int
fd79ac91 3124peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3125{
3126 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3127}
3128
3129/* neighbor passive. */
3130DEFUN (neighbor_passive,
3131 neighbor_passive_cmd,
3132 NEIGHBOR_CMD2 "passive",
3133 NEIGHBOR_STR
3134 NEIGHBOR_ADDR_STR2
3135 "Don't send open messages to this neighbor\n")
3136{
3137 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3138}
3139
3140DEFUN (no_neighbor_passive,
3141 no_neighbor_passive_cmd,
3142 NO_NEIGHBOR_CMD2 "passive",
3143 NO_STR
3144 NEIGHBOR_STR
3145 NEIGHBOR_ADDR_STR2
3146 "Don't send open messages to this neighbor\n")
3147{
3148 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3149}
6b0655a2 3150
718e3744 3151/* neighbor shutdown. */
3152DEFUN (neighbor_shutdown,
3153 neighbor_shutdown_cmd,
3154 NEIGHBOR_CMD2 "shutdown",
3155 NEIGHBOR_STR
3156 NEIGHBOR_ADDR_STR2
3157 "Administratively shut down this neighbor\n")
3158{
3159 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3160}
3161
3162DEFUN (no_neighbor_shutdown,
3163 no_neighbor_shutdown_cmd,
3164 NO_NEIGHBOR_CMD2 "shutdown",
3165 NO_STR
3166 NEIGHBOR_STR
3167 NEIGHBOR_ADDR_STR2
3168 "Administratively shut down this neighbor\n")
3169{
3170 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3171}
6b0655a2 3172
c9502438 3173/* Deprecated neighbor capability route-refresh. */
3174DEFUN_DEPRECATED (neighbor_capability_route_refresh,
3175 neighbor_capability_route_refresh_cmd,
3176 NEIGHBOR_CMD2 "capability route-refresh",
3177 NEIGHBOR_STR
3178 NEIGHBOR_ADDR_STR2
3179 "Advertise capability to the peer\n"
3180 "Advertise route-refresh capability to this neighbor\n")
718e3744 3181{
c9502438 3182 return CMD_SUCCESS;
718e3744 3183}
3184
c9502438 3185DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
3186 no_neighbor_capability_route_refresh_cmd,
3187 NO_NEIGHBOR_CMD2 "capability route-refresh",
3188 NO_STR
3189 NEIGHBOR_STR
3190 NEIGHBOR_ADDR_STR2
3191 "Advertise capability to the peer\n"
3192 "Advertise route-refresh capability to this neighbor\n")
718e3744 3193{
c9502438 3194 return CMD_SUCCESS;
718e3744 3195}
6b0655a2 3196
718e3744 3197/* neighbor capability dynamic. */
3198DEFUN (neighbor_capability_dynamic,
3199 neighbor_capability_dynamic_cmd,
3200 NEIGHBOR_CMD2 "capability dynamic",
3201 NEIGHBOR_STR
3202 NEIGHBOR_ADDR_STR2
3203 "Advertise capability to the peer\n"
3204 "Advertise dynamic capability to this neighbor\n")
3205{
3206 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3207}
3208
3209DEFUN (no_neighbor_capability_dynamic,
3210 no_neighbor_capability_dynamic_cmd,
3211 NO_NEIGHBOR_CMD2 "capability dynamic",
3212 NO_STR
3213 NEIGHBOR_STR
3214 NEIGHBOR_ADDR_STR2
3215 "Advertise capability to the peer\n"
3216 "Advertise dynamic capability to this neighbor\n")
3217{
3218 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3219}
6b0655a2 3220
718e3744 3221/* neighbor dont-capability-negotiate */
3222DEFUN (neighbor_dont_capability_negotiate,
3223 neighbor_dont_capability_negotiate_cmd,
3224 NEIGHBOR_CMD2 "dont-capability-negotiate",
3225 NEIGHBOR_STR
3226 NEIGHBOR_ADDR_STR2
3227 "Do not perform capability negotiation\n")
3228{
3229 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3230}
3231
3232DEFUN (no_neighbor_dont_capability_negotiate,
3233 no_neighbor_dont_capability_negotiate_cmd,
3234 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
3235 NO_STR
3236 NEIGHBOR_STR
3237 NEIGHBOR_ADDR_STR2
3238 "Do not perform capability negotiation\n")
3239{
3240 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3241}
6b0655a2 3242
8a92a8a0
DS
3243/* neighbor capability extended next hop encoding */
3244DEFUN (neighbor_capability_enhe,
3245 neighbor_capability_enhe_cmd,
3246 NEIGHBOR_CMD2 "capability extended-nexthop",
3247 NEIGHBOR_STR
3248 NEIGHBOR_ADDR_STR2
3249 "Advertise capability to the peer\n"
3250 "Advertise extended next-hop capability to the peer\n")
3251{
3252 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3253}
3254
3255DEFUN (no_neighbor_capability_enhe,
3256 no_neighbor_capability_enhe_cmd,
3257 NO_NEIGHBOR_CMD2 "capability extended-nexthop",
3258 NO_STR
3259 NEIGHBOR_STR
3260 NEIGHBOR_ADDR_STR2
3261 "Advertise capability to the peer\n"
3262 "Advertise extended next-hop capability to the peer\n")
3263{
3264 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3265}
3266
94f2b392 3267static int
fd79ac91 3268peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3269 safi_t safi, u_int32_t flag, int set)
718e3744 3270{
3271 int ret;
3272 struct peer *peer;
3273
3274 peer = peer_and_group_lookup_vty (vty, peer_str);
3275 if (! peer)
3276 return CMD_WARNING;
3277
3278 if (set)
3279 ret = peer_af_flag_set (peer, afi, safi, flag);
3280 else
3281 ret = peer_af_flag_unset (peer, afi, safi, flag);
3282
3283 return bgp_vty_return (vty, ret);
3284}
3285
94f2b392 3286static int
fd79ac91 3287peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3288 safi_t safi, u_int32_t flag)
718e3744 3289{
3290 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3291}
3292
94f2b392 3293static int
fd79ac91 3294peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3295 safi_t safi, u_int32_t flag)
718e3744 3296{
3297 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3298}
6b0655a2 3299
718e3744 3300/* neighbor capability orf prefix-list. */
3301DEFUN (neighbor_capability_orf_prefix,
3302 neighbor_capability_orf_prefix_cmd,
3303 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3304 NEIGHBOR_STR
3305 NEIGHBOR_ADDR_STR2
3306 "Advertise capability to the peer\n"
3307 "Advertise ORF capability to the peer\n"
3308 "Advertise prefixlist ORF capability to this neighbor\n"
3309 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3310 "Capability to RECEIVE the ORF from this neighbor\n"
3311 "Capability to SEND the ORF to this neighbor\n")
3312{
3313 u_int16_t flag = 0;
3314
3315 if (strncmp (argv[1], "s", 1) == 0)
3316 flag = PEER_FLAG_ORF_PREFIX_SM;
3317 else if (strncmp (argv[1], "r", 1) == 0)
3318 flag = PEER_FLAG_ORF_PREFIX_RM;
3319 else if (strncmp (argv[1], "b", 1) == 0)
3320 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3321 else
3322 return CMD_WARNING;
3323
3324 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3325 bgp_node_safi (vty), flag);
3326}
3327
3328DEFUN (no_neighbor_capability_orf_prefix,
3329 no_neighbor_capability_orf_prefix_cmd,
3330 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3331 NO_STR
3332 NEIGHBOR_STR
3333 NEIGHBOR_ADDR_STR2
3334 "Advertise capability to the peer\n"
3335 "Advertise ORF capability to the peer\n"
3336 "Advertise prefixlist ORF capability to this neighbor\n"
3337 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3338 "Capability to RECEIVE the ORF from this neighbor\n"
3339 "Capability to SEND the ORF to this neighbor\n")
3340{
3341 u_int16_t flag = 0;
3342
3343 if (strncmp (argv[1], "s", 1) == 0)
3344 flag = PEER_FLAG_ORF_PREFIX_SM;
3345 else if (strncmp (argv[1], "r", 1) == 0)
3346 flag = PEER_FLAG_ORF_PREFIX_RM;
3347 else if (strncmp (argv[1], "b", 1) == 0)
3348 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3349 else
3350 return CMD_WARNING;
3351
3352 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3353 bgp_node_safi (vty), flag);
3354}
6b0655a2 3355
718e3744 3356/* neighbor next-hop-self. */
3357DEFUN (neighbor_nexthop_self,
3358 neighbor_nexthop_self_cmd,
a538debe 3359 NEIGHBOR_CMD2 "next-hop-self",
718e3744 3360 NEIGHBOR_STR
3361 NEIGHBOR_ADDR_STR2
a538debe 3362 "Disable the next hop calculation for this neighbor\n")
718e3744 3363{
a538debe
DS
3364 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3365 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3366}
9e7a53c1 3367
a538debe
DS
3368/* neighbor next-hop-self. */
3369DEFUN (neighbor_nexthop_self_force,
3370 neighbor_nexthop_self_force_cmd,
3371 NEIGHBOR_CMD2 "next-hop-self force",
3372 NEIGHBOR_STR
3373 NEIGHBOR_ADDR_STR2
3374 "Disable the next hop calculation for this neighbor\n"
3375 "Set the next hop to self for reflected routes\n")
3376{
3377 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3378 bgp_node_safi (vty),
3379 (PEER_FLAG_FORCE_NEXTHOP_SELF |
3380 PEER_FLAG_NEXTHOP_SELF));
718e3744 3381}
3382
3383DEFUN (no_neighbor_nexthop_self,
3384 no_neighbor_nexthop_self_cmd,
a538debe 3385 NO_NEIGHBOR_CMD2 "next-hop-self",
718e3744 3386 NO_STR
3387 NEIGHBOR_STR
3388 NEIGHBOR_ADDR_STR2
a538debe 3389 "Disable the next hop calculation for this neighbor\n")
718e3744 3390{
3391 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
9e7a53c1 3392 bgp_node_safi (vty),
a538debe
DS
3393 (PEER_FLAG_NEXTHOP_SELF |
3394 PEER_FLAG_FORCE_NEXTHOP_SELF));
718e3744 3395}
6b0655a2 3396
a538debe
DS
3397ALIAS (no_neighbor_nexthop_self,
3398 no_neighbor_nexthop_self_force_cmd,
3399 NO_NEIGHBOR_CMD2 "next-hop-self force",
3400 NO_STR
3401 NEIGHBOR_STR
3402 NEIGHBOR_ADDR_STR2
3403 "Disable the next hop calculation for this neighbor\n"
3404 "Set the next hop to self for reflected routes\n")
3405
c7122e14
DS
3406/* neighbor as-override */
3407DEFUN (neighbor_as_override,
3408 neighbor_as_override_cmd,
3409 NEIGHBOR_CMD2 "as-override",
3410 NEIGHBOR_STR
3411 NEIGHBOR_ADDR_STR2
3412 "Override ASNs in outbound updates if aspath equals remote-as\n")
3413{
3414 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3415 bgp_node_safi (vty),
3416 PEER_FLAG_AS_OVERRIDE);
3417}
3418
3419DEFUN (no_neighbor_as_override,
3420 no_neighbor_as_override_cmd,
3421 NO_NEIGHBOR_CMD2 "as-override",
3422 NO_STR
3423 NEIGHBOR_STR
3424 NEIGHBOR_ADDR_STR2
3425 "Override ASNs in outbound updates if aspath equals remote-as\n")
3426{
3427 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3428 bgp_node_safi (vty),
3429 PEER_FLAG_AS_OVERRIDE);
3430}
3431
718e3744 3432/* neighbor remove-private-AS. */
3433DEFUN (neighbor_remove_private_as,
3434 neighbor_remove_private_as_cmd,
3435 NEIGHBOR_CMD2 "remove-private-AS",
3436 NEIGHBOR_STR
3437 NEIGHBOR_ADDR_STR2
5000f21c 3438 "Remove private ASNs in outbound updates\n")
718e3744 3439{
5000f21c
DS
3440 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3441 bgp_node_safi (vty),
3442 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3443 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
718e3744 3444 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3445 bgp_node_safi (vty),
3446 PEER_FLAG_REMOVE_PRIVATE_AS);
3447}
3448
5000f21c
DS
3449DEFUN (neighbor_remove_private_as_all,
3450 neighbor_remove_private_as_all_cmd,
3451 NEIGHBOR_CMD2 "remove-private-AS all",
3452 NEIGHBOR_STR
3453 NEIGHBOR_ADDR_STR2
3454 "Remove private ASNs in outbound updates\n"
3455 "Apply to all AS numbers")
3456{
3457 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3458 bgp_node_safi (vty),
3459 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3460 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3461 bgp_node_safi (vty),
3462 PEER_FLAG_REMOVE_PRIVATE_AS|
3463 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3464}
3465
3466DEFUN (neighbor_remove_private_as_replace_as,
3467 neighbor_remove_private_as_replace_as_cmd,
3468 NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3469 NEIGHBOR_STR
3470 NEIGHBOR_ADDR_STR2
3471 "Remove private ASNs in outbound updates\n"
3472 "Replace private ASNs with our ASN in outbound updates\n")
3473{
3474 peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3475 bgp_node_safi (vty),
3476 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3477 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3478 bgp_node_safi (vty),
3479 PEER_FLAG_REMOVE_PRIVATE_AS|
3480 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3481}
3482
3483DEFUN (neighbor_remove_private_as_all_replace_as,
3484 neighbor_remove_private_as_all_replace_as_cmd,
3485 NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3486 NEIGHBOR_STR
3487 NEIGHBOR_ADDR_STR2
3488 "Remove private ASNs in outbound updates\n"
3489 "Apply to all AS numbers"
3490 "Replace private ASNs with our ASN in outbound updates\n")
3491{
3492 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3493 bgp_node_safi (vty),
3494 PEER_FLAG_REMOVE_PRIVATE_AS|
3495 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3496 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3497}
3498
718e3744 3499DEFUN (no_neighbor_remove_private_as,
3500 no_neighbor_remove_private_as_cmd,
3501 NO_NEIGHBOR_CMD2 "remove-private-AS",
3502 NO_STR
3503 NEIGHBOR_STR
3504 NEIGHBOR_ADDR_STR2
5000f21c 3505 "Remove private ASNs in outbound updates\n")
718e3744 3506{
3507 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3508 bgp_node_safi (vty),
5000f21c
DS
3509 PEER_FLAG_REMOVE_PRIVATE_AS|
3510 PEER_FLAG_REMOVE_PRIVATE_AS_ALL|
3511 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
718e3744 3512}
6b0655a2 3513
5000f21c
DS
3514ALIAS (no_neighbor_remove_private_as,
3515 no_neighbor_remove_private_as_all_cmd,
3516 NO_NEIGHBOR_CMD2 "remove-private-AS all",
3517 NO_STR
3518 NEIGHBOR_STR
3519 NEIGHBOR_ADDR_STR2
3520 "Remove private ASNs in outbound updates\n"
3521 "Apply to all AS numbers")
3522
3523ALIAS (no_neighbor_remove_private_as,
3524 no_neighbor_remove_private_as_replace_as_cmd,
3525 NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3526 NO_STR
3527 NEIGHBOR_STR
3528 NEIGHBOR_ADDR_STR2
3529 "Remove private ASNs in outbound updates\n"
3530 "Replace private ASNs with our ASN in outbound updates\n")
3531
3532ALIAS (no_neighbor_remove_private_as,
3533 no_neighbor_remove_private_as_all_replace_as_cmd,
3534 NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3535 NO_STR
3536 NEIGHBOR_STR
3537 NEIGHBOR_ADDR_STR2
3538 "Remove private ASNs in outbound updates\n"
3539 "Apply to all AS numbers"
3540 "Replace private ASNs with our ASN in outbound updates\n")
3541
3542
718e3744 3543/* neighbor send-community. */
3544DEFUN (neighbor_send_community,
3545 neighbor_send_community_cmd,
3546 NEIGHBOR_CMD2 "send-community",
3547 NEIGHBOR_STR
3548 NEIGHBOR_ADDR_STR2
3549 "Send Community attribute to this neighbor\n")
3550{
3551 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3552 bgp_node_safi (vty),
3553 PEER_FLAG_SEND_COMMUNITY);
3554}
3555
3556DEFUN (no_neighbor_send_community,
3557 no_neighbor_send_community_cmd,
3558 NO_NEIGHBOR_CMD2 "send-community",
3559 NO_STR
3560 NEIGHBOR_STR
3561 NEIGHBOR_ADDR_STR2
3562 "Send Community attribute to this neighbor\n")
3563{
3564 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3565 bgp_node_safi (vty),
3566 PEER_FLAG_SEND_COMMUNITY);
3567}
6b0655a2 3568
718e3744 3569/* neighbor send-community extended. */
3570DEFUN (neighbor_send_community_type,
3571 neighbor_send_community_type_cmd,
3572 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3573 NEIGHBOR_STR
3574 NEIGHBOR_ADDR_STR2
3575 "Send Community attribute to this neighbor\n"
3576 "Send Standard and Extended Community attributes\n"
3577 "Send Extended Community attributes\n"
3578 "Send Standard Community attributes\n")
3579{
3580 if (strncmp (argv[1], "s", 1) == 0)
3581 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3582 bgp_node_safi (vty),
3583 PEER_FLAG_SEND_COMMUNITY);
3584 if (strncmp (argv[1], "e", 1) == 0)
3585 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3586 bgp_node_safi (vty),
3587 PEER_FLAG_SEND_EXT_COMMUNITY);
3588
3589 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3590 bgp_node_safi (vty),
3591 (PEER_FLAG_SEND_COMMUNITY|
3592 PEER_FLAG_SEND_EXT_COMMUNITY));
3593}
3594
3595DEFUN (no_neighbor_send_community_type,
3596 no_neighbor_send_community_type_cmd,
3597 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3598 NO_STR
3599 NEIGHBOR_STR
3600 NEIGHBOR_ADDR_STR2
3601 "Send Community attribute to this neighbor\n"
3602 "Send Standard and Extended Community attributes\n"
3603 "Send Extended Community attributes\n"
3604 "Send Standard Community attributes\n")
3605{
3606 if (strncmp (argv[1], "s", 1) == 0)
3607 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3608 bgp_node_safi (vty),
3609 PEER_FLAG_SEND_COMMUNITY);
3610 if (strncmp (argv[1], "e", 1) == 0)
3611 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3612 bgp_node_safi (vty),
3613 PEER_FLAG_SEND_EXT_COMMUNITY);
3614
3615 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3616 bgp_node_safi (vty),
3617 (PEER_FLAG_SEND_COMMUNITY |
3618 PEER_FLAG_SEND_EXT_COMMUNITY));
3619}
6b0655a2 3620
718e3744 3621/* neighbor soft-reconfig. */
3622DEFUN (neighbor_soft_reconfiguration,
3623 neighbor_soft_reconfiguration_cmd,
3624 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3625 NEIGHBOR_STR
3626 NEIGHBOR_ADDR_STR2
3627 "Per neighbor soft reconfiguration\n"
3628 "Allow inbound soft reconfiguration for this neighbor\n")
3629{
3630 return peer_af_flag_set_vty (vty, argv[0],
3631 bgp_node_afi (vty), bgp_node_safi (vty),
3632 PEER_FLAG_SOFT_RECONFIG);
3633}
3634
3635DEFUN (no_neighbor_soft_reconfiguration,
3636 no_neighbor_soft_reconfiguration_cmd,
3637 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3638 NO_STR
3639 NEIGHBOR_STR
3640 NEIGHBOR_ADDR_STR2
3641 "Per neighbor soft reconfiguration\n"
3642 "Allow inbound soft reconfiguration for this neighbor\n")
3643{
3644 return peer_af_flag_unset_vty (vty, argv[0],
3645 bgp_node_afi (vty), bgp_node_safi (vty),
3646 PEER_FLAG_SOFT_RECONFIG);
3647}
6b0655a2 3648
718e3744 3649DEFUN (neighbor_route_reflector_client,
3650 neighbor_route_reflector_client_cmd,
3651 NEIGHBOR_CMD2 "route-reflector-client",
3652 NEIGHBOR_STR
3653 NEIGHBOR_ADDR_STR2
3654 "Configure a neighbor as Route Reflector client\n")
3655{
3656 struct peer *peer;
3657
3658
3659 peer = peer_and_group_lookup_vty (vty, argv[0]);
3660 if (! peer)
3661 return CMD_WARNING;
3662
3663 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3664 bgp_node_safi (vty),
3665 PEER_FLAG_REFLECTOR_CLIENT);
3666}
3667
3668DEFUN (no_neighbor_route_reflector_client,
3669 no_neighbor_route_reflector_client_cmd,
3670 NO_NEIGHBOR_CMD2 "route-reflector-client",
3671 NO_STR
3672 NEIGHBOR_STR
3673 NEIGHBOR_ADDR_STR2
3674 "Configure a neighbor as Route Reflector client\n")
3675{
3676 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3677 bgp_node_safi (vty),
3678 PEER_FLAG_REFLECTOR_CLIENT);
3679}
6b0655a2 3680
94f2b392 3681static int
fd79ac91 3682peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
3683 int afi, int safi)
fee0f4c6 3684{
3685 int ret;
3686 struct bgp *bgp;
3687 struct peer *peer;
3688 struct peer_group *group;
1eb8ef25 3689 struct listnode *node, *nnode;
fee0f4c6 3690 struct bgp_filter *pfilter;
3691 struct bgp_filter *gfilter;
228da428 3692 int locked_and_added = 0;
fee0f4c6 3693
3694 bgp = vty->index;
3695
3696 peer = peer_and_group_lookup_vty (vty, peer_str);
3697 if ( ! peer )
3698 return CMD_WARNING;
3699
3700 /* If it is already a RS-Client, don't do anything. */
3701 if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
3702 return CMD_SUCCESS;
3703
3704 if ( ! peer_rsclient_active (peer) )
200df115 3705 {
3706 peer = peer_lock (peer); /* rsclient peer list reference */
3707 listnode_add_sort (bgp->rsclient, peer);
228da428 3708 locked_and_added = 1;
200df115 3709 }
fee0f4c6 3710
3711 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3712 if (ret < 0)
228da428
CC
3713 {
3714 if (locked_and_added)
3715 {
3716 listnode_delete (bgp->rsclient, peer);
3717 peer_unlock (peer); /* rsclient peer list reference */
3718 }
3719
3720 return bgp_vty_return (vty, ret);
3721 }
fee0f4c6 3722
64e580a7 3723 peer->rib[afi][safi] = bgp_table_init (afi, safi);
fee0f4c6 3724 peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
228da428
CC
3725 /* RIB peer reference. Released when table is free'd in bgp_table_free. */
3726 peer->rib[afi][safi]->owner = peer_lock (peer);
fee0f4c6 3727
3728 /* Check for existing 'network' and 'redistribute' routes. */
3729 bgp_check_local_routes_rsclient (peer, afi, safi);
3730
3731 /* Check for routes for peers configured with 'soft-reconfiguration'. */
3732 bgp_soft_reconfig_rsclient (peer, afi, safi);
3733
3734 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
3735 {
3736 group = peer->group;
3737 gfilter = &peer->filter[afi][safi];
3738
1eb8ef25 3739 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
fee0f4c6 3740 {
3741 pfilter = &peer->filter[afi][safi];
3742
3743 /* Members of a non-RS-Client group should not be RS-Clients, as that
3744 is checked when the become part of the peer-group */
3745 ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3746 if (ret < 0)
3747 return bgp_vty_return (vty, ret);
3748
3749 /* Make peer's RIB point to group's RIB. */
3750 peer->rib[afi][safi] = group->conf->rib[afi][safi];
3751
3752 /* Import policy. */
3753 if (pfilter->map[RMAP_IMPORT].name)
6e919709 3754 XFREE(MTYPE_BGP_FILTER_NAME, pfilter->map[RMAP_IMPORT].name);
fee0f4c6 3755 if (gfilter->map[RMAP_IMPORT].name)
3756 {
6e919709
DS
3757 pfilter->map[RMAP_IMPORT].name = XSTRDUP(MTYPE_BGP_FILTER_NAME,
3758 gfilter->map[RMAP_IMPORT].name);
fee0f4c6 3759 pfilter->map[RMAP_IMPORT].map = gfilter->map[RMAP_IMPORT].map;
3760 }
3761 else
3762 {
3763 pfilter->map[RMAP_IMPORT].name = NULL;
6e919709 3764 pfilter->map[RMAP_IMPORT].map = NULL;
fee0f4c6 3765 }
3766
3767 /* Export policy. */
3768 if (gfilter->map[RMAP_EXPORT].name && ! pfilter->map[RMAP_EXPORT].name)
3769 {
6e919709
DS
3770 pfilter->map[RMAP_EXPORT].name = XSTRDUP(MTYPE_BGP_FILTER_NAME,
3771 gfilter->map[RMAP_EXPORT].name);
fee0f4c6 3772 pfilter->map[RMAP_EXPORT].map = gfilter->map[RMAP_EXPORT].map;
3773 }
3774 }
3775 }
3776 return CMD_SUCCESS;
3777}
3778
94f2b392 3779static int
fd79ac91 3780peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
3781 int afi, int safi)
fee0f4c6 3782{
3783 int ret;
3784 struct bgp *bgp;
3785 struct peer *peer;
3786 struct peer_group *group;
1eb8ef25 3787 struct listnode *node, *nnode;
fee0f4c6 3788
3789 bgp = vty->index;
3790
3791 peer = peer_and_group_lookup_vty (vty, peer_str);
3792 if ( ! peer )
3793 return CMD_WARNING;
3794
3795 /* If it is not a RS-Client, don't do anything. */
3796 if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
3797 return CMD_SUCCESS;
3798
3799 if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
3800 {
3801 group = peer->group;
3802
1eb8ef25 3803 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
fee0f4c6 3804 {
3805 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3806 if (ret < 0)
3807 return bgp_vty_return (vty, ret);
3808
3809 peer->rib[afi][safi] = NULL;
3810 }
3811
3812 peer = group->conf;
3813 }
3814
3815 ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
3816 if (ret < 0)
3817 return bgp_vty_return (vty, ret);
3818
3819 if ( ! peer_rsclient_active (peer) )
200df115 3820 {
228da428 3821 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
200df115 3822 listnode_delete (bgp->rsclient, peer);
228da428 3823 peer_unlock (peer); /* peer bgp rsclient reference */
200df115 3824 }
fee0f4c6 3825
b608d5b5 3826 bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
fee0f4c6 3827
3828 return CMD_SUCCESS;
3829}
6b0655a2 3830
718e3744 3831/* neighbor route-server-client. */
3832DEFUN (neighbor_route_server_client,
3833 neighbor_route_server_client_cmd,
3834 NEIGHBOR_CMD2 "route-server-client",
3835 NEIGHBOR_STR
3836 NEIGHBOR_ADDR_STR2
3837 "Configure a neighbor as Route Server client\n")
3838{
fee0f4c6 3839 return peer_rsclient_set_vty (vty, argv[0], bgp_node_afi(vty),
3840 bgp_node_safi(vty));
718e3744 3841}
3842
3843DEFUN (no_neighbor_route_server_client,
3844 no_neighbor_route_server_client_cmd,
3845 NO_NEIGHBOR_CMD2 "route-server-client",
3846 NO_STR
3847 NEIGHBOR_STR
3848 NEIGHBOR_ADDR_STR2
3849 "Configure a neighbor as Route Server client\n")
fee0f4c6 3850{
3851 return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
3852 bgp_node_safi(vty));
3853}
6b0655a2 3854
fee0f4c6 3855DEFUN (neighbor_nexthop_local_unchanged,
3856 neighbor_nexthop_local_unchanged_cmd,
3857 NEIGHBOR_CMD2 "nexthop-local unchanged",
3858 NEIGHBOR_STR
3859 NEIGHBOR_ADDR_STR2
3860 "Configure treatment of outgoing link-local nexthop attribute\n"
3861 "Leave link-local nexthop unchanged for this peer\n")
3862{
3863 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3864 bgp_node_safi (vty),
3865 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
3866}
6b0655a2 3867
fee0f4c6 3868DEFUN (no_neighbor_nexthop_local_unchanged,
3869 no_neighbor_nexthop_local_unchanged_cmd,
3870 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
3871 NO_STR
3872 NEIGHBOR_STR
3873 NEIGHBOR_ADDR_STR2
3874 "Configure treatment of outgoing link-local-nexthop attribute\n"
3875 "Leave link-local nexthop unchanged for this peer\n")
718e3744 3876{
3877 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3878 bgp_node_safi (vty),
fee0f4c6 3879 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
718e3744 3880}
6b0655a2 3881
718e3744 3882DEFUN (neighbor_attr_unchanged,
3883 neighbor_attr_unchanged_cmd,
3884 NEIGHBOR_CMD2 "attribute-unchanged",
3885 NEIGHBOR_STR
3886 NEIGHBOR_ADDR_STR2
3887 "BGP attribute is propagated unchanged to this neighbor\n")
3888{
3889 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3890 bgp_node_safi (vty),
3891 (PEER_FLAG_AS_PATH_UNCHANGED |
3892 PEER_FLAG_NEXTHOP_UNCHANGED |
3893 PEER_FLAG_MED_UNCHANGED));
3894}
3895
3896DEFUN (neighbor_attr_unchanged1,
3897 neighbor_attr_unchanged1_cmd,
3898 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
3899 NEIGHBOR_STR
3900 NEIGHBOR_ADDR_STR2
3901 "BGP attribute is propagated unchanged to this neighbor\n"
3902 "As-path attribute\n"
3903 "Nexthop attribute\n"
3904 "Med attribute\n")
3905{
3906 u_int16_t flags = 0;
3907
3908 if (strncmp (argv[1], "as-path", 1) == 0)
3909 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3910 else if (strncmp (argv[1], "next-hop", 1) == 0)
3911 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3912 else if (strncmp (argv[1], "med", 1) == 0)
3913 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3914
3915 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3916 bgp_node_safi (vty), flags);
3917}
3918
3919DEFUN (neighbor_attr_unchanged2,
3920 neighbor_attr_unchanged2_cmd,
3921 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
3922 NEIGHBOR_STR
3923 NEIGHBOR_ADDR_STR2
3924 "BGP attribute is propagated unchanged to this neighbor\n"
3925 "As-path attribute\n"
3926 "Nexthop attribute\n"
3927 "Med attribute\n")
3928{
3929 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
3930
3931 if (strncmp (argv[1], "next-hop", 1) == 0)
3932 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3933 else if (strncmp (argv[1], "med", 1) == 0)
3934 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3935
3936 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3937 bgp_node_safi (vty), flags);
3938
3939}
3940
3941DEFUN (neighbor_attr_unchanged3,
3942 neighbor_attr_unchanged3_cmd,
3943 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
3944 NEIGHBOR_STR
3945 NEIGHBOR_ADDR_STR2
3946 "BGP attribute is propagated unchanged to this neighbor\n"
3947 "Nexthop attribute\n"
3948 "As-path attribute\n"
3949 "Med attribute\n")
3950{
3951 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
3952
3953 if (strncmp (argv[1], "as-path", 1) == 0)
3954 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3955 else if (strncmp (argv[1], "med", 1) == 0)
3956 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3957
3958 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3959 bgp_node_safi (vty), flags);
3960}
3961
3962DEFUN (neighbor_attr_unchanged4,
3963 neighbor_attr_unchanged4_cmd,
3964 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
3965 NEIGHBOR_STR
3966 NEIGHBOR_ADDR_STR2
3967 "BGP attribute is propagated unchanged to this neighbor\n"
3968 "Med attribute\n"
3969 "As-path attribute\n"
3970 "Nexthop attribute\n")
3971{
3972 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
3973
3974 if (strncmp (argv[1], "as-path", 1) == 0)
3975 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3976 else if (strncmp (argv[1], "next-hop", 1) == 0)
3977 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3978
3979 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3980 bgp_node_safi (vty), flags);
3981}
3982
3983ALIAS (neighbor_attr_unchanged,
3984 neighbor_attr_unchanged5_cmd,
3985 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
3986 NEIGHBOR_STR
3987 NEIGHBOR_ADDR_STR2
3988 "BGP attribute is propagated unchanged to this neighbor\n"
3989 "As-path attribute\n"
3990 "Nexthop attribute\n"
3991 "Med attribute\n")
3992
3993ALIAS (neighbor_attr_unchanged,
3994 neighbor_attr_unchanged6_cmd,
3995 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
3996 NEIGHBOR_STR
3997 NEIGHBOR_ADDR_STR2
3998 "BGP attribute is propagated unchanged to this neighbor\n"
3999 "As-path attribute\n"
4000 "Med attribute\n"
4001 "Nexthop attribute\n")
4002
4003ALIAS (neighbor_attr_unchanged,
4004 neighbor_attr_unchanged7_cmd,
4005 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4006 NEIGHBOR_STR
4007 NEIGHBOR_ADDR_STR2
4008 "BGP attribute is propagated unchanged to this neighbor\n"
4009 "Nexthop attribute\n"
4010 "Med attribute\n"
4011 "As-path attribute\n")
4012
4013ALIAS (neighbor_attr_unchanged,
4014 neighbor_attr_unchanged8_cmd,
4015 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4016 NEIGHBOR_STR
4017 NEIGHBOR_ADDR_STR2
4018 "BGP attribute is propagated unchanged to this neighbor\n"
4019 "Nexthop attribute\n"
4020 "As-path attribute\n"
4021 "Med attribute\n")
4022
4023ALIAS (neighbor_attr_unchanged,
4024 neighbor_attr_unchanged9_cmd,
4025 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4026 NEIGHBOR_STR
4027 NEIGHBOR_ADDR_STR2
4028 "BGP attribute is propagated unchanged to this neighbor\n"
4029 "Med attribute\n"
4030 "Nexthop attribute\n"
4031 "As-path attribute\n")
4032
4033ALIAS (neighbor_attr_unchanged,
4034 neighbor_attr_unchanged10_cmd,
4035 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4036 NEIGHBOR_STR
4037 NEIGHBOR_ADDR_STR2
4038 "BGP attribute is propagated unchanged to this neighbor\n"
4039 "Med attribute\n"
4040 "As-path attribute\n"
4041 "Nexthop attribute\n")
4042
4043DEFUN (no_neighbor_attr_unchanged,
4044 no_neighbor_attr_unchanged_cmd,
4045 NO_NEIGHBOR_CMD2 "attribute-unchanged",
4046 NO_STR
4047 NEIGHBOR_STR
4048 NEIGHBOR_ADDR_STR2
4049 "BGP attribute is propagated unchanged to this neighbor\n")
4050{
4051 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4052 bgp_node_safi (vty),
4053 (PEER_FLAG_AS_PATH_UNCHANGED |
4054 PEER_FLAG_NEXTHOP_UNCHANGED |
4055 PEER_FLAG_MED_UNCHANGED));
4056}
4057
4058DEFUN (no_neighbor_attr_unchanged1,
4059 no_neighbor_attr_unchanged1_cmd,
4060 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
4061 NO_STR
4062 NEIGHBOR_STR
4063 NEIGHBOR_ADDR_STR2
4064 "BGP attribute is propagated unchanged to this neighbor\n"
4065 "As-path attribute\n"
4066 "Nexthop attribute\n"
4067 "Med attribute\n")
4068{
4069 u_int16_t flags = 0;
4070
4071 if (strncmp (argv[1], "as-path", 1) == 0)
4072 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4073 else if (strncmp (argv[1], "next-hop", 1) == 0)
4074 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4075 else if (strncmp (argv[1], "med", 1) == 0)
4076 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4077
4078 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4079 bgp_node_safi (vty), flags);
4080}
4081
4082DEFUN (no_neighbor_attr_unchanged2,
4083 no_neighbor_attr_unchanged2_cmd,
4084 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4085 NO_STR
4086 NEIGHBOR_STR
4087 NEIGHBOR_ADDR_STR2
4088 "BGP attribute is propagated unchanged to this neighbor\n"
4089 "As-path attribute\n"
4090 "Nexthop attribute\n"
4091 "Med attribute\n")
4092{
4093 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4094
4095 if (strncmp (argv[1], "next-hop", 1) == 0)
4096 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4097 else if (strncmp (argv[1], "med", 1) == 0)
4098 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4099
4100 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4101 bgp_node_safi (vty), flags);
4102}
4103
4104DEFUN (no_neighbor_attr_unchanged3,
4105 no_neighbor_attr_unchanged3_cmd,
4106 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4107 NO_STR
4108 NEIGHBOR_STR
4109 NEIGHBOR_ADDR_STR2
4110 "BGP attribute is propagated unchanged to this neighbor\n"
4111 "Nexthop attribute\n"
4112 "As-path attribute\n"
4113 "Med attribute\n")
4114{
4115 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4116
4117 if (strncmp (argv[1], "as-path", 1) == 0)
4118 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4119 else if (strncmp (argv[1], "med", 1) == 0)
4120 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4121
4122 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4123 bgp_node_safi (vty), flags);
4124}
4125
4126DEFUN (no_neighbor_attr_unchanged4,
4127 no_neighbor_attr_unchanged4_cmd,
4128 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4129 NO_STR
4130 NEIGHBOR_STR
4131 NEIGHBOR_ADDR_STR2
4132 "BGP attribute is propagated unchanged to this neighbor\n"
4133 "Med attribute\n"
4134 "As-path attribute\n"
4135 "Nexthop attribute\n")
4136{
4137 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4138
4139 if (strncmp (argv[1], "as-path", 1) == 0)
4140 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4141 else if (strncmp (argv[1], "next-hop", 1) == 0)
4142 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4143
4144 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4145 bgp_node_safi (vty), flags);
4146}
4147
4148ALIAS (no_neighbor_attr_unchanged,
4149 no_neighbor_attr_unchanged5_cmd,
4150 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4151 NO_STR
4152 NEIGHBOR_STR
4153 NEIGHBOR_ADDR_STR2
4154 "BGP attribute is propagated unchanged to this neighbor\n"
4155 "As-path attribute\n"
4156 "Nexthop attribute\n"
4157 "Med attribute\n")
4158
4159ALIAS (no_neighbor_attr_unchanged,
4160 no_neighbor_attr_unchanged6_cmd,
4161 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4162 NO_STR
4163 NEIGHBOR_STR
4164 NEIGHBOR_ADDR_STR2
4165 "BGP attribute is propagated unchanged to this neighbor\n"
4166 "As-path attribute\n"
4167 "Med attribute\n"
4168 "Nexthop attribute\n")
4169
4170ALIAS (no_neighbor_attr_unchanged,
4171 no_neighbor_attr_unchanged7_cmd,
4172 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4173 NO_STR
4174 NEIGHBOR_STR
4175 NEIGHBOR_ADDR_STR2
4176 "BGP attribute is propagated unchanged to this neighbor\n"
4177 "Nexthop attribute\n"
4178 "Med attribute\n"
4179 "As-path attribute\n")
4180
4181ALIAS (no_neighbor_attr_unchanged,
4182 no_neighbor_attr_unchanged8_cmd,
4183 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4184 NO_STR
4185 NEIGHBOR_STR
4186 NEIGHBOR_ADDR_STR2
4187 "BGP attribute is propagated unchanged to this neighbor\n"
4188 "Nexthop attribute\n"
4189 "As-path attribute\n"
4190 "Med attribute\n")
4191
4192ALIAS (no_neighbor_attr_unchanged,
4193 no_neighbor_attr_unchanged9_cmd,
4194 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4195 NO_STR
4196 NEIGHBOR_STR
4197 NEIGHBOR_ADDR_STR2
4198 "BGP attribute is propagated unchanged to this neighbor\n"
4199 "Med attribute\n"
4200 "Nexthop attribute\n"
4201 "As-path attribute\n")
4202
4203ALIAS (no_neighbor_attr_unchanged,
4204 no_neighbor_attr_unchanged10_cmd,
4205 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4206 NO_STR
4207 NEIGHBOR_STR
4208 NEIGHBOR_ADDR_STR2
4209 "BGP attribute is propagated unchanged to this neighbor\n"
4210 "Med attribute\n"
4211 "As-path attribute\n"
4212 "Nexthop attribute\n")
4213
4214/* For old version Zebra compatibility. */
dd4c593f 4215DEFUN_DEPRECATED (neighbor_transparent_as,
4216 neighbor_transparent_as_cmd,
4217 NEIGHBOR_CMD "transparent-as",
4218 NEIGHBOR_STR
4219 NEIGHBOR_ADDR_STR
4220 "Do not append my AS number even peer is EBGP peer\n")
718e3744 4221{
4222 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4223 bgp_node_safi (vty),
4224 PEER_FLAG_AS_PATH_UNCHANGED);
4225}
4226
dd4c593f 4227DEFUN_DEPRECATED (neighbor_transparent_nexthop,
4228 neighbor_transparent_nexthop_cmd,
4229 NEIGHBOR_CMD "transparent-nexthop",
4230 NEIGHBOR_STR
4231 NEIGHBOR_ADDR_STR
4232 "Do not change nexthop even peer is EBGP peer\n")
718e3744 4233{
4234 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4235 bgp_node_safi (vty),
4236 PEER_FLAG_NEXTHOP_UNCHANGED);
4237}
6b0655a2 4238
718e3744 4239/* EBGP multihop configuration. */
94f2b392 4240static int
fd79ac91 4241peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
4242 const char *ttl_str)
718e3744 4243{
4244 struct peer *peer;
fd79ac91 4245 unsigned int ttl;
718e3744 4246
4247 peer = peer_and_group_lookup_vty (vty, ip_str);
4248 if (! peer)
4249 return CMD_WARNING;
4250
4251 if (! ttl_str)
4252 ttl = TTL_MAX;
4253 else
4254 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
4255
89b6d1f8 4256 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
718e3744 4257}
4258
94f2b392 4259static int
fd79ac91 4260peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4261{
4262 struct peer *peer;
4263
4264 peer = peer_and_group_lookup_vty (vty, ip_str);
4265 if (! peer)
4266 return CMD_WARNING;
4267
89b6d1f8 4268 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
718e3744 4269}
4270
4271/* neighbor ebgp-multihop. */
4272DEFUN (neighbor_ebgp_multihop,
4273 neighbor_ebgp_multihop_cmd,
4274 NEIGHBOR_CMD2 "ebgp-multihop",
4275 NEIGHBOR_STR
4276 NEIGHBOR_ADDR_STR2
4277 "Allow EBGP neighbors not on directly connected networks\n")
4278{
4279 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
4280}
4281
4282DEFUN (neighbor_ebgp_multihop_ttl,
4283 neighbor_ebgp_multihop_ttl_cmd,
4284 NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
4285 NEIGHBOR_STR
4286 NEIGHBOR_ADDR_STR2
4287 "Allow EBGP neighbors not on directly connected networks\n"
4288 "maximum hop count\n")
4289{
4290 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
4291}
4292
4293DEFUN (no_neighbor_ebgp_multihop,
4294 no_neighbor_ebgp_multihop_cmd,
4295 NO_NEIGHBOR_CMD2 "ebgp-multihop",
4296 NO_STR
4297 NEIGHBOR_STR
4298 NEIGHBOR_ADDR_STR2
4299 "Allow EBGP neighbors not on directly connected networks\n")
4300{
4301 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
4302}
4303
4304ALIAS (no_neighbor_ebgp_multihop,
4305 no_neighbor_ebgp_multihop_ttl_cmd,
4306 NO_NEIGHBOR_CMD2 "ebgp-multihop <1-255>",
4307 NO_STR
4308 NEIGHBOR_STR
4309 NEIGHBOR_ADDR_STR2
4310 "Allow EBGP neighbors not on directly connected networks\n"
4311 "maximum hop count\n")
6b0655a2 4312
6ffd2079 4313/* disable-connected-check */
4314DEFUN (neighbor_disable_connected_check,
4315 neighbor_disable_connected_check_cmd,
4316 NEIGHBOR_CMD2 "disable-connected-check",
4317 NEIGHBOR_STR
4318 NEIGHBOR_ADDR_STR2
4319 "one-hop away EBGP peer using loopback address\n")
4320{
4321 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4322}
4323
4324DEFUN (no_neighbor_disable_connected_check,
4325 no_neighbor_disable_connected_check_cmd,
4326 NO_NEIGHBOR_CMD2 "disable-connected-check",
4327 NO_STR
4328 NEIGHBOR_STR
4329 NEIGHBOR_ADDR_STR2
4330 "one-hop away EBGP peer using loopback address\n")
4331{
4332 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4333}
4334
718e3744 4335/* Enforce multihop. */
6ffd2079 4336ALIAS (neighbor_disable_connected_check,
718e3744 4337 neighbor_enforce_multihop_cmd,
4338 NEIGHBOR_CMD2 "enforce-multihop",
4339 NEIGHBOR_STR
4340 NEIGHBOR_ADDR_STR2
e8e1946e 4341 "Enforce EBGP neighbors perform multihop\n")
718e3744 4342
6ffd2079 4343/* Enforce multihop. */
4344ALIAS (no_neighbor_disable_connected_check,
718e3744 4345 no_neighbor_enforce_multihop_cmd,
4346 NO_NEIGHBOR_CMD2 "enforce-multihop",
4347 NO_STR
4348 NEIGHBOR_STR
4349 NEIGHBOR_ADDR_STR2
e8e1946e 4350 "Enforce EBGP neighbors perform multihop\n")
6b0655a2 4351
718e3744 4352DEFUN (neighbor_description,
4353 neighbor_description_cmd,
4354 NEIGHBOR_CMD2 "description .LINE",
4355 NEIGHBOR_STR
4356 NEIGHBOR_ADDR_STR2
4357 "Neighbor specific description\n"
4358 "Up to 80 characters describing this neighbor\n")
4359{
4360 struct peer *peer;
718e3744 4361 char *str;
718e3744 4362
4363 peer = peer_and_group_lookup_vty (vty, argv[0]);
4364 if (! peer)
4365 return CMD_WARNING;
4366
4367 if (argc == 1)
4368 return CMD_SUCCESS;
4369
3b8b1855 4370 str = argv_concat(argv, argc, 1);
718e3744 4371
4372 peer_description_set (peer, str);
4373
3b8b1855 4374 XFREE (MTYPE_TMP, str);
718e3744 4375
4376 return CMD_SUCCESS;
4377}
4378
4379DEFUN (no_neighbor_description,
4380 no_neighbor_description_cmd,
4381 NO_NEIGHBOR_CMD2 "description",
4382 NO_STR
4383 NEIGHBOR_STR
4384 NEIGHBOR_ADDR_STR2
4385 "Neighbor specific description\n")
4386{
4387 struct peer *peer;
4388
4389 peer = peer_and_group_lookup_vty (vty, argv[0]);
4390 if (! peer)
4391 return CMD_WARNING;
4392
4393 peer_description_unset (peer);
4394
4395 return CMD_SUCCESS;
4396}
4397
4398ALIAS (no_neighbor_description,
4399 no_neighbor_description_val_cmd,
4400 NO_NEIGHBOR_CMD2 "description .LINE",
4401 NO_STR
4402 NEIGHBOR_STR
4403 NEIGHBOR_ADDR_STR2
4404 "Neighbor specific description\n"
4405 "Up to 80 characters describing this neighbor\n")
6b0655a2 4406
718e3744 4407/* Neighbor update-source. */
94f2b392 4408static int
fd79ac91 4409peer_update_source_vty (struct vty *vty, const char *peer_str,
4410 const char *source_str)
718e3744 4411{
4412 struct peer *peer;
718e3744 4413
4414 peer = peer_and_group_lookup_vty (vty, peer_str);
4415 if (! peer)
4416 return CMD_WARNING;
4417
a80beece
DS
4418 if (peer->conf_if)
4419 return CMD_WARNING;
4420
718e3744 4421 if (source_str)
4422 {
c63b83fe
JBD
4423 union sockunion su;
4424 int ret = str2sockunion (source_str, &su);
4425
4426 if (ret == 0)
4427 peer_update_source_addr_set (peer, &su);
718e3744 4428 else
4429 peer_update_source_if_set (peer, source_str);
4430 }
4431 else
4432 peer_update_source_unset (peer);
4433
4434 return CMD_SUCCESS;
4435}
4436
dcb52bd5
DS
4437#define BGP_UPDATE_SOURCE_STR "A.B.C.D|X:X::X:X|WORD"
4438#define BGP_UPDATE_SOURCE_REQ_STR "(" BGP_UPDATE_SOURCE_STR ")"
4439#define BGP_UPDATE_SOURCE_OPT_STR "{" BGP_UPDATE_SOURCE_STR "}"
369688c0
PJ
4440#define BGP_UPDATE_SOURCE_HELP_STR \
4441 "IPv4 address\n" \
9a1a331d
PJ
4442 "IPv6 address\n" \
4443 "Interface name (requires zebra to be running)\n"
369688c0 4444
718e3744 4445DEFUN (neighbor_update_source,
4446 neighbor_update_source_cmd,
dcb52bd5 4447 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_REQ_STR,
718e3744 4448 NEIGHBOR_STR
4449 NEIGHBOR_ADDR_STR2
4450 "Source of routing updates\n"
369688c0 4451 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4452{
4453 return peer_update_source_vty (vty, argv[0], argv[1]);
4454}
4455
4456DEFUN (no_neighbor_update_source,
4457 no_neighbor_update_source_cmd,
dcb52bd5 4458 NO_NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_OPT_STR,
718e3744 4459 NO_STR
4460 NEIGHBOR_STR
4461 NEIGHBOR_ADDR_STR2
dcb52bd5
DS
4462 "Source of routing updates\n"
4463 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4464{
4465 return peer_update_source_vty (vty, argv[0], NULL);
4466}
6b0655a2 4467
94f2b392 4468static int
fd79ac91 4469peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4470 afi_t afi, safi_t safi,
4471 const char *rmap, int set)
718e3744 4472{
4473 int ret;
4474 struct peer *peer;
4475
4476 peer = peer_and_group_lookup_vty (vty, peer_str);
4477 if (! peer)
4478 return CMD_WARNING;
4479
4480 if (set)
4481 ret = peer_default_originate_set (peer, afi, safi, rmap);
4482 else
4483 ret = peer_default_originate_unset (peer, afi, safi);
4484
4485 return bgp_vty_return (vty, ret);
4486}
4487
4488/* neighbor default-originate. */
4489DEFUN (neighbor_default_originate,
4490 neighbor_default_originate_cmd,
4491 NEIGHBOR_CMD2 "default-originate",
4492 NEIGHBOR_STR
4493 NEIGHBOR_ADDR_STR2
4494 "Originate default route to this neighbor\n")
4495{
4496 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4497 bgp_node_safi (vty), NULL, 1);
4498}
4499
4500DEFUN (neighbor_default_originate_rmap,
4501 neighbor_default_originate_rmap_cmd,
4502 NEIGHBOR_CMD2 "default-originate route-map WORD",
4503 NEIGHBOR_STR
4504 NEIGHBOR_ADDR_STR2
4505 "Originate default route to this neighbor\n"
4506 "Route-map to specify criteria to originate default\n"
4507 "route-map name\n")
4508{
4509 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4510 bgp_node_safi (vty), argv[1], 1);
4511}
4512
4513DEFUN (no_neighbor_default_originate,
4514 no_neighbor_default_originate_cmd,
4515 NO_NEIGHBOR_CMD2 "default-originate",
4516 NO_STR
4517 NEIGHBOR_STR
4518 NEIGHBOR_ADDR_STR2
4519 "Originate default route to this neighbor\n")
4520{
4521 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4522 bgp_node_safi (vty), NULL, 0);
4523}
4524
4525ALIAS (no_neighbor_default_originate,
4526 no_neighbor_default_originate_rmap_cmd,
4527 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
4528 NO_STR
4529 NEIGHBOR_STR
4530 NEIGHBOR_ADDR_STR2
4531 "Originate default route to this neighbor\n"
4532 "Route-map to specify criteria to originate default\n"
4533 "route-map name\n")
6b0655a2 4534
718e3744 4535/* Set neighbor's BGP port. */
94f2b392 4536static int
fd79ac91 4537peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4538 const char *port_str)
718e3744 4539{
4540 struct peer *peer;
4541 u_int16_t port;
4542 struct servent *sp;
4543
4544 peer = peer_lookup_vty (vty, ip_str);
4545 if (! peer)
4546 return CMD_WARNING;
4547
4548 if (! port_str)
4549 {
4550 sp = getservbyname ("bgp", "tcp");
4551 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4552 }
4553 else
4554 {
4555 VTY_GET_INTEGER("port", port, port_str);
4556 }
4557
4558 peer_port_set (peer, port);
4559
4560 return CMD_SUCCESS;
4561}
4562
f418446b 4563/* Set specified peer's BGP port. */
718e3744 4564DEFUN (neighbor_port,
4565 neighbor_port_cmd,
4566 NEIGHBOR_CMD "port <0-65535>",
4567 NEIGHBOR_STR
4568 NEIGHBOR_ADDR_STR
4569 "Neighbor's BGP port\n"
4570 "TCP port number\n")
4571{
4572 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
4573}
4574
4575DEFUN (no_neighbor_port,
4576 no_neighbor_port_cmd,
4577 NO_NEIGHBOR_CMD "port",
4578 NO_STR
4579 NEIGHBOR_STR
4580 NEIGHBOR_ADDR_STR
4581 "Neighbor's BGP port\n")
4582{
4583 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
4584}
4585
4586ALIAS (no_neighbor_port,
4587 no_neighbor_port_val_cmd,
4588 NO_NEIGHBOR_CMD "port <0-65535>",
4589 NO_STR
4590 NEIGHBOR_STR
4591 NEIGHBOR_ADDR_STR
4592 "Neighbor's BGP port\n"
4593 "TCP port number\n")
6b0655a2 4594
718e3744 4595/* neighbor weight. */
94f2b392 4596static int
fd79ac91 4597peer_weight_set_vty (struct vty *vty, const char *ip_str,
4598 const char *weight_str)
718e3744 4599{
718e3744 4600 struct peer *peer;
4601 unsigned long weight;
4602
4603 peer = peer_and_group_lookup_vty (vty, ip_str);
4604 if (! peer)
4605 return CMD_WARNING;
4606
4607 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4608
ffd0c037 4609 peer_weight_set (peer, weight);
718e3744 4610
4611 return CMD_SUCCESS;
4612}
4613
94f2b392 4614static int
fd79ac91 4615peer_weight_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4616{
4617 struct peer *peer;
4618
4619 peer = peer_and_group_lookup_vty (vty, ip_str);
4620 if (! peer)
4621 return CMD_WARNING;
4622
4623 peer_weight_unset (peer);
4624
4625 return CMD_SUCCESS;
4626}
4627
4628DEFUN (neighbor_weight,
4629 neighbor_weight_cmd,
4630 NEIGHBOR_CMD2 "weight <0-65535>",
4631 NEIGHBOR_STR
4632 NEIGHBOR_ADDR_STR2
4633 "Set default weight for routes from this neighbor\n"
4634 "default weight\n")
4635{
4636 return peer_weight_set_vty (vty, argv[0], argv[1]);
4637}
4638
4639DEFUN (no_neighbor_weight,
4640 no_neighbor_weight_cmd,
4641 NO_NEIGHBOR_CMD2 "weight",
4642 NO_STR
4643 NEIGHBOR_STR
4644 NEIGHBOR_ADDR_STR2
4645 "Set default weight for routes from this neighbor\n")
4646{
4647 return peer_weight_unset_vty (vty, argv[0]);
4648}
4649
4650ALIAS (no_neighbor_weight,
4651 no_neighbor_weight_val_cmd,
4652 NO_NEIGHBOR_CMD2 "weight <0-65535>",
4653 NO_STR
4654 NEIGHBOR_STR
4655 NEIGHBOR_ADDR_STR2
4656 "Set default weight for routes from this neighbor\n"
4657 "default weight\n")
6b0655a2 4658
718e3744 4659/* Override capability negotiation. */
4660DEFUN (neighbor_override_capability,
4661 neighbor_override_capability_cmd,
4662 NEIGHBOR_CMD2 "override-capability",
4663 NEIGHBOR_STR
4664 NEIGHBOR_ADDR_STR2
4665 "Override capability negotiation result\n")
4666{
4667 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4668}
4669
4670DEFUN (no_neighbor_override_capability,
4671 no_neighbor_override_capability_cmd,
4672 NO_NEIGHBOR_CMD2 "override-capability",
4673 NO_STR
4674 NEIGHBOR_STR
4675 NEIGHBOR_ADDR_STR2
4676 "Override capability negotiation result\n")
4677{
4678 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4679}
6b0655a2 4680
718e3744 4681DEFUN (neighbor_strict_capability,
4682 neighbor_strict_capability_cmd,
4683 NEIGHBOR_CMD "strict-capability-match",
4684 NEIGHBOR_STR
4685 NEIGHBOR_ADDR_STR
4686 "Strict capability negotiation match\n")
4687{
4688 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4689}
4690
4691DEFUN (no_neighbor_strict_capability,
4692 no_neighbor_strict_capability_cmd,
4693 NO_NEIGHBOR_CMD "strict-capability-match",
4694 NO_STR
4695 NEIGHBOR_STR
4696 NEIGHBOR_ADDR_STR
4697 "Strict capability negotiation match\n")
4698{
4699 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4700}
6b0655a2 4701
94f2b392 4702static int
fd79ac91 4703peer_timers_set_vty (struct vty *vty, const char *ip_str,
4704 const char *keep_str, const char *hold_str)
718e3744 4705{
4706 int ret;
4707 struct peer *peer;
4708 u_int32_t keepalive;
4709 u_int32_t holdtime;
4710
4711 peer = peer_and_group_lookup_vty (vty, ip_str);
4712 if (! peer)
4713 return CMD_WARNING;
4714
4715 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
4716 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
4717
4718 ret = peer_timers_set (peer, keepalive, holdtime);
4719
4720 return bgp_vty_return (vty, ret);
4721}
6b0655a2 4722
94f2b392 4723static int
fd79ac91 4724peer_timers_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4725{
4726 int ret;
4727 struct peer *peer;
4728
4729 peer = peer_lookup_vty (vty, ip_str);
4730 if (! peer)
4731 return CMD_WARNING;
4732
4733 ret = peer_timers_unset (peer);
4734
4735 return bgp_vty_return (vty, ret);
4736}
4737
4738DEFUN (neighbor_timers,
4739 neighbor_timers_cmd,
4740 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4741 NEIGHBOR_STR
4742 NEIGHBOR_ADDR_STR2
4743 "BGP per neighbor timers\n"
4744 "Keepalive interval\n"
4745 "Holdtime\n")
4746{
4747 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
4748}
4749
4750DEFUN (no_neighbor_timers,
4751 no_neighbor_timers_cmd,
4752 NO_NEIGHBOR_CMD2 "timers",
4753 NO_STR
4754 NEIGHBOR_STR
4755 NEIGHBOR_ADDR_STR2
4756 "BGP per neighbor timers\n")
4757{
4758 return peer_timers_unset_vty (vty, argv[0]);
4759}
6b0655a2 4760
94f2b392 4761static int
fd79ac91 4762peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
4763 const char *time_str)
718e3744 4764{
4765 int ret;
4766 struct peer *peer;
4767 u_int32_t connect;
4768
966f821c 4769 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4770 if (! peer)
4771 return CMD_WARNING;
4772
4773 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
4774
4775 ret = peer_timers_connect_set (peer, connect);
4776
966f821c 4777 return bgp_vty_return (vty, ret);
718e3744 4778}
4779
94f2b392 4780static int
fd79ac91 4781peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4782{
4783 int ret;
4784 struct peer *peer;
4785
4786 peer = peer_and_group_lookup_vty (vty, ip_str);
4787 if (! peer)
4788 return CMD_WARNING;
4789
4790 ret = peer_timers_connect_unset (peer);
4791
966f821c 4792 return bgp_vty_return (vty, ret);
718e3744 4793}
4794
4795DEFUN (neighbor_timers_connect,
4796 neighbor_timers_connect_cmd,
966f821c 4797 NEIGHBOR_CMD2 "timers connect <0-65535>",
718e3744 4798 NEIGHBOR_STR
966f821c 4799 NEIGHBOR_ADDR_STR2
718e3744 4800 "BGP per neighbor timers\n"
4801 "BGP connect timer\n"
4802 "Connect timer\n")
4803{
4804 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
4805}
4806
4807DEFUN (no_neighbor_timers_connect,
4808 no_neighbor_timers_connect_cmd,
966f821c 4809 NO_NEIGHBOR_CMD2 "timers connect",
718e3744 4810 NO_STR
4811 NEIGHBOR_STR
966f821c 4812 NEIGHBOR_ADDR_STR2
718e3744 4813 "BGP per neighbor timers\n"
4814 "BGP connect timer\n")
4815{
4816 return peer_timers_connect_unset_vty (vty, argv[0]);
4817}
4818
4819ALIAS (no_neighbor_timers_connect,
4820 no_neighbor_timers_connect_val_cmd,
966f821c 4821 NO_NEIGHBOR_CMD2 "timers connect <0-65535>",
718e3744 4822 NO_STR
4823 NEIGHBOR_STR
966f821c 4824 NEIGHBOR_ADDR_STR2
718e3744 4825 "BGP per neighbor timers\n"
4826 "BGP connect timer\n"
4827 "Connect timer\n")
6b0655a2 4828
94f2b392 4829static int
fd79ac91 4830peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
4831 const char *time_str, int set)
718e3744 4832{
4833 int ret;
4834 struct peer *peer;
4835 u_int32_t routeadv = 0;
4836
966f821c 4837 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 4838 if (! peer)
4839 return CMD_WARNING;
4840
4841 if (time_str)
4842 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
4843
4844 if (set)
4845 ret = peer_advertise_interval_set (peer, routeadv);
4846 else
4847 ret = peer_advertise_interval_unset (peer);
4848
966f821c 4849 return bgp_vty_return (vty, ret);
718e3744 4850}
4851
4852DEFUN (neighbor_advertise_interval,
4853 neighbor_advertise_interval_cmd,
966f821c 4854 NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4855 NEIGHBOR_STR
966f821c 4856 NEIGHBOR_ADDR_STR2
718e3744 4857 "Minimum interval between sending BGP routing updates\n"
4858 "time in seconds\n")
4859{
4860 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
4861}
4862
4863DEFUN (no_neighbor_advertise_interval,
4864 no_neighbor_advertise_interval_cmd,
966f821c 4865 NO_NEIGHBOR_CMD2 "advertisement-interval",
718e3744 4866 NO_STR
4867 NEIGHBOR_STR
966f821c 4868 NEIGHBOR_ADDR_STR2
718e3744 4869 "Minimum interval between sending BGP routing updates\n")
4870{
4871 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
4872}
4873
4874ALIAS (no_neighbor_advertise_interval,
4875 no_neighbor_advertise_interval_val_cmd,
966f821c 4876 NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
718e3744 4877 NO_STR
4878 NEIGHBOR_STR
966f821c 4879 NEIGHBOR_ADDR_STR2
718e3744 4880 "Minimum interval between sending BGP routing updates\n"
4881 "time in seconds\n")
6b0655a2 4882
518f0eb1
DS
4883/* Time to wait before processing route-map updates */
4884DEFUN (bgp_set_route_map_delay_timer,
4885 bgp_set_route_map_delay_timer_cmd,
4886 "bgp route-map delay-timer <0-600>",
4887 SET_STR
4888 "BGP route-map delay timer\n"
4889 "Time in secs to wait before processing route-map changes\n"
f414725f 4890 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1
DS
4891{
4892 u_int32_t rmap_delay_timer;
4893 struct bgp *bgp;
4894
4895 bgp = vty->index;
4896 if (argv[0])
4897 {
4898 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
4899 bgp->rmap_update_timer = rmap_delay_timer;
4900
4901 /* if the dynamic update handling is being disabled, and a timer is
4902 * running, stop the timer and act as if the timer has already fired.
4903 */
4904 if (!rmap_delay_timer && bgp->t_rmap_update )
4905 {
4906 BGP_TIMER_OFF(bgp->t_rmap_update);
4907 thread_execute (bm->master, bgp_route_map_update_timer, &bgp, 0);
4908 }
4909 return CMD_SUCCESS;
4910 }
4911 else
ffd0c037 4912 return CMD_WARNING;
518f0eb1
DS
4913}
4914
4915DEFUN (no_bgp_set_route_map_delay_timer,
4916 no_bgp_set_route_map_delay_timer_cmd,
4917 "no bgp route-map delay-timer",
4918 NO_STR
4919 "Default BGP route-map delay timer\n"
f414725f 4920 "Reset to default time to wait for processing route-map changes\n")
518f0eb1 4921{
518f0eb1
DS
4922 struct bgp *bgp;
4923
4924 bgp = vty->index;
4925 bgp->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
4926
4927 return CMD_SUCCESS;
4928}
4929
f414725f
DS
4930ALIAS (no_bgp_set_route_map_delay_timer,
4931 no_bgp_set_route_map_delay_timer_val_cmd,
4932 "no bgp route-map delay-timer <0-600>",
4933 NO_STR
4934 "Default BGP route-map delay timer\n"
4935 "Reset to default time to wait for processing route-map changes\n"
4936 "0 disables the timer, no route updates happen when route-maps change\n")
4937
718e3744 4938/* neighbor interface */
94f2b392 4939static int
fd79ac91 4940peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
718e3744 4941{
718e3744 4942 struct peer *peer;
4943
4944 peer = peer_lookup_vty (vty, ip_str);
a80beece 4945 if (! peer || peer->conf_if)
718e3744 4946 return CMD_WARNING;
4947
4948 if (str)
ffd0c037 4949 peer_interface_set (peer, str);
718e3744 4950 else
ffd0c037 4951 peer_interface_unset (peer);
718e3744 4952
4953 return CMD_SUCCESS;
4954}
4955
4956DEFUN (neighbor_interface,
4957 neighbor_interface_cmd,
4958 NEIGHBOR_CMD "interface WORD",
4959 NEIGHBOR_STR
4960 NEIGHBOR_ADDR_STR
4961 "Interface\n"
4962 "Interface name\n")
4963{
8ffedcea
DS
4964 if (argc == 3)
4965 return peer_interface_vty (vty, argv[0], argv[1]);
4966 else
4967 return peer_interface_vty (vty, argv[0], argv[1]);
718e3744 4968}
4969
4970DEFUN (no_neighbor_interface,
4971 no_neighbor_interface_cmd,
8ffedcea 4972 NO_NEIGHBOR_CMD2 "interface WORD",
718e3744 4973 NO_STR
4974 NEIGHBOR_STR
4975 NEIGHBOR_ADDR_STR
4976 "Interface\n"
4977 "Interface name\n")
4978{
4979 return peer_interface_vty (vty, argv[0], NULL);
4980}
6b0655a2 4981
718e3744 4982/* Set distribute list to the peer. */
94f2b392 4983static int
fd79ac91 4984peer_distribute_set_vty (struct vty *vty, const char *ip_str,
4985 afi_t afi, safi_t safi,
4986 const char *name_str, const char *direct_str)
718e3744 4987{
4988 int ret;
4989 struct peer *peer;
4990 int direct = FILTER_IN;
4991
4992 peer = peer_and_group_lookup_vty (vty, ip_str);
4993 if (! peer)
4994 return CMD_WARNING;
4995
4996 /* Check filter direction. */
4997 if (strncmp (direct_str, "i", 1) == 0)
4998 direct = FILTER_IN;
4999 else if (strncmp (direct_str, "o", 1) == 0)
5000 direct = FILTER_OUT;
5001
5002 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5003
5004 return bgp_vty_return (vty, ret);
5005}
5006
94f2b392 5007static int
fd79ac91 5008peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5009 safi_t safi, const char *direct_str)
718e3744 5010{
5011 int ret;
5012 struct peer *peer;
5013 int direct = FILTER_IN;
5014
5015 peer = peer_and_group_lookup_vty (vty, ip_str);
5016 if (! peer)
5017 return CMD_WARNING;
5018
5019 /* Check filter direction. */
5020 if (strncmp (direct_str, "i", 1) == 0)
5021 direct = FILTER_IN;
5022 else if (strncmp (direct_str, "o", 1) == 0)
5023 direct = FILTER_OUT;
5024
5025 ret = peer_distribute_unset (peer, afi, safi, direct);
5026
5027 return bgp_vty_return (vty, ret);
5028}
5029
5030DEFUN (neighbor_distribute_list,
5031 neighbor_distribute_list_cmd,
5032 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5033 NEIGHBOR_STR
5034 NEIGHBOR_ADDR_STR2
5035 "Filter updates to/from this neighbor\n"
5036 "IP access-list number\n"
5037 "IP access-list number (expanded range)\n"
5038 "IP Access-list name\n"
5039 "Filter incoming updates\n"
5040 "Filter outgoing updates\n")
5041{
5042 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
5043 bgp_node_safi (vty), argv[1], argv[2]);
5044}
5045
5046DEFUN (no_neighbor_distribute_list,
5047 no_neighbor_distribute_list_cmd,
5048 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5049 NO_STR
5050 NEIGHBOR_STR
5051 NEIGHBOR_ADDR_STR2
5052 "Filter updates to/from this neighbor\n"
5053 "IP access-list number\n"
5054 "IP access-list number (expanded range)\n"
5055 "IP Access-list name\n"
5056 "Filter incoming updates\n"
5057 "Filter outgoing updates\n")
5058{
5059 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
5060 bgp_node_safi (vty), argv[2]);
5061}
6b0655a2 5062
718e3744 5063/* Set prefix list to the peer. */
94f2b392 5064static int
fd79ac91 5065peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5066 safi_t safi, const char *name_str,
5067 const char *direct_str)
718e3744 5068{
5069 int ret;
5070 struct peer *peer;
5071 int direct = FILTER_IN;
5072
5073 peer = peer_and_group_lookup_vty (vty, ip_str);
5074 if (! peer)
5075 return CMD_WARNING;
5076
5077 /* Check filter direction. */
5078 if (strncmp (direct_str, "i", 1) == 0)
5079 direct = FILTER_IN;
5080 else if (strncmp (direct_str, "o", 1) == 0)
5081 direct = FILTER_OUT;
5082
5083 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5084
5085 return bgp_vty_return (vty, ret);
5086}
5087
94f2b392 5088static int
fd79ac91 5089peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5090 safi_t safi, const char *direct_str)
718e3744 5091{
5092 int ret;
5093 struct peer *peer;
5094 int direct = FILTER_IN;
5095
5096 peer = peer_and_group_lookup_vty (vty, ip_str);
5097 if (! peer)
5098 return CMD_WARNING;
5099
5100 /* Check filter direction. */
5101 if (strncmp (direct_str, "i", 1) == 0)
5102 direct = FILTER_IN;
5103 else if (strncmp (direct_str, "o", 1) == 0)
5104 direct = FILTER_OUT;
5105
5106 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5107
5108 return bgp_vty_return (vty, ret);
5109}
5110
5111DEFUN (neighbor_prefix_list,
5112 neighbor_prefix_list_cmd,
5113 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5114 NEIGHBOR_STR
5115 NEIGHBOR_ADDR_STR2
5116 "Filter updates to/from this neighbor\n"
5117 "Name of a prefix list\n"
5118 "Filter incoming updates\n"
5119 "Filter outgoing updates\n")
5120{
5121 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
5122 bgp_node_safi (vty), argv[1], argv[2]);
5123}
5124
5125DEFUN (no_neighbor_prefix_list,
5126 no_neighbor_prefix_list_cmd,
5127 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5128 NO_STR
5129 NEIGHBOR_STR
5130 NEIGHBOR_ADDR_STR2
5131 "Filter updates to/from this neighbor\n"
5132 "Name of a prefix list\n"
5133 "Filter incoming updates\n"
5134 "Filter outgoing updates\n")
5135{
5136 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
5137 bgp_node_safi (vty), argv[2]);
5138}
6b0655a2 5139
94f2b392 5140static int
fd79ac91 5141peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5142 afi_t afi, safi_t safi,
5143 const char *name_str, const char *direct_str)
718e3744 5144{
5145 int ret;
5146 struct peer *peer;
5147 int direct = FILTER_IN;
5148
5149 peer = peer_and_group_lookup_vty (vty, ip_str);
5150 if (! peer)
5151 return CMD_WARNING;
5152
5153 /* Check filter direction. */
5154 if (strncmp (direct_str, "i", 1) == 0)
5155 direct = FILTER_IN;
5156 else if (strncmp (direct_str, "o", 1) == 0)
5157 direct = FILTER_OUT;
5158
5159 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5160
5161 return bgp_vty_return (vty, ret);
5162}
5163
94f2b392 5164static int
fd79ac91 5165peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5166 afi_t afi, safi_t safi,
5167 const char *direct_str)
718e3744 5168{
5169 int ret;
5170 struct peer *peer;
5171 int direct = FILTER_IN;
5172
5173 peer = peer_and_group_lookup_vty (vty, ip_str);
5174 if (! peer)
5175 return CMD_WARNING;
5176
5177 /* Check filter direction. */
5178 if (strncmp (direct_str, "i", 1) == 0)
5179 direct = FILTER_IN;
5180 else if (strncmp (direct_str, "o", 1) == 0)
5181 direct = FILTER_OUT;
5182
5183 ret = peer_aslist_unset (peer, afi, safi, direct);
5184
5185 return bgp_vty_return (vty, ret);
5186}
5187
5188DEFUN (neighbor_filter_list,
5189 neighbor_filter_list_cmd,
5190 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5191 NEIGHBOR_STR
5192 NEIGHBOR_ADDR_STR2
5193 "Establish BGP filters\n"
5194 "AS path access-list name\n"
5195 "Filter incoming routes\n"
5196 "Filter outgoing routes\n")
5197{
5198 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
5199 bgp_node_safi (vty), argv[1], argv[2]);
5200}
5201
5202DEFUN (no_neighbor_filter_list,
5203 no_neighbor_filter_list_cmd,
5204 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5205 NO_STR
5206 NEIGHBOR_STR
5207 NEIGHBOR_ADDR_STR2
5208 "Establish BGP filters\n"
5209 "AS path access-list name\n"
5210 "Filter incoming routes\n"
5211 "Filter outgoing routes\n")
5212{
5213 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
5214 bgp_node_safi (vty), argv[2]);
5215}
6b0655a2 5216
718e3744 5217/* Set route-map to the peer. */
94f2b392 5218static int
fd79ac91 5219peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5220 afi_t afi, safi_t safi,
5221 const char *name_str, const char *direct_str)
718e3744 5222{
5223 int ret;
5224 struct peer *peer;
fee0f4c6 5225 int direct = RMAP_IN;
718e3744 5226
5227 peer = peer_and_group_lookup_vty (vty, ip_str);
5228 if (! peer)
5229 return CMD_WARNING;
5230
5231 /* Check filter direction. */
fee0f4c6 5232 if (strncmp (direct_str, "in", 2) == 0)
5233 direct = RMAP_IN;
718e3744 5234 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5235 direct = RMAP_OUT;
5236 else if (strncmp (direct_str, "im", 2) == 0)
5237 direct = RMAP_IMPORT;
5238 else if (strncmp (direct_str, "e", 1) == 0)
5239 direct = RMAP_EXPORT;
718e3744 5240
5241 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5242
5243 return bgp_vty_return (vty, ret);
5244}
5245
94f2b392 5246static int
fd79ac91 5247peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5248 safi_t safi, const char *direct_str)
718e3744 5249{
5250 int ret;
5251 struct peer *peer;
fee0f4c6 5252 int direct = RMAP_IN;
718e3744 5253
5254 peer = peer_and_group_lookup_vty (vty, ip_str);
5255 if (! peer)
5256 return CMD_WARNING;
5257
5258 /* Check filter direction. */
fee0f4c6 5259 if (strncmp (direct_str, "in", 2) == 0)
5260 direct = RMAP_IN;
718e3744 5261 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5262 direct = RMAP_OUT;
5263 else if (strncmp (direct_str, "im", 2) == 0)
5264 direct = RMAP_IMPORT;
5265 else if (strncmp (direct_str, "e", 1) == 0)
5266 direct = RMAP_EXPORT;
718e3744 5267
5268 ret = peer_route_map_unset (peer, afi, safi, direct);
5269
5270 return bgp_vty_return (vty, ret);
5271}
5272
5273DEFUN (neighbor_route_map,
5274 neighbor_route_map_cmd,
fee0f4c6 5275 NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
718e3744 5276 NEIGHBOR_STR
5277 NEIGHBOR_ADDR_STR2
5278 "Apply route map to neighbor\n"
5279 "Name of route map\n"
5280 "Apply map to incoming routes\n"
fee0f4c6 5281 "Apply map to outbound routes\n"
5282 "Apply map to routes going into a Route-Server client's table\n"
5283 "Apply map to routes coming from a Route-Server client")
718e3744 5284{
5285 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5286 bgp_node_safi (vty), argv[1], argv[2]);
5287}
5288
5289DEFUN (no_neighbor_route_map,
5290 no_neighbor_route_map_cmd,
fee0f4c6 5291 NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
718e3744 5292 NO_STR
5293 NEIGHBOR_STR
5294 NEIGHBOR_ADDR_STR2
5295 "Apply route map to neighbor\n"
5296 "Name of route map\n"
5297 "Apply map to incoming routes\n"
fee0f4c6 5298 "Apply map to outbound routes\n"
5299 "Apply map to routes going into a Route-Server client's table\n"
5300 "Apply map to routes coming from a Route-Server client")
718e3744 5301{
5302 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5303 bgp_node_safi (vty), argv[2]);
5304}
6b0655a2 5305
718e3744 5306/* Set unsuppress-map to the peer. */
94f2b392 5307static int
fd79ac91 5308peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5309 safi_t safi, const char *name_str)
718e3744 5310{
5311 int ret;
5312 struct peer *peer;
5313
5314 peer = peer_and_group_lookup_vty (vty, ip_str);
5315 if (! peer)
5316 return CMD_WARNING;
5317
5318 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5319
5320 return bgp_vty_return (vty, ret);
5321}
5322
5323/* Unset route-map from the peer. */
94f2b392 5324static int
fd79ac91 5325peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5326 safi_t safi)
5327{
5328 int ret;
5329 struct peer *peer;
5330
5331 peer = peer_and_group_lookup_vty (vty, ip_str);
5332 if (! peer)
5333 return CMD_WARNING;
5334
5335 ret = peer_unsuppress_map_unset (peer, afi, safi);
5336
5337 return bgp_vty_return (vty, ret);
5338}
5339
5340DEFUN (neighbor_unsuppress_map,
5341 neighbor_unsuppress_map_cmd,
5342 NEIGHBOR_CMD2 "unsuppress-map WORD",
5343 NEIGHBOR_STR
5344 NEIGHBOR_ADDR_STR2
5345 "Route-map to selectively unsuppress suppressed routes\n"
5346 "Name of route map\n")
5347{
5348 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5349 bgp_node_safi (vty), argv[1]);
5350}
5351
5352DEFUN (no_neighbor_unsuppress_map,
5353 no_neighbor_unsuppress_map_cmd,
5354 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
5355 NO_STR
5356 NEIGHBOR_STR
5357 NEIGHBOR_ADDR_STR2
5358 "Route-map to selectively unsuppress suppressed routes\n"
5359 "Name of route map\n")
5360{
5361 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5362 bgp_node_safi (vty));
5363}
6b0655a2 5364
94f2b392 5365static int
fd79ac91 5366peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5367 safi_t safi, const char *num_str,
0a486e5f 5368 const char *threshold_str, int warning,
5369 const char *restart_str)
718e3744 5370{
5371 int ret;
5372 struct peer *peer;
5373 u_int32_t max;
e0701b79 5374 u_char threshold;
0a486e5f 5375 u_int16_t restart;
718e3744 5376
5377 peer = peer_and_group_lookup_vty (vty, ip_str);
5378 if (! peer)
5379 return CMD_WARNING;
5380
e6ec1c36 5381 VTY_GET_INTEGER ("maximum number", max, num_str);
e0701b79 5382 if (threshold_str)
5383 threshold = atoi (threshold_str);
5384 else
5385 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
718e3744 5386
0a486e5f 5387 if (restart_str)
5388 restart = atoi (restart_str);
5389 else
5390 restart = 0;
5391
5392 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
718e3744 5393
5394 return bgp_vty_return (vty, ret);
5395}
5396
94f2b392 5397static int
fd79ac91 5398peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5399 safi_t safi)
5400{
5401 int ret;
5402 struct peer *peer;
5403
5404 peer = peer_and_group_lookup_vty (vty, ip_str);
5405 if (! peer)
5406 return CMD_WARNING;
5407
5408 ret = peer_maximum_prefix_unset (peer, afi, safi);
5409
5410 return bgp_vty_return (vty, ret);
5411}
5412
5413/* Maximum number of prefix configuration. prefix count is different
5414 for each peer configuration. So this configuration can be set for
5415 each peer configuration. */
5416DEFUN (neighbor_maximum_prefix,
5417 neighbor_maximum_prefix_cmd,
5418 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5419 NEIGHBOR_STR
5420 NEIGHBOR_ADDR_STR2
5421 "Maximum number of prefix accept from this peer\n"
5422 "maximum no. of prefix limit\n")
5423{
5424 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5425 bgp_node_safi (vty), argv[1], NULL, 0,
5426 NULL);
718e3744 5427}
5428
e0701b79 5429DEFUN (neighbor_maximum_prefix_threshold,
5430 neighbor_maximum_prefix_threshold_cmd,
5431 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5432 NEIGHBOR_STR
5433 NEIGHBOR_ADDR_STR2
5434 "Maximum number of prefix accept from this peer\n"
5435 "maximum no. of prefix limit\n"
5436 "Threshold value (%) at which to generate a warning msg\n")
5437{
5438 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5439 bgp_node_safi (vty), argv[1], argv[2], 0,
5440 NULL);
5441}
e0701b79 5442
718e3744 5443DEFUN (neighbor_maximum_prefix_warning,
5444 neighbor_maximum_prefix_warning_cmd,
5445 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5446 NEIGHBOR_STR
5447 NEIGHBOR_ADDR_STR2
5448 "Maximum number of prefix accept from this peer\n"
5449 "maximum no. of prefix limit\n"
5450 "Only give warning message when limit is exceeded\n")
5451{
5452 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5453 bgp_node_safi (vty), argv[1], NULL, 1,
5454 NULL);
718e3744 5455}
5456
e0701b79 5457DEFUN (neighbor_maximum_prefix_threshold_warning,
5458 neighbor_maximum_prefix_threshold_warning_cmd,
5459 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5460 NEIGHBOR_STR
5461 NEIGHBOR_ADDR_STR2
5462 "Maximum number of prefix accept from this peer\n"
5463 "maximum no. of prefix limit\n"
5464 "Threshold value (%) at which to generate a warning msg\n"
5465 "Only give warning message when limit is exceeded\n")
5466{
5467 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
0a486e5f 5468 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5469}
5470
5471DEFUN (neighbor_maximum_prefix_restart,
5472 neighbor_maximum_prefix_restart_cmd,
5473 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5474 NEIGHBOR_STR
5475 NEIGHBOR_ADDR_STR2
5476 "Maximum number of prefix accept from this peer\n"
5477 "maximum no. of prefix limit\n"
5478 "Restart bgp connection after limit is exceeded\n"
5479 "Restart interval in minutes")
5480{
5481 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5482 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5483}
5484
5485DEFUN (neighbor_maximum_prefix_threshold_restart,
5486 neighbor_maximum_prefix_threshold_restart_cmd,
5487 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5488 NEIGHBOR_STR
5489 NEIGHBOR_ADDR_STR2
5490 "Maximum number of prefix accept from this peer\n"
5491 "maximum no. of prefix limit\n"
5492 "Threshold value (%) at which to generate a warning msg\n"
5493 "Restart bgp connection after limit is exceeded\n"
5494 "Restart interval in minutes")
5495{
5496 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5497 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5498}
e0701b79 5499
718e3744 5500DEFUN (no_neighbor_maximum_prefix,
5501 no_neighbor_maximum_prefix_cmd,
5502 NO_NEIGHBOR_CMD2 "maximum-prefix",
5503 NO_STR
5504 NEIGHBOR_STR
5505 NEIGHBOR_ADDR_STR2
5506 "Maximum number of prefix accept from this peer\n")
5507{
5508 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5509 bgp_node_safi (vty));
5510}
5511
5512ALIAS (no_neighbor_maximum_prefix,
5513 no_neighbor_maximum_prefix_val_cmd,
5514 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5515 NO_STR
5516 NEIGHBOR_STR
5517 NEIGHBOR_ADDR_STR2
5518 "Maximum number of prefix accept from this peer\n"
5519 "maximum no. of prefix limit\n")
5520
5521ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5522 no_neighbor_maximum_prefix_threshold_cmd,
5523 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5524 NO_STR
5525 NEIGHBOR_STR
5526 NEIGHBOR_ADDR_STR2
5527 "Maximum number of prefix accept from this peer\n"
5528 "maximum no. of prefix limit\n"
5529 "Threshold value (%) at which to generate a warning msg\n")
5530
5531ALIAS (no_neighbor_maximum_prefix,
5532 no_neighbor_maximum_prefix_warning_cmd,
5533 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5534 NO_STR
5535 NEIGHBOR_STR
5536 NEIGHBOR_ADDR_STR2
5537 "Maximum number of prefix accept from this peer\n"
5538 "maximum no. of prefix limit\n"
e8e1946e 5539 "Only give warning message when limit is exceeded\n")
0a486e5f 5540
5541ALIAS (no_neighbor_maximum_prefix,
5542 no_neighbor_maximum_prefix_threshold_warning_cmd,
e0701b79 5543 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5544 NO_STR
5545 NEIGHBOR_STR
5546 NEIGHBOR_ADDR_STR2
5547 "Maximum number of prefix accept from this peer\n"
5548 "maximum no. of prefix limit\n"
5549 "Threshold value (%) at which to generate a warning msg\n"
e8e1946e 5550 "Only give warning message when limit is exceeded\n")
e0701b79 5551
5552ALIAS (no_neighbor_maximum_prefix,
0a486e5f 5553 no_neighbor_maximum_prefix_restart_cmd,
5554 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
718e3744 5555 NO_STR
5556 NEIGHBOR_STR
5557 NEIGHBOR_ADDR_STR2
5558 "Maximum number of prefix accept from this peer\n"
5559 "maximum no. of prefix limit\n"
0a486e5f 5560 "Restart bgp connection after limit is exceeded\n"
5561 "Restart interval in minutes")
5562
5563ALIAS (no_neighbor_maximum_prefix,
5564 no_neighbor_maximum_prefix_threshold_restart_cmd,
5565 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5566 NO_STR
5567 NEIGHBOR_STR
5568 NEIGHBOR_ADDR_STR2
5569 "Maximum number of prefix accept from this peer\n"
5570 "maximum no. of prefix limit\n"
5571 "Threshold value (%) at which to generate a warning msg\n"
5572 "Restart bgp connection after limit is exceeded\n"
5573 "Restart interval in minutes")
6b0655a2 5574
718e3744 5575/* "neighbor allowas-in" */
5576DEFUN (neighbor_allowas_in,
5577 neighbor_allowas_in_cmd,
5578 NEIGHBOR_CMD2 "allowas-in",
5579 NEIGHBOR_STR
5580 NEIGHBOR_ADDR_STR2
5581 "Accept as-path with my AS present in it\n")
5582{
5583 int ret;
5584 struct peer *peer;
fd79ac91 5585 unsigned int allow_num;
718e3744 5586
5587 peer = peer_and_group_lookup_vty (vty, argv[0]);
5588 if (! peer)
5589 return CMD_WARNING;
5590
5591 if (argc == 1)
5592 allow_num = 3;
5593 else
5594 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5595
5596 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5597 allow_num);
5598
5599 return bgp_vty_return (vty, ret);
5600}
5601
5602ALIAS (neighbor_allowas_in,
5603 neighbor_allowas_in_arg_cmd,
5604 NEIGHBOR_CMD2 "allowas-in <1-10>",
5605 NEIGHBOR_STR
5606 NEIGHBOR_ADDR_STR2
5607 "Accept as-path with my AS present in it\n"
5608 "Number of occurances of AS number\n")
5609
5610DEFUN (no_neighbor_allowas_in,
5611 no_neighbor_allowas_in_cmd,
5612 NO_NEIGHBOR_CMD2 "allowas-in",
5613 NO_STR
5614 NEIGHBOR_STR
5615 NEIGHBOR_ADDR_STR2
5616 "allow local ASN appears in aspath attribute\n")
5617{
5618 int ret;
5619 struct peer *peer;
5620
5621 peer = peer_and_group_lookup_vty (vty, argv[0]);
5622 if (! peer)
5623 return CMD_WARNING;
5624
5625 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5626
5627 return bgp_vty_return (vty, ret);
5628}
6b0655a2 5629
fa411a21
NH
5630DEFUN (neighbor_ttl_security,
5631 neighbor_ttl_security_cmd,
5632 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5633 NEIGHBOR_STR
5634 NEIGHBOR_ADDR_STR2
5635 "Specify the maximum number of hops to the BGP peer\n")
5636{
5637 struct peer *peer;
89b6d1f8 5638 int gtsm_hops;
fa411a21
NH
5639
5640 peer = peer_and_group_lookup_vty (vty, argv[0]);
5641 if (! peer)
5642 return CMD_WARNING;
5643
5644 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5645
89b6d1f8 5646 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
fa411a21
NH
5647}
5648
5649DEFUN (no_neighbor_ttl_security,
5650 no_neighbor_ttl_security_cmd,
5651 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5652 NO_STR
5653 NEIGHBOR_STR
5654 NEIGHBOR_ADDR_STR2
5655 "Specify the maximum number of hops to the BGP peer\n")
5656{
5657 struct peer *peer;
fa411a21
NH
5658
5659 peer = peer_and_group_lookup_vty (vty, argv[0]);
5660 if (! peer)
5661 return CMD_WARNING;
5662
89b6d1f8 5663 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
fa411a21 5664}
6b0655a2 5665
718e3744 5666/* Address family configuration. */
5667DEFUN (address_family_ipv4,
5668 address_family_ipv4_cmd,
5669 "address-family ipv4",
5670 "Enter Address Family command mode\n"
5671 "Address family\n")
5672{
5673 vty->node = BGP_IPV4_NODE;
5674 return CMD_SUCCESS;
5675}
5676
5677DEFUN (address_family_ipv4_safi,
5678 address_family_ipv4_safi_cmd,
5679 "address-family ipv4 (unicast|multicast)",
5680 "Enter Address Family command mode\n"
5681 "Address family\n"
5682 "Address Family modifier\n"
5683 "Address Family modifier\n")
5684{
5685 if (strncmp (argv[0], "m", 1) == 0)
5686 vty->node = BGP_IPV4M_NODE;
5687 else
5688 vty->node = BGP_IPV4_NODE;
5689
5690 return CMD_SUCCESS;
5691}
5692
25ffbdc1 5693DEFUN (address_family_ipv6,
5694 address_family_ipv6_cmd,
5695 "address-family ipv6",
718e3744 5696 "Enter Address Family command mode\n"
25ffbdc1 5697 "Address family\n")
718e3744 5698{
5699 vty->node = BGP_IPV6_NODE;
5700 return CMD_SUCCESS;
5701}
5702
25ffbdc1 5703DEFUN (address_family_ipv6_safi,
5704 address_family_ipv6_safi_cmd,
5705 "address-family ipv6 (unicast|multicast)",
718e3744 5706 "Enter Address Family command mode\n"
25ffbdc1 5707 "Address family\n"
5708 "Address Family modifier\n"
5709 "Address Family modifier\n")
5710{
5711 if (strncmp (argv[0], "m", 1) == 0)
5712 vty->node = BGP_IPV6M_NODE;
5713 else
5714 vty->node = BGP_IPV6_NODE;
5715
5716 return CMD_SUCCESS;
5717}
718e3744 5718
5719DEFUN (address_family_vpnv4,
5720 address_family_vpnv4_cmd,
5721 "address-family vpnv4",
5722 "Enter Address Family command mode\n"
5723 "Address family\n")
5724{
5725 vty->node = BGP_VPNV4_NODE;
5726 return CMD_SUCCESS;
5727}
5728
5729ALIAS (address_family_vpnv4,
5730 address_family_vpnv4_unicast_cmd,
5731 "address-family vpnv4 unicast",
5732 "Enter Address Family command mode\n"
5733 "Address family\n"
5734 "Address Family Modifier\n")
5735
5736DEFUN (exit_address_family,
5737 exit_address_family_cmd,
5738 "exit-address-family",
5739 "Exit from Address Family configuration mode\n")
5740{
a8a80d53 5741 if (vty->node == BGP_IPV4_NODE
5742 || vty->node == BGP_IPV4M_NODE
718e3744 5743 || vty->node == BGP_VPNV4_NODE
25ffbdc1 5744 || vty->node == BGP_IPV6_NODE
5745 || vty->node == BGP_IPV6M_NODE)
718e3744 5746 vty->node = BGP_NODE;
5747 return CMD_SUCCESS;
5748}
6b0655a2 5749
8ad7271d
DS
5750/* Recalculate bestpath and re-advertise a prefix */
5751static int
5752bgp_clear_prefix (struct vty *vty, char *view_name, const char *ip_str,
5753 afi_t afi, safi_t safi, struct prefix_rd *prd)
5754{
5755 int ret;
5756 struct prefix match;
5757 struct bgp_node *rn;
5758 struct bgp_node *rm;
8ad7271d
DS
5759 struct bgp *bgp;
5760 struct bgp_table *table;
5761 struct bgp_table *rib;
5762
5763 /* BGP structure lookup. */
5764 if (view_name)
5765 {
5766 bgp = bgp_lookup_by_name (view_name);
5767 if (bgp == NULL)
5768 {
5769 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
5770 return CMD_WARNING;
5771 }
5772 }
5773 else
5774 {
5775 bgp = bgp_get_default ();
5776 if (bgp == NULL)
5777 {
5778 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
5779 return CMD_WARNING;
5780 }
5781 }
5782
5783 /* Check IP address argument. */
5784 ret = str2prefix (ip_str, &match);
5785 if (! ret)
5786 {
5787 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
5788 return CMD_WARNING;
5789 }
5790
5791 match.family = afi2family (afi);
5792 rib = bgp->rib[afi][safi];
5793
5794 if (safi == SAFI_MPLS_VPN)
5795 {
5796 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
5797 {
5798 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5799 continue;
5800
5801 if ((table = rn->info) != NULL)
5802 {
5803 if ((rm = bgp_node_match (table, &match)) != NULL)
5804 {
5805 if (rm->p.prefixlen == match.prefixlen)
5806 {
5807 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5808 bgp_process (bgp, rm, afi, safi);
5809 }
5810 bgp_unlock_node (rm);
5811 }
5812 }
5813 }
5814 }
5815 else
5816 {
5817 if ((rn = bgp_node_match (rib, &match)) != NULL)
5818 {
5819 if (rn->p.prefixlen == match.prefixlen)
5820 {
5821 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5822 bgp_process (bgp, rn, afi, safi);
5823 }
5824 bgp_unlock_node (rn);
5825 }
5826 }
5827
5828 return CMD_SUCCESS;
5829}
5830
718e3744 5831DEFUN (clear_ip_bgp_all,
5832 clear_ip_bgp_all_cmd,
5833 "clear ip bgp *",
5834 CLEAR_STR
5835 IP_STR
5836 BGP_STR
5837 "Clear all peers\n")
5838{
5839 if (argc == 1)
5840 return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5841
5842 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5843}
5844
5845ALIAS (clear_ip_bgp_all,
5846 clear_bgp_all_cmd,
5847 "clear bgp *",
5848 CLEAR_STR
5849 BGP_STR
5850 "Clear all peers\n")
5851
5852ALIAS (clear_ip_bgp_all,
5853 clear_bgp_ipv6_all_cmd,
5854 "clear bgp ipv6 *",
5855 CLEAR_STR
5856 BGP_STR
5857 "Address family\n"
5858 "Clear all peers\n")
5859
5860ALIAS (clear_ip_bgp_all,
5861 clear_ip_bgp_instance_all_cmd,
5862 "clear ip bgp view WORD *",
5863 CLEAR_STR
5864 IP_STR
5865 BGP_STR
5866 "BGP view\n"
5867 "view name\n"
5868 "Clear all peers\n")
5869
5870ALIAS (clear_ip_bgp_all,
5871 clear_bgp_instance_all_cmd,
5872 "clear bgp view WORD *",
5873 CLEAR_STR
5874 BGP_STR
5875 "BGP view\n"
5876 "view name\n"
5877 "Clear all peers\n")
5878
5879DEFUN (clear_ip_bgp_peer,
5880 clear_ip_bgp_peer_cmd,
a80beece 5881 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 5882 CLEAR_STR
5883 IP_STR
5884 BGP_STR
5885 "BGP neighbor IP address to clear\n"
a80beece
DS
5886 "BGP IPv6 neighbor to clear\n"
5887 "BGP neighbor on interface to clear\n")
718e3744 5888{
5889 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
5890}
5891
5892ALIAS (clear_ip_bgp_peer,
5893 clear_bgp_peer_cmd,
a80beece 5894 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
718e3744 5895 CLEAR_STR
5896 BGP_STR
5897 "BGP neighbor address to clear\n"
a80beece
DS
5898 "BGP IPv6 neighbor to clear\n"
5899 "BGP neighbor on interface to clear\n")
718e3744 5900
5901ALIAS (clear_ip_bgp_peer,
5902 clear_bgp_ipv6_peer_cmd,
a80beece 5903 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
718e3744 5904 CLEAR_STR
5905 BGP_STR
5906 "Address family\n"
5907 "BGP neighbor address to clear\n"
a80beece
DS
5908 "BGP IPv6 neighbor to clear\n"
5909 "BGP neighbor on interface to clear\n")
718e3744 5910
5911DEFUN (clear_ip_bgp_peer_group,
5912 clear_ip_bgp_peer_group_cmd,
5913 "clear ip bgp peer-group WORD",
5914 CLEAR_STR
5915 IP_STR
5916 BGP_STR
5917 "Clear all members of peer-group\n"
5918 "BGP peer-group name\n")
5919{
5920 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
5921}
5922
5923ALIAS (clear_ip_bgp_peer_group,
5924 clear_bgp_peer_group_cmd,
5925 "clear bgp peer-group WORD",
5926 CLEAR_STR
5927 BGP_STR
5928 "Clear all members of peer-group\n"
5929 "BGP peer-group name\n")
5930
5931ALIAS (clear_ip_bgp_peer_group,
5932 clear_bgp_ipv6_peer_group_cmd,
5933 "clear bgp ipv6 peer-group WORD",
5934 CLEAR_STR
5935 BGP_STR
5936 "Address family\n"
5937 "Clear all members of peer-group\n"
5938 "BGP peer-group name\n")
5939
5940DEFUN (clear_ip_bgp_external,
5941 clear_ip_bgp_external_cmd,
5942 "clear ip bgp external",
5943 CLEAR_STR
5944 IP_STR
5945 BGP_STR
5946 "Clear all external peers\n")
5947{
5948 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
5949}
5950
5951ALIAS (clear_ip_bgp_external,
5952 clear_bgp_external_cmd,
5953 "clear bgp external",
5954 CLEAR_STR
5955 BGP_STR
5956 "Clear all external peers\n")
5957
5958ALIAS (clear_ip_bgp_external,
5959 clear_bgp_ipv6_external_cmd,
5960 "clear bgp ipv6 external",
5961 CLEAR_STR
5962 BGP_STR
5963 "Address family\n"
5964 "Clear all external peers\n")
5965
8ad7271d
DS
5966DEFUN (clear_ip_bgp_prefix,
5967 clear_ip_bgp_prefix_cmd,
5968 "clear ip bgp prefix A.B.C.D/M",
5969 CLEAR_STR
5970 IP_STR
5971 BGP_STR
5972 "Clear bestpath and re-advertise\n"
5973 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5974{
5975 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
5976}
5977
5978ALIAS (clear_ip_bgp_prefix,
5979 clear_bgp_prefix_cmd,
5980 "clear bgp prefix A.B.C.D/M",
5981 CLEAR_STR
5982 BGP_STR
5983 "Clear bestpath and re-advertise\n"
5984 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5985
5986
718e3744 5987DEFUN (clear_ip_bgp_as,
5988 clear_ip_bgp_as_cmd,
320da874 5989 "clear ip bgp " CMD_AS_RANGE,
718e3744 5990 CLEAR_STR
5991 IP_STR
5992 BGP_STR
5993 "Clear peers with the AS number\n")
5994{
5995 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
5996}
5997
5998ALIAS (clear_ip_bgp_as,
5999 clear_bgp_as_cmd,
320da874 6000 "clear bgp " CMD_AS_RANGE,
718e3744 6001 CLEAR_STR
6002 BGP_STR
6003 "Clear peers with the AS number\n")
6004
6005ALIAS (clear_ip_bgp_as,
6006 clear_bgp_ipv6_as_cmd,
320da874 6007 "clear bgp ipv6 " CMD_AS_RANGE,
718e3744 6008 CLEAR_STR
6009 BGP_STR
6010 "Address family\n"
6011 "Clear peers with the AS number\n")
6b0655a2 6012
718e3744 6013/* Outbound soft-reconfiguration */
6014DEFUN (clear_ip_bgp_all_soft_out,
6015 clear_ip_bgp_all_soft_out_cmd,
6016 "clear ip bgp * soft out",
6017 CLEAR_STR
6018 IP_STR
6019 BGP_STR
6020 "Clear all peers\n"
e0bce756
DS
6021 BGP_SOFT_STR
6022 BGP_SOFT_OUT_STR)
718e3744 6023{
6024 if (argc == 1)
6025 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6026 BGP_CLEAR_SOFT_OUT, NULL);
6027
6028 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6029 BGP_CLEAR_SOFT_OUT, NULL);
6030}
6031
6032ALIAS (clear_ip_bgp_all_soft_out,
6033 clear_ip_bgp_all_out_cmd,
6034 "clear ip bgp * out",
6035 CLEAR_STR
6036 IP_STR
6037 BGP_STR
6038 "Clear all peers\n"
e0bce756 6039 BGP_SOFT_OUT_STR)
718e3744 6040
6041ALIAS (clear_ip_bgp_all_soft_out,
6042 clear_ip_bgp_instance_all_soft_out_cmd,
6043 "clear ip bgp view WORD * soft out",
6044 CLEAR_STR
6045 IP_STR
6046 BGP_STR
6047 "BGP view\n"
6048 "view name\n"
6049 "Clear all peers\n"
e0bce756
DS
6050 BGP_SOFT_STR
6051 BGP_SOFT_OUT_STR)
718e3744 6052
6053DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6054 clear_ip_bgp_all_ipv4_soft_out_cmd,
6055 "clear ip bgp * ipv4 (unicast|multicast) soft out",
6056 CLEAR_STR
6057 IP_STR
6058 BGP_STR
6059 "Clear all peers\n"
6060 "Address family\n"
6061 "Address Family modifier\n"
6062 "Address Family modifier\n"
e0bce756
DS
6063 BGP_SOFT_STR
6064 BGP_SOFT_OUT_STR)
718e3744 6065{
6066 if (strncmp (argv[0], "m", 1) == 0)
6067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6068 BGP_CLEAR_SOFT_OUT, NULL);
6069
6070 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6071 BGP_CLEAR_SOFT_OUT, NULL);
6072}
6073
6074ALIAS (clear_ip_bgp_all_ipv4_soft_out,
6075 clear_ip_bgp_all_ipv4_out_cmd,
6076 "clear ip bgp * ipv4 (unicast|multicast) out",
6077 CLEAR_STR
6078 IP_STR
6079 BGP_STR
6080 "Clear all peers\n"
6081 "Address family\n"
6082 "Address Family modifier\n"
6083 "Address Family modifier\n"
e0bce756 6084 BGP_SOFT_OUT_STR)
718e3744 6085
6086DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6087 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
6088 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft out",
6089 CLEAR_STR
6090 IP_STR
6091 BGP_STR
6092 "BGP view\n"
6093 "view name\n"
6094 "Clear all peers\n"
6095 "Address family\n"
6096 "Address Family modifier\n"
6097 "Address Family modifier\n"
e0bce756 6098 BGP_SOFT_OUT_STR)
718e3744 6099{
6100 if (strncmp (argv[1], "m", 1) == 0)
6101 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
6102 BGP_CLEAR_SOFT_OUT, NULL);
6103
6104 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6105 BGP_CLEAR_SOFT_OUT, NULL);
6106}
6107
6108DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
6109 clear_ip_bgp_all_vpnv4_soft_out_cmd,
6110 "clear ip bgp * vpnv4 unicast soft out",
6111 CLEAR_STR
6112 IP_STR
6113 BGP_STR
6114 "Clear all peers\n"
6115 "Address family\n"
6116 "Address Family Modifier\n"
e0bce756
DS
6117 BGP_SOFT_STR
6118 BGP_SOFT_OUT_STR)
718e3744 6119{
6120 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6121 BGP_CLEAR_SOFT_OUT, NULL);
6122}
6123
6124ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
6125 clear_ip_bgp_all_vpnv4_out_cmd,
6126 "clear ip bgp * vpnv4 unicast out",
6127 CLEAR_STR
6128 IP_STR
6129 BGP_STR
6130 "Clear all peers\n"
6131 "Address family\n"
6132 "Address Family Modifier\n"
e0bce756 6133 BGP_SOFT_OUT_STR)
718e3744 6134
6135DEFUN (clear_bgp_all_soft_out,
6136 clear_bgp_all_soft_out_cmd,
6137 "clear bgp * soft out",
6138 CLEAR_STR
6139 BGP_STR
6140 "Clear all peers\n"
e0bce756
DS
6141 BGP_SOFT_STR
6142 BGP_SOFT_OUT_STR)
718e3744 6143{
6144 if (argc == 1)
6145 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6146 BGP_CLEAR_SOFT_OUT, NULL);
6147
6148 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6149 BGP_CLEAR_SOFT_OUT, NULL);
6150}
6151
6152ALIAS (clear_bgp_all_soft_out,
6153 clear_bgp_instance_all_soft_out_cmd,
6154 "clear bgp view WORD * soft out",
6155 CLEAR_STR
6156 BGP_STR
6157 "BGP view\n"
6158 "view name\n"
6159 "Clear all peers\n"
e0bce756
DS
6160 BGP_SOFT_STR
6161 BGP_SOFT_OUT_STR)
718e3744 6162
6163ALIAS (clear_bgp_all_soft_out,
6164 clear_bgp_all_out_cmd,
6165 "clear bgp * out",
6166 CLEAR_STR
6167 BGP_STR
6168 "Clear all peers\n"
e0bce756 6169 BGP_SOFT_OUT_STR)
718e3744 6170
6171ALIAS (clear_bgp_all_soft_out,
6172 clear_bgp_ipv6_all_soft_out_cmd,
6173 "clear bgp ipv6 * soft out",
6174 CLEAR_STR
6175 BGP_STR
6176 "Address family\n"
6177 "Clear all peers\n"
e0bce756
DS
6178 BGP_SOFT_STR
6179 BGP_SOFT_OUT_STR)
718e3744 6180
6181ALIAS (clear_bgp_all_soft_out,
6182 clear_bgp_ipv6_all_out_cmd,
6183 "clear bgp ipv6 * out",
6184 CLEAR_STR
6185 BGP_STR
6186 "Address family\n"
6187 "Clear all peers\n"
e0bce756 6188 BGP_SOFT_OUT_STR)
718e3744 6189
8ad7271d
DS
6190DEFUN (clear_bgp_ipv6_safi_prefix,
6191 clear_bgp_ipv6_safi_prefix_cmd,
6192 "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
6193 CLEAR_STR
6194 BGP_STR
6195 "Address family\n"
6196 "Address Family Modifier\n"
6197 "Clear bestpath and re-advertise\n"
6198 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6199{
6200 if (strncmp (argv[0], "m", 1) == 0)
6201 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
6202 else
6203 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
6204}
6205
718e3744 6206DEFUN (clear_ip_bgp_peer_soft_out,
6207 clear_ip_bgp_peer_soft_out_cmd,
db64ea86 6208 "clear ip bgp (A.B.C.D|WORD) soft out",
718e3744 6209 CLEAR_STR
6210 IP_STR
6211 BGP_STR
6212 "BGP neighbor address to clear\n"
db64ea86 6213 "BGP neighbor on interface to clear\n"
e0bce756
DS
6214 BGP_SOFT_STR
6215 BGP_SOFT_OUT_STR)
718e3744 6216{
6217 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6218 BGP_CLEAR_SOFT_OUT, argv[0]);
6219}
6220
6221ALIAS (clear_ip_bgp_peer_soft_out,
6222 clear_ip_bgp_peer_out_cmd,
db64ea86 6223 "clear ip bgp (A.B.C.D|WORD) out",
718e3744 6224 CLEAR_STR
6225 IP_STR
6226 BGP_STR
6227 "BGP neighbor address to clear\n"
db64ea86 6228 "BGP neighbor on interface to clear\n"
e0bce756 6229 BGP_SOFT_OUT_STR)
718e3744 6230
6231DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6232 clear_ip_bgp_peer_ipv4_soft_out_cmd,
db64ea86 6233 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
718e3744 6234 CLEAR_STR
6235 IP_STR
6236 BGP_STR
6237 "BGP neighbor address to clear\n"
db64ea86 6238 "BGP neighbor on interface to clear\n"
718e3744 6239 "Address family\n"
6240 "Address Family modifier\n"
6241 "Address Family modifier\n"
e0bce756
DS
6242 BGP_SOFT_STR
6243 BGP_SOFT_OUT_STR)
718e3744 6244{
6245 if (strncmp (argv[1], "m", 1) == 0)
6246 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6247 BGP_CLEAR_SOFT_OUT, argv[0]);
6248
6249 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6250 BGP_CLEAR_SOFT_OUT, argv[0]);
6251}
6252
6253ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6254 clear_ip_bgp_peer_ipv4_out_cmd,
db64ea86 6255 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
718e3744 6256 CLEAR_STR
6257 IP_STR
6258 BGP_STR
6259 "BGP neighbor address to clear\n"
db64ea86 6260 "BGP neighbor on interface to clear\n"
718e3744 6261 "Address family\n"
6262 "Address Family modifier\n"
6263 "Address Family modifier\n"
e0bce756 6264 BGP_SOFT_OUT_STR)
718e3744 6265
db64ea86 6266/* NOTE: WORD peers have not been tested for vpnv4 */
718e3744 6267DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6268 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
db64ea86 6269 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out",
718e3744 6270 CLEAR_STR
6271 IP_STR
6272 BGP_STR
6273 "BGP neighbor address to clear\n"
db64ea86 6274 "BGP neighbor on interface to clear\n"
718e3744 6275 "Address family\n"
6276 "Address Family Modifier\n"
e0bce756
DS
6277 BGP_SOFT_STR
6278 BGP_SOFT_OUT_STR)
718e3744 6279{
6280 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6281 BGP_CLEAR_SOFT_OUT, argv[0]);
6282}
6283
6284ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
6285 clear_ip_bgp_peer_vpnv4_out_cmd,
db64ea86 6286 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out",
718e3744 6287 CLEAR_STR
6288 IP_STR
6289 BGP_STR
6290 "BGP neighbor address to clear\n"
db64ea86 6291 "BGP neighbor on interface to clear\n"
718e3744 6292 "Address family\n"
6293 "Address Family Modifier\n"
e0bce756 6294 BGP_SOFT_OUT_STR)
718e3744 6295
6296DEFUN (clear_bgp_peer_soft_out,
6297 clear_bgp_peer_soft_out_cmd,
a80beece 6298 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6299 CLEAR_STR
6300 BGP_STR
6301 "BGP neighbor address to clear\n"
6302 "BGP IPv6 neighbor to clear\n"
a80beece 6303 "BGP neighbor on interface to clear\n"
e0bce756
DS
6304 BGP_SOFT_STR
6305 BGP_SOFT_OUT_STR)
718e3744 6306{
6307 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6308 BGP_CLEAR_SOFT_OUT, argv[0]);
6309}
6310
6311ALIAS (clear_bgp_peer_soft_out,
6312 clear_bgp_ipv6_peer_soft_out_cmd,
a80beece 6313 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
718e3744 6314 CLEAR_STR
6315 BGP_STR
6316 "Address family\n"
6317 "BGP neighbor address to clear\n"
6318 "BGP IPv6 neighbor to clear\n"
a80beece 6319 "BGP neighbor on interface to clear\n"
e0bce756
DS
6320 BGP_SOFT_STR
6321 BGP_SOFT_OUT_STR)
718e3744 6322
6323ALIAS (clear_bgp_peer_soft_out,
6324 clear_bgp_peer_out_cmd,
a80beece 6325 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6326 CLEAR_STR
6327 BGP_STR
6328 "BGP neighbor address to clear\n"
6329 "BGP IPv6 neighbor to clear\n"
a80beece 6330 "BGP neighbor on interface to clear\n"
e0bce756 6331 BGP_SOFT_OUT_STR)
718e3744 6332
6333ALIAS (clear_bgp_peer_soft_out,
6334 clear_bgp_ipv6_peer_out_cmd,
a80beece 6335 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
718e3744 6336 CLEAR_STR
6337 BGP_STR
6338 "Address family\n"
6339 "BGP neighbor address to clear\n"
6340 "BGP IPv6 neighbor to clear\n"
a80beece 6341 "BGP neighbor on interface to clear\n"
e0bce756 6342 BGP_SOFT_OUT_STR)
718e3744 6343
6344DEFUN (clear_ip_bgp_peer_group_soft_out,
6345 clear_ip_bgp_peer_group_soft_out_cmd,
6346 "clear ip bgp peer-group WORD soft out",
6347 CLEAR_STR
6348 IP_STR
6349 BGP_STR
6350 "Clear all members of peer-group\n"
6351 "BGP peer-group name\n"
e0bce756
DS
6352 BGP_SOFT_STR
6353 BGP_SOFT_OUT_STR)
718e3744 6354{
6355 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6356 BGP_CLEAR_SOFT_OUT, argv[0]);
6357}
6358
6359ALIAS (clear_ip_bgp_peer_group_soft_out,
6360 clear_ip_bgp_peer_group_out_cmd,
6361 "clear ip bgp peer-group WORD out",
6362 CLEAR_STR
6363 IP_STR
6364 BGP_STR
6365 "Clear all members of peer-group\n"
6366 "BGP peer-group name\n"
e0bce756 6367 BGP_SOFT_OUT_STR)
718e3744 6368
6369DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6370 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
6371 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
6372 CLEAR_STR
6373 IP_STR
6374 BGP_STR
6375 "Clear all members of peer-group\n"
6376 "BGP peer-group name\n"
6377 "Address family\n"
6378 "Address Family modifier\n"
6379 "Address Family modifier\n"
e0bce756
DS
6380 BGP_SOFT_STR
6381 BGP_SOFT_OUT_STR)
718e3744 6382{
6383 if (strncmp (argv[1], "m", 1) == 0)
6384 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6385 BGP_CLEAR_SOFT_OUT, argv[0]);
6386
6387 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6388 BGP_CLEAR_SOFT_OUT, argv[0]);
6389}
6390
6391ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
6392 clear_ip_bgp_peer_group_ipv4_out_cmd,
6393 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
6394 CLEAR_STR
6395 IP_STR
6396 BGP_STR
6397 "Clear all members of peer-group\n"
6398 "BGP peer-group name\n"
6399 "Address family\n"
6400 "Address Family modifier\n"
6401 "Address Family modifier\n"
e0bce756 6402 BGP_SOFT_OUT_STR)
718e3744 6403
6404DEFUN (clear_bgp_peer_group_soft_out,
6405 clear_bgp_peer_group_soft_out_cmd,
6406 "clear bgp peer-group WORD soft out",
6407 CLEAR_STR
6408 BGP_STR
6409 "Clear all members of peer-group\n"
6410 "BGP peer-group name\n"
e0bce756
DS
6411 BGP_SOFT_STR
6412 BGP_SOFT_OUT_STR)
718e3744 6413{
6414 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6415 BGP_CLEAR_SOFT_OUT, argv[0]);
6416}
6417
6418ALIAS (clear_bgp_peer_group_soft_out,
6419 clear_bgp_ipv6_peer_group_soft_out_cmd,
6420 "clear bgp ipv6 peer-group WORD soft out",
6421 CLEAR_STR
6422 BGP_STR
6423 "Address family\n"
6424 "Clear all members of peer-group\n"
6425 "BGP peer-group name\n"
e0bce756
DS
6426 BGP_SOFT_STR
6427 BGP_SOFT_OUT_STR)
718e3744 6428
6429ALIAS (clear_bgp_peer_group_soft_out,
6430 clear_bgp_peer_group_out_cmd,
6431 "clear bgp peer-group WORD out",
6432 CLEAR_STR
6433 BGP_STR
6434 "Clear all members of peer-group\n"
6435 "BGP peer-group name\n"
e0bce756 6436 BGP_SOFT_OUT_STR)
718e3744 6437
6438ALIAS (clear_bgp_peer_group_soft_out,
6439 clear_bgp_ipv6_peer_group_out_cmd,
6440 "clear bgp ipv6 peer-group WORD out",
6441 CLEAR_STR
6442 BGP_STR
6443 "Address family\n"
6444 "Clear all members of peer-group\n"
6445 "BGP peer-group name\n"
e0bce756 6446 BGP_SOFT_OUT_STR)
718e3744 6447
6448DEFUN (clear_ip_bgp_external_soft_out,
6449 clear_ip_bgp_external_soft_out_cmd,
6450 "clear ip bgp external soft out",
6451 CLEAR_STR
6452 IP_STR
6453 BGP_STR
6454 "Clear all external peers\n"
e0bce756
DS
6455 BGP_SOFT_STR
6456 BGP_SOFT_OUT_STR)
718e3744 6457{
6458 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6459 BGP_CLEAR_SOFT_OUT, NULL);
6460}
6461
6462ALIAS (clear_ip_bgp_external_soft_out,
6463 clear_ip_bgp_external_out_cmd,
6464 "clear ip bgp external out",
6465 CLEAR_STR
6466 IP_STR
6467 BGP_STR
6468 "Clear all external peers\n"
e0bce756 6469 BGP_SOFT_OUT_STR)
718e3744 6470
6471DEFUN (clear_ip_bgp_external_ipv4_soft_out,
6472 clear_ip_bgp_external_ipv4_soft_out_cmd,
6473 "clear ip bgp external ipv4 (unicast|multicast) soft out",
6474 CLEAR_STR
6475 IP_STR
6476 BGP_STR
6477 "Clear all external peers\n"
6478 "Address family\n"
6479 "Address Family modifier\n"
6480 "Address Family modifier\n"
e0bce756
DS
6481 BGP_SOFT_STR
6482 BGP_SOFT_OUT_STR)
718e3744 6483{
6484 if (strncmp (argv[0], "m", 1) == 0)
6485 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6486 BGP_CLEAR_SOFT_OUT, NULL);
6487
6488 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6489 BGP_CLEAR_SOFT_OUT, NULL);
6490}
6491
6492ALIAS (clear_ip_bgp_external_ipv4_soft_out,
6493 clear_ip_bgp_external_ipv4_out_cmd,
6494 "clear ip bgp external ipv4 (unicast|multicast) out",
6495 CLEAR_STR
6496 IP_STR
6497 BGP_STR
6498 "Clear all external peers\n"
6499 "Address family\n"
6500 "Address Family modifier\n"
6501 "Address Family modifier\n"
e0bce756 6502 BGP_SOFT_OUT_STR)
718e3744 6503
6504DEFUN (clear_bgp_external_soft_out,
6505 clear_bgp_external_soft_out_cmd,
6506 "clear bgp external soft out",
6507 CLEAR_STR
6508 BGP_STR
6509 "Clear all external peers\n"
e0bce756
DS
6510 BGP_SOFT_STR
6511 BGP_SOFT_OUT_STR)
718e3744 6512{
6513 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6514 BGP_CLEAR_SOFT_OUT, NULL);
6515}
6516
6517ALIAS (clear_bgp_external_soft_out,
6518 clear_bgp_ipv6_external_soft_out_cmd,
6519 "clear bgp ipv6 external soft out",
6520 CLEAR_STR
6521 BGP_STR
6522 "Address family\n"
6523 "Clear all external peers\n"
e0bce756
DS
6524 BGP_SOFT_STR
6525 BGP_SOFT_OUT_STR)
718e3744 6526
6527ALIAS (clear_bgp_external_soft_out,
6528 clear_bgp_external_out_cmd,
6529 "clear bgp external out",
6530 CLEAR_STR
6531 BGP_STR
6532 "Clear all external peers\n"
e0bce756 6533 BGP_SOFT_OUT_STR)
718e3744 6534
6535ALIAS (clear_bgp_external_soft_out,
6536 clear_bgp_ipv6_external_out_cmd,
6537 "clear bgp ipv6 external WORD out",
6538 CLEAR_STR
6539 BGP_STR
6540 "Address family\n"
6541 "Clear all external peers\n"
e0bce756 6542 BGP_SOFT_OUT_STR)
718e3744 6543
6544DEFUN (clear_ip_bgp_as_soft_out,
6545 clear_ip_bgp_as_soft_out_cmd,
320da874 6546 "clear ip bgp " CMD_AS_RANGE " soft out",
718e3744 6547 CLEAR_STR
6548 IP_STR
6549 BGP_STR
6550 "Clear peers with the AS number\n"
e0bce756
DS
6551 BGP_SOFT_STR
6552 BGP_SOFT_OUT_STR)
718e3744 6553{
6554 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6555 BGP_CLEAR_SOFT_OUT, argv[0]);
6556}
6557
6558ALIAS (clear_ip_bgp_as_soft_out,
6559 clear_ip_bgp_as_out_cmd,
320da874 6560 "clear ip bgp " CMD_AS_RANGE " out",
718e3744 6561 CLEAR_STR
6562 IP_STR
6563 BGP_STR
6564 "Clear peers with the AS number\n"
e0bce756 6565 BGP_SOFT_OUT_STR)
718e3744 6566
6567DEFUN (clear_ip_bgp_as_ipv4_soft_out,
6568 clear_ip_bgp_as_ipv4_soft_out_cmd,
320da874 6569 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
718e3744 6570 CLEAR_STR
6571 IP_STR
6572 BGP_STR
6573 "Clear peers with the AS number\n"
6574 "Address family\n"
6575 "Address Family modifier\n"
6576 "Address Family modifier\n"
e0bce756
DS
6577 BGP_SOFT_STR
6578 BGP_SOFT_OUT_STR)
718e3744 6579{
6580 if (strncmp (argv[1], "m", 1) == 0)
6581 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6582 BGP_CLEAR_SOFT_OUT, argv[0]);
6583
6584 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6585 BGP_CLEAR_SOFT_OUT, argv[0]);
6586}
6587
6588ALIAS (clear_ip_bgp_as_ipv4_soft_out,
6589 clear_ip_bgp_as_ipv4_out_cmd,
320da874 6590 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
718e3744 6591 CLEAR_STR
6592 IP_STR
6593 BGP_STR
6594 "Clear peers with the AS number\n"
6595 "Address family\n"
6596 "Address Family modifier\n"
6597 "Address Family modifier\n"
e0bce756 6598 BGP_SOFT_OUT_STR)
718e3744 6599
6600DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
6601 clear_ip_bgp_as_vpnv4_soft_out_cmd,
320da874 6602 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
718e3744 6603 CLEAR_STR
6604 IP_STR
6605 BGP_STR
6606 "Clear peers with the AS number\n"
6607 "Address family\n"
6608 "Address Family modifier\n"
e0bce756
DS
6609 BGP_SOFT_STR
6610 BGP_SOFT_OUT_STR)
718e3744 6611{
6612 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6613 BGP_CLEAR_SOFT_OUT, argv[0]);
6614}
6615
6616ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
6617 clear_ip_bgp_as_vpnv4_out_cmd,
320da874 6618 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
718e3744 6619 CLEAR_STR
6620 IP_STR
6621 BGP_STR
6622 "Clear peers with the AS number\n"
6623 "Address family\n"
6624 "Address Family modifier\n"
e0bce756 6625 BGP_SOFT_OUT_STR)
718e3744 6626
6627DEFUN (clear_bgp_as_soft_out,
6628 clear_bgp_as_soft_out_cmd,
320da874 6629 "clear bgp " CMD_AS_RANGE " soft out",
718e3744 6630 CLEAR_STR
6631 BGP_STR
6632 "Clear peers with the AS number\n"
e0bce756
DS
6633 BGP_SOFT_STR
6634 BGP_SOFT_OUT_STR)
718e3744 6635{
6636 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6637 BGP_CLEAR_SOFT_OUT, argv[0]);
6638}
6639
6640ALIAS (clear_bgp_as_soft_out,
6641 clear_bgp_ipv6_as_soft_out_cmd,
320da874 6642 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
718e3744 6643 CLEAR_STR
6644 BGP_STR
6645 "Address family\n"
6646 "Clear peers with the AS number\n"
e0bce756
DS
6647 BGP_SOFT_STR
6648 BGP_SOFT_OUT_STR)
718e3744 6649
6650ALIAS (clear_bgp_as_soft_out,
6651 clear_bgp_as_out_cmd,
320da874 6652 "clear bgp " CMD_AS_RANGE " out",
718e3744 6653 CLEAR_STR
6654 BGP_STR
6655 "Clear peers with the AS number\n"
e0bce756 6656 BGP_SOFT_OUT_STR)
718e3744 6657
6658ALIAS (clear_bgp_as_soft_out,
6659 clear_bgp_ipv6_as_out_cmd,
320da874 6660 "clear bgp ipv6 " CMD_AS_RANGE " out",
718e3744 6661 CLEAR_STR
6662 BGP_STR
6663 "Address family\n"
6664 "Clear peers with the AS number\n"
e0bce756 6665 BGP_SOFT_OUT_STR)
6b0655a2 6666
718e3744 6667/* Inbound soft-reconfiguration */
6668DEFUN (clear_ip_bgp_all_soft_in,
6669 clear_ip_bgp_all_soft_in_cmd,
6670 "clear ip bgp * soft in",
6671 CLEAR_STR
6672 IP_STR
6673 BGP_STR
6674 "Clear all peers\n"
e0bce756
DS
6675 BGP_SOFT_STR
6676 BGP_SOFT_IN_STR)
718e3744 6677{
6678 if (argc == 1)
6679 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6680 BGP_CLEAR_SOFT_IN, NULL);
6681
6682 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6683 BGP_CLEAR_SOFT_IN, NULL);
6684}
6685
6686ALIAS (clear_ip_bgp_all_soft_in,
6687 clear_ip_bgp_instance_all_soft_in_cmd,
6688 "clear ip bgp view WORD * soft in",
6689 CLEAR_STR
6690 IP_STR
6691 BGP_STR
6692 "BGP view\n"
6693 "view name\n"
6694 "Clear all peers\n"
e0bce756
DS
6695 BGP_SOFT_STR
6696 BGP_SOFT_IN_STR)
718e3744 6697
6698ALIAS (clear_ip_bgp_all_soft_in,
6699 clear_ip_bgp_all_in_cmd,
6700 "clear ip bgp * in",
6701 CLEAR_STR
6702 IP_STR
6703 BGP_STR
6704 "Clear all peers\n"
e0bce756 6705 BGP_SOFT_IN_STR)
718e3744 6706
6707DEFUN (clear_ip_bgp_all_in_prefix_filter,
6708 clear_ip_bgp_all_in_prefix_filter_cmd,
6709 "clear ip bgp * in prefix-filter",
6710 CLEAR_STR
6711 IP_STR
6712 BGP_STR
6713 "Clear all peers\n"
e0bce756 6714 BGP_SOFT_IN_STR
718e3744 6715 "Push out prefix-list ORF and do inbound soft reconfig\n")
6716{
6717 if (argc== 1)
6718 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6719 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6720
6721 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6722 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6723}
6724
6725ALIAS (clear_ip_bgp_all_in_prefix_filter,
6726 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
6727 "clear ip bgp view WORD * in prefix-filter",
6728 CLEAR_STR
6729 IP_STR
6730 BGP_STR
6731 "BGP view\n"
6732 "view name\n"
6733 "Clear all peers\n"
e0bce756 6734 BGP_SOFT_IN_STR
718e3744 6735 "Push out prefix-list ORF and do inbound soft reconfig\n")
6736
6737
6738DEFUN (clear_ip_bgp_all_ipv4_soft_in,
6739 clear_ip_bgp_all_ipv4_soft_in_cmd,
6740 "clear ip bgp * ipv4 (unicast|multicast) soft in",
6741 CLEAR_STR
6742 IP_STR
6743 BGP_STR
6744 "Clear all peers\n"
6745 "Address family\n"
6746 "Address Family modifier\n"
6747 "Address Family modifier\n"
e0bce756
DS
6748 BGP_SOFT_STR
6749 BGP_SOFT_IN_STR)
718e3744 6750{
6751 if (strncmp (argv[0], "m", 1) == 0)
6752 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6753 BGP_CLEAR_SOFT_IN, NULL);
6754
6755 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6756 BGP_CLEAR_SOFT_IN, NULL);
6757}
6758
6759ALIAS (clear_ip_bgp_all_ipv4_soft_in,
6760 clear_ip_bgp_all_ipv4_in_cmd,
6761 "clear ip bgp * ipv4 (unicast|multicast) in",
6762 CLEAR_STR
6763 IP_STR
6764 BGP_STR
6765 "Clear all peers\n"
6766 "Address family\n"
6767 "Address Family modifier\n"
6768 "Address Family modifier\n"
e0bce756 6769 BGP_SOFT_IN_STR)
718e3744 6770
6771DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
6772 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
6773 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft in",
6774 CLEAR_STR
6775 IP_STR
6776 BGP_STR
6777 "BGP view\n"
6778 "view name\n"
6779 "Clear all peers\n"
6780 "Address family\n"
6781 "Address Family modifier\n"
6782 "Address Family modifier\n"
e0bce756
DS
6783 BGP_SOFT_STR
6784 BGP_SOFT_IN_STR)
718e3744 6785{
6786 if (strncmp (argv[1], "m", 1) == 0)
6787 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
6788 BGP_CLEAR_SOFT_IN, NULL);
6789
6790 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6791 BGP_CLEAR_SOFT_IN, NULL);
6792}
6793
6794DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
6795 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
6796 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
6797 CLEAR_STR
6798 IP_STR
6799 BGP_STR
6800 "Clear all peers\n"
6801 "Address family\n"
6802 "Address Family modifier\n"
6803 "Address Family modifier\n"
e0bce756 6804 BGP_SOFT_IN_STR
718e3744 6805 "Push out prefix-list ORF and do inbound soft reconfig\n")
6806{
6807 if (strncmp (argv[0], "m", 1) == 0)
6808 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6809 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6810
6811 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6812 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6813}
6814
6815DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
6816 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
6817 "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter",
6818 CLEAR_STR
6819 IP_STR
6820 BGP_STR
6821 "Clear all peers\n"
6822 "Address family\n"
6823 "Address Family modifier\n"
6824 "Address Family modifier\n"
e0bce756 6825 BGP_SOFT_IN_STR
718e3744 6826 "Push out prefix-list ORF and do inbound soft reconfig\n")
6827{
6828 if (strncmp (argv[1], "m", 1) == 0)
6829 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all,
6830 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6831
6832 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6833 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6834}
6835
6836DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
6837 clear_ip_bgp_all_vpnv4_soft_in_cmd,
6838 "clear ip bgp * vpnv4 unicast soft in",
6839 CLEAR_STR
6840 IP_STR
6841 BGP_STR
6842 "Clear all peers\n"
6843 "Address family\n"
6844 "Address Family Modifier\n"
e0bce756
DS
6845 BGP_SOFT_STR
6846 BGP_SOFT_IN_STR)
718e3744 6847{
6848 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6849 BGP_CLEAR_SOFT_IN, NULL);
6850}
6851
6852ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
6853 clear_ip_bgp_all_vpnv4_in_cmd,
6854 "clear ip bgp * vpnv4 unicast in",
6855 CLEAR_STR
6856 IP_STR
6857 BGP_STR
6858 "Clear all peers\n"
6859 "Address family\n"
6860 "Address Family Modifier\n"
e0bce756 6861 BGP_SOFT_IN_STR)
718e3744 6862
6863DEFUN (clear_bgp_all_soft_in,
6864 clear_bgp_all_soft_in_cmd,
6865 "clear bgp * soft in",
6866 CLEAR_STR
6867 BGP_STR
6868 "Clear all peers\n"
e0bce756
DS
6869 BGP_SOFT_STR
6870 BGP_SOFT_IN_STR)
718e3744 6871{
6872 if (argc == 1)
6873 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
6874 BGP_CLEAR_SOFT_IN, NULL);
6875
6876 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6877 BGP_CLEAR_SOFT_IN, NULL);
6878}
6879
6880ALIAS (clear_bgp_all_soft_in,
6881 clear_bgp_instance_all_soft_in_cmd,
6882 "clear bgp view WORD * soft in",
6883 CLEAR_STR
6884 BGP_STR
6885 "BGP view\n"
6886 "view name\n"
6887 "Clear all peers\n"
e0bce756
DS
6888 BGP_SOFT_STR
6889 BGP_SOFT_IN_STR)
718e3744 6890
6891ALIAS (clear_bgp_all_soft_in,
6892 clear_bgp_ipv6_all_soft_in_cmd,
6893 "clear bgp ipv6 * soft in",
6894 CLEAR_STR
6895 BGP_STR
6896 "Address family\n"
6897 "Clear all peers\n"
e0bce756
DS
6898 BGP_SOFT_STR
6899 BGP_SOFT_IN_STR)
718e3744 6900
6901ALIAS (clear_bgp_all_soft_in,
6902 clear_bgp_all_in_cmd,
6903 "clear bgp * in",
6904 CLEAR_STR
6905 BGP_STR
6906 "Clear all peers\n"
e0bce756 6907 BGP_SOFT_IN_STR)
718e3744 6908
6909ALIAS (clear_bgp_all_soft_in,
6910 clear_bgp_ipv6_all_in_cmd,
6911 "clear bgp ipv6 * in",
6912 CLEAR_STR
6913 BGP_STR
6914 "Address family\n"
6915 "Clear all peers\n"
e0bce756 6916 BGP_SOFT_IN_STR)
718e3744 6917
6918DEFUN (clear_bgp_all_in_prefix_filter,
6919 clear_bgp_all_in_prefix_filter_cmd,
6920 "clear bgp * in prefix-filter",
6921 CLEAR_STR
6922 BGP_STR
6923 "Clear all peers\n"
e0bce756 6924 BGP_SOFT_IN_STR
718e3744 6925 "Push out prefix-list ORF and do inbound soft reconfig\n")
6926{
6927 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6928 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6929}
6930
6931ALIAS (clear_bgp_all_in_prefix_filter,
6932 clear_bgp_ipv6_all_in_prefix_filter_cmd,
6933 "clear bgp ipv6 * in prefix-filter",
6934 CLEAR_STR
6935 BGP_STR
6936 "Address family\n"
6937 "Clear all peers\n"
e0bce756 6938 BGP_SOFT_IN_STR
718e3744 6939 "Push out prefix-list ORF and do inbound soft reconfig\n")
6940
6941DEFUN (clear_ip_bgp_peer_soft_in,
6942 clear_ip_bgp_peer_soft_in_cmd,
db64ea86 6943 "clear ip bgp (A.B.C.D|WORD) soft in",
718e3744 6944 CLEAR_STR
6945 IP_STR
6946 BGP_STR
6947 "BGP neighbor address to clear\n"
db64ea86 6948 "BGP neighbor on interface to clear\n"
e0bce756
DS
6949 BGP_SOFT_STR
6950 BGP_SOFT_IN_STR)
718e3744 6951{
6952 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6953 BGP_CLEAR_SOFT_IN, argv[0]);
6954}
6955
6956ALIAS (clear_ip_bgp_peer_soft_in,
6957 clear_ip_bgp_peer_in_cmd,
db64ea86 6958 "clear ip bgp (A.B.C.D|WORD) in",
718e3744 6959 CLEAR_STR
6960 IP_STR
6961 BGP_STR
6962 "BGP neighbor address to clear\n"
db64ea86 6963 "BGP neighbor on interface to clear\n"
e0bce756 6964 BGP_SOFT_IN_STR)
718e3744 6965
6966DEFUN (clear_ip_bgp_peer_in_prefix_filter,
6967 clear_ip_bgp_peer_in_prefix_filter_cmd,
db64ea86 6968 "clear ip bgp (A.B.C.D|WORD) in prefix-filter",
718e3744 6969 CLEAR_STR
6970 IP_STR
6971 BGP_STR
6972 "BGP neighbor address to clear\n"
db64ea86 6973 "BGP neighbor on interface to clear\n"
e0bce756 6974 BGP_SOFT_IN_STR
718e3744 6975 "Push out the existing ORF prefix-list\n")
6976{
6977 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6978 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
6979}
6980
6981DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
6982 clear_ip_bgp_peer_ipv4_soft_in_cmd,
db64ea86 6983 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
718e3744 6984 CLEAR_STR
6985 IP_STR
6986 BGP_STR
6987 "BGP neighbor address to clear\n"
db64ea86 6988 "BGP neighbor on interface to clear\n"
718e3744 6989 "Address family\n"
6990 "Address Family modifier\n"
6991 "Address Family modifier\n"
e0bce756
DS
6992 BGP_SOFT_STR
6993 BGP_SOFT_IN_STR)
718e3744 6994{
6995 if (strncmp (argv[1], "m", 1) == 0)
6996 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6997 BGP_CLEAR_SOFT_IN, argv[0]);
6998
6999 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7000 BGP_CLEAR_SOFT_IN, argv[0]);
7001}
7002
7003ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
7004 clear_ip_bgp_peer_ipv4_in_cmd,
db64ea86 7005 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
718e3744 7006 CLEAR_STR
7007 IP_STR
7008 BGP_STR
7009 "BGP neighbor address to clear\n"
db64ea86 7010 "BGP neighbor on interface to clear\n"
718e3744 7011 "Address family\n"
7012 "Address Family modifier\n"
7013 "Address Family modifier\n"
e0bce756 7014 BGP_SOFT_IN_STR)
718e3744 7015
7016DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
7017 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
db64ea86 7018 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter",
718e3744 7019 CLEAR_STR
7020 IP_STR
7021 BGP_STR
7022 "BGP neighbor address to clear\n"
db64ea86 7023 "BGP neighbor on interface to clear\n"
718e3744 7024 "Address family\n"
7025 "Address Family modifier\n"
7026 "Address Family modifier\n"
e0bce756 7027 BGP_SOFT_IN_STR
718e3744 7028 "Push out the existing ORF prefix-list\n")
7029{
7030 if (strncmp (argv[1], "m", 1) == 0)
7031 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7032 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7033
7034 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7035 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7036}
7037
7038DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
7039 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
db64ea86 7040 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in",
718e3744 7041 CLEAR_STR
7042 IP_STR
7043 BGP_STR
7044 "BGP neighbor address to clear\n"
db64ea86 7045 "BGP neighbor on interface to clear\n"
718e3744 7046 "Address family\n"
7047 "Address Family Modifier\n"
e0bce756
DS
7048 BGP_SOFT_STR
7049 BGP_SOFT_IN_STR)
718e3744 7050{
7051 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7052 BGP_CLEAR_SOFT_IN, argv[0]);
7053}
7054
7055ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
7056 clear_ip_bgp_peer_vpnv4_in_cmd,
db64ea86 7057 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in",
718e3744 7058 CLEAR_STR
7059 IP_STR
7060 BGP_STR
7061 "BGP neighbor address to clear\n"
db64ea86 7062 "BGP neighbor on interface to clear\n"
718e3744 7063 "Address family\n"
7064 "Address Family Modifier\n"
e0bce756 7065 BGP_SOFT_IN_STR)
718e3744 7066
7067DEFUN (clear_bgp_peer_soft_in,
7068 clear_bgp_peer_soft_in_cmd,
a80beece 7069 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 7070 CLEAR_STR
7071 BGP_STR
7072 "BGP neighbor address to clear\n"
7073 "BGP IPv6 neighbor to clear\n"
a80beece 7074 "BGP neighbor on interface to clear\n"
e0bce756
DS
7075 BGP_SOFT_STR
7076 BGP_SOFT_IN_STR)
718e3744 7077{
7078 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7079 BGP_CLEAR_SOFT_IN, argv[0]);
7080}
7081
7082ALIAS (clear_bgp_peer_soft_in,
7083 clear_bgp_ipv6_peer_soft_in_cmd,
a80beece 7084 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
718e3744 7085 CLEAR_STR
7086 BGP_STR
7087 "Address family\n"
7088 "BGP neighbor address to clear\n"
7089 "BGP IPv6 neighbor to clear\n"
a80beece 7090 "BGP neighbor on interface to clear\n"
e0bce756
DS
7091 BGP_SOFT_STR
7092 BGP_SOFT_IN_STR)
718e3744 7093
7094ALIAS (clear_bgp_peer_soft_in,
7095 clear_bgp_peer_in_cmd,
a80beece 7096 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
718e3744 7097 CLEAR_STR
7098 BGP_STR
7099 "BGP neighbor address to clear\n"
7100 "BGP IPv6 neighbor to clear\n"
a80beece 7101 "BGP neighbor on interface to clear\n"
e0bce756 7102 BGP_SOFT_IN_STR)
718e3744 7103
7104ALIAS (clear_bgp_peer_soft_in,
7105 clear_bgp_ipv6_peer_in_cmd,
a80beece 7106 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
718e3744 7107 CLEAR_STR
7108 BGP_STR
7109 "Address family\n"
7110 "BGP neighbor address to clear\n"
7111 "BGP IPv6 neighbor to clear\n"
a80beece 7112 "BGP neighbor on interface to clear\n"
e0bce756 7113 BGP_SOFT_IN_STR)
718e3744 7114
7115DEFUN (clear_bgp_peer_in_prefix_filter,
7116 clear_bgp_peer_in_prefix_filter_cmd,
a80beece 7117 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 7118 CLEAR_STR
7119 BGP_STR
7120 "BGP neighbor address to clear\n"
7121 "BGP IPv6 neighbor to clear\n"
a80beece 7122 "BGP neighbor on interface to clear\n"
e0bce756 7123 BGP_SOFT_IN_STR
718e3744 7124 "Push out the existing ORF prefix-list\n")
7125{
7126 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7127 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7128}
7129
7130ALIAS (clear_bgp_peer_in_prefix_filter,
7131 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
a80beece 7132 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
718e3744 7133 CLEAR_STR
7134 BGP_STR
7135 "Address family\n"
7136 "BGP neighbor address to clear\n"
7137 "BGP IPv6 neighbor to clear\n"
a80beece 7138 "BGP neighbor on interface to clear\n"
e0bce756 7139 BGP_SOFT_IN_STR
718e3744 7140 "Push out the existing ORF prefix-list\n")
7141
7142DEFUN (clear_ip_bgp_peer_group_soft_in,
7143 clear_ip_bgp_peer_group_soft_in_cmd,
7144 "clear ip bgp peer-group WORD soft in",
7145 CLEAR_STR
7146 IP_STR
7147 BGP_STR
7148 "Clear all members of peer-group\n"
7149 "BGP peer-group name\n"
e0bce756
DS
7150 BGP_SOFT_STR
7151 BGP_SOFT_IN_STR)
718e3744 7152{
7153 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7154 BGP_CLEAR_SOFT_IN, argv[0]);
7155}
7156
7157ALIAS (clear_ip_bgp_peer_group_soft_in,
7158 clear_ip_bgp_peer_group_in_cmd,
7159 "clear ip bgp peer-group WORD in",
7160 CLEAR_STR
7161 IP_STR
7162 BGP_STR
7163 "Clear all members of peer-group\n"
7164 "BGP peer-group name\n"
e0bce756 7165 BGP_SOFT_IN_STR)
718e3744 7166
7167DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
7168 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
7169 "clear ip bgp peer-group WORD in prefix-filter",
7170 CLEAR_STR
7171 IP_STR
7172 BGP_STR
7173 "Clear all members of peer-group\n"
7174 "BGP peer-group name\n"
e0bce756 7175 BGP_SOFT_IN_STR
718e3744 7176 "Push out prefix-list ORF and do inbound soft reconfig\n")
7177{
7178 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7179 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7180}
7181
7182DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
7183 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
7184 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
7185 CLEAR_STR
7186 IP_STR
7187 BGP_STR
7188 "Clear all members of peer-group\n"
7189 "BGP peer-group name\n"
7190 "Address family\n"
7191 "Address Family modifier\n"
7192 "Address Family modifier\n"
e0bce756
DS
7193 BGP_SOFT_STR
7194 BGP_SOFT_IN_STR)
718e3744 7195{
7196 if (strncmp (argv[1], "m", 1) == 0)
7197 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7198 BGP_CLEAR_SOFT_IN, argv[0]);
7199
7200 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7201 BGP_CLEAR_SOFT_IN, argv[0]);
7202}
7203
7204ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
7205 clear_ip_bgp_peer_group_ipv4_in_cmd,
7206 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
7207 CLEAR_STR
7208 IP_STR
7209 BGP_STR
7210 "Clear all members of peer-group\n"
7211 "BGP peer-group name\n"
7212 "Address family\n"
7213 "Address Family modifier\n"
7214 "Address Family modifier\n"
e0bce756 7215 BGP_SOFT_IN_STR)
718e3744 7216
7217DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
7218 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
7219 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
7220 CLEAR_STR
7221 IP_STR
7222 BGP_STR
7223 "Clear all members of peer-group\n"
7224 "BGP peer-group name\n"
7225 "Address family\n"
7226 "Address Family modifier\n"
7227 "Address Family modifier\n"
e0bce756 7228 BGP_SOFT_IN_STR
718e3744 7229 "Push out prefix-list ORF and do inbound soft reconfig\n")
7230{
7231 if (strncmp (argv[1], "m", 1) == 0)
7232 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7233 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7234
7235 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7236 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7237}
7238
7239DEFUN (clear_bgp_peer_group_soft_in,
7240 clear_bgp_peer_group_soft_in_cmd,
7241 "clear bgp peer-group WORD soft in",
7242 CLEAR_STR
7243 BGP_STR
7244 "Clear all members of peer-group\n"
7245 "BGP peer-group name\n"
e0bce756
DS
7246 BGP_SOFT_STR
7247 BGP_SOFT_IN_STR)
718e3744 7248{
7249 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7250 BGP_CLEAR_SOFT_IN, argv[0]);
7251}
7252
7253ALIAS (clear_bgp_peer_group_soft_in,
7254 clear_bgp_ipv6_peer_group_soft_in_cmd,
7255 "clear bgp ipv6 peer-group WORD soft in",
7256 CLEAR_STR
7257 BGP_STR
7258 "Address family\n"
7259 "Clear all members of peer-group\n"
7260 "BGP peer-group name\n"
e0bce756
DS
7261 BGP_SOFT_STR
7262 BGP_SOFT_IN_STR)
718e3744 7263
7264ALIAS (clear_bgp_peer_group_soft_in,
7265 clear_bgp_peer_group_in_cmd,
7266 "clear bgp peer-group WORD in",
7267 CLEAR_STR
7268 BGP_STR
7269 "Clear all members of peer-group\n"
7270 "BGP peer-group name\n"
e0bce756 7271 BGP_SOFT_IN_STR)
718e3744 7272
7273ALIAS (clear_bgp_peer_group_soft_in,
7274 clear_bgp_ipv6_peer_group_in_cmd,
7275 "clear bgp ipv6 peer-group WORD in",
7276 CLEAR_STR
7277 BGP_STR
7278 "Address family\n"
7279 "Clear all members of peer-group\n"
7280 "BGP peer-group name\n"
e0bce756 7281 BGP_SOFT_IN_STR)
718e3744 7282
7283DEFUN (clear_bgp_peer_group_in_prefix_filter,
7284 clear_bgp_peer_group_in_prefix_filter_cmd,
7285 "clear bgp peer-group WORD in prefix-filter",
7286 CLEAR_STR
7287 BGP_STR
7288 "Clear all members of peer-group\n"
7289 "BGP peer-group name\n"
e0bce756 7290 BGP_SOFT_IN_STR
718e3744 7291 "Push out prefix-list ORF and do inbound soft reconfig\n")
7292{
7293 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7294 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7295}
7296
7297ALIAS (clear_bgp_peer_group_in_prefix_filter,
7298 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
7299 "clear bgp ipv6 peer-group WORD in prefix-filter",
7300 CLEAR_STR
7301 BGP_STR
7302 "Address family\n"
7303 "Clear all members of peer-group\n"
7304 "BGP peer-group name\n"
e0bce756 7305 BGP_SOFT_IN_STR
718e3744 7306 "Push out prefix-list ORF and do inbound soft reconfig\n")
7307
7308DEFUN (clear_ip_bgp_external_soft_in,
7309 clear_ip_bgp_external_soft_in_cmd,
7310 "clear ip bgp external soft in",
7311 CLEAR_STR
7312 IP_STR
7313 BGP_STR
7314 "Clear all external peers\n"
e0bce756
DS
7315 BGP_SOFT_STR
7316 BGP_SOFT_IN_STR)
718e3744 7317{
7318 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7319 BGP_CLEAR_SOFT_IN, NULL);
7320}
7321
7322ALIAS (clear_ip_bgp_external_soft_in,
7323 clear_ip_bgp_external_in_cmd,
7324 "clear ip bgp external in",
7325 CLEAR_STR
7326 IP_STR
7327 BGP_STR
7328 "Clear all external peers\n"
e0bce756 7329 BGP_SOFT_IN_STR)
718e3744 7330
7331DEFUN (clear_ip_bgp_external_in_prefix_filter,
7332 clear_ip_bgp_external_in_prefix_filter_cmd,
7333 "clear ip bgp external in prefix-filter",
7334 CLEAR_STR
7335 IP_STR
7336 BGP_STR
7337 "Clear all external peers\n"
e0bce756 7338 BGP_SOFT_IN_STR
718e3744 7339 "Push out prefix-list ORF and do inbound soft reconfig\n")
7340{
7341 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7342 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7343}
7344
7345DEFUN (clear_ip_bgp_external_ipv4_soft_in,
7346 clear_ip_bgp_external_ipv4_soft_in_cmd,
7347 "clear ip bgp external ipv4 (unicast|multicast) soft in",
7348 CLEAR_STR
7349 IP_STR
7350 BGP_STR
7351 "Clear all external peers\n"
7352 "Address family\n"
7353 "Address Family modifier\n"
7354 "Address Family modifier\n"
e0bce756
DS
7355 BGP_SOFT_STR
7356 BGP_SOFT_IN_STR)
718e3744 7357{
7358 if (strncmp (argv[0], "m", 1) == 0)
7359 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7360 BGP_CLEAR_SOFT_IN, NULL);
7361
7362 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7363 BGP_CLEAR_SOFT_IN, NULL);
7364}
7365
7366ALIAS (clear_ip_bgp_external_ipv4_soft_in,
7367 clear_ip_bgp_external_ipv4_in_cmd,
7368 "clear ip bgp external ipv4 (unicast|multicast) in",
7369 CLEAR_STR
7370 IP_STR
7371 BGP_STR
7372 "Clear all external peers\n"
7373 "Address family\n"
7374 "Address Family modifier\n"
7375 "Address Family modifier\n"
e0bce756 7376 BGP_SOFT_IN_STR)
718e3744 7377
7378DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
7379 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
7380 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
7381 CLEAR_STR
7382 IP_STR
7383 BGP_STR
7384 "Clear all external peers\n"
7385 "Address family\n"
7386 "Address Family modifier\n"
7387 "Address Family modifier\n"
e0bce756 7388 BGP_SOFT_IN_STR
718e3744 7389 "Push out prefix-list ORF and do inbound soft reconfig\n")
7390{
7391 if (strncmp (argv[0], "m", 1) == 0)
7392 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7393 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7394
7395 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7396 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7397}
7398
7399DEFUN (clear_bgp_external_soft_in,
7400 clear_bgp_external_soft_in_cmd,
7401 "clear bgp external soft in",
7402 CLEAR_STR
7403 BGP_STR
7404 "Clear all external peers\n"
e0bce756
DS
7405 BGP_SOFT_STR
7406 BGP_SOFT_IN_STR)
718e3744 7407{
7408 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7409 BGP_CLEAR_SOFT_IN, NULL);
7410}
7411
7412ALIAS (clear_bgp_external_soft_in,
7413 clear_bgp_ipv6_external_soft_in_cmd,
7414 "clear bgp ipv6 external soft in",
7415 CLEAR_STR
7416 BGP_STR
7417 "Address family\n"
7418 "Clear all external peers\n"
e0bce756
DS
7419 BGP_SOFT_STR
7420 BGP_SOFT_IN_STR)
718e3744 7421
7422ALIAS (clear_bgp_external_soft_in,
7423 clear_bgp_external_in_cmd,
7424 "clear bgp external in",
7425 CLEAR_STR
7426 BGP_STR
7427 "Clear all external peers\n"
e0bce756 7428 BGP_SOFT_IN_STR)
718e3744 7429
7430ALIAS (clear_bgp_external_soft_in,
7431 clear_bgp_ipv6_external_in_cmd,
7432 "clear bgp ipv6 external WORD in",
7433 CLEAR_STR
7434 BGP_STR
7435 "Address family\n"
7436 "Clear all external peers\n"
e0bce756 7437 BGP_SOFT_IN_STR)
718e3744 7438
7439DEFUN (clear_bgp_external_in_prefix_filter,
7440 clear_bgp_external_in_prefix_filter_cmd,
7441 "clear bgp external in prefix-filter",
7442 CLEAR_STR
7443 BGP_STR
7444 "Clear all external peers\n"
e0bce756 7445 BGP_SOFT_IN_STR
718e3744 7446 "Push out prefix-list ORF and do inbound soft reconfig\n")
7447{
7448 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7449 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7450}
7451
7452ALIAS (clear_bgp_external_in_prefix_filter,
7453 clear_bgp_ipv6_external_in_prefix_filter_cmd,
7454 "clear bgp ipv6 external in prefix-filter",
7455 CLEAR_STR
7456 BGP_STR
7457 "Address family\n"
7458 "Clear all external peers\n"
e0bce756 7459 BGP_SOFT_IN_STR
718e3744 7460 "Push out prefix-list ORF and do inbound soft reconfig\n")
7461
7462DEFUN (clear_ip_bgp_as_soft_in,
7463 clear_ip_bgp_as_soft_in_cmd,
320da874 7464 "clear ip bgp " CMD_AS_RANGE " soft in",
718e3744 7465 CLEAR_STR
7466 IP_STR
7467 BGP_STR
7468 "Clear peers with the AS number\n"
e0bce756
DS
7469 BGP_SOFT_STR
7470 BGP_SOFT_IN_STR)
718e3744 7471{
7472 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7473 BGP_CLEAR_SOFT_IN, argv[0]);
7474}
7475
7476ALIAS (clear_ip_bgp_as_soft_in,
7477 clear_ip_bgp_as_in_cmd,
320da874 7478 "clear ip bgp " CMD_AS_RANGE " in",
718e3744 7479 CLEAR_STR
7480 IP_STR
7481 BGP_STR
7482 "Clear peers with the AS number\n"
e0bce756 7483 BGP_SOFT_IN_STR)
718e3744 7484
7485DEFUN (clear_ip_bgp_as_in_prefix_filter,
7486 clear_ip_bgp_as_in_prefix_filter_cmd,
320da874 7487 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 7488 CLEAR_STR
7489 IP_STR
7490 BGP_STR
7491 "Clear peers with the AS number\n"
e0bce756 7492 BGP_SOFT_IN_STR
718e3744 7493 "Push out prefix-list ORF and do inbound soft reconfig\n")
7494{
7495 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7496 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7497}
7498
7499DEFUN (clear_ip_bgp_as_ipv4_soft_in,
7500 clear_ip_bgp_as_ipv4_soft_in_cmd,
320da874 7501 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
718e3744 7502 CLEAR_STR
7503 IP_STR
7504 BGP_STR
7505 "Clear peers with the AS number\n"
7506 "Address family\n"
7507 "Address Family modifier\n"
7508 "Address Family modifier\n"
e0bce756
DS
7509 BGP_SOFT_STR
7510 BGP_SOFT_IN_STR)
718e3744 7511{
7512 if (strncmp (argv[1], "m", 1) == 0)
7513 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7514 BGP_CLEAR_SOFT_IN, argv[0]);
7515
7516 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7517 BGP_CLEAR_SOFT_IN, argv[0]);
7518}
7519
7520ALIAS (clear_ip_bgp_as_ipv4_soft_in,
7521 clear_ip_bgp_as_ipv4_in_cmd,
320da874 7522 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
718e3744 7523 CLEAR_STR
7524 IP_STR
7525 BGP_STR
7526 "Clear peers with the AS number\n"
7527 "Address family\n"
7528 "Address Family modifier\n"
7529 "Address Family modifier\n"
e0bce756 7530 BGP_SOFT_IN_STR)
718e3744 7531
7532DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
7533 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
320da874 7534 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
718e3744 7535 CLEAR_STR
7536 IP_STR
7537 BGP_STR
7538 "Clear peers with the AS number\n"
7539 "Address family\n"
7540 "Address Family modifier\n"
7541 "Address Family modifier\n"
e0bce756 7542 BGP_SOFT_IN_STR
718e3744 7543 "Push out prefix-list ORF and do inbound soft reconfig\n")
7544{
7545 if (strncmp (argv[1], "m", 1) == 0)
7546 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7547 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7548
7549 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7550 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7551}
7552
7553DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
7554 clear_ip_bgp_as_vpnv4_soft_in_cmd,
320da874 7555 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
718e3744 7556 CLEAR_STR
7557 IP_STR
7558 BGP_STR
7559 "Clear peers with the AS number\n"
7560 "Address family\n"
7561 "Address Family modifier\n"
e0bce756
DS
7562 BGP_SOFT_STR
7563 BGP_SOFT_IN_STR)
718e3744 7564{
7565 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7566 BGP_CLEAR_SOFT_IN, argv[0]);
7567}
7568
7569ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
7570 clear_ip_bgp_as_vpnv4_in_cmd,
320da874 7571 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
718e3744 7572 CLEAR_STR
7573 IP_STR
7574 BGP_STR
7575 "Clear peers with the AS number\n"
7576 "Address family\n"
7577 "Address Family modifier\n"
e0bce756 7578 BGP_SOFT_IN_STR)
718e3744 7579
7580DEFUN (clear_bgp_as_soft_in,
7581 clear_bgp_as_soft_in_cmd,
320da874 7582 "clear bgp " CMD_AS_RANGE " soft in",
718e3744 7583 CLEAR_STR
7584 BGP_STR
7585 "Clear peers with the AS number\n"
e0bce756
DS
7586 BGP_SOFT_STR
7587 BGP_SOFT_IN_STR)
718e3744 7588{
7589 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7590 BGP_CLEAR_SOFT_IN, argv[0]);
7591}
7592
7593ALIAS (clear_bgp_as_soft_in,
7594 clear_bgp_ipv6_as_soft_in_cmd,
320da874 7595 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
718e3744 7596 CLEAR_STR
7597 BGP_STR
7598 "Address family\n"
7599 "Clear peers with the AS number\n"
e0bce756
DS
7600 BGP_SOFT_STR
7601 BGP_SOFT_IN_STR)
718e3744 7602
7603ALIAS (clear_bgp_as_soft_in,
7604 clear_bgp_as_in_cmd,
320da874 7605 "clear bgp " CMD_AS_RANGE " in",
718e3744 7606 CLEAR_STR
7607 BGP_STR
7608 "Clear peers with the AS number\n"
e0bce756 7609 BGP_SOFT_IN_STR)
718e3744 7610
7611ALIAS (clear_bgp_as_soft_in,
7612 clear_bgp_ipv6_as_in_cmd,
320da874 7613 "clear bgp ipv6 " CMD_AS_RANGE " in",
718e3744 7614 CLEAR_STR
7615 BGP_STR
7616 "Address family\n"
7617 "Clear peers with the AS number\n"
e0bce756 7618 BGP_SOFT_IN_STR)
718e3744 7619
7620DEFUN (clear_bgp_as_in_prefix_filter,
7621 clear_bgp_as_in_prefix_filter_cmd,
320da874 7622 "clear bgp " CMD_AS_RANGE " in prefix-filter",
718e3744 7623 CLEAR_STR
7624 BGP_STR
7625 "Clear peers with the AS number\n"
e0bce756 7626 BGP_SOFT_IN_STR
718e3744 7627 "Push out prefix-list ORF and do inbound soft reconfig\n")
7628{
7629 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7630 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7631}
7632
7633ALIAS (clear_bgp_as_in_prefix_filter,
7634 clear_bgp_ipv6_as_in_prefix_filter_cmd,
320da874 7635 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
718e3744 7636 CLEAR_STR
7637 BGP_STR
7638 "Address family\n"
7639 "Clear peers with the AS number\n"
e0bce756 7640 BGP_SOFT_IN_STR
718e3744 7641 "Push out prefix-list ORF and do inbound soft reconfig\n")
6b0655a2 7642
718e3744 7643/* Both soft-reconfiguration */
7644DEFUN (clear_ip_bgp_all_soft,
7645 clear_ip_bgp_all_soft_cmd,
7646 "clear ip bgp * soft",
7647 CLEAR_STR
7648 IP_STR
7649 BGP_STR
7650 "Clear all peers\n"
e0bce756 7651 BGP_SOFT_STR)
718e3744 7652{
7653 if (argc == 1)
7654 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
7655 BGP_CLEAR_SOFT_BOTH, NULL);
7656
7657 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7658 BGP_CLEAR_SOFT_BOTH, NULL);
7659}
7660
7661ALIAS (clear_ip_bgp_all_soft,
7662 clear_ip_bgp_instance_all_soft_cmd,
7663 "clear ip bgp view WORD * soft",
7664 CLEAR_STR
7665 IP_STR
7666 BGP_STR
7667 "BGP view\n"
7668 "view name\n"
7669 "Clear all peers\n"
e0bce756 7670 BGP_SOFT_STR)
718e3744 7671
7672
7673DEFUN (clear_ip_bgp_all_ipv4_soft,
7674 clear_ip_bgp_all_ipv4_soft_cmd,
7675 "clear ip bgp * ipv4 (unicast|multicast) soft",
7676 CLEAR_STR
7677 IP_STR
7678 BGP_STR
7679 "Clear all peers\n"
7680 "Address family\n"
7681 "Address Family Modifier\n"
7682 "Address Family Modifier\n"
e0bce756 7683 BGP_SOFT_STR)
718e3744 7684{
7685 if (strncmp (argv[0], "m", 1) == 0)
7686 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7687 BGP_CLEAR_SOFT_BOTH, NULL);
7688
7689 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7690 BGP_CLEAR_SOFT_BOTH, NULL);
7691}
7692
7693DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
7694 clear_ip_bgp_instance_all_ipv4_soft_cmd,
7695 "clear ip bgp view WORD * ipv4 (unicast|multicast) soft",
7696 CLEAR_STR
7697 IP_STR
7698 BGP_STR
7699 "BGP view\n"
7700 "view name\n"
7701 "Clear all peers\n"
7702 "Address family\n"
7703 "Address Family Modifier\n"
7704 "Address Family Modifier\n"
e0bce756 7705 BGP_SOFT_STR)
718e3744 7706{
7707 if (strncmp (argv[1], "m", 1) == 0)
7708 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7709 BGP_CLEAR_SOFT_BOTH, NULL);
7710
7711 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7712 BGP_CLEAR_SOFT_BOTH, NULL);
7713}
7714
7715DEFUN (clear_ip_bgp_all_vpnv4_soft,
7716 clear_ip_bgp_all_vpnv4_soft_cmd,
7717 "clear ip bgp * vpnv4 unicast soft",
7718 CLEAR_STR
7719 IP_STR
7720 BGP_STR
7721 "Clear all peers\n"
7722 "Address family\n"
7723 "Address Family Modifier\n"
e0bce756 7724 BGP_SOFT_STR)
718e3744 7725{
7726 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7727 BGP_CLEAR_SOFT_BOTH, argv[0]);
7728}
7729
7730DEFUN (clear_bgp_all_soft,
7731 clear_bgp_all_soft_cmd,
7732 "clear bgp * soft",
7733 CLEAR_STR
7734 BGP_STR
7735 "Clear all peers\n"
e0bce756 7736 BGP_SOFT_STR)
718e3744 7737{
7738 if (argc == 1)
7739 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
7740 BGP_CLEAR_SOFT_BOTH, argv[0]);
7741
7742 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7743 BGP_CLEAR_SOFT_BOTH, argv[0]);
7744}
7745
7746ALIAS (clear_bgp_all_soft,
7747 clear_bgp_instance_all_soft_cmd,
7748 "clear bgp view WORD * soft",
7749 CLEAR_STR
7750 BGP_STR
7751 "BGP view\n"
7752 "view name\n"
7753 "Clear all peers\n"
e0bce756 7754 BGP_SOFT_STR)
718e3744 7755
7756ALIAS (clear_bgp_all_soft,
7757 clear_bgp_ipv6_all_soft_cmd,
7758 "clear bgp ipv6 * soft",
7759 CLEAR_STR
7760 BGP_STR
7761 "Address family\n"
7762 "Clear all peers\n"
e0bce756 7763 BGP_SOFT_STR)
718e3744 7764
7765DEFUN (clear_ip_bgp_peer_soft,
7766 clear_ip_bgp_peer_soft_cmd,
db64ea86 7767 "clear ip bgp (A.B.C.D|WORD) soft",
718e3744 7768 CLEAR_STR
7769 IP_STR
7770 BGP_STR
7771 "BGP neighbor address to clear\n"
db64ea86 7772 "BGP neighbor on interface to clear\n"
e0bce756 7773 BGP_SOFT_STR)
718e3744 7774{
7775 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7776 BGP_CLEAR_SOFT_BOTH, argv[0]);
7777}
7778
7779DEFUN (clear_ip_bgp_peer_ipv4_soft,
7780 clear_ip_bgp_peer_ipv4_soft_cmd,
db64ea86 7781 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
718e3744 7782 CLEAR_STR
7783 IP_STR
7784 BGP_STR
7785 "BGP neighbor address to clear\n"
db64ea86 7786 "BGP neighbor on interface to clear\n"
718e3744 7787 "Address family\n"
7788 "Address Family Modifier\n"
7789 "Address Family Modifier\n"
e0bce756 7790 BGP_SOFT_STR)
718e3744 7791{
7792 if (strncmp (argv[1], "m", 1) == 0)
7793 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7794 BGP_CLEAR_SOFT_BOTH, argv[0]);
7795
7796 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7797 BGP_CLEAR_SOFT_BOTH, argv[0]);
7798}
7799
7800DEFUN (clear_ip_bgp_peer_vpnv4_soft,
7801 clear_ip_bgp_peer_vpnv4_soft_cmd,
db64ea86 7802 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft",
718e3744 7803 CLEAR_STR
7804 IP_STR
7805 BGP_STR
7806 "BGP neighbor address to clear\n"
db64ea86 7807 "BGP neighbor on interface to clear\n"
718e3744 7808 "Address family\n"
7809 "Address Family Modifier\n"
e0bce756 7810 BGP_SOFT_STR)
718e3744 7811{
7812 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7813 BGP_CLEAR_SOFT_BOTH, argv[0]);
7814}
7815
7816DEFUN (clear_bgp_peer_soft,
7817 clear_bgp_peer_soft_cmd,
a80beece 7818 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 7819 CLEAR_STR
7820 BGP_STR
7821 "BGP neighbor address to clear\n"
7822 "BGP IPv6 neighbor to clear\n"
a80beece 7823 "BGP neighbor on interface to clear\n"
e0bce756 7824 BGP_SOFT_STR)
718e3744 7825{
7826 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7827 BGP_CLEAR_SOFT_BOTH, argv[0]);
7828}
7829
7830ALIAS (clear_bgp_peer_soft,
7831 clear_bgp_ipv6_peer_soft_cmd,
a80beece 7832 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
718e3744 7833 CLEAR_STR
7834 BGP_STR
7835 "Address family\n"
7836 "BGP neighbor address to clear\n"
7837 "BGP IPv6 neighbor to clear\n"
a80beece 7838 "BGP neighbor on interface to clear\n"
e0bce756 7839 BGP_SOFT_STR)
718e3744 7840
7841DEFUN (clear_ip_bgp_peer_group_soft,
7842 clear_ip_bgp_peer_group_soft_cmd,
7843 "clear ip bgp peer-group WORD soft",
7844 CLEAR_STR
7845 IP_STR
7846 BGP_STR
7847 "Clear all members of peer-group\n"
7848 "BGP peer-group name\n"
e0bce756 7849 BGP_SOFT_STR)
718e3744 7850{
7851 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7852 BGP_CLEAR_SOFT_BOTH, argv[0]);
7853}
7854
7855DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
7856 clear_ip_bgp_peer_group_ipv4_soft_cmd,
7857 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
7858 CLEAR_STR
7859 IP_STR
7860 BGP_STR
7861 "Clear all members of peer-group\n"
7862 "BGP peer-group name\n"
7863 "Address family\n"
7864 "Address Family modifier\n"
7865 "Address Family modifier\n"
e0bce756 7866 BGP_SOFT_STR)
718e3744 7867{
7868 if (strncmp (argv[1], "m", 1) == 0)
7869 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7870 BGP_CLEAR_SOFT_BOTH, argv[0]);
7871
7872 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7873 BGP_CLEAR_SOFT_BOTH, argv[0]);
7874}
7875
7876DEFUN (clear_bgp_peer_group_soft,
7877 clear_bgp_peer_group_soft_cmd,
7878 "clear bgp peer-group WORD soft",
7879 CLEAR_STR
7880 BGP_STR
7881 "Clear all members of peer-group\n"
7882 "BGP peer-group name\n"
e0bce756 7883 BGP_SOFT_STR)
718e3744 7884{
7885 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7886 BGP_CLEAR_SOFT_BOTH, argv[0]);
7887}
7888
7889ALIAS (clear_bgp_peer_group_soft,
7890 clear_bgp_ipv6_peer_group_soft_cmd,
7891 "clear bgp ipv6 peer-group WORD soft",
7892 CLEAR_STR
7893 BGP_STR
7894 "Address family\n"
7895 "Clear all members of peer-group\n"
7896 "BGP peer-group name\n"
e0bce756 7897 BGP_SOFT_STR)
718e3744 7898
7899DEFUN (clear_ip_bgp_external_soft,
7900 clear_ip_bgp_external_soft_cmd,
7901 "clear ip bgp external soft",
7902 CLEAR_STR
7903 IP_STR
7904 BGP_STR
7905 "Clear all external peers\n"
e0bce756 7906 BGP_SOFT_STR)
718e3744 7907{
7908 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7909 BGP_CLEAR_SOFT_BOTH, NULL);
7910}
7911
7912DEFUN (clear_ip_bgp_external_ipv4_soft,
7913 clear_ip_bgp_external_ipv4_soft_cmd,
7914 "clear ip bgp external ipv4 (unicast|multicast) soft",
7915 CLEAR_STR
7916 IP_STR
7917 BGP_STR
7918 "Clear all external peers\n"
7919 "Address family\n"
7920 "Address Family modifier\n"
7921 "Address Family modifier\n"
e0bce756 7922 BGP_SOFT_STR)
718e3744 7923{
7924 if (strncmp (argv[0], "m", 1) == 0)
7925 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7926 BGP_CLEAR_SOFT_BOTH, NULL);
7927
7928 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7929 BGP_CLEAR_SOFT_BOTH, NULL);
7930}
7931
7932DEFUN (clear_bgp_external_soft,
7933 clear_bgp_external_soft_cmd,
7934 "clear bgp external soft",
7935 CLEAR_STR
7936 BGP_STR
7937 "Clear all external peers\n"
e0bce756 7938 BGP_SOFT_STR)
718e3744 7939{
7940 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7941 BGP_CLEAR_SOFT_BOTH, NULL);
7942}
7943
7944ALIAS (clear_bgp_external_soft,
7945 clear_bgp_ipv6_external_soft_cmd,
7946 "clear bgp ipv6 external soft",
7947 CLEAR_STR
7948 BGP_STR
7949 "Address family\n"
7950 "Clear all external peers\n"
e0bce756 7951 BGP_SOFT_STR)
718e3744 7952
7953DEFUN (clear_ip_bgp_as_soft,
7954 clear_ip_bgp_as_soft_cmd,
320da874 7955 "clear ip bgp " CMD_AS_RANGE " soft",
718e3744 7956 CLEAR_STR
7957 IP_STR
7958 BGP_STR
7959 "Clear peers with the AS number\n"
e0bce756 7960 BGP_SOFT_STR)
718e3744 7961{
7962 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7963 BGP_CLEAR_SOFT_BOTH, argv[0]);
7964}
7965
7966DEFUN (clear_ip_bgp_as_ipv4_soft,
7967 clear_ip_bgp_as_ipv4_soft_cmd,
320da874 7968 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
718e3744 7969 CLEAR_STR
7970 IP_STR
7971 BGP_STR
7972 "Clear peers with the AS number\n"
7973 "Address family\n"
7974 "Address Family Modifier\n"
7975 "Address Family Modifier\n"
e0bce756 7976 BGP_SOFT_STR)
718e3744 7977{
7978 if (strncmp (argv[1], "m", 1) == 0)
7979 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7980 BGP_CLEAR_SOFT_BOTH, argv[0]);
7981
7982 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
7983 BGP_CLEAR_SOFT_BOTH, argv[0]);
7984}
7985
7986DEFUN (clear_ip_bgp_as_vpnv4_soft,
7987 clear_ip_bgp_as_vpnv4_soft_cmd,
320da874 7988 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
718e3744 7989 CLEAR_STR
7990 IP_STR
7991 BGP_STR
7992 "Clear peers with the AS number\n"
7993 "Address family\n"
7994 "Address Family Modifier\n"
e0bce756 7995 BGP_SOFT_STR)
718e3744 7996{
7997 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7998 BGP_CLEAR_SOFT_BOTH, argv[0]);
7999}
8000
8001DEFUN (clear_bgp_as_soft,
8002 clear_bgp_as_soft_cmd,
320da874 8003 "clear bgp " CMD_AS_RANGE " soft",
718e3744 8004 CLEAR_STR
8005 BGP_STR
8006 "Clear peers with the AS number\n"
e0bce756 8007 BGP_SOFT_STR)
718e3744 8008{
8009 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8010 BGP_CLEAR_SOFT_BOTH, argv[0]);
8011}
8012
8013ALIAS (clear_bgp_as_soft,
8014 clear_bgp_ipv6_as_soft_cmd,
320da874 8015 "clear bgp ipv6 " CMD_AS_RANGE " soft",
718e3744 8016 CLEAR_STR
8017 BGP_STR
8018 "Address family\n"
8019 "Clear peers with the AS number\n"
e0bce756 8020 BGP_SOFT_STR)
6b0655a2 8021
fee0f4c6 8022/* RS-client soft reconfiguration. */
8023#ifdef HAVE_IPV6
8024DEFUN (clear_bgp_all_rsclient,
8025 clear_bgp_all_rsclient_cmd,
8026 "clear bgp * rsclient",
8027 CLEAR_STR
8028 BGP_STR
8029 "Clear all peers\n"
e0bce756 8030 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8031{
8032 if (argc == 1)
8033 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
8034 BGP_CLEAR_SOFT_RSCLIENT, NULL);
8035
8036 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
8037 BGP_CLEAR_SOFT_RSCLIENT, NULL);
8038}
8039
8040ALIAS (clear_bgp_all_rsclient,
8041 clear_bgp_ipv6_all_rsclient_cmd,
8042 "clear bgp ipv6 * rsclient",
8043 CLEAR_STR
8044 BGP_STR
8045 "Address family\n"
8046 "Clear all peers\n"
e0bce756 8047 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8048
8049ALIAS (clear_bgp_all_rsclient,
8050 clear_bgp_instance_all_rsclient_cmd,
8051 "clear bgp view WORD * rsclient",
8052 CLEAR_STR
8053 BGP_STR
8054 "BGP view\n"
8055 "view name\n"
8056 "Clear all peers\n"
e0bce756 8057 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8058
8059ALIAS (clear_bgp_all_rsclient,
8060 clear_bgp_ipv6_instance_all_rsclient_cmd,
8061 "clear bgp ipv6 view WORD * rsclient",
8062 CLEAR_STR
8063 BGP_STR
8064 "Address family\n"
8065 "BGP view\n"
8066 "view name\n"
8067 "Clear all peers\n"
e0bce756 8068 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8069#endif /* HAVE_IPV6 */
8070
8071DEFUN (clear_ip_bgp_all_rsclient,
8072 clear_ip_bgp_all_rsclient_cmd,
8073 "clear ip bgp * rsclient",
8074 CLEAR_STR
8075 IP_STR
8076 BGP_STR
8077 "Clear all peers\n"
e0bce756 8078 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8079{
8080 if (argc == 1)
8081 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
8082 BGP_CLEAR_SOFT_RSCLIENT, NULL);
8083
8084 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8085 BGP_CLEAR_SOFT_RSCLIENT, NULL);
8086}
8087
8088ALIAS (clear_ip_bgp_all_rsclient,
8089 clear_ip_bgp_instance_all_rsclient_cmd,
8090 "clear ip bgp view WORD * rsclient",
8091 CLEAR_STR
8092 IP_STR
8093 BGP_STR
8094 "BGP view\n"
8095 "view name\n"
8096 "Clear all peers\n"
e0bce756 8097 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8098
8099#ifdef HAVE_IPV6
8100DEFUN (clear_bgp_peer_rsclient,
8101 clear_bgp_peer_rsclient_cmd,
a80beece 8102 "clear bgp (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8103 CLEAR_STR
8104 BGP_STR
8105 "BGP neighbor IP address to clear\n"
8106 "BGP IPv6 neighbor to clear\n"
a80beece 8107 "BGP neighbor on interface to clear\n"
e0bce756 8108 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8109{
8110 if (argc == 2)
8111 return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_peer,
8112 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
8113
8114 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
8115 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
8116}
8117
8118ALIAS (clear_bgp_peer_rsclient,
8119 clear_bgp_ipv6_peer_rsclient_cmd,
a80beece 8120 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8121 CLEAR_STR
8122 BGP_STR
8123 "Address family\n"
8124 "BGP neighbor IP address to clear\n"
8125 "BGP IPv6 neighbor to clear\n"
a80beece 8126 "BGP neighbor on interface to clear\n"
e0bce756 8127 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8128
8129ALIAS (clear_bgp_peer_rsclient,
8130 clear_bgp_instance_peer_rsclient_cmd,
a80beece 8131 "clear bgp view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8132 CLEAR_STR
8133 BGP_STR
8134 "BGP view\n"
8135 "view name\n"
8136 "BGP neighbor IP address to clear\n"
8137 "BGP IPv6 neighbor to clear\n"
a80beece 8138 "BGP neighbor on interface to clear\n"
e0bce756 8139 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8140
8141ALIAS (clear_bgp_peer_rsclient,
8142 clear_bgp_ipv6_instance_peer_rsclient_cmd,
a80beece 8143 "clear bgp ipv6 view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8144 CLEAR_STR
8145 BGP_STR
8146 "Address family\n"
8147 "BGP view\n"
8148 "view name\n"
8149 "BGP neighbor IP address to clear\n"
8150 "BGP IPv6 neighbor to clear\n"
a80beece 8151 "BGP neighbor on interface to clear\n"
e0bce756 8152 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8153#endif /* HAVE_IPV6 */
8154
8155DEFUN (clear_ip_bgp_peer_rsclient,
8156 clear_ip_bgp_peer_rsclient_cmd,
a80beece 8157 "clear ip bgp (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8158 CLEAR_STR
8159 IP_STR
8160 BGP_STR
8161 "BGP neighbor IP address to clear\n"
8162 "BGP IPv6 neighbor to clear\n"
a80beece 8163 "BGP neighbor on interface to clear\n"
e0bce756 8164 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8165{
8166 if (argc == 2)
8167 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_peer,
8168 BGP_CLEAR_SOFT_RSCLIENT, argv[1]);
8169
8170 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
8171 BGP_CLEAR_SOFT_RSCLIENT, argv[0]);
8172}
8173
8174ALIAS (clear_ip_bgp_peer_rsclient,
8175 clear_ip_bgp_instance_peer_rsclient_cmd,
a80beece 8176 "clear ip bgp view WORD (A.B.C.D|X:X::X:X|WORD) rsclient",
fee0f4c6 8177 CLEAR_STR
8178 IP_STR
8179 BGP_STR
8180 "BGP view\n"
8181 "view name\n"
8182 "BGP neighbor IP address to clear\n"
8183 "BGP IPv6 neighbor to clear\n"
a80beece 8184 "BGP neighbor on interface to clear\n"
e0bce756 8185 BGP_SOFT_RSCLIENT_RIB_STR)
fee0f4c6 8186
e0081f70
ML
8187DEFUN (show_bgp_views,
8188 show_bgp_views_cmd,
8189 "show bgp views",
8190 SHOW_STR
8191 BGP_STR
8192 "Show the defined BGP views\n")
8193{
8194 struct list *inst = bm->bgp;
8195 struct listnode *node;
8196 struct bgp *bgp;
8197
8198 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
8199 {
8200 vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
8201 return CMD_WARNING;
8202 }
8203
8204 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
8205 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8206 vty_out (vty, "\t%s (AS%u)%s",
8207 bgp->name ? bgp->name : "(null)",
8208 bgp->as, VTY_NEWLINE);
8209
8210 return CMD_SUCCESS;
8211}
8212
4bf6a362
PJ
8213DEFUN (show_bgp_memory,
8214 show_bgp_memory_cmd,
8215 "show bgp memory",
8216 SHOW_STR
8217 BGP_STR
8218 "Global BGP memory statistics\n")
8219{
8220 char memstrbuf[MTYPE_MEMSTR_LEN];
8221 unsigned long count;
8222
8223 /* RIB related usage stats */
8224 count = mtype_stats_alloc (MTYPE_BGP_NODE);
8225 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
8226 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8227 count * sizeof (struct bgp_node)),
8228 VTY_NEWLINE);
8229
8230 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
8231 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
8232 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8233 count * sizeof (struct bgp_info)),
8234 VTY_NEWLINE);
fb982c25
PJ
8235 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
8236 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
8237 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8238 count * sizeof (struct bgp_info_extra)),
8239 VTY_NEWLINE);
4bf6a362
PJ
8240
8241 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
8242 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
8243 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8244 count * sizeof (struct bgp_static)),
8245 VTY_NEWLINE);
3f9c7369
DS
8246
8247 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
8248 vty_out (vty, "%ld Packets, using %s of memory%s", count,
8249 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8250 count * sizeof (struct bpacket)),
8251 VTY_NEWLINE);
4bf6a362
PJ
8252
8253 /* Adj-In/Out */
8254 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
8255 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
8256 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8257 count * sizeof (struct bgp_adj_in)),
8258 VTY_NEWLINE);
8259 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
8260 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
8261 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8262 count * sizeof (struct bgp_adj_out)),
8263 VTY_NEWLINE);
8264
8265 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
8266 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
8267 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8268 count * sizeof (struct bgp_nexthop_cache)),
8269 VTY_NEWLINE);
8270
8271 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
8272 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
8273 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8274 count * sizeof (struct bgp_damp_info)),
8275 VTY_NEWLINE);
8276
8277 /* Attributes */
8278 count = attr_count();
8279 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
8280 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8281 count * sizeof(struct attr)),
8282 VTY_NEWLINE);
fb982c25
PJ
8283 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
8284 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
8285 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8286 count * sizeof(struct attr_extra)),
8287 VTY_NEWLINE);
4bf6a362
PJ
8288
8289 if ((count = attr_unknown_count()))
8290 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
8291
8292 /* AS_PATH attributes */
8293 count = aspath_count ();
8294 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
8295 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8296 count * sizeof (struct aspath)),
8297 VTY_NEWLINE);
8298
8299 count = mtype_stats_alloc (MTYPE_AS_SEG);
8300 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
8301 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8302 count * sizeof (struct assegment)),
8303 VTY_NEWLINE);
8304
8305 /* Other attributes */
8306 if ((count = community_count ()))
8307 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8308 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8309 count * sizeof (struct community)),
8310 VTY_NEWLINE);
8311 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
8312 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8313 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8314 count * sizeof (struct ecommunity)),
8315 VTY_NEWLINE);
8316
8317 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
8318 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
8319 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8320 count * sizeof (struct cluster_list)),
8321 VTY_NEWLINE);
8322
8323 /* Peer related usage */
8324 count = mtype_stats_alloc (MTYPE_BGP_PEER);
8325 vty_out (vty, "%ld peers, using %s of memory%s", count,
8326 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8327 count * sizeof (struct peer)),
8328 VTY_NEWLINE);
8329
6e919709 8330 if ((count = mtype_stats_alloc (MTYPE_BGP_PEER_GROUP)))
4bf6a362
PJ
8331 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
8332 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8333 count * sizeof (struct peer_group)),
8334 VTY_NEWLINE);
8335
8336 /* Other */
8337 if ((count = mtype_stats_alloc (MTYPE_HASH)))
8338 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
8339 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8340 count * sizeof (struct hash)),
8341 VTY_NEWLINE);
8342 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
8343 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
8344 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8345 count * sizeof (struct hash_backet)),
8346 VTY_NEWLINE);
8347 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
8348 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
8349 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8350 count * sizeof (regex_t)),
8351 VTY_NEWLINE);
8352 return CMD_SUCCESS;
8353}
fee0f4c6 8354
47fc97cc
DS
8355static int
8356bgp_adj_out_count (struct peer *peer, int afi, int safi)
8357{
8358 struct bgp_table *table;
8359 struct bgp_node *rn;
47fc97cc
DS
8360 int count = 0;
8361
8362 if (!peer) return(0);
8363
8364 table = peer->bgp->rib[afi][safi];
8365 if (!table) return(0);
8366 for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
8367 if (bgp_adj_out_lookup(peer, NULL, afi, safi, rn))
8368 count++;
8369 return (count);
8370}
8371
718e3744 8372/* Show BGP peer's summary information. */
94f2b392 8373static int
b05a1c8b
DS
8374bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
8375 u_char use_json)
718e3744 8376{
8377 struct peer *peer;
1eb8ef25 8378 struct listnode *node, *nnode;
f14e6fdb
DS
8379 unsigned int count = 0, dn_count = 0;
8380 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
718e3744 8381 int len;
ffd0c037 8382 json_object *json = NULL;
ffd0c037
DS
8383 json_object *json_peer = NULL;
8384 json_object *json_peers = NULL;
718e3744 8385
8386 /* Header string for each address family. */
8387 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
47fc97cc 8388
b05a1c8b
DS
8389 if (use_json)
8390 {
8391 json = json_object_new_object();
f1aa5d8a 8392 json_peers = json_object_new_object();
b05a1c8b
DS
8393 }
8394
1eb8ef25 8395 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 8396 {
1ff9a340
DS
8397 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
8398 continue;
8399
718e3744 8400 if (peer->afc[afi][safi])
8401 {
b05a1c8b 8402 if (!count)
4bf6a362
PJ
8403 {
8404 unsigned long ents;
8405 char memstrbuf[MTYPE_MEMSTR_LEN];
b05a1c8b 8406
4bf6a362 8407 /* Usage summary and header */
b05a1c8b
DS
8408 if (use_json)
8409 {
62d6dca0 8410 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
f1aa5d8a 8411 json_object_int_add(json, "as", bgp->as);
b05a1c8b
DS
8412 }
8413 else
8414 {
8415 vty_out (vty,
8416 "BGP router identifier %s, local AS number %u%s",
8417 inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
8418 }
8419
f188f2c4
DS
8420 if (bgp_update_delay_configured(bgp))
8421 {
b05a1c8b 8422 if (use_json)
f188f2c4 8423 {
62d6dca0 8424 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
b05a1c8b
DS
8425
8426 if (bgp->v_update_delay != bgp->v_establish_wait)
62d6dca0 8427 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
b05a1c8b
DS
8428
8429 if (bgp_update_delay_active(bgp))
8430 {
62d6dca0
DS
8431 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
8432 json_object_boolean_true_add(json, "updateDelayInProgress");
b05a1c8b
DS
8433 }
8434 else
8435 {
8436 if (bgp->update_delay_over)
8437 {
62d6dca0 8438 json_object_string_add(json, "updateDelayFirstNeighbor",
f1aa5d8a 8439 bgp->update_delay_begin_time);
62d6dca0 8440 json_object_string_add(json, "updateDelayBestpathResumed",
f1aa5d8a 8441 bgp->update_delay_end_time);
62d6dca0 8442 json_object_string_add(json, "updateDelayZebraUpdateResume",
f1aa5d8a 8443 bgp->update_delay_zebra_resume_time);
62d6dca0 8444 json_object_string_add(json, "updateDelayPeerUpdateResume",
f1aa5d8a 8445 bgp->update_delay_peers_resume_time);
b05a1c8b
DS
8446 }
8447 }
f188f2c4
DS
8448 }
8449 else
8450 {
b05a1c8b
DS
8451 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
8452 bgp->v_update_delay, VTY_NEWLINE);
8453 if (bgp->v_update_delay != bgp->v_establish_wait)
8454 vty_out (vty, " Establish wait: %d seconds%s",
8455 bgp->v_establish_wait, VTY_NEWLINE);
8456
8457 if (bgp_update_delay_active(bgp))
f188f2c4
DS
8458 {
8459 vty_out (vty, " First neighbor established: %s%s",
8460 bgp->update_delay_begin_time, VTY_NEWLINE);
b05a1c8b
DS
8461 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
8462 }
8463 else
8464 {
8465 if (bgp->update_delay_over)
8466 {
8467 vty_out (vty, " First neighbor established: %s%s",
8468 bgp->update_delay_begin_time, VTY_NEWLINE);
8469 vty_out (vty, " Best-paths resumed: %s%s",
8470 bgp->update_delay_end_time, VTY_NEWLINE);
8471 vty_out (vty, " zebra update resumed: %s%s",
8472 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
8473 vty_out (vty, " peers update resumed: %s%s",
8474 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
8475 }
f188f2c4
DS
8476 }
8477 }
8478 }
4bf6a362 8479
b05a1c8b
DS
8480 if (use_json)
8481 {
8482 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
62d6dca0 8483 json_object_boolean_true_add(json, "maxMedOnStartup");
b05a1c8b 8484 if (bgp->v_maxmed_admin)
62d6dca0 8485 json_object_boolean_true_add(json, "maxMedAdministrative");
b05a1c8b 8486
62d6dca0 8487 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
b05a1c8b
DS
8488
8489 ents = bgp_table_count (bgp->rib[afi][safi]);
62d6dca0
DS
8490 json_object_int_add(json, "ribCount", ents);
8491 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
b05a1c8b
DS
8492
8493 ents = listcount (bgp->peer);
62d6dca0
DS
8494 json_object_int_add(json, "peerCount", ents);
8495 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
b05a1c8b
DS
8496
8497 if ((ents = listcount (bgp->rsclient)))
8498 {
62d6dca0
DS
8499 json_object_int_add(json, "rsclientCount", ents);
8500 json_object_int_add(json, "rsclientMemory", ents * sizeof (struct peer));
b05a1c8b 8501 }
abc920f8 8502
b05a1c8b
DS
8503 if ((ents = listcount (bgp->group)))
8504 {
62d6dca0
DS
8505 json_object_int_add(json, "peerGroupCount", ents);
8506 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
b05a1c8b 8507 }
3f9c7369 8508
b05a1c8b 8509 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
62d6dca0 8510 json_object_boolean_true_add(json, "dampeningEnabled");
b05a1c8b
DS
8511 }
8512 else
8513 {
8514 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
8515 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
8516 if (bgp->v_maxmed_admin)
8517 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
8518
ffd0c037 8519 vty_out(vty, "BGP table version %" PRIu64 "%s",
b05a1c8b
DS
8520 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
8521
8522 ents = bgp_table_count (bgp->rib[afi][safi]);
8523 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
8524 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8525 ents * sizeof (struct bgp_node)),
8526 VTY_NEWLINE);
8527
8528 /* Peer related usage */
8529 ents = listcount (bgp->peer);
8530 vty_out (vty, "Peers %ld, using %s of memory%s",
8531 ents,
8532 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8533 ents * sizeof (struct peer)),
8534 VTY_NEWLINE);
8535
8536 if ((ents = listcount (bgp->rsclient)))
8537 vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
8538 ents,
8539 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8540 ents * sizeof (struct peer)),
8541 VTY_NEWLINE);
8542
8543 if ((ents = listcount (bgp->group)))
8544 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
8545 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8546 ents * sizeof (struct peer_group)),
8547 VTY_NEWLINE);
8548
8549 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
8550 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
8551 vty_out (vty, "%s", VTY_NEWLINE);
8552 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8553 }
4bf6a362
PJ
8554 }
8555
b05a1c8b 8556 count++;
718e3744 8557
b05a1c8b
DS
8558 if (use_json)
8559 {
8560 json_peer = json_object_new_object();
f14e6fdb 8561
b05a1c8b 8562 if (peer_dynamic_neighbor(peer))
62d6dca0 8563 json_object_boolean_true_add(json_peer, "dynamicPeer");
b05a1c8b 8564
62d6dca0 8565 json_object_int_add(json_peer, "remoteAs", peer->as);
f1aa5d8a 8566 json_object_int_add(json_peer, "version", 4);
62d6dca0 8567 json_object_int_add(json_peer, "msgRcvd",
f1aa5d8a
DS
8568 peer->open_in + peer->update_in + peer->keepalive_in
8569 + peer->notify_in + peer->refresh_in
8570 + peer->dynamic_cap_in);
62d6dca0 8571 json_object_int_add(json_peer, "msgSent",
f1aa5d8a
DS
8572 peer->open_out + peer->update_out + peer->keepalive_out
8573 + peer->notify_out + peer->refresh_out
8574 + peer->dynamic_cap_out);
8575
62d6dca0 8576 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
f1aa5d8a
DS
8577 json_object_int_add(json_peer, "outq", peer->obuf->count);
8578 json_object_int_add(json_peer, "inq", 0);
856ca177 8579 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
62d6dca0
DS
8580 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
8581 json_object_int_add(json_peer, "prefixAdvertisedCount", bgp_adj_out_count(peer, afi, safi));
b05a1c8b
DS
8582
8583 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
f1aa5d8a 8584 json_object_string_add(json_peer, "state", "Idle (Admin)");
b05a1c8b 8585 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
f1aa5d8a 8586 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
b05a1c8b 8587 else
f1aa5d8a 8588 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b 8589
f1aa5d8a 8590 if (peer->conf_if)
62d6dca0 8591 json_object_string_add(json_peer, "idType", "interface");
f1aa5d8a 8592 else if (peer->su.sa.sa_family == AF_INET)
62d6dca0 8593 json_object_string_add(json_peer, "idType", "ipv4");
f1aa5d8a 8594 else if (peer->su.sa.sa_family == AF_INET6)
62d6dca0 8595 json_object_string_add(json_peer, "idType", "ipv6");
b05a1c8b 8596
f1aa5d8a 8597 json_object_object_add(json_peers, peer->host, json_peer);
b05a1c8b
DS
8598 }
8599 else
8600 {
8601 memset(dn_flag, '\0', sizeof(dn_flag));
8602 if (peer_dynamic_neighbor(peer))
8603 {
8604 dn_count++;
8605 dn_flag[0] = '*';
8606 }
8607
c744aa9f 8608 len = vty_out (vty, "%s%s", dn_flag, peer->host);
b05a1c8b
DS
8609 len = 16 - len;
8610
8611 if (len < 1)
8612 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8613 else
8614 vty_out (vty, "%*s", len, " ");
8615
8616 vty_out (vty, "4 ");
8617
ee046671 8618 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
b05a1c8b
DS
8619 peer->as,
8620 peer->open_in + peer->update_in + peer->keepalive_in
8621 + peer->notify_in + peer->refresh_in
8622 + peer->dynamic_cap_in,
8623 peer->open_out + peer->update_out + peer->keepalive_out
8624 + peer->notify_out + peer->refresh_out
8625 + peer->dynamic_cap_out,
8626 peer->version[afi][safi],
8627 0,
ffd0c037 8628 peer->obuf->count);
b05a1c8b 8629
f1aa5d8a 8630 vty_out (vty, "%-8s",
856ca177 8631 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
b05a1c8b
DS
8632
8633 if (peer->status == Established)
8634 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
8635 else
8636 {
8637 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
8638 vty_out (vty, " Idle (Admin)");
8639 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8640 vty_out (vty, " Idle (PfxCt)");
8641 else
8642 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
8643 }
8644 vty_out (vty, "%s", VTY_NEWLINE);
8645 }
718e3744 8646 }
8647 }
8648
b05a1c8b
DS
8649 if (use_json)
8650 {
8651 json_object_object_add(json, "peers", json_peers);
14151a32 8652
62d6dca0
DS
8653 json_object_int_add(json, "totalPeers", count);
8654 json_object_int_add(json, "dynamicPeers", dn_count);
14151a32 8655
b05a1c8b 8656 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
f1aa5d8a 8657 json_object_free(json);
b05a1c8b
DS
8658 }
8659 else
f14e6fdb 8660 {
b05a1c8b
DS
8661 if (count)
8662 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
8663 count, VTY_NEWLINE);
8664 else
8665 vty_out (vty, "No %s neighbor is configured%s",
8666 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8667
8668 if (dn_count)
8669 {
8670 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
8671 vty_out(vty,
8672 "%d dynamic neighbor(s), limit %d%s",
8673 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
8674 }
f14e6fdb
DS
8675 }
8676
718e3744 8677 return CMD_SUCCESS;
8678}
8679
47fc97cc
DS
8680static int
8681bgp_show_summary_vty (struct vty *vty, const char *name,
b05a1c8b 8682 afi_t afi, safi_t safi, u_char use_json)
718e3744 8683{
8684 struct bgp *bgp;
8685
8686 if (name)
8687 {
8688 bgp = bgp_lookup_by_name (name);
47fc97cc 8689
718e3744 8690 if (! bgp)
8691 {
47fc97cc 8692 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
718e3744 8693 return CMD_WARNING;
8694 }
8695
b05a1c8b 8696 bgp_show_summary (vty, bgp, afi, safi, use_json);
718e3744 8697 return CMD_SUCCESS;
8698 }
47fc97cc 8699
718e3744 8700 bgp = bgp_get_default ();
8701
8702 if (bgp)
b05a1c8b 8703 bgp_show_summary (vty, bgp, afi, safi, use_json);
47fc97cc 8704
718e3744 8705 return CMD_SUCCESS;
8706}
8707
8708/* `show ip bgp summary' commands. */
47fc97cc 8709DEFUN (show_ip_bgp_summary,
718e3744 8710 show_ip_bgp_summary_cmd,
b05a1c8b 8711 "show ip bgp summary {json}",
47fc97cc
DS
8712 SHOW_STR
8713 IP_STR
8714 BGP_STR
b05a1c8b
DS
8715 "Summary of BGP neighbor status\n"
8716 "JavaScript Object Notation\n")
47fc97cc 8717{
b05a1c8b
DS
8718 u_char use_json = (argv[0] != NULL);
8719 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, use_json);
718e3744 8720}
8721
8722DEFUN (show_ip_bgp_instance_summary,
8723 show_ip_bgp_instance_summary_cmd,
b05a1c8b 8724 "show ip bgp view WORD summary {json}",
718e3744 8725 SHOW_STR
8726 IP_STR
8727 BGP_STR
8728 "BGP view\n"
8729 "View name\n"
b05a1c8b
DS
8730 "Summary of BGP neighbor status\n"
8731 "JavaScript Object Notation\n")
718e3744 8732{
b05a1c8b
DS
8733 u_char use_json = (argv[1] != NULL);
8734 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, use_json);
718e3744 8735}
8736
8737DEFUN (show_ip_bgp_ipv4_summary,
8738 show_ip_bgp_ipv4_summary_cmd,
b05a1c8b 8739 "show ip bgp ipv4 (unicast|multicast) summary {json}",
718e3744 8740 SHOW_STR
8741 IP_STR
8742 BGP_STR
8743 "Address family\n"
8744 "Address Family modifier\n"
8745 "Address Family modifier\n"
b05a1c8b
DS
8746 "Summary of BGP neighbor status\n"
8747 "JavaScript Object Notation\n")
718e3744 8748{
b05a1c8b 8749 u_char use_json = (argv[1] != NULL);
718e3744 8750 if (strncmp (argv[0], "m", 1) == 0)
b05a1c8b 8751 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, use_json);
718e3744 8752
b05a1c8b 8753 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, use_json);
718e3744 8754}
8755
95cbbd2a
ML
8756ALIAS (show_ip_bgp_ipv4_summary,
8757 show_bgp_ipv4_safi_summary_cmd,
b05a1c8b 8758 "show bgp ipv4 (unicast|multicast) summary {json}",
95cbbd2a
ML
8759 SHOW_STR
8760 BGP_STR
8761 "Address family\n"
8762 "Address Family modifier\n"
8763 "Address Family modifier\n"
8764 "Summary of BGP neighbor status\n")
8765
718e3744 8766DEFUN (show_ip_bgp_instance_ipv4_summary,
8767 show_ip_bgp_instance_ipv4_summary_cmd,
b05a1c8b 8768 "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}",
718e3744 8769 SHOW_STR
8770 IP_STR
8771 BGP_STR
8772 "BGP view\n"
8773 "View name\n"
8774 "Address family\n"
8775 "Address Family modifier\n"
8776 "Address Family modifier\n"
b05a1c8b
DS
8777 "Summary of BGP neighbor status\n"
8778 "JavaScript Object Notation\n")
718e3744 8779{
b05a1c8b 8780 u_char use_json = (argv[2] != NULL);
718e3744 8781 if (strncmp (argv[1], "m", 1) == 0)
b05a1c8b 8782 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, use_json);
718e3744 8783 else
b05a1c8b 8784 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, use_json);
718e3744 8785}
8786
95cbbd2a
ML
8787ALIAS (show_ip_bgp_instance_ipv4_summary,
8788 show_bgp_instance_ipv4_safi_summary_cmd,
b05a1c8b 8789 "show bgp view WORD ipv4 (unicast|multicast) summary {json}",
95cbbd2a
ML
8790 SHOW_STR
8791 BGP_STR
8792 "BGP view\n"
8793 "View name\n"
8794 "Address family\n"
8795 "Address Family modifier\n"
8796 "Address Family modifier\n"
8797 "Summary of BGP neighbor status\n")
8798
718e3744 8799DEFUN (show_ip_bgp_vpnv4_all_summary,
8800 show_ip_bgp_vpnv4_all_summary_cmd,
b05a1c8b 8801 "show ip bgp vpnv4 all summary {json}",
718e3744 8802 SHOW_STR
8803 IP_STR
8804 BGP_STR
8805 "Display VPNv4 NLRI specific information\n"
8806 "Display information about all VPNv4 NLRIs\n"
b05a1c8b
DS
8807 "Summary of BGP neighbor status\n"
8808 "JavaScript Object Notation\n")
718e3744 8809{
b05a1c8b
DS
8810 u_char use_json = (argv[0] != NULL);
8811 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json);
718e3744 8812}
8813
8814DEFUN (show_ip_bgp_vpnv4_rd_summary,
8815 show_ip_bgp_vpnv4_rd_summary_cmd,
b05a1c8b 8816 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}",
718e3744 8817 SHOW_STR
8818 IP_STR
8819 BGP_STR
8820 "Display VPNv4 NLRI specific information\n"
8821 "Display information for a route distinguisher\n"
8822 "VPN Route Distinguisher\n"
b05a1c8b
DS
8823 "Summary of BGP neighbor status\n"
8824 "JavaScript Object Notation\n")
718e3744 8825{
8826 int ret;
8827 struct prefix_rd prd;
b05a1c8b 8828 u_char use_json = (argv[1] != NULL);
718e3744 8829
8830 ret = str2prefix_rd (argv[0], &prd);
8831 if (! ret)
8832 {
8833 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
8834 return CMD_WARNING;
8835 }
8836
b05a1c8b 8837 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json);
718e3744 8838}
8839
8840#ifdef HAVE_IPV6
47fc97cc 8841DEFUN (show_bgp_summary,
718e3744 8842 show_bgp_summary_cmd,
b05a1c8b 8843 "show bgp summary {json}",
718e3744 8844 SHOW_STR
8845 BGP_STR
b05a1c8b
DS
8846 "Summary of BGP neighbor status\n"
8847 "JavaScript Object Notation\n")
718e3744 8848{
b05a1c8b
DS
8849 u_char use_json = (argv[0] != NULL);
8850 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json);
718e3744 8851}
8852
8853DEFUN (show_bgp_instance_summary,
8854 show_bgp_instance_summary_cmd,
b05a1c8b 8855 "show bgp view WORD summary {json}",
718e3744 8856 SHOW_STR
8857 BGP_STR
8858 "BGP view\n"
8859 "View name\n"
b05a1c8b
DS
8860 "Summary of BGP neighbor status\n"
8861 "JavaScript Object Notation\n")
718e3744 8862{
b05a1c8b
DS
8863 u_char use_json = (argv[1] != NULL);
8864 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, use_json);
718e3744 8865}
8866
8867ALIAS (show_bgp_summary,
8868 show_bgp_ipv6_summary_cmd,
b05a1c8b 8869 "show bgp ipv6 summary {json}",
718e3744 8870 SHOW_STR
8871 BGP_STR
8872 "Address family\n"
8873 "Summary of BGP neighbor status\n")
8874
8875ALIAS (show_bgp_instance_summary,
8876 show_bgp_instance_ipv6_summary_cmd,
b05a1c8b 8877 "show bgp view WORD ipv6 summary {json}",
718e3744 8878 SHOW_STR
8879 BGP_STR
8880 "BGP view\n"
8881 "View name\n"
8882 "Address family\n"
8883 "Summary of BGP neighbor status\n")
8884
95cbbd2a
ML
8885DEFUN (show_bgp_ipv6_safi_summary,
8886 show_bgp_ipv6_safi_summary_cmd,
b05a1c8b 8887 "show bgp ipv6 (unicast|multicast) summary {json}",
95cbbd2a
ML
8888 SHOW_STR
8889 BGP_STR
8890 "Address family\n"
8891 "Address Family modifier\n"
8892 "Address Family modifier\n"
b05a1c8b
DS
8893 "Summary of BGP neighbor status\n"
8894 "JavaScript Object Notation\n")
95cbbd2a 8895{
b05a1c8b 8896 u_char use_json = (argv[1] != NULL);
95cbbd2a 8897 if (strncmp (argv[0], "m", 1) == 0)
b05a1c8b 8898 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, use_json);
95cbbd2a 8899
b05a1c8b 8900 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json);
95cbbd2a
ML
8901}
8902
8903DEFUN (show_bgp_instance_ipv6_safi_summary,
8904 show_bgp_instance_ipv6_safi_summary_cmd,
b05a1c8b 8905 "show bgp view WORD ipv6 (unicast|multicast) summary {json}",
95cbbd2a
ML
8906 SHOW_STR
8907 BGP_STR
8908 "BGP view\n"
8909 "View name\n"
8910 "Address family\n"
8911 "Address Family modifier\n"
8912 "Address Family modifier\n"
b05a1c8b
DS
8913 "Summary of BGP neighbor status\n"
8914 "JavaScript Object Notation\n")
95cbbd2a 8915{
b05a1c8b 8916 u_char use_json = (argv[2] != NULL);
95cbbd2a 8917 if (strncmp (argv[1], "m", 1) == 0)
b05a1c8b 8918 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_MULTICAST, use_json);
95cbbd2a 8919
b05a1c8b 8920 return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, use_json);
95cbbd2a
ML
8921}
8922
718e3744 8923/* old command */
8924DEFUN (show_ipv6_bgp_summary,
8925 show_ipv6_bgp_summary_cmd,
b05a1c8b 8926 "show ipv6 bgp summary {json}",
718e3744 8927 SHOW_STR
8928 IPV6_STR
8929 BGP_STR
b05a1c8b
DS
8930 "Summary of BGP neighbor status\n"
8931 "JavaScript Object Notation\n")
718e3744 8932{
b05a1c8b
DS
8933 u_char use_json = (argv[0] != NULL);
8934 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json);
718e3744 8935}
8936
8937/* old command */
8938DEFUN (show_ipv6_mbgp_summary,
8939 show_ipv6_mbgp_summary_cmd,
b05a1c8b 8940 "show ipv6 mbgp summary {json}",
718e3744 8941 SHOW_STR
8942 IPV6_STR
8943 MBGP_STR
b05a1c8b
DS
8944 "Summary of BGP neighbor status\n"
8945 "JavaScript Object Notation\n")
718e3744 8946{
b05a1c8b
DS
8947 u_char use_json = (argv[0] != NULL);
8948 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, use_json);
718e3744 8949}
8950#endif /* HAVE_IPV6 */
6b0655a2 8951
fd79ac91 8952const char *
538621f2 8953afi_safi_print (afi_t afi, safi_t safi)
8954{
8955 if (afi == AFI_IP && safi == SAFI_UNICAST)
8956 return "IPv4 Unicast";
8957 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
8958 return "IPv4 Multicast";
8959 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
8960 return "VPNv4 Unicast";
8961 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
8962 return "IPv6 Unicast";
8963 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
8964 return "IPv6 Multicast";
8965 else
8966 return "Unknown";
8967}
8968
718e3744 8969/* Show BGP peer's information. */
8970enum show_type
8971{
8972 show_all,
8973 show_peer
8974};
8975
94f2b392 8976static void
856ca177
MS
8977bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
8978 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
8979 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
718e3744 8980{
8981 /* Send-Mode */
8982 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
8983 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8984 {
856ca177
MS
8985 if (use_json)
8986 {
8987 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8988 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
8989 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
8990 json_object_string_add(json_pref, "sendMode", "advertised");
8991 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
8992 json_object_string_add(json_pref, "sendMode", "received");
8993 }
8994 else
8995 {
8996 vty_out (vty, " Send-mode: ");
8997 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
8998 vty_out (vty, "advertised");
8999 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9000 vty_out (vty, "%sreceived",
9001 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
9002 ", " : "");
9003 vty_out (vty, "%s", VTY_NEWLINE);
9004 }
718e3744 9005 }
9006
9007 /* Receive-Mode */
9008 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
9009 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9010 {
856ca177
MS
9011 if (use_json)
9012 {
9013 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9014 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
9015 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9016 json_object_string_add(json_pref, "recvMode", "advertised");
9017 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9018 json_object_string_add(json_pref, "recvMode", "received");
9019 }
9020 else
9021 {
9022 vty_out (vty, " Receive-mode: ");
9023 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9024 vty_out (vty, "advertised");
9025 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9026 vty_out (vty, "%sreceived",
9027 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
9028 ", " : "");
9029 vty_out (vty, "%s", VTY_NEWLINE);
9030 }
718e3744 9031 }
9032}
9033
94f2b392 9034static void
856ca177
MS
9035bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
9036 u_char use_json, json_object *json_neigh)
718e3744 9037{
9038 struct bgp_filter *filter;
3f9c7369 9039 struct peer_af *paf;
718e3744 9040 char orf_pfx_name[BUFSIZ];
9041 int orf_pfx_count;
856ca177
MS
9042 json_object *json_af = NULL;
9043 json_object *json_prefA = NULL;
9044 json_object *json_prefB = NULL;
9045 json_object *json_addr = NULL;
718e3744 9046
856ca177
MS
9047 if (use_json)
9048 {
9049 json_addr = json_object_new_object();
9050 json_af = json_object_new_object();
9051 json_prefA = json_object_new_object();
9052 json_prefB = json_object_new_object();
9053 filter = &p->filter[afi][safi];
718e3744 9054
856ca177
MS
9055 if (p->af_group[afi][safi])
9056 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
538621f2 9057
856ca177
MS
9058 paf = peer_af_find(p, afi, safi);
9059 if (paf && PAF_SUBGRP(paf))
9060 {
9061 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
9062 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
9063 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
9064 }
9065
9066 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9067 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9068 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9069 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
9070 {
9071 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
9072 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9073 PEER_CAP_ORF_PREFIX_SM_ADV,
9074 PEER_CAP_ORF_PREFIX_RM_ADV,
9075 PEER_CAP_ORF_PREFIX_SM_RCV,
9076 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
9077 json_object_object_add(json_af, "orfPrefixList", json_prefA);
9078 }
9079
9080 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9081 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9082 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9083 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9084 {
9085 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
9086 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9087 PEER_CAP_ORF_PREFIX_SM_ADV,
9088 PEER_CAP_ORF_PREFIX_RM_ADV,
9089 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
9090 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
9091 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
9092 }
9093
9094 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9095 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9096 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9097 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9098 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
9099 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9100 json_object_object_add(json_addr, "afDependentCap", json_af);
9101
9102 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
9103 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
9104
9105 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
9106 || orf_pfx_count)
9107 {
9108 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
9109 json_object_boolean_true_add(json_neigh, "orfSent");
9110 if (orf_pfx_count)
9111 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
9112 }
9113 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
9114 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
9115
9116 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
9117 json_object_boolean_true_add(json_addr, "routeReflectorClient");
9118 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9119 json_object_boolean_true_add(json_addr, "routeServerClient");
9120 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
9121 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
9122
9123 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
9124 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
9125 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
9126 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
9127
9128 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
9129 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
9130
9131 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
9132 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
9133 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
9134 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
9135 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
9136 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
9137 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
9138 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
9139 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
718e3744 9140 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
856ca177
MS
9141 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9142 {
9143 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9144 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9145 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
9146 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9147 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
9148 else
9149 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
9150 }
9151 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
9152 {
9153 if (p->default_rmap[afi][safi].name)
9154 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
9155
9156 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
9157 json_object_boolean_true_add(json_addr, "defaultSent");
9158 else
9159 json_object_boolean_true_add(json_addr, "defaultNotSent");
9160 }
9161
9162 if (filter->plist[FILTER_IN].name
9163 || filter->dlist[FILTER_IN].name
9164 || filter->aslist[FILTER_IN].name
9165 || filter->map[RMAP_IN].name)
9166 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
9167 if (filter->plist[FILTER_OUT].name
9168 || filter->dlist[FILTER_OUT].name
9169 || filter->aslist[FILTER_OUT].name
9170 || filter->map[RMAP_OUT].name
9171 || filter->usmap.name)
9172 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
9173 if (filter->map[RMAP_IMPORT].name)
9174 json_object_boolean_true_add(json_addr, "importPolicyRsClientConfig");
9175 if (filter->map[RMAP_EXPORT].name)
9176 json_object_boolean_true_add(json_addr, "exportPolicyRsClientConfig");
9177
9178 /* prefix-list */
9179 if (filter->plist[FILTER_IN].name)
9180 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
9181 if (filter->plist[FILTER_OUT].name)
9182 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
9183
9184 /* distribute-list */
9185 if (filter->dlist[FILTER_IN].name)
9186 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
9187 if (filter->dlist[FILTER_OUT].name)
9188 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
9189
9190 /* filter-list. */
9191 if (filter->aslist[FILTER_IN].name)
9192 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
9193 if (filter->aslist[FILTER_OUT].name)
9194 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
9195
9196 /* route-map. */
9197 if (filter->map[RMAP_IN].name)
9198 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
9199 if (filter->map[RMAP_OUT].name)
9200 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
9201 if (filter->map[RMAP_IMPORT].name)
9202 json_object_string_add(json_addr, "routeMapForAdvertisementsIntoRsClient", filter->map[RMAP_IMPORT].name);
9203 if (filter->map[RMAP_EXPORT].name)
9204 json_object_string_add(json_addr, "routeMapForAdvertisementsFromRsClient", filter->map[RMAP_EXPORT].name);
9205
9206 /* unsuppress-map */
9207 if (filter->usmap.name)
9208 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
9209
9210 /* Receive prefix count */
9211 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
9212
9213 /* Maximum prefix */
9214 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
9215 {
9216 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
9217 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
9218 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
9219 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
9220 if (p->pmax_restart[afi][safi])
9221 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
9222 }
9223 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
9224
9225 }
9226 else
9227 {
9228 filter = &p->filter[afi][safi];
9229
9230 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
9231 VTY_NEWLINE);
9232
9233 if (p->af_group[afi][safi])
9234 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
9235
9236 paf = peer_af_find(p, afi, safi);
9237 if (paf && PAF_SUBGRP(paf))
9238 {
9239 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
9240 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
9241 vty_out (vty, " Packet Queue length %d%s",
9242 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
9243 }
718e3744 9244 else
856ca177
MS
9245 {
9246 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
9247 }
9248 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9249 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9250 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9251 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9252 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
9253 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9254 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
9255
9256 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9257 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9258 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9259 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
9260 {
9261 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
9262 ORF_TYPE_PREFIX, VTY_NEWLINE);
9263 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9264 PEER_CAP_ORF_PREFIX_SM_ADV,
9265 PEER_CAP_ORF_PREFIX_RM_ADV,
9266 PEER_CAP_ORF_PREFIX_SM_RCV,
9267 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
9268 }
9269 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9270 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9271 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9272 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9273 {
9274 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
9275 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
9276 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9277 PEER_CAP_ORF_PREFIX_SM_ADV,
9278 PEER_CAP_ORF_PREFIX_RM_ADV,
9279 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
9280 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
9281 }
718e3744 9282
856ca177
MS
9283 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
9284 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
718e3744 9285
856ca177
MS
9286 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
9287 || orf_pfx_count)
9288 {
9289 vty_out (vty, " Outbound Route Filter (ORF):");
9290 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
9291 vty_out (vty, " sent;");
9292 if (orf_pfx_count)
9293 vty_out (vty, " received (%d entries)", orf_pfx_count);
9294 vty_out (vty, "%s", VTY_NEWLINE);
9295 }
9296 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
9297 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
9298
9299 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
9300 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
9301 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9302 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
9303 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
9304 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
9305
9306 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
9307 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
9308 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
9309 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
9310
9311 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
9312 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
9313
9314 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
9315 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
9316 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
9317 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
9318 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9319 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
9320 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9321 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
9322 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9323 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9324 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9325 {
9326 vty_out (vty, " Community attribute sent to this neighbor");
9327 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9328 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9329 vty_out (vty, "(both)%s", VTY_NEWLINE);
9330 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9331 vty_out (vty, "(extended)%s", VTY_NEWLINE);
9332 else
9333 vty_out (vty, "(standard)%s", VTY_NEWLINE);
9334 }
9335 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
9336 {
9337 vty_out (vty, " Default information originate,");
9338
9339 if (p->default_rmap[afi][safi].name)
9340 vty_out (vty, " default route-map %s%s,",
9341 p->default_rmap[afi][safi].map ? "*" : "",
9342 p->default_rmap[afi][safi].name);
9343 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
9344 vty_out (vty, " default sent%s", VTY_NEWLINE);
9345 else
9346 vty_out (vty, " default not sent%s", VTY_NEWLINE);
9347 }
718e3744 9348
856ca177
MS
9349 if (filter->plist[FILTER_IN].name
9350 || filter->dlist[FILTER_IN].name
9351 || filter->aslist[FILTER_IN].name
9352 || filter->map[RMAP_IN].name)
9353 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
9354 if (filter->plist[FILTER_OUT].name
9355 || filter->dlist[FILTER_OUT].name
9356 || filter->aslist[FILTER_OUT].name
9357 || filter->map[RMAP_OUT].name
9358 || filter->usmap.name)
9359 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
9360 if (filter->map[RMAP_IMPORT].name)
9361 vty_out (vty, " Import policy for this RS-client configured%s", VTY_NEWLINE);
9362 if (filter->map[RMAP_EXPORT].name)
9363 vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
9364
9365 /* prefix-list */
9366 if (filter->plist[FILTER_IN].name)
9367 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
9368 filter->plist[FILTER_IN].plist ? "*" : "",
9369 filter->plist[FILTER_IN].name,
9370 VTY_NEWLINE);
9371 if (filter->plist[FILTER_OUT].name)
9372 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
9373 filter->plist[FILTER_OUT].plist ? "*" : "",
9374 filter->plist[FILTER_OUT].name,
9375 VTY_NEWLINE);
9376
9377 /* distribute-list */
9378 if (filter->dlist[FILTER_IN].name)
9379 vty_out (vty, " Incoming update network filter list is %s%s%s",
9380 filter->dlist[FILTER_IN].alist ? "*" : "",
9381 filter->dlist[FILTER_IN].name,
9382 VTY_NEWLINE);
9383 if (filter->dlist[FILTER_OUT].name)
9384 vty_out (vty, " Outgoing update network filter list is %s%s%s",
9385 filter->dlist[FILTER_OUT].alist ? "*" : "",
9386 filter->dlist[FILTER_OUT].name,
9387 VTY_NEWLINE);
9388
9389 /* filter-list. */
9390 if (filter->aslist[FILTER_IN].name)
9391 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
9392 filter->aslist[FILTER_IN].aslist ? "*" : "",
9393 filter->aslist[FILTER_IN].name,
9394 VTY_NEWLINE);
9395 if (filter->aslist[FILTER_OUT].name)
9396 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
9397 filter->aslist[FILTER_OUT].aslist ? "*" : "",
9398 filter->aslist[FILTER_OUT].name,
9399 VTY_NEWLINE);
9400
9401 /* route-map. */
9402 if (filter->map[RMAP_IN].name)
9403 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
9404 filter->map[RMAP_IN].map ? "*" : "",
9405 filter->map[RMAP_IN].name,
9406 VTY_NEWLINE);
9407 if (filter->map[RMAP_OUT].name)
9408 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
9409 filter->map[RMAP_OUT].map ? "*" : "",
9410 filter->map[RMAP_OUT].name,
9411 VTY_NEWLINE);
9412 if (filter->map[RMAP_IMPORT].name)
9413 vty_out (vty, " Route map for advertisements going into this RS-client's table is %s%s%s",
9414 filter->map[RMAP_IMPORT].map ? "*" : "",
9415 filter->map[RMAP_IMPORT].name,
9416 VTY_NEWLINE);
9417 if (filter->map[RMAP_EXPORT].name)
9418 vty_out (vty, " Route map for advertisements coming from this RS-client is %s%s%s",
9419 filter->map[RMAP_EXPORT].map ? "*" : "",
9420 filter->map[RMAP_EXPORT].name,
9421 VTY_NEWLINE);
9422
9423 /* unsuppress-map */
9424 if (filter->usmap.name)
9425 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
9426 filter->usmap.map ? "*" : "",
9427 filter->usmap.name, VTY_NEWLINE);
9428
9429 /* Receive prefix count */
9430 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
9431
9432 /* Maximum prefix */
9433 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
9434 {
9435 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
9436 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
9437 ? " (warning-only)" : "", VTY_NEWLINE);
9438 vty_out (vty, " Threshold for warning message %d%%",
9439 p->pmax_threshold[afi][safi]);
9440 if (p->pmax_restart[afi][safi])
9441 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
9442 vty_out (vty, "%s", VTY_NEWLINE);
9443 }
718e3744 9444
0a486e5f 9445 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 9446 }
718e3744 9447}
9448
94f2b392 9449static void
856ca177 9450bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json, json_object *json_neigh)
718e3744 9451{
9452 struct bgp *bgp;
a80beece 9453 char buf1[BUFSIZ], buf[SU_ADDRSTRLEN];
718e3744 9454 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 9455 char dn_flag[2];
538621f2 9456 afi_t afi;
9457 safi_t safi;
d6661008
DS
9458 u_int16_t i;
9459 u_char *msg;
718e3744 9460
9461 bgp = p->bgp;
9462
856ca177 9463 if (!use_json)
f14e6fdb 9464 {
856ca177
MS
9465 if (p->conf_if) /* Configured interface name. */
9466 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
9467 BGP_PEER_SU_UNSPEC(p) ? "None" :
9468 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
9469 else /* Configured IP address. */
9470 {
9471 memset(dn_flag, '\0', sizeof(dn_flag));
9472 if (peer_dynamic_neighbor(p))
9473 dn_flag[0] = '*';
f14e6fdb 9474
856ca177
MS
9475 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
9476 }
f14e6fdb
DS
9477 }
9478
856ca177
MS
9479 if (use_json)
9480 {
9481 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
9482 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
9483 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
9484 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
9485
9486 json_object_int_add(json_neigh, "remoteAs", p->as);
9487
9488 if (p->change_local_as)
9489 json_object_int_add(json_neigh, "localAs", p->change_local_as);
9490 else
9491 json_object_int_add(json_neigh, "localAs", p->local_as);
9492
9493 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
9494 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
66b199b2 9495
856ca177
MS
9496 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
9497 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
9498 }
9499 else
9500 {
f8cfafda
DS
9501 if ((p->as_type == AS_SPECIFIED) ||
9502 (p->as_type == AS_EXTERNAL) ||
9503 (p->as_type == AS_INTERNAL))
9504 vty_out (vty, "remote AS %u, ", p->as);
9505 else
9506 vty_out (vty, "remote AS Unspecified, ");
856ca177
MS
9507 vty_out (vty, "local AS %u%s%s, ",
9508 p->change_local_as ? p->change_local_as : p->local_as,
9509 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
9510 " no-prepend" : "",
9511 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
9512 " replace-as" : "");
9513 }
66b199b2
DS
9514 /* peer type internal, external, confed-internal or confed-external */
9515 if (p->as == p->local_as)
9516 {
856ca177
MS
9517 if (use_json)
9518 {
9519 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9520 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
9521 else
9522 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
9523 }
66b199b2 9524 else
856ca177
MS
9525 {
9526 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9527 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
9528 else
9529 vty_out (vty, "internal link%s", VTY_NEWLINE);
9530 }
66b199b2
DS
9531 }
9532 else
9533 {
856ca177
MS
9534 if (use_json)
9535 {
9536 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9537 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
9538 else
9539 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
9540 }
66b199b2 9541 else
856ca177
MS
9542 {
9543 if (bgp_confederation_peers_check(bgp, p->as))
9544 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
9545 else
9546 vty_out (vty, "external link%s", VTY_NEWLINE);
9547 }
66b199b2 9548 }
718e3744 9549
9550 /* Description. */
9551 if (p->desc)
856ca177
MS
9552 {
9553 if (use_json)
9554 json_object_string_add(json_neigh, "nbrDesc", p->desc);
9555 else
9556 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
9557 }
6410e93a 9558
c744aa9f 9559 /* Peer-group */
718e3744 9560 if (p->group)
f14e6fdb 9561 {
856ca177
MS
9562 if (use_json)
9563 {
9564 json_object_string_add(json_neigh, "peerGroup", p->group->name);
9565
9566 if (dn_flag[0])
9567 {
9568 struct prefix *prefix = NULL, *range = NULL;
f14e6fdb 9569
856ca177
MS
9570 prefix = sockunion2hostprefix(&(p->su));
9571 if (prefix)
9572 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
9573
9574 if (range)
9575 {
9576 prefix2str(range, buf1, sizeof(buf1));
9577 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
9578 }
9579 }
9580 }
9581 else
f14e6fdb 9582 {
856ca177
MS
9583 vty_out (vty, " Member of peer-group %s for session parameters%s",
9584 p->group->name, VTY_NEWLINE);
f14e6fdb 9585
856ca177 9586 if (dn_flag[0])
f14e6fdb 9587 {
856ca177
MS
9588 struct prefix *prefix = NULL, *range = NULL;
9589
9590 prefix = sockunion2hostprefix(&(p->su));
9591 if (prefix)
9592 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
9593
9594 if (range)
9595 {
9596 prefix2str(range, buf1, sizeof(buf1));
9597 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
9598 }
f14e6fdb
DS
9599 }
9600 }
9601 }
718e3744 9602
856ca177
MS
9603 if (use_json)
9604 {
9605 /* Administrative shutdown. */
9606 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
9607 json_object_boolean_true_add(json_neigh, "adminShutDown");
718e3744 9608
856ca177
MS
9609 /* BGP Version. */
9610 json_object_int_add(json_neigh, "bgpVersion", 4);
9611 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
718e3744 9612
856ca177
MS
9613 /* Confederation */
9614 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
9615 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
9616
9617 /* Status. */
9618 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
9619
9620 if (p->status == Established)
9621 {
9622 time_t uptime;
9623 struct tm *tm;
9624
9625 uptime = bgp_clock();
9626 uptime -= p->uptime;
9627 tm = gmtime(&uptime);
9628
9629 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9630 }
9631
9632 else if (p->status == Active)
9633 {
9634 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
9635 json_object_string_add(json_neigh, "bgpStateIs", "passive");
9636 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
9637 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
9638 }
9639
9640 /* read timer */
9641 time_t uptime;
9642 struct tm *tm;
9643
9644 uptime = bgp_clock();
9645 uptime -= p->readtime;
9646 tm = gmtime(&uptime);
9647 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9648
9649 uptime = bgp_clock();
9650 uptime -= p->last_write;
9651 tm = gmtime(&uptime);
9652 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9653
9654 /* Configured timer values. */
9655 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
9656 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
9657
9658 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
9659 {
9660 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
9661 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
9662 }
93406d87 9663 }
856ca177
MS
9664 else
9665 {
9666 /* Administrative shutdown. */
9667 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
9668 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
9669
9670 /* BGP Version. */
9671 vty_out (vty, " BGP version 4");
9672 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
9673 VTY_NEWLINE);
9674
9675 /* Confederation */
9676 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
9677 && bgp_confederation_peers_check (bgp, p->as))
9678 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
718e3744 9679
856ca177
MS
9680 /* Status. */
9681 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
718e3744 9682
856ca177
MS
9683 if (p->status == Established)
9684 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
9685
9686 else if (p->status == Active)
9687 {
9688 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
9689 vty_out (vty, " (passive)");
9690 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
9691 vty_out (vty, " (NSF passive)");
9692 }
9693 vty_out (vty, "%s", VTY_NEWLINE);
93406d87 9694
856ca177
MS
9695 /* read timer */
9696 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
9697 vty_out (vty, ", Last write %s%s",
9698 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
9699
9700 /* Configured timer values. */
9701 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
9702 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
9703 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
9704 {
9705 vty_out (vty, " Configured hold time is %d", p->holdtime);
9706 vty_out (vty, ", keepalive interval is %d seconds%s",
9707 p->keepalive, VTY_NEWLINE);
9708 }
9709 }
718e3744 9710 /* Capability. */
9711 if (p->status == Established)
9712 {
538621f2 9713 if (p->cap
718e3744 9714 || p->afc_adv[AFI_IP][SAFI_UNICAST]
9715 || p->afc_recv[AFI_IP][SAFI_UNICAST]
9716 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
9717 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
9718#ifdef HAVE_IPV6
9719 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
9720 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
9721 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
9722 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
9723#endif /* HAVE_IPV6 */
9724 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
9725 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
9726 {
856ca177
MS
9727 if (use_json)
9728 {
9729 json_object *json_cap = NULL;
9730
9731 json_cap = json_object_new_object();
9732
9733 /* AS4 */
9734 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
9735 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9736 {
9737 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9738 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
9739 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9740 json_object_string_add(json_cap, "4byteAs", "advertised");
9741 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9742 json_object_string_add(json_cap, "4byteAs", "received");
9743 }
9744
9745 /* AddPath */
9746 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
9747 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
9748 {
9749 json_object *json_add = NULL;
9750 const char *print_store;
718e3744 9751
856ca177 9752 json_add = json_object_new_object();
a82478b9 9753
856ca177
MS
9754 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9755 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9756 {
9757 json_object *json_sub = NULL;
9758 json_sub = json_object_new_object();
9759 print_store = afi_safi_print (afi, safi);
9760
9761 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9762 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9763 {
9764 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9765 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
9766 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
9767 json_object_boolean_true_add(json_sub, "txAdvertised");
9768 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9769 json_object_boolean_true_add(json_sub, "txReceived");
9770 }
9771
9772 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
9773 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9774 {
9775 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9776 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
9777 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
9778 json_object_boolean_true_add(json_sub, "rxAdvertised");
9779 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9780 json_object_boolean_true_add(json_sub, "rxReceived");
9781 }
9782
9783 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9784 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
9785 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
9786 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9787 json_object_object_add(json_add, print_store, json_sub);
9788 }
a82478b9 9789
856ca177
MS
9790 json_object_object_add(json_cap, "addPath", json_add);
9791 }
9792
9793 /* Dynamic */
9794 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
9795 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9796 {
9797 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
9798 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
9799 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9800 json_object_string_add(json_cap, "dynamic", "advertised");
9801 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
9802 json_object_string_add(json_cap, "dynamic", "received");
9803 }
9804
9805 /* Extended nexthop */
9806 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
9807 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
9808 {
9809 json_object *json_nxt = NULL;
9810 const char *print_store;
9811
9812 json_nxt = json_object_new_object();
9813
9814 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9815 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
9816 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
9817 json_object_string_add(json_cap, "extendedNexthop", "advertised");
9818 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9819 json_object_string_add(json_cap, "extendedNexthop", "received");
9820
9821 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9822 {
9823 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9824 {
9825 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
9826 {
9827 print_store = afi_safi_print (AFI_IP, safi);
9828 json_object_string_add(json_nxt, print_store, "recieved");
9829 }
9830 }
9831 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
9832 }
9833 }
9834
9835 /* Route Refresh */
9836 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
9837 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
9838 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9839 {
9840 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) && (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)))
9841 {
9842 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
9843 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
9844 else
9845 {
9846 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9847 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
9848 else
9849 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
9850 }
9851 }
9852 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
9853 json_object_string_add(json_cap, "routeRefresh", "advertised");
9854 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9855 json_object_string_add(json_cap, "routeRefresh", "received");
9856 }
9857
9858 /* Multiprotocol Extensions */
9859 json_object *json_multi = NULL;
9860 json_multi = json_object_new_object();
9861
9862 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9863 {
9864 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9865 {
9866 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
9867 {
9868 json_object *json_exten = NULL;
9869 json_exten = json_object_new_object();
9870
9871 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
9872 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
9873 else if (p->afc_adv[afi][safi])
9874 json_object_boolean_true_add(json_exten, "advertised");
9875 else if (p->afc_recv[afi][safi])
9876 json_object_boolean_true_add(json_exten, "received");
9877
9878 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
9879 }
9880 }
9881 }
9882 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
9883
9884 /* Gracefull Restart */
9885 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
9886 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
9887 {
9888 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9889 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
9890 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
9891 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
9892 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9893 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
9894
9895 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9896 {
9897 int restart_af_count = 0;
9898 json_object *json_restart = NULL;
9899 json_restart = json_object_new_object();
9900
9901 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
9902
9903 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9904 {
9905 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9906 {
9907 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
9908 {
9909 json_object *json_sub = NULL;
9910 json_sub = json_object_new_object();
9911
9912 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
9913 json_object_boolean_true_add(json_sub, "preserved");
9914 restart_af_count++;
9915 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
9916 }
9917 }
9918 }
9919 if (! restart_af_count)
9920 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
9921 else
9922 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
9923 }
9924 }
9925 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
9926 }
9927 else
9928 {
9929 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
9930
9931 /* AS4 */
9932 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
9933 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9934 {
9935 vty_out (vty, " 4 Byte AS:");
9936 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9937 vty_out (vty, " advertised");
9938 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9939 vty_out (vty, " %sreceived",
9940 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
9941 vty_out (vty, "%s", VTY_NEWLINE);
9942 }
9943
9944 /* AddPath */
9945 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
9946 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
9947 {
9948 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
a82478b9 9949
856ca177
MS
9950 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9951 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
a82478b9 9952 {
856ca177
MS
9953 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9954 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9955 {
9956 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
a82478b9 9957
856ca177
MS
9958 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
9959 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 9960
856ca177
MS
9961 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9962 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
a82478b9 9963
856ca177
MS
9964 vty_out (vty, "%s", VTY_NEWLINE);
9965 }
a82478b9 9966
856ca177 9967 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
a82478b9 9968 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
856ca177
MS
9969 {
9970 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
a82478b9 9971
856ca177
MS
9972 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
9973 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 9974
856ca177
MS
9975 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9976 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
a82478b9 9977
856ca177
MS
9978 vty_out (vty, "%s", VTY_NEWLINE);
9979 }
a82478b9 9980 }
856ca177 9981 }
a82478b9 9982
856ca177
MS
9983 /* Dynamic */
9984 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
9985 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9986 {
9987 vty_out (vty, " Dynamic:");
9988 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9989 vty_out (vty, " advertised");
9990 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
9991 vty_out (vty, " %sreceived",
9992 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
9993 vty_out (vty, "%s", VTY_NEWLINE);
9994 }
9995
9996 /* Extended nexthop */
9997 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
9998 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
9999 {
10000 vty_out (vty, " Extended nexthop:");
10001 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
10002 vty_out (vty, " advertised");
10003 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10004 vty_out (vty, " %sreceived",
10005 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
10006 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 10007
856ca177
MS
10008 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10009 {
10010 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
10011 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10012 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
10013 vty_out (vty, " %s%s",
10014 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
10015 }
10016 }
8a92a8a0 10017
856ca177
MS
10018 /* Route Refresh */
10019 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
10020 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
10021 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10022 {
10023 vty_out (vty, " Route refresh:");
10024 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
10025 vty_out (vty, " advertised");
10026 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
10027 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10028 vty_out (vty, " %sreceived(%s)",
10029 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
10030 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
10031 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
10032 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8a92a8a0 10033
856ca177
MS
10034 vty_out (vty, "%s", VTY_NEWLINE);
10035 }
718e3744 10036
856ca177
MS
10037 /* Multiprotocol Extensions */
10038 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10039 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10040 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
10041 {
10042 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
10043 if (p->afc_adv[afi][safi])
10044 vty_out (vty, " advertised");
10045 if (p->afc_recv[afi][safi])
10046 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
10047 vty_out (vty, "%s", VTY_NEWLINE);
10048 }
538621f2 10049
856ca177
MS
10050 /* Gracefull Restart */
10051 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
10052 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
10053 {
10054 vty_out (vty, " Graceful Restart Capabilty:");
10055 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
538621f2 10056 vty_out (vty, " advertised");
856ca177
MS
10057 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10058 vty_out (vty, " %sreceived",
10059 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
10060 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 10061
856ca177
MS
10062 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10063 {
10064 int restart_af_count = 0;
10065
10066 vty_out (vty, " Remote Restart timer is %d seconds%s",
10067 p->v_gr_restart, VTY_NEWLINE);
10068 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
10069
10070 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10071 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10072 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
10073 {
10074 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
10075 afi_safi_print (afi, safi),
10076 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
10077 "preserved" : "not preserved");
10078 restart_af_count++;
10079 }
10080 if (! restart_af_count)
10081 vty_out (vty, "none");
10082 vty_out (vty, "%s", VTY_NEWLINE);
10083 }
10084 }
10085 }
718e3744 10086 }
10087 }
10088
93406d87 10089 /* graceful restart information */
10090 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
10091 || p->t_gr_restart
10092 || p->t_gr_stale)
10093 {
856ca177
MS
10094 json_object *json_grace = NULL;
10095 json_object *json_grace_send = NULL;
10096 json_object *json_grace_recv = NULL;
93406d87 10097 int eor_send_af_count = 0;
10098 int eor_receive_af_count = 0;
10099
856ca177
MS
10100 if (use_json)
10101 {
10102 json_grace = json_object_new_object();
10103 json_grace_send = json_object_new_object();
10104 json_grace_recv = json_object_new_object();
10105
10106 if (p->status == Established)
10107 {
10108 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10109 {
10110 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10111 {
10112 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
10113 {
10114 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
10115 eor_send_af_count++;
10116 }
10117 }
10118 }
10119 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10120 {
10121 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10122 {
10123 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
10124 {
10125 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
10126 eor_receive_af_count++;
10127 }
10128 }
10129 }
10130 }
10131
10132 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
10133 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
10134
10135 if (p->t_gr_restart)
10136 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
10137
10138 if (p->t_gr_stale)
10139 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
10140
10141 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
10142 }
10143 else
10144 {
10145 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
10146 if (p->status == Established)
10147 {
10148 vty_out (vty, " End-of-RIB send: ");
10149 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10150 {
10151 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10152 {
10153 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
10154 {
10155 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
10156 afi_safi_print (afi, safi));
10157 eor_send_af_count++;
10158 }
10159 }
10160 }
10161 vty_out (vty, "%s", VTY_NEWLINE);
10162 vty_out (vty, " End-of-RIB received: ");
10163 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10164 {
10165 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10166 {
10167 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
10168 {
10169 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
10170 afi_safi_print (afi, safi));
10171 eor_receive_af_count++;
10172 }
10173 }
10174 }
10175 vty_out (vty, "%s", VTY_NEWLINE);
10176 }
93406d87 10177
856ca177
MS
10178 if (p->t_gr_restart)
10179 vty_out (vty, " The remaining time of restart timer is %ld%s",
10180 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
0b2aa3a0 10181
856ca177
MS
10182 if (p->t_gr_stale)
10183 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
10184 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
10185 }
10186 }
10187 if (use_json)
10188 {
10189 json_object *json_stat = NULL;
10190 json_stat = json_object_new_object();
10191 /* Packet counts. */
10192 json_object_int_add(json_stat, "depthInq", 0);
10193 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
10194 json_object_int_add(json_stat, "opensSent", p->open_out);
10195 json_object_int_add(json_stat, "opensRecv", p->open_in);
10196 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
10197 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
10198 json_object_int_add(json_stat, "updatesSent", p->update_out);
10199 json_object_int_add(json_stat, "updatesRecv", p->update_in);
10200 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
10201 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
10202 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
10203 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
10204 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
10205 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
10206 json_object_int_add(json_stat, "totalSent", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out);
10207 json_object_int_add(json_stat, "totalRecv", p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + p->dynamic_cap_in);
10208 json_object_object_add(json_neigh, "messageStats", json_stat);
10209 }
10210 else
10211 {
10212 /* Packet counts. */
10213 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
10214 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
10215 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
10216 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
10217 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
10218 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
10219 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
10220 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
10221 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
10222 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
10223 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
10224 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
10225 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
10226 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 10227 }
10228
856ca177
MS
10229 if (use_json)
10230 {
10231 /* advertisement-interval */
10232 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
718e3744 10233
856ca177
MS
10234 /* Update-source. */
10235 if (p->update_if || p->update_source)
10236 {
10237 if (p->update_if)
10238 json_object_string_add(json_neigh, "updateSource", p->update_if);
10239 else if (p->update_source)
10240 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
10241 }
10242
10243 /* Default weight */
10244 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
10245 json_object_int_add(json_neigh, "defaultWeight", p->weight);
10246
10247 }
10248 else
10249 {
10250 /* advertisement-interval */
10251 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
10252 p->v_routeadv, VTY_NEWLINE);
10253
10254 /* Update-source. */
10255 if (p->update_if || p->update_source)
10256 {
10257 vty_out (vty, " Update source is ");
10258 if (p->update_if)
10259 vty_out (vty, "%s", p->update_if);
10260 else if (p->update_source)
10261 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
10262 vty_out (vty, "%s", VTY_NEWLINE);
10263 }
10264
10265 /* Default weight */
10266 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
10267 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
10268
10269 vty_out (vty, "%s", VTY_NEWLINE);
10270 }
718e3744 10271
10272 /* Address Family Information */
856ca177
MS
10273 json_object *json_hold = NULL;
10274
10275 if (use_json)
10276 json_hold = json_object_new_object();
10277
538621f2 10278 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10279 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10280 if (p->afc[afi][safi])
856ca177 10281 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
718e3744 10282
856ca177
MS
10283 if (use_json)
10284 {
10285 json_object_int_add(json_hold, "connectionsEstablished", p->established);
10286 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
10287 }
10288 else
10289 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
10290 VTY_NEWLINE);
718e3744 10291
d6661008 10292 if (! p->last_reset)
856ca177
MS
10293 {
10294 if (use_json)
10295 json_object_string_add(json_hold, "lastReset", "never");
10296 else
10297 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
10298 }
e0701b79 10299 else
d6661008 10300 {
856ca177
MS
10301 if (use_json)
10302 {
10303 time_t uptime;
10304 struct tm *tm;
10305
10306 uptime = bgp_clock();
10307 uptime -= p->resettime;
10308 tm = gmtime(&uptime);
10309 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
10310 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
10311 if (p->last_reset_cause_size)
10312 {
10313 msg = p->last_reset_cause;
10314 char adapter[BUFSIZ];
10315 sprintf(adapter, "%s", msg);
10316 json_object_string_add(json_hold, "messageReceivedThatCausedBgpNotification", adapter);
10317 }
10318 }
10319 else
d6661008 10320 {
856ca177
MS
10321 vty_out (vty, " Last reset %s, due to %s%s",
10322 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL),
10323 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
10324
10325 if (p->last_reset_cause_size)
d6661008 10326 {
856ca177
MS
10327 msg = p->last_reset_cause;
10328 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
10329 for (i = 1; i <= p->last_reset_cause_size; i++)
10330 {
10331 vty_out(vty, "%02X", *msg++);
d6661008 10332
856ca177
MS
10333 if (i != p->last_reset_cause_size)
10334 {
10335 if (i % 16 == 0)
10336 {
10337 vty_out(vty, "%s ", VTY_NEWLINE);
10338 }
10339 else if (i % 4 == 0)
10340 {
10341 vty_out(vty, " ");
10342 }
10343 }
10344 }
10345 vty_out(vty, "%s", VTY_NEWLINE);
d6661008 10346 }
d6661008
DS
10347 }
10348 }
848973c7 10349
718e3744 10350 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10351 {
856ca177
MS
10352 if (use_json)
10353 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
10354 else
10355 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 10356
10357 if (p->t_pmax_restart)
856ca177
MS
10358 {
10359 if (use_json)
10360 {
10361 json_object_string_add(json_hold, "reducePrefixNumFrom", p->host);
10362 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
10363 }
10364 else
10365 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
10366 p->host, thread_timer_remain_second (p->t_pmax_restart),
10367 VTY_NEWLINE);
10368 }
0a486e5f 10369 else
856ca177
MS
10370 {
10371 if (use_json)
10372 json_object_string_add(json_hold, "reducePrefixNumAndClearIpBgp", p->host);
10373 else
10374 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
10375 p->host, VTY_NEWLINE);
10376 }
718e3744 10377 }
10378
856ca177
MS
10379 if (use_json)
10380 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
10381
f5a4827d 10382 /* EBGP Multihop and GTSM */
6d85b15b 10383 if (p->sort != BGP_PEER_IBGP)
f5a4827d 10384 {
856ca177
MS
10385 if (use_json)
10386 {
10387 if (p->gtsm_hops > 0)
10388 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
10389 else if (p->ttl > 1)
10390 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
10391 }
10392 else
10393 {
10394 if (p->gtsm_hops > 0)
10395 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
10396 p->gtsm_hops, VTY_NEWLINE);
10397 else if (p->ttl > 1)
10398 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
10399 p->ttl, VTY_NEWLINE);
10400 }
f5a4827d 10401 }
5d804b43
PM
10402 else
10403 {
10404 if (p->gtsm_hops > 0)
856ca177
MS
10405 {
10406 if (use_json)
10407 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
10408 else
10409 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
10410 p->gtsm_hops, VTY_NEWLINE);
10411 }
5d804b43 10412 }
718e3744 10413
10414 /* Local address. */
10415 if (p->su_local)
10416 {
856ca177
MS
10417 if (use_json)
10418 {
10419 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
10420 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
10421 }
10422 else
10423 vty_out (vty, "Local host: %s, Local port: %d%s",
10424 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
10425 ntohs (p->su_local->sin.sin_port),
10426 VTY_NEWLINE);
718e3744 10427 }
10428
10429 /* Remote address. */
10430 if (p->su_remote)
10431 {
856ca177
MS
10432 if (use_json)
10433 {
10434 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
10435 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
10436 }
10437 else
10438 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
718e3744 10439 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
10440 ntohs (p->su_remote->sin.sin_port),
10441 VTY_NEWLINE);
10442 }
10443
10444 /* Nexthop display. */
10445 if (p->su_local)
10446 {
856ca177
MS
10447 if (use_json)
10448 {
10449 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
718e3744 10450#ifdef HAVE_IPV6
856ca177
MS
10451 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
10452 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
10453 if (p->shared_network)
10454 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
10455 else
10456 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
10457#endif /* HAVE_IPV6 */
10458 }
10459 else
10460 {
10461 vty_out (vty, "Nexthop: %s%s",
10462 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
10463 VTY_NEWLINE);
10464#ifdef HAVE_IPV6
10465 vty_out (vty, "Nexthop global: %s%s",
10466 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
10467 VTY_NEWLINE);
10468 vty_out (vty, "Nexthop local: %s%s",
10469 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
10470 VTY_NEWLINE);
10471 vty_out (vty, "BGP connection: %s%s",
10472 p->shared_network ? "shared network" : "non shared network",
10473 VTY_NEWLINE);
718e3744 10474#endif /* HAVE_IPV6 */
856ca177 10475 }
718e3744 10476 }
10477
10478 /* Timer information. */
856ca177
MS
10479 if (use_json)
10480 {
10481 if (p->t_start)
10482 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
10483 if (p->t_connect)
10484 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
10485 if (p->t_routeadv)
10486 {
10487 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
10488 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
10489 }
cb1faec9 10490
856ca177
MS
10491 if (p->t_read)
10492 json_object_string_add(json_neigh, "readThread", "on");
10493 else
10494 json_object_string_add(json_neigh, "readThread", "off");
10495 if (p->t_write)
10496 json_object_string_add(json_neigh, "writeThread", "on");
10497 else
10498 json_object_string_add(json_neigh, "writeThread", "off");
10499 }
10500 else
10501 {
10502 if (p->t_start)
10503 vty_out (vty, "Next start timer due in %ld seconds%s",
10504 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
10505 if (p->t_connect)
10506 vty_out (vty, "Next connect timer due in %ld seconds%s",
10507 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
10508 if (p->t_routeadv)
10509 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
10510 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
10511 VTY_NEWLINE);
10512
10513 vty_out (vty, "Read thread: %s Write thread: %s%s",
10514 p->t_read ? "on" : "off",
10515 p->t_write ? "on" : "off",
10516 VTY_NEWLINE);
10517 }
718e3744 10518
10519 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
10520 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
856ca177
MS
10521 bgp_capability_vty_out (vty, p, use_json, json_neigh);
10522
10523 if (!use_json)
10524 vty_out (vty, "%s", VTY_NEWLINE);
c43ed2e4
DS
10525
10526 /* BFD information. */
856ca177
MS
10527 bgp_bfd_show_info(vty, p, use_json, json_neigh);
10528
10529 if (use_json)
10530 {
10531 if (p->conf_if) /* Configured interface name. */
10532 json_object_object_add(json, p->conf_if, json_neigh);
10533 else /* Configured IP address. */
10534 json_object_object_add(json, p->host, json_neigh);
10535 }
718e3744 10536}
10537
94f2b392 10538static int
856ca177
MS
10539bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
10540 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
718e3744 10541{
1eb8ef25 10542 struct listnode *node, *nnode;
718e3744 10543 struct peer *peer;
10544 int find = 0;
856ca177
MS
10545 json_object *json_neigh = NULL;
10546
10547 if (use_json)
10548 json_neigh = json_object_new_object();
718e3744 10549
1eb8ef25 10550 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 10551 {
1ff9a340
DS
10552 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
10553 continue;
10554
718e3744 10555 switch (type)
856ca177
MS
10556 {
10557 case show_all:
10558 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10559 break;
10560 case show_peer:
10561 if (conf_if)
10562 {
10563 if (peer->conf_if && !strcmp(peer->conf_if, conf_if))
10564 {
10565 find = 1;
10566 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10567 }
10568 }
10569 else
10570 {
10571 if (sockunion_same (&peer->su, su))
10572 {
10573 find = 1;
10574 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10575 }
10576 }
10577 break;
718e3744 10578 }
10579 }
10580
10581 if (type == show_peer && ! find)
856ca177
MS
10582 {
10583 if (use_json)
10584 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
10585 else
10586 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
10587 }
10588
10589 if (use_json)
10590 {
10591 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
10592 json_object_free(json);
10593 }
10594 else
10595 {
10596 vty_out (vty, "%s", VTY_NEWLINE);
10597 }
10598
718e3744 10599 return CMD_SUCCESS;
10600}
10601
94f2b392 10602static int
fd79ac91 10603bgp_show_neighbor_vty (struct vty *vty, const char *name,
856ca177 10604 enum show_type type, const char *ip_str, u_char use_json)
718e3744 10605{
10606 int ret;
10607 struct bgp *bgp;
10608 union sockunion su;
856ca177
MS
10609 json_object *json = NULL;
10610
10611 if (use_json)
10612 json = json_object_new_object();
718e3744 10613
718e3744 10614 if (name)
10615 {
10616 bgp = bgp_lookup_by_name (name);
718e3744 10617 if (! bgp)
10618 {
856ca177
MS
10619 if (use_json)
10620 {
10621 json_object_boolean_true_add(json, "bgpNoSuchInstance");
10622 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
10623 json_object_free(json);
10624 }
10625 else
10626 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10627
718e3744 10628 return CMD_WARNING;
10629 }
718e3744 10630 }
a80beece
DS
10631 else
10632 {
10633 bgp = bgp_get_default ();
10634 }
718e3744 10635
10636 if (bgp)
a80beece
DS
10637 {
10638 if (ip_str)
10639 {
10640 ret = str2sockunion (ip_str, &su);
10641 if (ret < 0)
856ca177 10642 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
a80beece 10643 else
856ca177 10644 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
a80beece
DS
10645 }
10646 else
10647 {
856ca177 10648 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
a80beece
DS
10649 }
10650 }
718e3744 10651
10652 return CMD_SUCCESS;
10653}
10654
10655/* "show ip bgp neighbors" commands. */
10656DEFUN (show_ip_bgp_neighbors,
10657 show_ip_bgp_neighbors_cmd,
856ca177 10658 "show ip bgp neighbors {json}",
718e3744 10659 SHOW_STR
10660 IP_STR
10661 BGP_STR
856ca177
MS
10662 "Detailed information on TCP and BGP neighbor connections\n"
10663 "JavaScript Object Notation\n")
718e3744 10664{
856ca177
MS
10665 u_char use_json;
10666
10667 if (argv[argc - 1] && strcmp(argv[argc - 1], "json") == 0)
10668 use_json = 1;
10669 else
10670 use_json = 0;
10671
10672 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, use_json);
718e3744 10673}
10674
10675ALIAS (show_ip_bgp_neighbors,
10676 show_ip_bgp_ipv4_neighbors_cmd,
856ca177 10677 "show ip bgp ipv4 (unicast|multicast) neighbors {json}",
718e3744 10678 SHOW_STR
10679 IP_STR
10680 BGP_STR
10681 "Address family\n"
10682 "Address Family modifier\n"
10683 "Address Family modifier\n"
856ca177
MS
10684 "Detailed information on TCP and BGP neighbor connections\n"
10685 "JavaScript Object Notation\n")
718e3744 10686
10687ALIAS (show_ip_bgp_neighbors,
10688 show_ip_bgp_vpnv4_all_neighbors_cmd,
856ca177 10689 "show ip bgp vpnv4 all neighbors {json}",
718e3744 10690 SHOW_STR
10691 IP_STR
10692 BGP_STR
10693 "Display VPNv4 NLRI specific information\n"
10694 "Display information about all VPNv4 NLRIs\n"
856ca177
MS
10695 "Detailed information on TCP and BGP neighbor connections\n"
10696 "JavaScript Object Notation\n")
718e3744 10697
10698ALIAS (show_ip_bgp_neighbors,
10699 show_ip_bgp_vpnv4_rd_neighbors_cmd,
856ca177 10700 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}",
718e3744 10701 SHOW_STR
10702 IP_STR
10703 BGP_STR
10704 "Display VPNv4 NLRI specific information\n"
10705 "Display information for a route distinguisher\n"
10706 "VPN Route Distinguisher\n"
856ca177
MS
10707 "Detailed information on TCP and BGP neighbor connections\n"
10708 "JavaScript Object Notation\n")
718e3744 10709
10710ALIAS (show_ip_bgp_neighbors,
10711 show_bgp_neighbors_cmd,
856ca177 10712 "show bgp neighbors {json}",
718e3744 10713 SHOW_STR
10714 BGP_STR
856ca177
MS
10715 "Detailed information on TCP and BGP neighbor connections\n"
10716 "JavaScript Object Notation\n")
718e3744 10717
10718ALIAS (show_ip_bgp_neighbors,
10719 show_bgp_ipv6_neighbors_cmd,
856ca177 10720 "show bgp ipv6 neighbors {json}",
718e3744 10721 SHOW_STR
10722 BGP_STR
10723 "Address family\n"
856ca177
MS
10724 "Detailed information on TCP and BGP neighbor connections\n"
10725 "JavaScript Object Notation\n")
718e3744 10726
10727DEFUN (show_ip_bgp_neighbors_peer,
10728 show_ip_bgp_neighbors_peer_cmd,
856ca177 10729 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 10730 SHOW_STR
10731 IP_STR
10732 BGP_STR
10733 "Detailed information on TCP and BGP neighbor connections\n"
10734 "Neighbor to display information about\n"
a80beece 10735 "Neighbor to display information about\n"
856ca177
MS
10736 "Neighbor on bgp configured interface\n"
10737 "JavaScript Object Notation\n")
718e3744 10738{
856ca177
MS
10739 u_char use_json;
10740
10741 if (argv[argc - 1] && strcmp(argv[argc - 1], "json") == 0)
10742 use_json = 1;
10743 else
10744 use_json = 0;
10745
10746 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], use_json);
718e3744 10747}
10748
10749ALIAS (show_ip_bgp_neighbors_peer,
10750 show_ip_bgp_ipv4_neighbors_peer_cmd,
856ca177 10751 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 10752 SHOW_STR
10753 IP_STR
10754 BGP_STR
10755 "Address family\n"
10756 "Address Family modifier\n"
10757 "Address Family modifier\n"
10758 "Detailed information on TCP and BGP neighbor connections\n"
10759 "Neighbor to display information about\n"
a80beece 10760 "Neighbor to display information about\n"
856ca177
MS
10761 "Neighbor on bgp configured interface\n"
10762 "JavaScript Object Notation\n")
718e3744 10763
10764ALIAS (show_ip_bgp_neighbors_peer,
10765 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
856ca177 10766 "show ip bgp vpnv4 all neighbors A.B.C.D {json}",
718e3744 10767 SHOW_STR
10768 IP_STR
10769 BGP_STR
10770 "Display VPNv4 NLRI specific information\n"
10771 "Display information about all VPNv4 NLRIs\n"
10772 "Detailed information on TCP and BGP neighbor connections\n"
856ca177
MS
10773 "Neighbor to display information about\n"
10774 "JavaScript Object Notation\n")
718e3744 10775
10776ALIAS (show_ip_bgp_neighbors_peer,
10777 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
856ca177 10778 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}",
718e3744 10779 SHOW_STR
10780 IP_STR
10781 BGP_STR
10782 "Display VPNv4 NLRI specific information\n"
10783 "Display information about all VPNv4 NLRIs\n"
10784 "Detailed information on TCP and BGP neighbor connections\n"
856ca177
MS
10785 "Neighbor to display information about\n"
10786 "JavaScript Object Notation\n")
718e3744 10787
10788ALIAS (show_ip_bgp_neighbors_peer,
10789 show_bgp_neighbors_peer_cmd,
856ca177 10790 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 10791 SHOW_STR
10792 BGP_STR
10793 "Detailed information on TCP and BGP neighbor connections\n"
10794 "Neighbor to display information about\n"
a80beece 10795 "Neighbor to display information about\n"
856ca177
MS
10796 "Neighbor on bgp configured interface\n"
10797 "JavaScript Object Notation\n")
718e3744 10798
10799ALIAS (show_ip_bgp_neighbors_peer,
10800 show_bgp_ipv6_neighbors_peer_cmd,
856ca177 10801 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 10802 SHOW_STR
10803 BGP_STR
10804 "Address family\n"
10805 "Detailed information on TCP and BGP neighbor connections\n"
10806 "Neighbor to display information about\n"
a80beece 10807 "Neighbor to display information about\n"
856ca177
MS
10808 "Neighbor on bgp configured interface\n"
10809 "JavaScript Object Notation\n")
718e3744 10810
10811DEFUN (show_ip_bgp_instance_neighbors,
10812 show_ip_bgp_instance_neighbors_cmd,
856ca177 10813 "show ip bgp view WORD neighbors {json}",
718e3744 10814 SHOW_STR
10815 IP_STR
10816 BGP_STR
10817 "BGP view\n"
10818 "View name\n"
856ca177
MS
10819 "Detailed information on TCP and BGP neighbor connections\n"
10820 "JavaScript Object Notation\n")
718e3744 10821{
856ca177
MS
10822 u_char use_json;
10823
10824 if (argv[1] && strcmp(argv[1], "json") == 0)
10825 use_json = 1;
10826 else
10827 use_json = 0;
10828
10829 return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL, use_json);
718e3744 10830}
10831
bb46e94f 10832ALIAS (show_ip_bgp_instance_neighbors,
10833 show_bgp_instance_neighbors_cmd,
856ca177 10834 "show bgp view WORD neighbors {json}",
bb46e94f 10835 SHOW_STR
10836 BGP_STR
10837 "BGP view\n"
10838 "View name\n"
856ca177
MS
10839 "Detailed information on TCP and BGP neighbor connections\n"
10840 "JavaScript Object Notation\n")
bb46e94f 10841
10842ALIAS (show_ip_bgp_instance_neighbors,
10843 show_bgp_instance_ipv6_neighbors_cmd,
856ca177 10844 "show bgp view WORD ipv6 neighbors {json}",
bb46e94f 10845 SHOW_STR
10846 BGP_STR
10847 "BGP view\n"
10848 "View name\n"
10849 "Address family\n"
856ca177
MS
10850 "Detailed information on TCP and BGP neighbor connections\n"
10851 "JavaScript Object Notation\n")
bb46e94f 10852
718e3744 10853DEFUN (show_ip_bgp_instance_neighbors_peer,
10854 show_ip_bgp_instance_neighbors_peer_cmd,
856ca177 10855 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
718e3744 10856 SHOW_STR
10857 IP_STR
10858 BGP_STR
10859 "BGP view\n"
10860 "View name\n"
10861 "Detailed information on TCP and BGP neighbor connections\n"
10862 "Neighbor to display information about\n"
a80beece 10863 "Neighbor to display information about\n"
856ca177
MS
10864 "Neighbor on bgp configured interface\n"
10865 "JavaScript Object Notation\n")
718e3744 10866{
856ca177
MS
10867 u_char use_json;
10868
10869 if (argv[2] && strcmp(argv[2], "json") == 0)
10870 use_json = 1;
10871 else
10872 use_json = 0;
10873
10874 return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1], use_json);
718e3744 10875}
bb46e94f 10876
10877ALIAS (show_ip_bgp_instance_neighbors_peer,
10878 show_bgp_instance_neighbors_peer_cmd,
856ca177 10879 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
bb46e94f 10880 SHOW_STR
10881 BGP_STR
10882 "BGP view\n"
10883 "View name\n"
10884 "Detailed information on TCP and BGP neighbor connections\n"
10885 "Neighbor to display information about\n"
a80beece 10886 "Neighbor to display information about\n"
856ca177
MS
10887 "Neighbor on bgp configured interface\n"
10888 "JavaScript Object Notation\n")
bb46e94f 10889
10890ALIAS (show_ip_bgp_instance_neighbors_peer,
10891 show_bgp_instance_ipv6_neighbors_peer_cmd,
856ca177 10892 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
bb46e94f 10893 SHOW_STR
10894 BGP_STR
10895 "BGP view\n"
10896 "View name\n"
10897 "Address family\n"
10898 "Detailed information on TCP and BGP neighbor connections\n"
10899 "Neighbor to display information about\n"
a80beece 10900 "Neighbor to display information about\n"
856ca177
MS
10901 "Neighbor on bgp configured interface\n"
10902 "JavaScript Object Notation\n")
6b0655a2 10903
718e3744 10904/* Show BGP's AS paths internal data. There are both `show ip bgp
10905 paths' and `show ip mbgp paths'. Those functions results are the
10906 same.*/
10907DEFUN (show_ip_bgp_paths,
10908 show_ip_bgp_paths_cmd,
10909 "show ip bgp paths",
10910 SHOW_STR
10911 IP_STR
10912 BGP_STR
10913 "Path information\n")
10914{
10915 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
10916 aspath_print_all_vty (vty);
10917 return CMD_SUCCESS;
10918}
10919
10920DEFUN (show_ip_bgp_ipv4_paths,
10921 show_ip_bgp_ipv4_paths_cmd,
10922 "show ip bgp ipv4 (unicast|multicast) paths",
10923 SHOW_STR
10924 IP_STR
10925 BGP_STR
10926 "Address family\n"
10927 "Address Family modifier\n"
10928 "Address Family modifier\n"
10929 "Path information\n")
10930{
10931 vty_out (vty, "Address Refcnt Path\r\n");
10932 aspath_print_all_vty (vty);
10933
10934 return CMD_SUCCESS;
10935}
6b0655a2 10936
718e3744 10937#include "hash.h"
10938
94f2b392 10939static void
718e3744 10940community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
10941{
10942 struct community *com;
10943
10944 com = (struct community *) backet->data;
10945 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
10946 community_str (com), VTY_NEWLINE);
10947}
10948
10949/* Show BGP's community internal data. */
10950DEFUN (show_ip_bgp_community_info,
10951 show_ip_bgp_community_info_cmd,
10952 "show ip bgp community-info",
10953 SHOW_STR
10954 IP_STR
10955 BGP_STR
10956 "List all bgp community information\n")
10957{
10958 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
10959
10960 hash_iterate (community_hash (),
10961 (void (*) (struct hash_backet *, void *))
10962 community_show_all_iterator,
10963 vty);
10964
10965 return CMD_SUCCESS;
10966}
10967
10968DEFUN (show_ip_bgp_attr_info,
10969 show_ip_bgp_attr_info_cmd,
10970 "show ip bgp attribute-info",
10971 SHOW_STR
10972 IP_STR
10973 BGP_STR
10974 "List all bgp attribute information\n")
10975{
10976 attr_show_all (vty);
10977 return CMD_SUCCESS;
10978}
6b0655a2 10979
94f2b392 10980static int
fee0f4c6 10981bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
10982 afi_t afi, safi_t safi)
10983{
10984 char timebuf[BGP_UPTIME_LEN];
10985 char rmbuf[14];
fd79ac91 10986 const char *rmname;
fee0f4c6 10987 struct peer *peer;
1eb8ef25 10988 struct listnode *node, *nnode;
fee0f4c6 10989 int len;
10990 int count = 0;
10991
10992 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
10993 {
1eb8ef25 10994 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
fee0f4c6 10995 {
10996 count++;
10997 bgp_write_rsclient_summary (vty, peer, afi, safi);
10998 }
10999 return count;
11000 }
11001
11002 len = vty_out (vty, "%s", rsclient->host);
11003 len = 16 - len;
11004
11005 if (len < 1)
11006 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
11007 else
11008 vty_out (vty, "%*s", len, " ");
11009
3d515fd9 11010 vty_out (vty, "4 ");
fee0f4c6 11011
0b2aa3a0 11012 vty_out (vty, "%11d ", rsclient->as);
fee0f4c6 11013
11014 rmname = ROUTE_MAP_EXPORT_NAME(&rsclient->filter[afi][safi]);
11015 if ( rmname && strlen (rmname) > 13 )
11016 {
11017 sprintf (rmbuf, "%13s", "...");
11018 rmname = strncpy (rmbuf, rmname, 10);
11019 }
11020 else if (! rmname)
11021 rmname = "<none>";
11022 vty_out (vty, " %13s ", rmname);
11023
11024 rmname = ROUTE_MAP_IMPORT_NAME(&rsclient->filter[afi][safi]);
11025 if ( rmname && strlen (rmname) > 13 )
11026 {
11027 sprintf (rmbuf, "%13s", "...");
11028 rmname = strncpy (rmbuf, rmname, 10);
11029 }
11030 else if (! rmname)
11031 rmname = "<none>";
11032 vty_out (vty, " %13s ", rmname);
11033
856ca177 11034 vty_out (vty, "%8s", peer_uptime (rsclient->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
fee0f4c6 11035
11036 if (CHECK_FLAG (rsclient->flags, PEER_FLAG_SHUTDOWN))
11037 vty_out (vty, " Idle (Admin)");
11038 else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11039 vty_out (vty, " Idle (PfxCt)");
11040 else
11041 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
11042
11043 vty_out (vty, "%s", VTY_NEWLINE);
11044
11045 return 1;
11046}
11047
94f2b392 11048static int
fd79ac91 11049bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
11050 afi_t afi, safi_t safi)
fee0f4c6 11051{
11052 struct peer *peer;
1eb8ef25 11053 struct listnode *node, *nnode;
fee0f4c6 11054 int count = 0;
11055
11056 /* Header string for each address family. */
11057 static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
11058
1eb8ef25 11059 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
fee0f4c6 11060 {
11061 if (peer->afc[afi][safi] &&
11062 CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
11063 {
11064 if (! count)
11065 {
11066 vty_out (vty,
11067 "Route Server's BGP router identifier %s%s",
11068 inet_ntoa (bgp->router_id), VTY_NEWLINE);
11069 vty_out (vty,
aea339f7 11070 "Route Server's local AS number %u%s", bgp->as,
fee0f4c6 11071 VTY_NEWLINE);
11072
11073 vty_out (vty, "%s", VTY_NEWLINE);
11074 vty_out (vty, "%s%s", header, VTY_NEWLINE);
11075 }
11076
11077 count += bgp_write_rsclient_summary (vty, peer, afi, safi);
11078 }
11079 }
11080
11081 if (count)
11082 vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE,
11083 count, VTY_NEWLINE);
11084 else
11085 vty_out (vty, "No %s Route Server Client is configured%s",
11086 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
11087
11088 return CMD_SUCCESS;
11089}
11090
94f2b392 11091static int
fd79ac91 11092bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
11093 afi_t afi, safi_t safi)
fee0f4c6 11094{
11095 struct bgp *bgp;
11096
11097 if (name)
11098 {
11099 bgp = bgp_lookup_by_name (name);
11100
11101 if (! bgp)
11102 {
11103 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
11104 return CMD_WARNING;
11105 }
11106
11107 bgp_show_rsclient_summary (vty, bgp, afi, safi);
11108 return CMD_SUCCESS;
11109 }
11110
11111 bgp = bgp_get_default ();
11112
11113 if (bgp)
11114 bgp_show_rsclient_summary (vty, bgp, afi, safi);
11115
11116 return CMD_SUCCESS;
11117}
11118
11119/* 'show bgp rsclient' commands. */
11120DEFUN (show_ip_bgp_rsclient_summary,
11121 show_ip_bgp_rsclient_summary_cmd,
11122 "show ip bgp rsclient summary",
11123 SHOW_STR
11124 IP_STR
11125 BGP_STR
11126 "Information about Route Server Clients\n"
11127 "Summary of all Route Server Clients\n")
11128{
11129 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
11130}
11131
11132DEFUN (show_ip_bgp_instance_rsclient_summary,
11133 show_ip_bgp_instance_rsclient_summary_cmd,
11134 "show ip bgp view WORD rsclient summary",
11135 SHOW_STR
11136 IP_STR
11137 BGP_STR
11138 "BGP view\n"
11139 "View name\n"
11140 "Information about Route Server Clients\n"
11141 "Summary of all Route Server Clients\n")
11142{
11143 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
11144}
11145
11146DEFUN (show_ip_bgp_ipv4_rsclient_summary,
11147 show_ip_bgp_ipv4_rsclient_summary_cmd,
11148 "show ip bgp ipv4 (unicast|multicast) rsclient summary",
11149 SHOW_STR
11150 IP_STR
11151 BGP_STR
11152 "Address family\n"
11153 "Address Family modifier\n"
11154 "Address Family modifier\n"
11155 "Information about Route Server Clients\n"
11156 "Summary of all Route Server Clients\n")
11157{
11158 if (strncmp (argv[0], "m", 1) == 0)
11159 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST);
11160
11161 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST);
11162}
11163
11164DEFUN (show_ip_bgp_instance_ipv4_rsclient_summary,
11165 show_ip_bgp_instance_ipv4_rsclient_summary_cmd,
11166 "show ip bgp view WORD ipv4 (unicast|multicast) rsclient summary",
11167 SHOW_STR
11168 IP_STR
11169 BGP_STR
11170 "BGP view\n"
11171 "View name\n"
11172 "Address family\n"
11173 "Address Family modifier\n"
11174 "Address Family modifier\n"
11175 "Information about Route Server Clients\n"
11176 "Summary of all Route Server Clients\n")
11177{
11178 if (strncmp (argv[1], "m", 1) == 0)
11179 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST);
11180
11181 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
11182}
11183
95cbbd2a
ML
11184DEFUN (show_bgp_instance_ipv4_safi_rsclient_summary,
11185 show_bgp_instance_ipv4_safi_rsclient_summary_cmd,
11186 "show bgp view WORD ipv4 (unicast|multicast) rsclient summary",
11187 SHOW_STR
11188 BGP_STR
11189 "BGP view\n"
11190 "View name\n"
11191 "Address family\n"
11192 "Address Family modifier\n"
11193 "Address Family modifier\n"
11194 "Information about Route Server Clients\n"
11195 "Summary of all Route Server Clients\n")
11196{
11197 safi_t safi;
11198
11199 if (argc == 2) {
11200 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11201 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP, safi);
11202 } else {
11203 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11204 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP, safi);
11205 }
11206}
11207
11208ALIAS (show_bgp_instance_ipv4_safi_rsclient_summary,
11209 show_bgp_ipv4_safi_rsclient_summary_cmd,
11210 "show bgp ipv4 (unicast|multicast) rsclient summary",
11211 SHOW_STR
11212 BGP_STR
11213 "Address family\n"
11214 "Address Family modifier\n"
11215 "Address Family modifier\n"
11216 "Information about Route Server Clients\n"
11217 "Summary of all Route Server Clients\n")
11218
fee0f4c6 11219#ifdef HAVE_IPV6
11220DEFUN (show_bgp_rsclient_summary,
11221 show_bgp_rsclient_summary_cmd,
11222 "show bgp rsclient summary",
11223 SHOW_STR
11224 BGP_STR
11225 "Information about Route Server Clients\n"
11226 "Summary of all Route Server Clients\n")
11227{
11228 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST);
11229}
11230
11231DEFUN (show_bgp_instance_rsclient_summary,
11232 show_bgp_instance_rsclient_summary_cmd,
11233 "show bgp view WORD rsclient summary",
11234 SHOW_STR
11235 BGP_STR
11236 "BGP view\n"
11237 "View name\n"
11238 "Information about Route Server Clients\n"
11239 "Summary of all Route Server Clients\n")
11240{
11241 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
11242}
11243
11244ALIAS (show_bgp_rsclient_summary,
11245 show_bgp_ipv6_rsclient_summary_cmd,
11246 "show bgp ipv6 rsclient summary",
11247 SHOW_STR
11248 BGP_STR
11249 "Address family\n"
11250 "Information about Route Server Clients\n"
11251 "Summary of all Route Server Clients\n")
11252
11253ALIAS (show_bgp_instance_rsclient_summary,
11254 show_bgp_instance_ipv6_rsclient_summary_cmd,
11255 "show bgp view WORD ipv6 rsclient summary",
11256 SHOW_STR
11257 BGP_STR
11258 "BGP view\n"
11259 "View name\n"
11260 "Address family\n"
11261 "Information about Route Server Clients\n"
11262 "Summary of all Route Server Clients\n")
95cbbd2a
ML
11263
11264DEFUN (show_bgp_instance_ipv6_safi_rsclient_summary,
11265 show_bgp_instance_ipv6_safi_rsclient_summary_cmd,
11266 "show bgp view WORD ipv6 (unicast|multicast) rsclient summary",
11267 SHOW_STR
11268 BGP_STR
11269 "BGP view\n"
11270 "View name\n"
11271 "Address family\n"
11272 "Address Family modifier\n"
11273 "Address Family modifier\n"
11274 "Information about Route Server Clients\n"
11275 "Summary of all Route Server Clients\n")
11276{
11277 safi_t safi;
11278
11279 if (argc == 2) {
11280 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11281 return bgp_show_rsclient_summary_vty (vty, argv[0], AFI_IP6, safi);
11282 } else {
11283 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11284 return bgp_show_rsclient_summary_vty (vty, NULL, AFI_IP6, safi);
11285 }
11286}
11287
11288ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
11289 show_bgp_ipv6_safi_rsclient_summary_cmd,
11290 "show bgp ipv6 (unicast|multicast) rsclient summary",
11291 SHOW_STR
11292 BGP_STR
11293 "Address family\n"
11294 "Address Family modifier\n"
11295 "Address Family modifier\n"
11296 "Information about Route Server Clients\n"
11297 "Summary of all Route Server Clients\n")
11298
fee0f4c6 11299#endif /* HAVE IPV6 */
6b0655a2 11300
8fe8a7f6
DS
11301static int bgp_show_update_groups(int afi, int safi, struct vty *vty,
11302 u_int64_t subgrp_id)
3f9c7369
DS
11303{
11304 struct bgp *bgp;
11305
11306 bgp = bgp_get_default();
11307 if (bgp)
8fe8a7f6 11308 update_group_show(bgp, afi, safi, vty, subgrp_id);
3f9c7369
DS
11309 return CMD_SUCCESS;
11310}
11311
8fe8a7f6
DS
11312DEFUN (show_ip_bgp_updgrps,
11313 show_ip_bgp_updgrps_cmd,
11314 "show ip bgp update-groups",
11315 SHOW_STR
11316 IP_STR
11317 BGP_STR
11318 "Detailed info about dynamic update groups\n")
11319{
11320 return (bgp_show_update_groups(AFI_IP, SAFI_UNICAST, vty, 0));
11321}
11322
3f9c7369
DS
11323DEFUN (show_bgp_ipv6_updgrps,
11324 show_bgp_ipv6_updgrps_cmd,
8fe8a7f6 11325 "show bgp update-groups",
3f9c7369
DS
11326 SHOW_STR
11327 BGP_STR
8fe8a7f6 11328 "Detailed info about v6 dynamic update groups\n")
3f9c7369 11329{
8fe8a7f6 11330 return (bgp_show_update_groups(AFI_IP6, SAFI_UNICAST, vty, 0));
3f9c7369
DS
11331}
11332
11333DEFUN (show_bgp_updgrps,
11334 show_bgp_updgrps_cmd,
8fe8a7f6 11335 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups",
3f9c7369
DS
11336 SHOW_STR
11337 BGP_STR
11338 "Address family\n"
11339 "Address family\n"
11340 "Address Family modifier\n"
11341 "Address Family modifier\n"
8fe8a7f6 11342 "Detailed info about dynamic update groups\n")
3f9c7369 11343{
3f9c7369
DS
11344 afi_t afi;
11345 safi_t safi;
11346
11347 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11348 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8fe8a7f6
DS
11349 return (bgp_show_update_groups(afi, safi, vty, 0));
11350}
11351
11352DEFUN (show_ip_bgp_updgrps_s,
11353 show_ip_bgp_updgrps_s_cmd,
11354 "show ip bgp update-groups SUBGROUP-ID",
11355 SHOW_STR
11356 IP_STR
11357 BGP_STR
11358 "Detailed info about dynamic update groups\n"
11359 "Specific subgroup to display detailed info for\n")
11360{
11361 u_int64_t subgrp_id;
11362
11363 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11364 return (bgp_show_update_groups(AFI_IP, SAFI_UNICAST, vty, subgrp_id));
11365}
11366
11367DEFUN (show_bgp_ipv6_updgrps_s,
11368 show_bgp_ipv6_updgrps_s_cmd,
11369 "show bgp update-groups SUBGROUP-ID",
11370 SHOW_STR
11371 BGP_STR
11372 "Detailed info about v6 dynamic update groups\n"
11373 "Specific subgroup to display detailed info for\n")
11374{
11375 u_int64_t subgrp_id;
11376
11377 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11378 return(bgp_show_update_groups(AFI_IP6, SAFI_UNICAST, vty, subgrp_id));
11379}
11380
11381DEFUN (show_bgp_updgrps_s,
11382 show_bgp_updgrps_s_cmd,
11383 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID",
11384 SHOW_STR
11385 BGP_STR
11386 "Address family\n"
11387 "Address family\n"
11388 "Address Family modifier\n"
11389 "Address Family modifier\n"
11390 "Detailed info about v6 dynamic update groups\n"
11391 "Specific subgroup to display detailed info for")
11392{
11393 afi_t afi;
11394 safi_t safi;
11395 u_int64_t subgrp_id;
11396
11397 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11398 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11399
11400 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11401 return(bgp_show_update_groups(afi, safi, vty, subgrp_id));
3f9c7369
DS
11402}
11403
11404DEFUN (show_bgp_updgrps_stats,
11405 show_bgp_updgrps_stats_cmd,
11406 "show bgp update-groups statistics",
11407 SHOW_STR
11408 BGP_STR
11409 "BGP update groups\n"
11410 "Statistics\n")
11411{
11412 struct bgp *bgp;
11413
11414 bgp = bgp_get_default();
11415 if (bgp)
11416 update_group_show_stats(bgp, vty);
11417
11418 return CMD_SUCCESS;
11419}
11420
11421static void
11422show_bgp_updgrps_adj_info_aux (struct vty *vty, afi_t afi, safi_t safi,
11423 const char *what, u_int64_t subgrp_id)
11424{
11425 struct bgp *bgp;
11426 bgp = bgp_get_default();
11427 if (bgp)
11428 {
11429 if (!strcmp(what, "advertise-queue"))
11430 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
11431 else if (!strcmp(what, "advertised-routes"))
11432 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
11433 else if (!strcmp(what, "packet-queue"))
11434 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
11435 }
11436}
11437
11438DEFUN (show_ip_bgp_updgrps_adj,
11439 show_ip_bgp_updgrps_adj_cmd,
11440 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
11441 SHOW_STR
11442 IP_STR
11443 BGP_STR
11444 "BGP update groups\n"
11445 "Advertisement queue\n"
11446 "Announced routes\n"
11447 "Packet queue\n")
8fe8a7f6 11448
3f9c7369
DS
11449{
11450 show_bgp_updgrps_adj_info_aux(vty, AFI_IP, SAFI_UNICAST, argv[0], 0);
11451 return CMD_SUCCESS;
11452}
11453
11454DEFUN (show_bgp_updgrps_afi_adj,
11455 show_bgp_updgrps_afi_adj_cmd,
11456 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)",
11457 SHOW_STR
11458 BGP_STR
11459 "Address family\n"
11460 "Address family\n"
11461 "Address Family modifier\n"
11462 "Address Family modifier\n"
11463 "BGP update groups\n"
11464 "Advertisement queue\n"
11465 "Announced routes\n"
8fe8a7f6
DS
11466 "Packet queue\n"
11467 "Specific subgroup info wanted for\n")
3f9c7369
DS
11468{
11469 afi_t afi;
11470 safi_t safi;
11471
11472 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11473 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11474 show_bgp_updgrps_adj_info_aux(vty, afi, safi, argv[2], 0);
8fe8a7f6 11475 return CMD_SUCCESS;
3f9c7369
DS
11476}
11477
11478DEFUN (show_bgp_updgrps_adj,
11479 show_bgp_updgrps_adj_cmd,
11480 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
11481 SHOW_STR
11482 BGP_STR
11483 "BGP update groups\n"
11484 "Advertisement queue\n"
11485 "Announced routes\n"
11486 "Packet queue\n")
11487{
11488 show_bgp_updgrps_adj_info_aux(vty, AFI_IP6, SAFI_UNICAST, argv[0], 0);
11489 return CMD_SUCCESS;
11490}
11491
11492DEFUN (show_ip_bgp_updgrps_adj_s,
8fe8a7f6 11493 show_ip_bgp_updgrps_adj_s_cmd,
3f9c7369
DS
11494 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11495 SHOW_STR
11496 IP_STR
11497 BGP_STR
11498 "BGP update groups\n"
8fe8a7f6 11499 "Specific subgroup to display info for\n"
3f9c7369
DS
11500 "Advertisement queue\n"
11501 "Announced routes\n"
11502 "Packet queue\n")
3f9c7369 11503
3f9c7369 11504{
8fe8a7f6
DS
11505 u_int64_t subgrp_id;
11506
11507 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11508
11509 show_bgp_updgrps_adj_info_aux(vty, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
3f9c7369
DS
11510 return CMD_SUCCESS;
11511}
11512
8fe8a7f6
DS
11513DEFUN (show_bgp_updgrps_afi_adj_s,
11514 show_bgp_updgrps_afi_adj_s_cmd,
3f9c7369
DS
11515 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11516 SHOW_STR
11517 BGP_STR
11518 "Address family\n"
11519 "Address family\n"
11520 "Address Family modifier\n"
11521 "Address Family modifier\n"
11522 "BGP update groups\n"
8fe8a7f6 11523 "Specific subgroup to display info for\n"
3f9c7369
DS
11524 "Advertisement queue\n"
11525 "Announced routes\n"
8fe8a7f6
DS
11526 "Packet queue\n"
11527 "Specific subgroup info wanted for\n")
3f9c7369
DS
11528{
11529 afi_t afi;
11530 safi_t safi;
8fe8a7f6 11531 u_int64_t subgrp_id;
3f9c7369
DS
11532
11533 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11534 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
8fe8a7f6
DS
11535 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11536
11537 show_bgp_updgrps_adj_info_aux(vty, afi, safi, argv[3], subgrp_id);
11538 return CMD_SUCCESS;
3f9c7369
DS
11539}
11540
8fe8a7f6
DS
11541DEFUN (show_bgp_updgrps_adj_s,
11542 show_bgp_updgrps_adj_s_cmd,
11543 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11544 SHOW_STR
11545 BGP_STR
11546 "BGP update groups\n"
11547 "Specific subgroup to display info for\n"
11548 "Advertisement queue\n"
11549 "Announced routes\n"
11550 "Packet queue\n")
11551{
11552 u_int64_t subgrp_id;
11553
11554 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11555
11556 show_bgp_updgrps_adj_info_aux(vty, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
11557 return CMD_SUCCESS;
11558}
11559
11560
f14e6fdb
DS
11561static int
11562bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
11563{
11564 struct listnode *node, *nnode;
11565 struct prefix *range;
11566 struct peer *conf;
11567 struct peer *peer;
11568 char buf[128];
11569 afi_t afi;
11570 safi_t safi;
ffd0c037
DS
11571 const char *peer_status;
11572 const char *af_str;
f14e6fdb
DS
11573 int lr_count;
11574 int dynamic;
11575 int af_cfgd;
11576
11577 conf = group->conf;
11578
0299c004
DS
11579 if (conf->as_type == AS_SPECIFIED ||
11580 conf->as_type == AS_EXTERNAL) {
66b199b2 11581 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
f14e6fdb 11582 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
0299c004 11583 } else if (conf->as_type == AS_INTERNAL) {
66b199b2 11584 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
0299c004 11585 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
66b199b2
DS
11586 } else {
11587 vty_out (vty, "%sBGP peer-group %s%s",
11588 VTY_NEWLINE, group->name, VTY_NEWLINE);
0299c004 11589 }
f14e6fdb 11590
0299c004 11591 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
f14e6fdb
DS
11592 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
11593 else
11594 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
11595
11596 /* Display AFs configured. */
11597 vty_out (vty, " Configured address-families:");
11598 for (afi = AFI_IP; afi < AFI_MAX; afi++)
11599 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11600 {
11601 if (conf->afc[afi][safi])
11602 {
11603 af_cfgd = 1;
11604 vty_out (vty, " %s;", afi_safi_print(afi, safi));
11605 }
11606 }
11607 if (!af_cfgd)
11608 vty_out (vty, " none%s", VTY_NEWLINE);
11609 else
11610 vty_out (vty, "%s", VTY_NEWLINE);
11611
11612 /* Display listen ranges (for dynamic neighbors), if any */
11613 for (afi = AFI_IP; afi < AFI_MAX; afi++)
11614 {
11615 if (afi == AFI_IP)
11616 af_str = "IPv4";
11617 else if (afi == AFI_IP6)
11618 af_str = "IPv6";
11619 lr_count = listcount(group->listen_range[afi]);
11620 if (lr_count)
11621 {
11622 vty_out(vty,
11623 " %d %s listen range(s)%s",
11624 lr_count, af_str, VTY_NEWLINE);
11625
11626
11627 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
11628 nnode, range))
11629 {
11630 prefix2str(range, buf, sizeof(buf));
11631 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
11632 }
11633 }
11634 }
11635
11636 /* Display group members and their status */
11637 if (listcount(group->peer))
11638 {
11639 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
11640 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
11641 {
11642 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
11643 peer_status = "Idle (Admin)";
11644 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11645 peer_status = "Idle (PfxCt)";
11646 else
11647 peer_status = LOOKUP(bgp_status_msg, peer->status);
11648
11649 dynamic = peer_dynamic_neighbor(peer);
11650 vty_out (vty, " %s %s %s %s",
11651 peer->host, dynamic ? "(dynamic)" : "",
11652 peer_status, VTY_NEWLINE);
11653 }
11654 }
11655
11656 return CMD_SUCCESS;
11657}
11658
11659/* Show BGP peer group's information. */
11660enum show_group_type
11661{
11662 show_all_groups,
11663 show_peer_group
11664};
11665
11666static int
11667bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
11668 enum show_group_type type, const char *group_name)
11669{
11670 struct listnode *node, *nnode;
11671 struct peer_group *group;
11672 int find = 0;
11673
11674 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
11675 {
11676 switch (type)
11677 {
11678 case show_all_groups:
11679 bgp_show_one_peer_group (vty, group);
11680 break;
11681 case show_peer_group:
11682 if (group_name && (strcmp(group->name, group_name) == 0))
11683 {
11684 find = 1;
11685 bgp_show_one_peer_group (vty, group);
11686 }
11687 break;
11688 }
11689 }
11690
11691 if (type == show_peer_group && ! find)
11692 vty_out (vty, "%% No such peer-groupr%s", VTY_NEWLINE);
11693
11694 return CMD_SUCCESS;
11695}
11696
11697static int
11698bgp_show_peer_group_vty (struct vty *vty, const char *name,
11699 enum show_group_type type, const char *group_name)
11700{
11701 struct bgp *bgp;
11702 int ret = CMD_SUCCESS;
11703
11704 if (name)
11705 {
11706 bgp = bgp_lookup_by_name (name);
11707
11708 if (! bgp)
11709 {
11710 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
11711 return CMD_WARNING;
11712 }
11713 }
11714
11715 bgp = bgp_get_default ();
11716
11717 if (bgp)
11718 ret = bgp_show_peer_group (vty, bgp, type, group_name);
11719
11720 return ret;
11721}
11722
11723DEFUN (show_ip_bgp_peer_groups,
11724 show_ip_bgp_peer_groups_cmd,
11725 "show ip bgp peer-group",
11726 SHOW_STR
11727 IP_STR
11728 BGP_STR
11729 "Detailed information on all BGP peer groups\n")
11730{
11731 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
11732}
11733
11734DEFUN (show_ip_bgp_instance_peer_groups,
11735 show_ip_bgp_instance_peer_groups_cmd,
11736 "show ip bgp view WORD peer-group",
11737 SHOW_STR
11738 IP_STR
11739 BGP_STR
11740 "BGP View\n"
11741 "Detailed information on all BGP peer groups\n")
11742{
11743 return bgp_show_peer_group_vty (vty, argv[0], show_all_groups, NULL);
11744}
11745
11746DEFUN (show_ip_bgp_peer_group,
11747 show_ip_bgp_peer_group_cmd,
11748 "show ip bgp peer-group WORD",
11749 SHOW_STR
11750 IP_STR
11751 BGP_STR
11752 "BGP peer-group name\n"
11753 "Detailed information on a BGP peer group\n")
11754{
11755 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
11756}
11757
11758DEFUN (show_ip_bgp_instance_peer_group,
11759 show_ip_bgp_instance_peer_group_cmd,
11760 "show ip bgp view WORD peer-group WORD",
11761 SHOW_STR
11762 IP_STR
11763 BGP_STR
11764 "BGP View\n"
11765 "BGP peer-group name\n"
11766 "Detailed information on a BGP peer group\n")
11767{
11768 return bgp_show_peer_group_vty (vty, argv[0], show_peer_group, argv[1]);
11769}
3f9c7369 11770
718e3744 11771/* Redistribute VTY commands. */
11772
718e3744 11773DEFUN (bgp_redistribute_ipv4,
11774 bgp_redistribute_ipv4_cmd,
e0ca5fde 11775 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 11776 "Redistribute information from another routing protocol\n"
e0ca5fde 11777 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 11778{
11779 int type;
11780
e0ca5fde
DL
11781 type = proto_redistnum (AFI_IP, argv[0]);
11782 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 11783 {
11784 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11785 return CMD_WARNING;
11786 }
7c8ff89e 11787 bgp_redist_add(vty->index, AFI_IP, type, 0);
8bb0831e 11788 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 11789}
11790
11791DEFUN (bgp_redistribute_ipv4_rmap,
11792 bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 11793 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 11794 "Redistribute information from another routing protocol\n"
e0ca5fde 11795 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 11796 "Route map reference\n"
11797 "Pointer to route-map entries\n")
11798{
11799 int type;
7c8ff89e 11800 struct bgp_redist *red;
718e3744 11801
e0ca5fde
DL
11802 type = proto_redistnum (AFI_IP, argv[0]);
11803 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 11804 {
11805 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11806 return CMD_WARNING;
11807 }
11808
7c8ff89e
DS
11809 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11810 bgp_redistribute_rmap_set (red, argv[1]);
8bb0831e 11811 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 11812}
11813
11814DEFUN (bgp_redistribute_ipv4_metric,
11815 bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 11816 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 11817 "Redistribute information from another routing protocol\n"
e0ca5fde 11818 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 11819 "Metric for redistributed routes\n"
11820 "Default metric\n")
11821{
11822 int type;
11823 u_int32_t metric;
7c8ff89e 11824 struct bgp_redist *red;
718e3744 11825
e0ca5fde
DL
11826 type = proto_redistnum (AFI_IP, argv[0]);
11827 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 11828 {
11829 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11830 return CMD_WARNING;
11831 }
11832 VTY_GET_INTEGER ("metric", metric, argv[1]);
11833
7c8ff89e 11834 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 11835 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
8bb0831e 11836 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 11837}
11838
11839DEFUN (bgp_redistribute_ipv4_rmap_metric,
11840 bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 11841 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 11842 "Redistribute information from another routing protocol\n"
e0ca5fde 11843 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 11844 "Route map reference\n"
11845 "Pointer to route-map entries\n"
11846 "Metric for redistributed routes\n"
11847 "Default metric\n")
11848{
11849 int type;
11850 u_int32_t metric;
7c8ff89e 11851 struct bgp_redist *red;
718e3744 11852
e0ca5fde
DL
11853 type = proto_redistnum (AFI_IP, argv[0]);
11854 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 11855 {
11856 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11857 return CMD_WARNING;
11858 }
11859 VTY_GET_INTEGER ("metric", metric, argv[2]);
11860
7c8ff89e
DS
11861 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11862 bgp_redistribute_rmap_set (red, argv[1]);
caf958b4 11863 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
8bb0831e 11864 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 11865}
11866
11867DEFUN (bgp_redistribute_ipv4_metric_rmap,
11868 bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 11869 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 11870 "Redistribute information from another routing protocol\n"
e0ca5fde 11871 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 11872 "Metric for redistributed routes\n"
11873 "Default metric\n"
11874 "Route map reference\n"
11875 "Pointer to route-map entries\n")
11876{
11877 int type;
11878 u_int32_t metric;
7c8ff89e 11879 struct bgp_redist *red;
718e3744 11880
e0ca5fde
DL
11881 type = proto_redistnum (AFI_IP, argv[0]);
11882 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 11883 {
11884 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11885 return CMD_WARNING;
11886 }
11887 VTY_GET_INTEGER ("metric", metric, argv[1]);
11888
7c8ff89e 11889 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
caf958b4 11890 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
7c8ff89e 11891 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 11892 return bgp_redistribute_set (AFI_IP, type, 0);
718e3744 11893}
11894
7c8ff89e
DS
11895DEFUN (bgp_redistribute_ipv4_ospf,
11896 bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 11897 "redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
11898 "Redistribute information from another routing protocol\n"
11899 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
11900 "Non-main Kernel Routing Table\n"
11901 "Instance ID/Table ID\n")
7c8ff89e
DS
11902{
11903 u_short instance;
7a4bb9c5 11904 u_short protocol;
7c8ff89e 11905
7a4bb9c5
DS
11906 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11907
11908 if (strncmp(argv[0], "o", 1) == 0)
11909 protocol = ZEBRA_ROUTE_OSPF;
11910 else
11911 protocol = ZEBRA_ROUTE_TABLE;
11912
11913 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
8bb0831e 11914 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
11915}
11916
11917DEFUN (bgp_redistribute_ipv4_ospf_rmap,
11918 bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 11919 "redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
11920 "Redistribute information from another routing protocol\n"
11921 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
11922 "Non-main Kernel Routing Table\n"
11923 "Instance ID/Table ID\n"
7c8ff89e
DS
11924 "Route map reference\n"
11925 "Pointer to route-map entries\n")
11926{
11927 struct bgp_redist *red;
11928 u_short instance;
7a4bb9c5 11929 int protocol;
7c8ff89e 11930
7a4bb9c5
DS
11931 if (strncmp(argv[0], "o", 1) == 0)
11932 protocol = ZEBRA_ROUTE_OSPF;
11933 else
11934 protocol = ZEBRA_ROUTE_TABLE;
11935
11936 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11937 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11938 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 11939 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
11940}
11941
11942DEFUN (bgp_redistribute_ipv4_ospf_metric,
11943 bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 11944 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
11945 "Redistribute information from another routing protocol\n"
11946 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
11947 "Non-main Kernel Routing Table\n"
11948 "Instance ID/Table ID\n"
7c8ff89e
DS
11949 "Metric for redistributed routes\n"
11950 "Default metric\n")
11951{
11952 u_int32_t metric;
11953 struct bgp_redist *red;
11954 u_short instance;
7a4bb9c5 11955 int protocol;
7c8ff89e 11956
7a4bb9c5
DS
11957 if (strncmp(argv[0], "o", 1) == 0)
11958 protocol = ZEBRA_ROUTE_OSPF;
11959 else
11960 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 11961
7a4bb9c5
DS
11962 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11963 VTY_GET_INTEGER ("metric", metric, argv[2]);
11964
11965 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 11966 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
8bb0831e 11967 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
11968}
11969
11970DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
11971 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 11972 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
11973 "Redistribute information from another routing protocol\n"
11974 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
11975 "Non-main Kernel Routing Table\n"
11976 "Instance ID/Table ID\n"
7c8ff89e
DS
11977 "Route map reference\n"
11978 "Pointer to route-map entries\n"
11979 "Metric for redistributed routes\n"
11980 "Default metric\n")
11981{
11982 u_int32_t metric;
11983 struct bgp_redist *red;
11984 u_short instance;
7a4bb9c5 11985 int protocol;
7c8ff89e 11986
7a4bb9c5
DS
11987 if (strncmp(argv[0], "o", 1) == 0)
11988 protocol = ZEBRA_ROUTE_OSPF;
11989 else
11990 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 11991
7a4bb9c5
DS
11992 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11993 VTY_GET_INTEGER ("metric", metric, argv[3]);
11994
11995 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11996 bgp_redistribute_rmap_set (red, argv[2]);
caf958b4 11997 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
8bb0831e 11998 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
11999}
12000
12001DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
12002 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 12003 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
12004 "Redistribute information from another routing protocol\n"
12005 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12006 "Non-main Kernel Routing Table\n"
12007 "Instance ID/Table ID\n"
7c8ff89e
DS
12008 "Metric for redistributed routes\n"
12009 "Default metric\n"
12010 "Route map reference\n"
12011 "Pointer to route-map entries\n")
12012{
12013 u_int32_t metric;
12014 struct bgp_redist *red;
12015 u_short instance;
7a4bb9c5 12016 int protocol;
7c8ff89e 12017
7a4bb9c5
DS
12018 if (strncmp(argv[0], "o", 1) == 0)
12019 protocol = ZEBRA_ROUTE_OSPF;
12020 else
12021 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 12022
7a4bb9c5
DS
12023 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
12024 VTY_GET_INTEGER ("metric", metric, argv[2]);
12025
12026 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
caf958b4 12027 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
7a4bb9c5 12028 bgp_redistribute_rmap_set (red, argv[3]);
8bb0831e 12029 return bgp_redistribute_set (AFI_IP, protocol, instance);
7c8ff89e
DS
12030}
12031
12032DEFUN (no_bgp_redistribute_ipv4_ospf,
12033 no_bgp_redistribute_ipv4_ospf_cmd,
7a4bb9c5 12034 "no redistribute (ospf|table) <1-65535>",
7c8ff89e
DS
12035 NO_STR
12036 "Redistribute information from another routing protocol\n"
12037 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12038 "Non-main Kernel Routing Table\n"
12039 "Instance ID/Table ID\n")
7c8ff89e
DS
12040{
12041 u_short instance;
7a4bb9c5
DS
12042 int protocol;
12043
12044 if (strncmp(argv[0], "o", 1) == 0)
12045 protocol = ZEBRA_ROUTE_OSPF;
12046 else
12047 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 12048
7a4bb9c5
DS
12049 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
12050 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
7c8ff89e
DS
12051}
12052
12053ALIAS (no_bgp_redistribute_ipv4_ospf,
12054 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
7a4bb9c5 12055 "no redistribute (ospf|table) <1-65535> route-map WORD",
7c8ff89e
DS
12056 NO_STR
12057 "Redistribute information from another routing protocol\n"
12058 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12059 "Non-main Kernel Routing Table\n"
12060 "Instance ID/Table ID\n"
7c8ff89e
DS
12061 "Route map reference\n"
12062 "Pointer to route-map entries\n")
12063
12064ALIAS (no_bgp_redistribute_ipv4_ospf,
12065 no_bgp_redistribute_ipv4_ospf_metric_cmd,
7a4bb9c5 12066 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
7c8ff89e
DS
12067 NO_STR
12068 "Redistribute information from another routing protocol\n"
12069 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12070 "Non-main Kernel Routing Table\n"
12071 "Instance ID/Table ID\n"
7c8ff89e
DS
12072 "Metric for redistributed routes\n"
12073 "Default metric\n")
12074
12075ALIAS (no_bgp_redistribute_ipv4_ospf,
12076 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
7a4bb9c5 12077 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
7c8ff89e
DS
12078 NO_STR
12079 "Redistribute information from another routing protocol\n"
12080 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12081 "Non-main Kernel Routing Table\n"
12082 "Instance ID/Table ID\n"
7c8ff89e
DS
12083 "Route map reference\n"
12084 "Pointer to route-map entries\n"
12085 "Metric for redistributed routes\n"
12086 "Default metric\n")
12087
12088ALIAS (no_bgp_redistribute_ipv4_ospf,
12089 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
7a4bb9c5 12090 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
7c8ff89e
DS
12091 NO_STR
12092 "Redistribute information from another routing protocol\n"
12093 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
12094 "Non-main Kernel Routing Table\n"
12095 "Instance ID/Table ID\n"
7c8ff89e
DS
12096 "Metric for redistributed routes\n"
12097 "Default metric\n"
12098 "Route map reference\n"
12099 "Pointer to route-map entries\n")
12100
718e3744 12101DEFUN (no_bgp_redistribute_ipv4,
12102 no_bgp_redistribute_ipv4_cmd,
e0ca5fde 12103 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
718e3744 12104 NO_STR
12105 "Redistribute information from another routing protocol\n"
e0ca5fde 12106 QUAGGA_IP_REDIST_HELP_STR_BGPD)
718e3744 12107{
12108 int type;
12109
e0ca5fde
DL
12110 type = proto_redistnum (AFI_IP, argv[0]);
12111 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12112 {
12113 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12114 return CMD_WARNING;
12115 }
7c8ff89e 12116 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
718e3744 12117}
12118
503006bc 12119ALIAS (no_bgp_redistribute_ipv4,
718e3744 12120 no_bgp_redistribute_ipv4_rmap_cmd,
e0ca5fde 12121 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 12122 NO_STR
12123 "Redistribute information from another routing protocol\n"
e0ca5fde 12124 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12125 "Route map reference\n"
12126 "Pointer to route-map entries\n")
718e3744 12127
503006bc 12128ALIAS (no_bgp_redistribute_ipv4,
718e3744 12129 no_bgp_redistribute_ipv4_metric_cmd,
e0ca5fde 12130 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 12131 NO_STR
12132 "Redistribute information from another routing protocol\n"
e0ca5fde 12133 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12134 "Metric for redistributed routes\n"
12135 "Default metric\n")
718e3744 12136
503006bc 12137ALIAS (no_bgp_redistribute_ipv4,
718e3744 12138 no_bgp_redistribute_ipv4_rmap_metric_cmd,
e0ca5fde 12139 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 12140 NO_STR
12141 "Redistribute information from another routing protocol\n"
e0ca5fde 12142 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12143 "Route map reference\n"
12144 "Pointer to route-map entries\n"
12145 "Metric for redistributed routes\n"
12146 "Default metric\n")
718e3744 12147
503006bc 12148ALIAS (no_bgp_redistribute_ipv4,
718e3744 12149 no_bgp_redistribute_ipv4_metric_rmap_cmd,
e0ca5fde 12150 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 12151 NO_STR
12152 "Redistribute information from another routing protocol\n"
e0ca5fde 12153 QUAGGA_IP_REDIST_HELP_STR_BGPD
718e3744 12154 "Metric for redistributed routes\n"
12155 "Default metric\n"
12156 "Route map reference\n"
12157 "Pointer to route-map entries\n")
6b0655a2 12158
718e3744 12159#ifdef HAVE_IPV6
12160DEFUN (bgp_redistribute_ipv6,
12161 bgp_redistribute_ipv6_cmd,
e0ca5fde 12162 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 12163 "Redistribute information from another routing protocol\n"
e0ca5fde 12164 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 12165{
12166 int type;
12167
e0ca5fde
DL
12168 type = proto_redistnum (AFI_IP6, argv[0]);
12169 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12170 {
12171 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12172 return CMD_WARNING;
12173 }
12174
7c8ff89e 12175 bgp_redist_add(vty->index, AFI_IP6, type, 0);
8bb0831e 12176 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 12177}
12178
12179DEFUN (bgp_redistribute_ipv6_rmap,
12180 bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 12181 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 12182 "Redistribute information from another routing protocol\n"
e0ca5fde 12183 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12184 "Route map reference\n"
12185 "Pointer to route-map entries\n")
12186{
12187 int type;
7c8ff89e 12188 struct bgp_redist *red;
718e3744 12189
e0ca5fde
DL
12190 type = proto_redistnum (AFI_IP6, argv[0]);
12191 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12192 {
12193 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12194 return CMD_WARNING;
12195 }
12196
7c8ff89e
DS
12197 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12198 bgp_redistribute_rmap_set (red, argv[1]);
8bb0831e 12199 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 12200}
12201
12202DEFUN (bgp_redistribute_ipv6_metric,
12203 bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 12204 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 12205 "Redistribute information from another routing protocol\n"
e0ca5fde 12206 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12207 "Metric for redistributed routes\n"
12208 "Default metric\n")
12209{
12210 int type;
12211 u_int32_t metric;
7c8ff89e 12212 struct bgp_redist *red;
718e3744 12213
e0ca5fde
DL
12214 type = proto_redistnum (AFI_IP6, argv[0]);
12215 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12216 {
12217 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12218 return CMD_WARNING;
12219 }
12220 VTY_GET_INTEGER ("metric", metric, argv[1]);
12221
7c8ff89e 12222 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 12223 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
8bb0831e 12224 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 12225}
12226
12227DEFUN (bgp_redistribute_ipv6_rmap_metric,
12228 bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 12229 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 12230 "Redistribute information from another routing protocol\n"
e0ca5fde 12231 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12232 "Route map reference\n"
12233 "Pointer to route-map entries\n"
12234 "Metric for redistributed routes\n"
12235 "Default metric\n")
12236{
12237 int type;
12238 u_int32_t metric;
7c8ff89e 12239 struct bgp_redist *red;
718e3744 12240
e0ca5fde
DL
12241 type = proto_redistnum (AFI_IP6, argv[0]);
12242 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12243 {
12244 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12245 return CMD_WARNING;
12246 }
12247 VTY_GET_INTEGER ("metric", metric, argv[2]);
12248
7c8ff89e
DS
12249 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12250 bgp_redistribute_rmap_set (red, argv[1]);
caf958b4 12251 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
8bb0831e 12252 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 12253}
12254
12255DEFUN (bgp_redistribute_ipv6_metric_rmap,
12256 bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 12257 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 12258 "Redistribute information from another routing protocol\n"
e0ca5fde 12259 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12260 "Metric for redistributed routes\n"
12261 "Default metric\n"
12262 "Route map reference\n"
12263 "Pointer to route-map entries\n")
12264{
12265 int type;
12266 u_int32_t metric;
7c8ff89e 12267 struct bgp_redist *red;
718e3744 12268
e0ca5fde
DL
12269 type = proto_redistnum (AFI_IP6, argv[0]);
12270 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12271 {
12272 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12273 return CMD_WARNING;
12274 }
12275 VTY_GET_INTEGER ("metric", metric, argv[1]);
12276
7c8ff89e 12277 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
caf958b4 12278 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
7c8ff89e 12279 bgp_redistribute_rmap_set (red, argv[2]);
8bb0831e 12280 return bgp_redistribute_set (AFI_IP6, type, 0);
718e3744 12281}
12282
12283DEFUN (no_bgp_redistribute_ipv6,
12284 no_bgp_redistribute_ipv6_cmd,
e0ca5fde 12285 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
718e3744 12286 NO_STR
12287 "Redistribute information from another routing protocol\n"
e0ca5fde 12288 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
718e3744 12289{
12290 int type;
12291
e0ca5fde
DL
12292 type = proto_redistnum (AFI_IP6, argv[0]);
12293 if (type < 0 || type == ZEBRA_ROUTE_BGP)
718e3744 12294 {
12295 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12296 return CMD_WARNING;
12297 }
12298
7c8ff89e 12299 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
718e3744 12300}
12301
503006bc 12302ALIAS (no_bgp_redistribute_ipv6,
718e3744 12303 no_bgp_redistribute_ipv6_rmap_cmd,
e0ca5fde 12304 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 12305 NO_STR
12306 "Redistribute information from another routing protocol\n"
e0ca5fde 12307 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12308 "Route map reference\n"
12309 "Pointer to route-map entries\n")
718e3744 12310
503006bc 12311ALIAS (no_bgp_redistribute_ipv6,
718e3744 12312 no_bgp_redistribute_ipv6_metric_cmd,
e0ca5fde 12313 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
718e3744 12314 NO_STR
12315 "Redistribute information from another routing protocol\n"
e0ca5fde 12316 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12317 "Metric for redistributed routes\n"
12318 "Default metric\n")
718e3744 12319
503006bc 12320ALIAS (no_bgp_redistribute_ipv6,
718e3744 12321 no_bgp_redistribute_ipv6_rmap_metric_cmd,
e0ca5fde 12322 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
718e3744 12323 NO_STR
12324 "Redistribute information from another routing protocol\n"
e0ca5fde 12325 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12326 "Route map reference\n"
12327 "Pointer to route-map entries\n"
12328 "Metric for redistributed routes\n"
12329 "Default metric\n")
718e3744 12330
503006bc 12331ALIAS (no_bgp_redistribute_ipv6,
718e3744 12332 no_bgp_redistribute_ipv6_metric_rmap_cmd,
e0ca5fde 12333 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
718e3744 12334 NO_STR
12335 "Redistribute information from another routing protocol\n"
e0ca5fde 12336 QUAGGA_IP6_REDIST_HELP_STR_BGPD
718e3744 12337 "Metric for redistributed routes\n"
12338 "Default metric\n"
12339 "Route map reference\n"
12340 "Pointer to route-map entries\n")
12341#endif /* HAVE_IPV6 */
6b0655a2 12342
718e3744 12343int
12344bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
12345 safi_t safi, int *write)
12346{
12347 int i;
718e3744 12348
12349 /* Unicast redistribution only. */
12350 if (safi != SAFI_UNICAST)
12351 return 0;
12352
12353 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
12354 {
12355 /* Redistribute BGP does not make sense. */
7c8ff89e 12356 if (i != ZEBRA_ROUTE_BGP)
718e3744 12357 {
7c8ff89e
DS
12358 struct list *red_list;
12359 struct listnode *node;
12360 struct bgp_redist *red;
718e3744 12361
7c8ff89e
DS
12362 red_list = bgp->redist[afi][i];
12363 if (!red_list)
12364 continue;
718e3744 12365
7c8ff89e
DS
12366 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
12367 {
12368 /* Display "address-family" when it is not yet diplayed. */
12369 bgp_config_write_family_header (vty, afi, safi, write);
12370
12371 /* "redistribute" configuration. */
12372 vty_out (vty, " redistribute %s", zebra_route_string(i));
12373 if (red->instance)
12374 vty_out (vty, " %d", red->instance);
12375 if (red->redist_metric_flag)
12376 vty_out (vty, " metric %u", red->redist_metric);
12377 if (red->rmap.name)
12378 vty_out (vty, " route-map %s", red->rmap.name);
12379 vty_out (vty, "%s", VTY_NEWLINE);
12380 }
718e3744 12381 }
12382 }
12383 return *write;
12384}
6b0655a2 12385
718e3744 12386/* BGP node structure. */
7fc626de 12387static struct cmd_node bgp_node =
718e3744 12388{
12389 BGP_NODE,
12390 "%s(config-router)# ",
12391 1,
12392};
12393
7fc626de 12394static struct cmd_node bgp_ipv4_unicast_node =
718e3744 12395{
12396 BGP_IPV4_NODE,
12397 "%s(config-router-af)# ",
12398 1,
12399};
12400
7fc626de 12401static struct cmd_node bgp_ipv4_multicast_node =
718e3744 12402{
12403 BGP_IPV4M_NODE,
12404 "%s(config-router-af)# ",
12405 1,
12406};
12407
7fc626de 12408static struct cmd_node bgp_ipv6_unicast_node =
718e3744 12409{
12410 BGP_IPV6_NODE,
12411 "%s(config-router-af)# ",
12412 1,
12413};
12414
7fc626de 12415static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 12416{
12417 BGP_IPV6M_NODE,
12418 "%s(config-router-af)# ",
12419 1,
12420};
12421
7fc626de 12422static struct cmd_node bgp_vpnv4_node =
718e3744 12423{
12424 BGP_VPNV4_NODE,
12425 "%s(config-router-af)# ",
12426 1
12427};
6b0655a2 12428
1f8ae70b 12429static void community_list_vty (void);
12430
718e3744 12431void
94f2b392 12432bgp_vty_init (void)
718e3744 12433{
718e3744 12434 /* Install bgp top node. */
12435 install_node (&bgp_node, bgp_config_write);
12436 install_node (&bgp_ipv4_unicast_node, NULL);
12437 install_node (&bgp_ipv4_multicast_node, NULL);
12438 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 12439 install_node (&bgp_ipv6_multicast_node, NULL);
718e3744 12440 install_node (&bgp_vpnv4_node, NULL);
12441
12442 /* Install default VTY commands to new nodes. */
12443 install_default (BGP_NODE);
12444 install_default (BGP_IPV4_NODE);
12445 install_default (BGP_IPV4M_NODE);
12446 install_default (BGP_IPV6_NODE);
25ffbdc1 12447 install_default (BGP_IPV6M_NODE);
718e3744 12448 install_default (BGP_VPNV4_NODE);
12449
12450 /* "bgp multiple-instance" commands. */
12451 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
12452 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
12453
12454 /* "bgp config-type" commands. */
12455 install_element (CONFIG_NODE, &bgp_config_type_cmd);
12456 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
12457
12458 /* Dummy commands (Currently not supported) */
12459 install_element (BGP_NODE, &no_synchronization_cmd);
12460 install_element (BGP_NODE, &no_auto_summary_cmd);
12461
12462 /* "router bgp" commands. */
12463 install_element (CONFIG_NODE, &router_bgp_cmd);
12464 install_element (CONFIG_NODE, &router_bgp_view_cmd);
12465
12466 /* "no router bgp" commands. */
12467 install_element (CONFIG_NODE, &no_router_bgp_cmd);
12468 install_element (CONFIG_NODE, &no_router_bgp_view_cmd);
12469
12470 /* "bgp router-id" commands. */
12471 install_element (BGP_NODE, &bgp_router_id_cmd);
12472 install_element (BGP_NODE, &no_bgp_router_id_cmd);
12473 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
12474
12475 /* "bgp cluster-id" commands. */
12476 install_element (BGP_NODE, &bgp_cluster_id_cmd);
12477 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
12478 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
12479 install_element (BGP_NODE, &no_bgp_cluster_id_arg_cmd);
12480
12481 /* "bgp confederation" commands. */
12482 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
12483 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
12484 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
12485
12486 /* "bgp confederation peers" commands. */
12487 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
12488 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
12489
abc920f8
DS
12490 /* bgp max-med command */
12491 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
12492 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
12493 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
12494 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
12495 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
12496 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
12497 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
12498 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
12499 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
12500
907f92c8
DS
12501 /* bgp disable-ebgp-connected-nh-check */
12502 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
12503 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
12504
f188f2c4
DS
12505 /* bgp update-delay command */
12506 install_element (BGP_NODE, &bgp_update_delay_cmd);
12507 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
12508 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
12509 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
12510
cb1faec9
DS
12511 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
12512 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
12513
3f9c7369
DS
12514 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
12515 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
12516
165b5fff
JB
12517 /* "maximum-paths" commands. */
12518 install_element (BGP_NODE, &bgp_maxpaths_cmd);
12519 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
12520 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
12521 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
12522 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
12523 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
431aa9f9
DS
12524 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
12525 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
12526 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
165b5fff 12527 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 12528 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff
JB
12529 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
12530 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 12531 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 12532 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 12533 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 12534 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
5e242b0d 12535 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 12536 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
431aa9f9 12537 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
5e242b0d 12538 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9
DS
12539 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
12540 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
5e242b0d 12541 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 12542
718e3744 12543 /* "timers bgp" commands. */
12544 install_element (BGP_NODE, &bgp_timers_cmd);
12545 install_element (BGP_NODE, &no_bgp_timers_cmd);
12546 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
12547
518f0eb1
DS
12548 /* route-map delay-timer commands */
12549 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
12550 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
f414725f 12551 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
518f0eb1 12552
718e3744 12553 /* "bgp client-to-client reflection" commands */
12554 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
12555 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
12556
12557 /* "bgp always-compare-med" commands */
12558 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
12559 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
12560
12561 /* "bgp deterministic-med" commands */
12562 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
12563 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 12564
538621f2 12565 /* "bgp graceful-restart" commands */
12566 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
12567 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 12568 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
12569 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
12570 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
718e3744 12571
12572 /* "bgp fast-external-failover" commands */
12573 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
12574 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
12575
12576 /* "bgp enforce-first-as" commands */
12577 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
12578 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
12579
12580 /* "bgp bestpath compare-routerid" commands */
12581 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
12582 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
12583
12584 /* "bgp bestpath as-path ignore" commands */
12585 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
12586 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
12587
6811845b 12588 /* "bgp bestpath as-path confed" commands */
12589 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
12590 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
12591
2fdd455c
PM
12592 /* "bgp bestpath as-path multipath-relax" commands */
12593 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
12594 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
12595
16fc1eec
DS
12596 /* "bgp bestpath as-path multipath-relax no-as-set" commands */
12597 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_no_as_set_cmd);
12598 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_no_as_set_cmd);
12599
848973c7 12600 /* "bgp log-neighbor-changes" commands */
12601 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
12602 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
12603
718e3744 12604 /* "bgp bestpath med" commands */
12605 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
12606 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
12607 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
12608 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
12609 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
12610 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
12611
12612 /* "no bgp default ipv4-unicast" commands. */
12613 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
12614 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
12615
12616 /* "bgp network import-check" commands. */
12617 install_element (BGP_NODE, &bgp_network_import_check_cmd);
12618 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
12619
12620 /* "bgp default local-preference" commands. */
12621 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
12622 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
12623 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
12624
3f9c7369
DS
12625 /* "bgp default subgroup-pkt-queue-max" commands. */
12626 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
12627 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
12628
8bd9d948
DS
12629 /* bgp ibgp-allow-policy-mods command */
12630 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
12631 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
12632
f14e6fdb
DS
12633 /* "bgp listen limit" commands. */
12634 install_element (BGP_NODE, &bgp_listen_limit_cmd);
12635 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
12636
12637 /* "bgp listen range" commands. */
12638 install_element (BGP_NODE, &bgp_listen_range_cmd);
12639 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
12640
718e3744 12641 /* "neighbor remote-as" commands. */
12642 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 12643 install_element (BGP_NODE, &neighbor_interface_config_cmd);
718e3744 12644 install_element (BGP_NODE, &no_neighbor_cmd);
12645 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
a80beece 12646 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
718e3744 12647
12648 /* "neighbor peer-group" commands. */
12649 install_element (BGP_NODE, &neighbor_peer_group_cmd);
12650 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 12651 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 12652
12653 /* "neighbor local-as" commands. */
12654 install_element (BGP_NODE, &neighbor_local_as_cmd);
12655 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 12656 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 12657 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
12658 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
12659 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
9d3f9705 12660 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
718e3744 12661
3f9c7369
DS
12662 /* "neighbor solo" commands. */
12663 install_element (BGP_NODE, &neighbor_solo_cmd);
12664 install_element (BGP_NODE, &no_neighbor_solo_cmd);
12665
0df7c91f
PJ
12666 /* "neighbor password" commands. */
12667 install_element (BGP_NODE, &neighbor_password_cmd);
12668 install_element (BGP_NODE, &no_neighbor_password_cmd);
12669
718e3744 12670 /* "neighbor activate" commands. */
12671 install_element (BGP_NODE, &neighbor_activate_cmd);
12672 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
12673 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
12674 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 12675 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
718e3744 12676 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
12677
12678 /* "no neighbor activate" commands. */
12679 install_element (BGP_NODE, &no_neighbor_activate_cmd);
12680 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
12681 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
12682 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 12683 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
718e3744 12684 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
12685
12686 /* "neighbor peer-group set" commands. */
12687 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
12688 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
12689 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
12690 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
25ffbdc1 12691 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
a58545bb 12692 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
12693
718e3744 12694 /* "no neighbor peer-group unset" commands. */
12695 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
12696 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
12697 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
12698 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
25ffbdc1 12699 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
a58545bb 12700 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
12701
718e3744 12702 /* "neighbor softreconfiguration inbound" commands.*/
12703 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
12704 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
12705 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
12706 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
12707 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
12708 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
12709 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
12710 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 12711 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
12712 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 12713 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
12714 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 12715
12716 /* "neighbor attribute-unchanged" commands. */
12717 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
12718 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
12719 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
12720 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
12721 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
12722 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
12723 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
12724 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
12725 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
12726 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
12727 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
12728 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
12729 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
12730 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
12731 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
12732 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
12733 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
12734 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
12735 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
12736 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
12737 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
12738 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
12739 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
12740 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
12741 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
12742 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
12743 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
12744 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
12745 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
12746 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
12747 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
12748 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
12749 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
12750 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
12751 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
12752 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
12753 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
12754 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
12755 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
12756 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
12757 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
12758 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
12759 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
12760 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
12761 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
12762 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
12763 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
12764 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
12765 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
12766 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
12767 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
12768 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
12769 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
12770 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
12771 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
12772 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
12773 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
12774 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
12775 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
12776 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
12777 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
12778 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
12779 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
12780 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
12781 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
12782 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
12783 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
12784 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
12785 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
12786 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
12787 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
12788 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
12789 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
12790 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
12791 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
12792 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
12793 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
12794 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
12795 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
12796 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
12797 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
12798 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
12799 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
12800 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
12801 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
12802 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
12803 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
12804 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
25ffbdc1 12805 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
12806 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
12807 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
12808 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
12809 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
12810 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
12811 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
12812 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
12813 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
12814 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
12815 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
12816 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
12817 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
12818 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
12819 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
12820 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
12821 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
12822 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
12823 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
12824 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
12825 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
12826 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
718e3744 12827 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
12828 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
12829 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
12830 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
12831 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
12832 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
12833 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
12834 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
12835 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
12836 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
12837 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
12838 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
12839 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
12840 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
12841 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
12842 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
12843 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
12844 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
12845 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
12846 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
12847 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
12848 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
12849
fee0f4c6 12850 /* "nexthop-local unchanged" commands */
12851 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
12852 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
12853
718e3744 12854 /* "transparent-as" and "transparent-nexthop" for old version
12855 compatibility. */
12856 install_element (BGP_NODE, &neighbor_transparent_as_cmd);
12857 install_element (BGP_NODE, &neighbor_transparent_nexthop_cmd);
12858
12859 /* "neighbor next-hop-self" commands. */
12860 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
12861 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
12862 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
12863 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
12864 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
12865 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
12866 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
12867 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 12868 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
12869 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 12870 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
12871 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
12872
a538debe
DS
12873 /* "neighbor next-hop-self force" commands. */
12874 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
12875 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
12876 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
12877 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
12878 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
12879 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
12880 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
12881 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
12882 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
12883 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
12884 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
12885 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
12886
c7122e14
DS
12887 /* "neighbor as-override" commands. */
12888 install_element (BGP_NODE, &neighbor_as_override_cmd);
12889 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
12890 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
12891 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
12892 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
12893 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
12894 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
12895 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
12896 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
12897 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
12898 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
12899 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
12900
718e3744 12901 /* "neighbor remove-private-AS" commands. */
12902 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
12903 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12904 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
12905 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
12906 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
12907 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12908 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12909 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 12910 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
12911 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12912 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
12913 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
12914 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
12915 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12916 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12917 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 12918 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
12919 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12920 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
12921 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
12922 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
12923 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12924 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12925 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 12926 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
12927 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12928 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
12929 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
12930 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
12931 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12932 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12933 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 12934 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
12935 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12936 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
12937 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
12938 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
12939 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12940 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12941 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 12942 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
12943 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
12944 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
12945 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
12946 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
12947 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12948 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12949 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 12950
12951 /* "neighbor send-community" commands.*/
12952 install_element (BGP_NODE, &neighbor_send_community_cmd);
12953 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
12954 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
12955 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
12956 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
12957 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
12958 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
12959 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
12960 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
12961 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
12962 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
12963 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
12964 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
12965 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
12966 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
12967 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 12968 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
12969 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
12970 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
12971 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
718e3744 12972 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
12973 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
12974 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
12975 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
12976
12977 /* "neighbor route-reflector" commands.*/
12978 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
12979 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
12980 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
12981 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
12982 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
12983 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
12984 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
12985 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 12986 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
12987 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 12988 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
12989 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
12990
12991 /* "neighbor route-server" commands.*/
12992 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
12993 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
12994 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
12995 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
12996 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
12997 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
12998 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
12999 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 13000 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
13001 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
718e3744 13002 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
13003 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
13004
13005 /* "neighbor passive" commands. */
13006 install_element (BGP_NODE, &neighbor_passive_cmd);
13007 install_element (BGP_NODE, &no_neighbor_passive_cmd);
13008
d5a5c8f0 13009
718e3744 13010 /* "neighbor shutdown" commands. */
13011 install_element (BGP_NODE, &neighbor_shutdown_cmd);
13012 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
13013
c9502438 13014 /* Deprecated "neighbor capability route-refresh" commands.*/
718e3744 13015 install_element (BGP_NODE, &neighbor_capability_route_refresh_cmd);
13016 install_element (BGP_NODE, &no_neighbor_capability_route_refresh_cmd);
13017
8a92a8a0
DS
13018 /* "neighbor capability extended-nexthop" commands.*/
13019 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
13020 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
13021
718e3744 13022 /* "neighbor capability orf prefix-list" commands.*/
13023 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
13024 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
13025 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
13026 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
13027 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
13028 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
13029 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
13030 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 13031 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
13032 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 13033
13034 /* "neighbor capability dynamic" commands.*/
13035 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
13036 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
13037
13038 /* "neighbor dont-capability-negotiate" commands. */
13039 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
13040 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
13041
13042 /* "neighbor ebgp-multihop" commands. */
13043 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
13044 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
13045 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
13046 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
13047
6ffd2079 13048 /* "neighbor disable-connected-check" commands. */
13049 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
13050 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 13051 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
13052 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
13053
13054 /* "neighbor description" commands. */
13055 install_element (BGP_NODE, &neighbor_description_cmd);
13056 install_element (BGP_NODE, &no_neighbor_description_cmd);
13057 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
13058
13059 /* "neighbor update-source" commands. "*/
13060 install_element (BGP_NODE, &neighbor_update_source_cmd);
13061 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
13062
13063 /* "neighbor default-originate" commands. */
13064 install_element (BGP_NODE, &neighbor_default_originate_cmd);
13065 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
13066 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
13067 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
13068 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
13069 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
13070 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
13071 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
13072 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
13073 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
13074 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
13075 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
13076 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
13077 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
13078 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
13079 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
25ffbdc1 13080 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
13081 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
13082 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
13083 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
718e3744 13084
13085 /* "neighbor port" commands. */
13086 install_element (BGP_NODE, &neighbor_port_cmd);
13087 install_element (BGP_NODE, &no_neighbor_port_cmd);
13088 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
13089
13090 /* "neighbor weight" commands. */
13091 install_element (BGP_NODE, &neighbor_weight_cmd);
13092 install_element (BGP_NODE, &no_neighbor_weight_cmd);
13093 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
13094
13095 /* "neighbor override-capability" commands. */
13096 install_element (BGP_NODE, &neighbor_override_capability_cmd);
13097 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
13098
13099 /* "neighbor strict-capability-match" commands. */
13100 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
13101 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
13102
13103 /* "neighbor timers" commands. */
13104 install_element (BGP_NODE, &neighbor_timers_cmd);
13105 install_element (BGP_NODE, &no_neighbor_timers_cmd);
13106
13107 /* "neighbor timers connect" commands. */
13108 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
13109 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
13110 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
13111
13112 /* "neighbor advertisement-interval" commands. */
13113 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
13114 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
13115 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
13116
13117 /* "neighbor version" commands. */
13118 install_element (BGP_NODE, &neighbor_version_cmd);
718e3744 13119
13120 /* "neighbor interface" commands. */
13121 install_element (BGP_NODE, &neighbor_interface_cmd);
13122 install_element (BGP_NODE, &no_neighbor_interface_cmd);
13123
13124 /* "neighbor distribute" commands. */
13125 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
13126 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
13127 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
13128 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
13129 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
13130 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
13131 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
13132 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 13133 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
13134 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
718e3744 13135 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
13136 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
13137
13138 /* "neighbor prefix-list" commands. */
13139 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
13140 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
13141 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
13142 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
13143 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
13144 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
13145 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
13146 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 13147 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
13148 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
718e3744 13149 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
13150 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
13151
13152 /* "neighbor filter-list" commands. */
13153 install_element (BGP_NODE, &neighbor_filter_list_cmd);
13154 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
13155 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
13156 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
13157 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
13158 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
13159 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
13160 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 13161 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
13162 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
718e3744 13163 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
13164 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
13165
13166 /* "neighbor route-map" commands. */
13167 install_element (BGP_NODE, &neighbor_route_map_cmd);
13168 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
13169 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
13170 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
13171 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
13172 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
13173 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
13174 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 13175 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
13176 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
718e3744 13177 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
13178 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
13179
13180 /* "neighbor unsuppress-map" commands. */
13181 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
13182 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
13183 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
13184 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
13185 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
13186 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
13187 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
13188 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 13189 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
13190 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 13191 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
13192 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 13193
13194 /* "neighbor maximum-prefix" commands. */
13195 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 13196 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 13197 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 13198 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 13199 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
13200 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13201 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
13202 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 13203 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13204 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13205 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13206 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13207 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13208 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 13209 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 13210 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 13211 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 13212 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
13213 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13214 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
13215 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 13216 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13217 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13218 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13219 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13220 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13221 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 13222 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 13223 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 13224 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 13225 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
13226 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13227 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
13228 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 13229 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13230 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13231 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13232 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13233 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13234 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 13235 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 13236 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 13237 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 13238 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
13239 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13240 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
13241 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 13242 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13243 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13244 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13245 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13246 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
25ffbdc1 13247 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
13248 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
13249 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
13250 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13251 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
13252 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13253 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
13254 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
13255 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13256 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13257 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13258 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13259 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13260 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 13261 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 13262 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 13263 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 13264 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
13265 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13266 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
13267 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
0a486e5f 13268 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13269 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13270 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13271 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13272 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 13273
13274 /* "neighbor allowas-in" */
13275 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
13276 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
13277 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
13278 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
13279 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
13280 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
13281 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
13282 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
13283 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
13284 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
13285 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
13286 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
25ffbdc1 13287 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
13288 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
13289 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
718e3744 13290 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
13291 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
13292 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
13293
13294 /* address-family commands. */
13295 install_element (BGP_NODE, &address_family_ipv4_cmd);
13296 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
13297#ifdef HAVE_IPV6
13298 install_element (BGP_NODE, &address_family_ipv6_cmd);
25ffbdc1 13299 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
718e3744 13300#endif /* HAVE_IPV6 */
13301 install_element (BGP_NODE, &address_family_vpnv4_cmd);
13302 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
13303
13304 /* "exit-address-family" command. */
13305 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
13306 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
13307 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 13308 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
718e3744 13309 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
13310
13311 /* "clear ip bgp commands" */
13312 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
13313 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
13314 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
13315 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
13316 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
13317 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
13318#ifdef HAVE_IPV6
13319 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
13320 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
13321 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
13322 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
13323 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
13324 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
13325 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
13326 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
13327 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
13328 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
13329 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
13330#endif /* HAVE_IPV6 */
13331
13332 /* "clear ip bgp neighbor soft in" */
13333 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
13334 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
13335 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
13336 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
13337 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
13338 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
13339 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
13340 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
13341 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
13342 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
13343 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
13344 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
13345 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
13346 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
13347 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
13348 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
13349 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
13350 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
13351 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
13352 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
13353 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
13354 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
13355 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
13356 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
13357 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
13358 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
13359 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
13360 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
13361 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
13362 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
13363 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
13364 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
13365 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
13366 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
13367 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
13368 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
13369 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
13370 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
13371 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
13372 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
13373#ifdef HAVE_IPV6
13374 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
13375 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
13376 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
13377 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
13378 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
13379 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
13380 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
13381 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
13382 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
13383 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
13384 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
13385 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
13386 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
13387 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
13388 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
13389 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
13390 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
13391 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
13392 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
13393 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
13394 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
13395 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
13396 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
13397 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
13398 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
13399 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
13400 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
13401 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
13402 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
13403 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
13404 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
13405#endif /* HAVE_IPV6 */
13406
8ad7271d
DS
13407 /* clear ip bgp prefix */
13408 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
13409 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
13410
718e3744 13411 /* "clear ip bgp neighbor soft out" */
13412 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
13413 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
13414 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
13415 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
13416 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
13417 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
13418 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
13419 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
13420 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
13421 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
13422 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
13423 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
13424 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
13425 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
13426 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
13427 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
13428 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
13429 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
13430 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
13431 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
13432 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
13433 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
13434 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
13435 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
13436 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
13437 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
13438 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
13439 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
13440#ifdef HAVE_IPV6
13441 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
13442 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
13443 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
13444 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
13445 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
13446 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
13447 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
13448 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
13449 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
13450 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
13451 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
13452 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
13453 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
13454 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
13455 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
13456 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
13457 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
13458 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
13459 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
13460 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
13461 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
13462#endif /* HAVE_IPV6 */
13463
13464 /* "clear ip bgp neighbor soft" */
13465 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
13466 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
13467 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
13468 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
13469 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
13470 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
13471 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
13472 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
13473 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
13474 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
13475 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
13476 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
13477 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
13478 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
13479 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
13480#ifdef HAVE_IPV6
13481 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
13482 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
13483 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
13484 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
13485 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
13486 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
13487 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
13488 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
13489 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
13490 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
13491 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
13492#endif /* HAVE_IPV6 */
13493
fee0f4c6 13494 /* "clear ip bgp neighbor rsclient" */
13495 install_element (ENABLE_NODE, &clear_ip_bgp_all_rsclient_cmd);
13496 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_rsclient_cmd);
13497 install_element (ENABLE_NODE, &clear_ip_bgp_peer_rsclient_cmd);
13498 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_rsclient_cmd);
13499#ifdef HAVE_IPV6
13500 install_element (ENABLE_NODE, &clear_bgp_all_rsclient_cmd);
13501 install_element (ENABLE_NODE, &clear_bgp_instance_all_rsclient_cmd);
13502 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_rsclient_cmd);
13503 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_all_rsclient_cmd);
13504 install_element (ENABLE_NODE, &clear_bgp_peer_rsclient_cmd);
13505 install_element (ENABLE_NODE, &clear_bgp_instance_peer_rsclient_cmd);
13506 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_rsclient_cmd);
13507 install_element (ENABLE_NODE, &clear_bgp_ipv6_instance_peer_rsclient_cmd);
13508#endif /* HAVE_IPV6 */
13509
718e3744 13510 /* "show ip bgp summary" commands. */
13511 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
3f9c7369
DS
13512 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
13513 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
13514 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
8fe8a7f6
DS
13515 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
13516 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
13517 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
3f9c7369
DS
13518 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
13519 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
13520 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6
DS
13521 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13522 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
13523 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 13524 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
13525 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 13526 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 13527 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 13528 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 13529 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13530 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13531#ifdef HAVE_IPV6
13532 install_element (VIEW_NODE, &show_bgp_summary_cmd);
13533 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
13534 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 13535 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 13536 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 13537 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
62687ff1
PJ
13538#endif /* HAVE_IPV6 */
13539 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
3f9c7369
DS
13540 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
13541 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
13542 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
8fe8a7f6
DS
13543 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
13544 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
13545 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
3f9c7369
DS
13546 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
13547 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
13548 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6
DS
13549 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13550 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
13551 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
62687ff1
PJ
13552 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
13553 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 13554 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
62687ff1 13555 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 13556 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
62687ff1
PJ
13557 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13558 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13559#ifdef HAVE_IPV6
13560 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
13561 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
13562 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 13563 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
62687ff1 13564 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 13565 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 13566#endif /* HAVE_IPV6 */
13567 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
3f9c7369
DS
13568 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
13569 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
13570 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
8fe8a7f6
DS
13571 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
13572 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
13573 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
3f9c7369
DS
13574 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
13575 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
13576 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
8fe8a7f6
DS
13577 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13578 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
13579 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
718e3744 13580 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
13581 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
95cbbd2a 13582 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
718e3744 13583 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
95cbbd2a 13584 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
718e3744 13585 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13586 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13587#ifdef HAVE_IPV6
13588 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
13589 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
13590 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
95cbbd2a 13591 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
718e3744 13592 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
95cbbd2a 13593 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
718e3744 13594#endif /* HAVE_IPV6 */
13595
13596 /* "show ip bgp neighbors" commands. */
13597 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
13598 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
13599 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
13600 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13601 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
13602 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
13603 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13604 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13605 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
13606 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
62687ff1
PJ
13607 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
13608 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13609 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13610 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13611 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
718e3744 13612 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
13613 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
13614 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
13615 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13616 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
13617 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
13618 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13619 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13620 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
13621 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
13622
13623#ifdef HAVE_IPV6
13624 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
13625 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
13626 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
13627 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 13628 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
13629 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
13630 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
13631 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
62687ff1
PJ
13632 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
13633 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
13634 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
13635 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 13636 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
13637 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
13638 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
13639 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
bb46e94f 13640 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
13641 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
13642 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
13643 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
718e3744 13644
13645 /* Old commands. */
13646 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
13647 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
13648 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
13649 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
13650#endif /* HAVE_IPV6 */
fee0f4c6 13651
f14e6fdb
DS
13652 /* "show ip bgp peer-group" commands. */
13653 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
13654 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
13655 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
13656 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
13657 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
13658 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
13659 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
13660 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
13661
fee0f4c6 13662 /* "show ip bgp rsclient" commands. */
13663 install_element (VIEW_NODE, &show_ip_bgp_rsclient_summary_cmd);
13664 install_element (VIEW_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
13665 install_element (VIEW_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
13666 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
13667 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
13668 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
62687ff1
PJ
13669 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_summary_cmd);
13670 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
13671 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
13672 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
13673 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
13674 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
fee0f4c6 13675 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_summary_cmd);
13676 install_element (ENABLE_NODE, &show_ip_bgp_instance_rsclient_summary_cmd);
13677 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_rsclient_summary_cmd);
13678 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_rsclient_summary_cmd);
95cbbd2a
ML
13679 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_rsclient_summary_cmd);
13680 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_summary_cmd);
fee0f4c6 13681
13682#ifdef HAVE_IPV6
13683 install_element (VIEW_NODE, &show_bgp_rsclient_summary_cmd);
13684 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
13685 install_element (VIEW_NODE, &show_bgp_instance_rsclient_summary_cmd);
13686 install_element (VIEW_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
13687 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
13688 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
62687ff1
PJ
13689 install_element (RESTRICTED_NODE, &show_bgp_rsclient_summary_cmd);
13690 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
13691 install_element (RESTRICTED_NODE, &show_bgp_instance_rsclient_summary_cmd);
13692 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
13693 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
13694 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
fee0f4c6 13695 install_element (ENABLE_NODE, &show_bgp_rsclient_summary_cmd);
13696 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_summary_cmd);
13697 install_element (ENABLE_NODE, &show_bgp_instance_rsclient_summary_cmd);
13698 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_rsclient_summary_cmd);
95cbbd2a
ML
13699 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_rsclient_summary_cmd);
13700 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_summary_cmd);
fee0f4c6 13701#endif /* HAVE_IPV6 */
718e3744 13702
13703 /* "show ip bgp paths" commands. */
13704 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
13705 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
13706 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
13707 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
13708
13709 /* "show ip bgp community" commands. */
13710 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
13711 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
13712
13713 /* "show ip bgp attribute-info" commands. */
13714 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
13715 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
13716
13717 /* "redistribute" commands. */
13718 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
13719 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
13720 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
13721 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
13722 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
13723 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
13724 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
13725 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
13726 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
13727 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
7c8ff89e
DS
13728 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
13729 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
13730 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
13731 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
13732 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
13733 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
13734 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13735 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13736 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
13737 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 13738#ifdef HAVE_IPV6
13739 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
13740 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
13741 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
13742 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
13743 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
13744 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
13745 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
13746 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
13747 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
13748 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
13749#endif /* HAVE_IPV6 */
13750
fa411a21
NH
13751 /* ttl_security commands */
13752 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
13753 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
13754
4bf6a362
PJ
13755 /* "show bgp memory" commands. */
13756 install_element (VIEW_NODE, &show_bgp_memory_cmd);
62687ff1 13757 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
4bf6a362
PJ
13758 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
13759
e0081f70
ML
13760 /* "show bgp views" commands. */
13761 install_element (VIEW_NODE, &show_bgp_views_cmd);
13762 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
13763 install_element (ENABLE_NODE, &show_bgp_views_cmd);
13764
718e3744 13765 /* Community-list. */
13766 community_list_vty ();
13767}
6b0655a2 13768
718e3744 13769#include "memory.h"
13770#include "bgp_regex.h"
13771#include "bgp_clist.h"
13772#include "bgp_ecommunity.h"
13773
13774/* VTY functions. */
13775
13776/* Direction value to string conversion. */
94f2b392 13777static const char *
718e3744 13778community_direct_str (int direct)
13779{
13780 switch (direct)
13781 {
13782 case COMMUNITY_DENY:
13783 return "deny";
718e3744 13784 case COMMUNITY_PERMIT:
13785 return "permit";
718e3744 13786 default:
13787 return "unknown";
718e3744 13788 }
13789}
13790
13791/* Display error string. */
94f2b392 13792static void
718e3744 13793community_list_perror (struct vty *vty, int ret)
13794{
13795 switch (ret)
13796 {
13797 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 13798 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 13799 break;
13800 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
13801 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
13802 break;
13803 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
13804 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
13805 break;
13806 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
13807 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
13808 break;
13809 }
13810}
13811
13812/* VTY interface for community_set() function. */
94f2b392 13813static int
fd79ac91 13814community_list_set_vty (struct vty *vty, int argc, const char **argv,
13815 int style, int reject_all_digit_name)
718e3744 13816{
13817 int ret;
13818 int direct;
13819 char *str;
13820
13821 /* Check the list type. */
13822 if (strncmp (argv[1], "p", 1) == 0)
13823 direct = COMMUNITY_PERMIT;
13824 else if (strncmp (argv[1], "d", 1) == 0)
13825 direct = COMMUNITY_DENY;
13826 else
13827 {
13828 vty_out (vty, "%% Matching condition must be permit or deny%s",
13829 VTY_NEWLINE);
13830 return CMD_WARNING;
13831 }
13832
13833 /* All digit name check. */
13834 if (reject_all_digit_name && all_digit (argv[0]))
13835 {
13836 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
13837 return CMD_WARNING;
13838 }
13839
13840 /* Concat community string argument. */
13841 if (argc > 1)
13842 str = argv_concat (argv, argc, 2);
13843 else
13844 str = NULL;
13845
13846 /* When community_list_set() return nevetive value, it means
13847 malformed community string. */
13848 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
13849
13850 /* Free temporary community list string allocated by
13851 argv_concat(). */
13852 if (str)
13853 XFREE (MTYPE_TMP, str);
13854
13855 if (ret < 0)
13856 {
13857 /* Display error string. */
13858 community_list_perror (vty, ret);
13859 return CMD_WARNING;
13860 }
13861
13862 return CMD_SUCCESS;
13863}
13864
718e3744 13865/* Communiyt-list entry delete. */
94f2b392 13866static int
fee6e4e4 13867community_list_unset_vty (struct vty *vty, int argc, const char **argv,
13868 int style)
718e3744 13869{
13870 int ret;
fee6e4e4 13871 int direct = 0;
13872 char *str = NULL;
718e3744 13873
fee6e4e4 13874 if (argc > 1)
718e3744 13875 {
fee6e4e4 13876 /* Check the list direct. */
13877 if (strncmp (argv[1], "p", 1) == 0)
13878 direct = COMMUNITY_PERMIT;
13879 else if (strncmp (argv[1], "d", 1) == 0)
13880 direct = COMMUNITY_DENY;
13881 else
13882 {
13883 vty_out (vty, "%% Matching condition must be permit or deny%s",
13884 VTY_NEWLINE);
13885 return CMD_WARNING;
13886 }
718e3744 13887
fee6e4e4 13888 /* Concat community string argument. */
13889 str = argv_concat (argv, argc, 2);
13890 }
718e3744 13891
13892 /* Unset community list. */
13893 ret = community_list_unset (bgp_clist, argv[0], str, direct, style);
13894
13895 /* Free temporary community list string allocated by
13896 argv_concat(). */
fee6e4e4 13897 if (str)
13898 XFREE (MTYPE_TMP, str);
718e3744 13899
13900 if (ret < 0)
13901 {
13902 community_list_perror (vty, ret);
13903 return CMD_WARNING;
13904 }
13905
13906 return CMD_SUCCESS;
13907}
13908
13909/* "community-list" keyword help string. */
13910#define COMMUNITY_LIST_STR "Add a community list entry\n"
13911#define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
13912
718e3744 13913DEFUN (ip_community_list_standard,
13914 ip_community_list_standard_cmd,
13915 "ip community-list <1-99> (deny|permit) .AA:NN",
13916 IP_STR
13917 COMMUNITY_LIST_STR
13918 "Community list number (standard)\n"
13919 "Specify community to reject\n"
13920 "Specify community to accept\n"
13921 COMMUNITY_VAL_STR)
13922{
13923 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
13924}
13925
13926ALIAS (ip_community_list_standard,
13927 ip_community_list_standard2_cmd,
13928 "ip community-list <1-99> (deny|permit)",
13929 IP_STR
13930 COMMUNITY_LIST_STR
13931 "Community list number (standard)\n"
13932 "Specify community to reject\n"
13933 "Specify community to accept\n")
13934
13935DEFUN (ip_community_list_expanded,
13936 ip_community_list_expanded_cmd,
fee6e4e4 13937 "ip community-list <100-500> (deny|permit) .LINE",
718e3744 13938 IP_STR
13939 COMMUNITY_LIST_STR
13940 "Community list number (expanded)\n"
13941 "Specify community to reject\n"
13942 "Specify community to accept\n"
13943 "An ordered list as a regular-expression\n")
13944{
13945 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
13946}
13947
13948DEFUN (ip_community_list_name_standard,
13949 ip_community_list_name_standard_cmd,
13950 "ip community-list standard WORD (deny|permit) .AA:NN",
13951 IP_STR
13952 COMMUNITY_LIST_STR
13953 "Add a standard community-list entry\n"
13954 "Community list name\n"
13955 "Specify community to reject\n"
13956 "Specify community to accept\n"
13957 COMMUNITY_VAL_STR)
13958{
13959 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
13960}
13961
13962ALIAS (ip_community_list_name_standard,
13963 ip_community_list_name_standard2_cmd,
13964 "ip community-list standard WORD (deny|permit)",
13965 IP_STR
13966 COMMUNITY_LIST_STR
13967 "Add a standard community-list entry\n"
13968 "Community list name\n"
13969 "Specify community to reject\n"
13970 "Specify community to accept\n")
13971
13972DEFUN (ip_community_list_name_expanded,
13973 ip_community_list_name_expanded_cmd,
13974 "ip community-list expanded WORD (deny|permit) .LINE",
13975 IP_STR
13976 COMMUNITY_LIST_STR
13977 "Add an expanded community-list entry\n"
13978 "Community list name\n"
13979 "Specify community to reject\n"
13980 "Specify community to accept\n"
13981 "An ordered list as a regular-expression\n")
13982{
13983 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
13984}
13985
fee6e4e4 13986DEFUN (no_ip_community_list_standard_all,
13987 no_ip_community_list_standard_all_cmd,
13988 "no ip community-list <1-99>",
13989 NO_STR
13990 IP_STR
13991 COMMUNITY_LIST_STR
13992 "Community list number (standard)\n")
13993{
13994 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
13995}
13996
13997DEFUN (no_ip_community_list_expanded_all,
13998 no_ip_community_list_expanded_all_cmd,
13999 "no ip community-list <100-500>",
718e3744 14000 NO_STR
14001 IP_STR
14002 COMMUNITY_LIST_STR
718e3744 14003 "Community list number (expanded)\n")
14004{
fee6e4e4 14005 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
718e3744 14006}
14007
fee6e4e4 14008DEFUN (no_ip_community_list_name_standard_all,
14009 no_ip_community_list_name_standard_all_cmd,
14010 "no ip community-list standard WORD",
718e3744 14011 NO_STR
14012 IP_STR
14013 COMMUNITY_LIST_STR
14014 "Add a standard community-list entry\n"
718e3744 14015 "Community list name\n")
14016{
fee6e4e4 14017 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
718e3744 14018}
14019
fee6e4e4 14020DEFUN (no_ip_community_list_name_expanded_all,
14021 no_ip_community_list_name_expanded_all_cmd,
14022 "no ip community-list expanded WORD",
718e3744 14023 NO_STR
14024 IP_STR
14025 COMMUNITY_LIST_STR
fee6e4e4 14026 "Add an expanded community-list entry\n"
14027 "Community list name\n")
718e3744 14028{
fee6e4e4 14029 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
718e3744 14030}
14031
14032DEFUN (no_ip_community_list_standard,
14033 no_ip_community_list_standard_cmd,
14034 "no ip community-list <1-99> (deny|permit) .AA:NN",
14035 NO_STR
14036 IP_STR
14037 COMMUNITY_LIST_STR
14038 "Community list number (standard)\n"
14039 "Specify community to reject\n"
14040 "Specify community to accept\n"
14041 COMMUNITY_VAL_STR)
14042{
14043 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
14044}
14045
14046DEFUN (no_ip_community_list_expanded,
14047 no_ip_community_list_expanded_cmd,
fee6e4e4 14048 "no ip community-list <100-500> (deny|permit) .LINE",
718e3744 14049 NO_STR
14050 IP_STR
14051 COMMUNITY_LIST_STR
14052 "Community list number (expanded)\n"
14053 "Specify community to reject\n"
14054 "Specify community to accept\n"
14055 "An ordered list as a regular-expression\n")
14056{
14057 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
14058}
14059
14060DEFUN (no_ip_community_list_name_standard,
14061 no_ip_community_list_name_standard_cmd,
14062 "no ip community-list standard WORD (deny|permit) .AA:NN",
14063 NO_STR
14064 IP_STR
14065 COMMUNITY_LIST_STR
14066 "Specify a standard community-list\n"
14067 "Community list name\n"
14068 "Specify community to reject\n"
14069 "Specify community to accept\n"
14070 COMMUNITY_VAL_STR)
14071{
14072 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD);
14073}
14074
14075DEFUN (no_ip_community_list_name_expanded,
14076 no_ip_community_list_name_expanded_cmd,
14077 "no ip community-list expanded WORD (deny|permit) .LINE",
14078 NO_STR
14079 IP_STR
14080 COMMUNITY_LIST_STR
14081 "Specify an expanded community-list\n"
14082 "Community list name\n"
14083 "Specify community to reject\n"
14084 "Specify community to accept\n"
14085 "An ordered list as a regular-expression\n")
14086{
14087 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED);
14088}
14089
94f2b392 14090static void
718e3744 14091community_list_show (struct vty *vty, struct community_list *list)
14092{
14093 struct community_entry *entry;
14094
14095 for (entry = list->head; entry; entry = entry->next)
14096 {
14097 if (entry == list->head)
14098 {
14099 if (all_digit (list->name))
14100 vty_out (vty, "Community %s list %s%s",
14101 entry->style == COMMUNITY_LIST_STANDARD ?
14102 "standard" : "(expanded) access",
14103 list->name, VTY_NEWLINE);
14104 else
14105 vty_out (vty, "Named Community %s list %s%s",
14106 entry->style == COMMUNITY_LIST_STANDARD ?
14107 "standard" : "expanded",
14108 list->name, VTY_NEWLINE);
14109 }
14110 if (entry->any)
14111 vty_out (vty, " %s%s",
14112 community_direct_str (entry->direct), VTY_NEWLINE);
14113 else
14114 vty_out (vty, " %s %s%s",
14115 community_direct_str (entry->direct),
14116 entry->style == COMMUNITY_LIST_STANDARD
14117 ? community_str (entry->u.com) : entry->config,
14118 VTY_NEWLINE);
14119 }
14120}
14121
14122DEFUN (show_ip_community_list,
14123 show_ip_community_list_cmd,
14124 "show ip community-list",
14125 SHOW_STR
14126 IP_STR
14127 "List community-list\n")
14128{
14129 struct community_list *list;
14130 struct community_list_master *cm;
14131
fee6e4e4 14132 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 14133 if (! cm)
14134 return CMD_SUCCESS;
14135
14136 for (list = cm->num.head; list; list = list->next)
14137 community_list_show (vty, list);
14138
14139 for (list = cm->str.head; list; list = list->next)
14140 community_list_show (vty, list);
14141
14142 return CMD_SUCCESS;
14143}
14144
14145DEFUN (show_ip_community_list_arg,
14146 show_ip_community_list_arg_cmd,
fee6e4e4 14147 "show ip community-list (<1-500>|WORD)",
718e3744 14148 SHOW_STR
14149 IP_STR
14150 "List community-list\n"
14151 "Community-list number\n"
14152 "Community-list name\n")
14153{
14154 struct community_list *list;
14155
fee6e4e4 14156 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
718e3744 14157 if (! list)
14158 {
b729294c 14159 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 14160 return CMD_WARNING;
14161 }
14162
14163 community_list_show (vty, list);
14164
14165 return CMD_SUCCESS;
14166}
6b0655a2 14167
94f2b392 14168static int
fd79ac91 14169extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
14170 int style, int reject_all_digit_name)
718e3744 14171{
14172 int ret;
14173 int direct;
14174 char *str;
14175
14176 /* Check the list type. */
14177 if (strncmp (argv[1], "p", 1) == 0)
14178 direct = COMMUNITY_PERMIT;
14179 else if (strncmp (argv[1], "d", 1) == 0)
14180 direct = COMMUNITY_DENY;
14181 else
14182 {
14183 vty_out (vty, "%% Matching condition must be permit or deny%s",
14184 VTY_NEWLINE);
14185 return CMD_WARNING;
14186 }
14187
14188 /* All digit name check. */
14189 if (reject_all_digit_name && all_digit (argv[0]))
14190 {
14191 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
14192 return CMD_WARNING;
14193 }
14194
14195 /* Concat community string argument. */
14196 if (argc > 1)
14197 str = argv_concat (argv, argc, 2);
14198 else
14199 str = NULL;
14200
14201 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
14202
14203 /* Free temporary community list string allocated by
14204 argv_concat(). */
14205 if (str)
14206 XFREE (MTYPE_TMP, str);
14207
14208 if (ret < 0)
14209 {
14210 community_list_perror (vty, ret);
14211 return CMD_WARNING;
14212 }
14213 return CMD_SUCCESS;
14214}
14215
94f2b392 14216static int
fee6e4e4 14217extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
14218 int style)
718e3744 14219{
14220 int ret;
fee6e4e4 14221 int direct = 0;
14222 char *str = NULL;
718e3744 14223
fee6e4e4 14224 if (argc > 1)
718e3744 14225 {
fee6e4e4 14226 /* Check the list direct. */
14227 if (strncmp (argv[1], "p", 1) == 0)
14228 direct = COMMUNITY_PERMIT;
14229 else if (strncmp (argv[1], "d", 1) == 0)
14230 direct = COMMUNITY_DENY;
14231 else
14232 {
14233 vty_out (vty, "%% Matching condition must be permit or deny%s",
14234 VTY_NEWLINE);
14235 return CMD_WARNING;
14236 }
718e3744 14237
fee6e4e4 14238 /* Concat community string argument. */
14239 str = argv_concat (argv, argc, 2);
718e3744 14240 }
14241
718e3744 14242 /* Unset community list. */
14243 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
14244
14245 /* Free temporary community list string allocated by
14246 argv_concat(). */
fee6e4e4 14247 if (str)
14248 XFREE (MTYPE_TMP, str);
718e3744 14249
14250 if (ret < 0)
14251 {
14252 community_list_perror (vty, ret);
14253 return CMD_WARNING;
14254 }
14255
14256 return CMD_SUCCESS;
14257}
14258
14259/* "extcommunity-list" keyword help string. */
14260#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14261#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14262
14263DEFUN (ip_extcommunity_list_standard,
14264 ip_extcommunity_list_standard_cmd,
14265 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
14266 IP_STR
14267 EXTCOMMUNITY_LIST_STR
14268 "Extended Community list number (standard)\n"
14269 "Specify community to reject\n"
14270 "Specify community to accept\n"
14271 EXTCOMMUNITY_VAL_STR)
14272{
14273 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14274}
14275
14276ALIAS (ip_extcommunity_list_standard,
14277 ip_extcommunity_list_standard2_cmd,
14278 "ip extcommunity-list <1-99> (deny|permit)",
14279 IP_STR
14280 EXTCOMMUNITY_LIST_STR
14281 "Extended Community list number (standard)\n"
14282 "Specify community to reject\n"
14283 "Specify community to accept\n")
14284
14285DEFUN (ip_extcommunity_list_expanded,
14286 ip_extcommunity_list_expanded_cmd,
fee6e4e4 14287 "ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 14288 IP_STR
14289 EXTCOMMUNITY_LIST_STR
14290 "Extended Community list number (expanded)\n"
14291 "Specify community to reject\n"
14292 "Specify community to accept\n"
14293 "An ordered list as a regular-expression\n")
14294{
14295 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
14296}
14297
14298DEFUN (ip_extcommunity_list_name_standard,
14299 ip_extcommunity_list_name_standard_cmd,
14300 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
14301 IP_STR
14302 EXTCOMMUNITY_LIST_STR
14303 "Specify standard extcommunity-list\n"
14304 "Extended Community list name\n"
14305 "Specify community to reject\n"
14306 "Specify community to accept\n"
14307 EXTCOMMUNITY_VAL_STR)
14308{
14309 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
14310}
14311
14312ALIAS (ip_extcommunity_list_name_standard,
14313 ip_extcommunity_list_name_standard2_cmd,
14314 "ip extcommunity-list standard WORD (deny|permit)",
14315 IP_STR
14316 EXTCOMMUNITY_LIST_STR
14317 "Specify standard extcommunity-list\n"
14318 "Extended Community list name\n"
14319 "Specify community to reject\n"
14320 "Specify community to accept\n")
14321
14322DEFUN (ip_extcommunity_list_name_expanded,
14323 ip_extcommunity_list_name_expanded_cmd,
14324 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
14325 IP_STR
14326 EXTCOMMUNITY_LIST_STR
14327 "Specify expanded extcommunity-list\n"
14328 "Extended Community list name\n"
14329 "Specify community to reject\n"
14330 "Specify community to accept\n"
14331 "An ordered list as a regular-expression\n")
14332{
14333 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
14334}
14335
fee6e4e4 14336DEFUN (no_ip_extcommunity_list_standard_all,
14337 no_ip_extcommunity_list_standard_all_cmd,
14338 "no ip extcommunity-list <1-99>",
14339 NO_STR
14340 IP_STR
14341 EXTCOMMUNITY_LIST_STR
14342 "Extended Community list number (standard)\n")
14343{
14344 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
14345}
14346
14347DEFUN (no_ip_extcommunity_list_expanded_all,
14348 no_ip_extcommunity_list_expanded_all_cmd,
14349 "no ip extcommunity-list <100-500>",
718e3744 14350 NO_STR
14351 IP_STR
14352 EXTCOMMUNITY_LIST_STR
718e3744 14353 "Extended Community list number (expanded)\n")
14354{
fee6e4e4 14355 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
718e3744 14356}
14357
fee6e4e4 14358DEFUN (no_ip_extcommunity_list_name_standard_all,
14359 no_ip_extcommunity_list_name_standard_all_cmd,
14360 "no ip extcommunity-list standard WORD",
718e3744 14361 NO_STR
14362 IP_STR
14363 EXTCOMMUNITY_LIST_STR
14364 "Specify standard extcommunity-list\n"
fee6e4e4 14365 "Extended Community list name\n")
14366{
14367 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
14368}
14369
14370DEFUN (no_ip_extcommunity_list_name_expanded_all,
14371 no_ip_extcommunity_list_name_expanded_all_cmd,
14372 "no ip extcommunity-list expanded WORD",
14373 NO_STR
14374 IP_STR
14375 EXTCOMMUNITY_LIST_STR
718e3744 14376 "Specify expanded extcommunity-list\n"
14377 "Extended Community list name\n")
14378{
fee6e4e4 14379 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
718e3744 14380}
14381
14382DEFUN (no_ip_extcommunity_list_standard,
14383 no_ip_extcommunity_list_standard_cmd,
14384 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
14385 NO_STR
14386 IP_STR
14387 EXTCOMMUNITY_LIST_STR
14388 "Extended Community list number (standard)\n"
14389 "Specify community to reject\n"
14390 "Specify community to accept\n"
14391 EXTCOMMUNITY_VAL_STR)
14392{
14393 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
14394}
14395
14396DEFUN (no_ip_extcommunity_list_expanded,
14397 no_ip_extcommunity_list_expanded_cmd,
fee6e4e4 14398 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
718e3744 14399 NO_STR
14400 IP_STR
14401 EXTCOMMUNITY_LIST_STR
14402 "Extended Community list number (expanded)\n"
14403 "Specify community to reject\n"
14404 "Specify community to accept\n"
14405 "An ordered list as a regular-expression\n")
14406{
14407 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
14408}
14409
14410DEFUN (no_ip_extcommunity_list_name_standard,
14411 no_ip_extcommunity_list_name_standard_cmd,
14412 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
14413 NO_STR
14414 IP_STR
14415 EXTCOMMUNITY_LIST_STR
14416 "Specify standard extcommunity-list\n"
14417 "Extended Community list name\n"
14418 "Specify community to reject\n"
14419 "Specify community to accept\n"
14420 EXTCOMMUNITY_VAL_STR)
14421{
14422 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD);
14423}
14424
14425DEFUN (no_ip_extcommunity_list_name_expanded,
14426 no_ip_extcommunity_list_name_expanded_cmd,
14427 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
14428 NO_STR
14429 IP_STR
14430 EXTCOMMUNITY_LIST_STR
14431 "Specify expanded extcommunity-list\n"
14432 "Community list name\n"
14433 "Specify community to reject\n"
14434 "Specify community to accept\n"
14435 "An ordered list as a regular-expression\n")
14436{
14437 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED);
14438}
14439
94f2b392 14440static void
718e3744 14441extcommunity_list_show (struct vty *vty, struct community_list *list)
14442{
14443 struct community_entry *entry;
14444
14445 for (entry = list->head; entry; entry = entry->next)
14446 {
14447 if (entry == list->head)
14448 {
14449 if (all_digit (list->name))
14450 vty_out (vty, "Extended community %s list %s%s",
14451 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14452 "standard" : "(expanded) access",
14453 list->name, VTY_NEWLINE);
14454 else
14455 vty_out (vty, "Named extended community %s list %s%s",
14456 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14457 "standard" : "expanded",
14458 list->name, VTY_NEWLINE);
14459 }
14460 if (entry->any)
14461 vty_out (vty, " %s%s",
14462 community_direct_str (entry->direct), VTY_NEWLINE);
14463 else
14464 vty_out (vty, " %s %s%s",
14465 community_direct_str (entry->direct),
14466 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14467 entry->u.ecom->str : entry->config,
14468 VTY_NEWLINE);
14469 }
14470}
14471
14472DEFUN (show_ip_extcommunity_list,
14473 show_ip_extcommunity_list_cmd,
14474 "show ip extcommunity-list",
14475 SHOW_STR
14476 IP_STR
14477 "List extended-community list\n")
14478{
14479 struct community_list *list;
14480 struct community_list_master *cm;
14481
fee6e4e4 14482 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 14483 if (! cm)
14484 return CMD_SUCCESS;
14485
14486 for (list = cm->num.head; list; list = list->next)
14487 extcommunity_list_show (vty, list);
14488
14489 for (list = cm->str.head; list; list = list->next)
14490 extcommunity_list_show (vty, list);
14491
14492 return CMD_SUCCESS;
14493}
14494
14495DEFUN (show_ip_extcommunity_list_arg,
14496 show_ip_extcommunity_list_arg_cmd,
fee6e4e4 14497 "show ip extcommunity-list (<1-500>|WORD)",
718e3744 14498 SHOW_STR
14499 IP_STR
14500 "List extended-community list\n"
14501 "Extcommunity-list number\n"
14502 "Extcommunity-list name\n")
14503{
14504 struct community_list *list;
14505
fee6e4e4 14506 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
718e3744 14507 if (! list)
14508 {
b729294c 14509 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 14510 return CMD_WARNING;
14511 }
14512
14513 extcommunity_list_show (vty, list);
14514
14515 return CMD_SUCCESS;
14516}
6b0655a2 14517
718e3744 14518/* Return configuration string of community-list entry. */
fd79ac91 14519static const char *
718e3744 14520community_list_config_str (struct community_entry *entry)
14521{
fd79ac91 14522 const char *str;
718e3744 14523
14524 if (entry->any)
14525 str = "";
14526 else
14527 {
14528 if (entry->style == COMMUNITY_LIST_STANDARD)
14529 str = community_str (entry->u.com);
14530 else
14531 str = entry->config;
14532 }
14533 return str;
14534}
14535
14536/* Display community-list and extcommunity-list configuration. */
94f2b392 14537static int
718e3744 14538community_list_config_write (struct vty *vty)
14539{
14540 struct community_list *list;
14541 struct community_entry *entry;
14542 struct community_list_master *cm;
14543 int write = 0;
14544
14545 /* Community-list. */
fee6e4e4 14546 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 14547
14548 for (list = cm->num.head; list; list = list->next)
14549 for (entry = list->head; entry; entry = entry->next)
14550 {
fee6e4e4 14551 vty_out (vty, "ip community-list %s %s %s%s",
14552 list->name, community_direct_str (entry->direct),
14553 community_list_config_str (entry),
14554 VTY_NEWLINE);
718e3744 14555 write++;
14556 }
14557 for (list = cm->str.head; list; list = list->next)
14558 for (entry = list->head; entry; entry = entry->next)
14559 {
14560 vty_out (vty, "ip community-list %s %s %s %s%s",
14561 entry->style == COMMUNITY_LIST_STANDARD
14562 ? "standard" : "expanded",
14563 list->name, community_direct_str (entry->direct),
14564 community_list_config_str (entry),
14565 VTY_NEWLINE);
14566 write++;
14567 }
14568
14569 /* Extcommunity-list. */
fee6e4e4 14570 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 14571
14572 for (list = cm->num.head; list; list = list->next)
14573 for (entry = list->head; entry; entry = entry->next)
14574 {
fee6e4e4 14575 vty_out (vty, "ip extcommunity-list %s %s %s%s",
14576 list->name, community_direct_str (entry->direct),
14577 community_list_config_str (entry), VTY_NEWLINE);
718e3744 14578 write++;
14579 }
14580 for (list = cm->str.head; list; list = list->next)
14581 for (entry = list->head; entry; entry = entry->next)
14582 {
14583 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
14584 entry->style == EXTCOMMUNITY_LIST_STANDARD
14585 ? "standard" : "expanded",
14586 list->name, community_direct_str (entry->direct),
14587 community_list_config_str (entry), VTY_NEWLINE);
14588 write++;
14589 }
14590 return write;
14591}
14592
7fc626de 14593static struct cmd_node community_list_node =
718e3744 14594{
14595 COMMUNITY_LIST_NODE,
14596 "",
14597 1 /* Export to vtysh. */
14598};
14599
94f2b392 14600static void
14601community_list_vty (void)
718e3744 14602{
14603 install_node (&community_list_node, community_list_config_write);
14604
14605 /* Community-list. */
718e3744 14606 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
14607 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
14608 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
14609 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
14610 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
14611 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
fee6e4e4 14612 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
14613 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
14614 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
14615 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
718e3744 14616 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
14617 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
14618 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
14619 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
14620 install_element (VIEW_NODE, &show_ip_community_list_cmd);
14621 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
14622 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
14623 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
14624
14625 /* Extcommunity-list. */
14626 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
14627 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
14628 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
14629 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
14630 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
14631 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 14632 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
14633 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
14634 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
14635 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
718e3744 14636 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
14637 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
14638 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
14639 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
14640 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
14641 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
14642 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
14643 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
14644}