]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_vty.c
c1648c1c96cdb6cdf1d2104e3bf392b6287919d7
[mirror_frr.git] / bgpd / bgp_vty.c
1 /* BGP VTY interface.
2 Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
3
4 This file is part of GNU Zebra.
5
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21 #include <zebra.h>
22
23 #include "lib/json.h"
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"
32 #include "memory.h"
33 #include "hash.h"
34 #include "queue.h"
35
36 #include "bgpd/bgpd.h"
37 #include "bgpd/bgp_advertise.h"
38 #include "bgpd/bgp_attr.h"
39 #include "bgpd/bgp_aspath.h"
40 #include "bgpd/bgp_community.h"
41 #include "bgpd/bgp_ecommunity.h"
42 #include "bgpd/bgp_damp.h"
43 #include "bgpd/bgp_debug.h"
44 #include "bgpd/bgp_fsm.h"
45 #include "bgpd/bgp_mplsvpn.h"
46 #include "bgpd/bgp_nexthop.h"
47 #include "bgpd/bgp_open.h"
48 #include "bgpd/bgp_regex.h"
49 #include "bgpd/bgp_route.h"
50 #include "bgpd/bgp_zebra.h"
51 #include "bgpd/bgp_table.h"
52 #include "bgpd/bgp_vty.h"
53 #include "bgpd/bgp_mpath.h"
54 #include "bgpd/bgp_packet.h"
55 #include "bgpd/bgp_updgrp.h"
56 #include "bgpd/bgp_bfd.h"
57
58 static struct peer_group *
59 listen_range_exists (struct bgp *bgp, struct prefix *range, int exact);
60
61 /* Utility function to get address family from current node. */
62 afi_t
63 bgp_node_afi (struct vty *vty)
64 {
65 if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
66 return AFI_IP6;
67 return AFI_IP;
68 }
69
70 /* Utility function to get subsequent address family from current
71 node. */
72 safi_t
73 bgp_node_safi (struct vty *vty)
74 {
75 if (vty->node == BGP_VPNV4_NODE)
76 return SAFI_MPLS_VPN;
77 if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
78 return SAFI_MULTICAST;
79 return SAFI_UNICAST;
80 }
81
82 static int
83 peer_address_self_check (struct bgp *bgp, union sockunion *su)
84 {
85 struct interface *ifp = NULL;
86
87 if (su->sa.sa_family == AF_INET)
88 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id);
89 #ifdef HAVE_IPV6
90 else if (su->sa.sa_family == AF_INET6)
91 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
92 su->sin6.sin6_scope_id, bgp->vrf_id);
93 #endif /* HAVE IPV6 */
94
95 if (ifp)
96 return 1;
97
98 return 0;
99 }
100
101 /* Utility function for looking up peer from VTY. */
102 /* This is used only for configuration, so disallow if attempted on
103 * a dynamic neighbor.
104 */
105 static struct peer *
106 peer_lookup_vty (struct vty *vty, const char *ip_str)
107 {
108 int ret;
109 struct bgp *bgp;
110 union sockunion su;
111 struct peer *peer;
112
113 bgp = vty->index;
114
115 ret = str2sockunion (ip_str, &su);
116 if (ret < 0)
117 {
118 peer = peer_lookup_by_conf_if (bgp, ip_str);
119 if (!peer)
120 {
121 if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL)
122 {
123 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
124 return NULL;
125 }
126 }
127 }
128 else
129 {
130 peer = peer_lookup (bgp, &su);
131 if (! peer)
132 {
133 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
134 VTY_NEWLINE);
135 return NULL;
136 }
137 if (peer_dynamic_neighbor (peer))
138 {
139 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
140 VTY_NEWLINE);
141 return NULL;
142 }
143
144 }
145 return peer;
146 }
147
148 /* Utility function for looking up peer or peer group. */
149 /* This is used only for configuration, so disallow if attempted on
150 * a dynamic neighbor.
151 */
152 struct peer *
153 peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
154 {
155 int ret;
156 struct bgp *bgp;
157 union sockunion su;
158 struct peer *peer = NULL;
159 struct peer_group *group = NULL;
160
161 bgp = vty->index;
162
163 ret = str2sockunion (peer_str, &su);
164 if (ret == 0)
165 {
166 /* IP address, locate peer. */
167 peer = peer_lookup (bgp, &su);
168 }
169 else
170 {
171 /* Not IP, could match either peer configured on interface or a group. */
172 peer = peer_lookup_by_conf_if (bgp, peer_str);
173 if (!peer)
174 group = peer_group_lookup (bgp, peer_str);
175 }
176
177 if (peer)
178 {
179 if (peer_dynamic_neighbor (peer))
180 {
181 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
182 VTY_NEWLINE);
183 return NULL;
184 }
185
186 return peer;
187 }
188
189 if (group)
190 return group->conf;
191
192 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
193 VTY_NEWLINE);
194
195 return NULL;
196 }
197
198 int
199 bgp_vty_return (struct vty *vty, int ret)
200 {
201 const char *str = NULL;
202
203 switch (ret)
204 {
205 case BGP_ERR_INVALID_VALUE:
206 str = "Invalid value";
207 break;
208 case BGP_ERR_INVALID_FLAG:
209 str = "Invalid flag";
210 break;
211 case BGP_ERR_PEER_GROUP_SHUTDOWN:
212 str = "Peer-group has been shutdown. Activate the peer-group first";
213 break;
214 case BGP_ERR_PEER_FLAG_CONFLICT:
215 str = "Can't set override-capability and strict-capability-match at the same time";
216 break;
217 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
218 str = "Specify remote-as or peer-group remote AS first";
219 break;
220 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
221 str = "Cannot change the peer-group. Deconfigure first";
222 break;
223 case BGP_ERR_PEER_GROUP_MISMATCH:
224 str = "Peer is not a member of this peer-group";
225 break;
226 case BGP_ERR_PEER_FILTER_CONFLICT:
227 str = "Prefix/distribute list can not co-exist";
228 break;
229 case BGP_ERR_NOT_INTERNAL_PEER:
230 str = "Invalid command. Not an internal neighbor";
231 break;
232 case BGP_ERR_REMOVE_PRIVATE_AS:
233 str = "remove-private-AS cannot be configured for IBGP peers";
234 break;
235 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
236 str = "Local-AS allowed only for EBGP peers";
237 break;
238 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
239 str = "Cannot have local-as same as BGP AS number";
240 break;
241 case BGP_ERR_TCPSIG_FAILED:
242 str = "Error while applying TCP-Sig to session(s)";
243 break;
244 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
245 str = "ebgp-multihop and ttl-security cannot be configured together";
246 break;
247 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
248 str = "ttl-security only allowed for EBGP peers";
249 break;
250 case BGP_ERR_AS_OVERRIDE:
251 str = "as-override cannot be configured for IBGP peers";
252 break;
253 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
254 str = "Invalid limit for number of dynamic neighbors";
255 break;
256 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
257 str = "Dynamic neighbor listen range already exists";
258 break;
259 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
260 str = "Operation not allowed on a dynamic neighbor";
261 break;
262 }
263 if (str)
264 {
265 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
266 return CMD_WARNING;
267 }
268 return CMD_SUCCESS;
269 }
270
271 /* BGP clear sort. */
272 enum clear_sort
273 {
274 clear_all,
275 clear_peer,
276 clear_group,
277 clear_external,
278 clear_as
279 };
280
281 static void
282 bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
283 safi_t safi, int error)
284 {
285 switch (error)
286 {
287 case BGP_ERR_AF_UNCONFIGURED:
288 vty_out (vty,
289 "%%BGP: Enable %s %s address family for the neighbor %s%s",
290 afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
291 safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
292 peer->host, VTY_NEWLINE);
293 break;
294 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
295 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);
296 break;
297 default:
298 break;
299 }
300 }
301
302 /* `clear ip bgp' functions. */
303 static int
304 bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
305 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
306 {
307 int ret;
308 struct peer *peer;
309 struct listnode *node, *nnode;
310
311 /* Clear all neighbors. */
312 /*
313 * Pass along pointer to next node to peer_clear() when walking all nodes
314 * on the BGP instance as that may get freed if it is a doppelganger
315 */
316 if (sort == clear_all)
317 {
318 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
319 {
320 if (stype == BGP_CLEAR_SOFT_NONE)
321 ret = peer_clear (peer, &nnode);
322 else if (peer->afc[afi][safi])
323 ret = peer_clear_soft (peer, afi, safi, stype);
324 else
325 ret = 0;
326
327 if (ret < 0)
328 bgp_clear_vty_error (vty, peer, afi, safi, ret);
329 }
330
331 /* This is to apply read-only mode on this clear. */
332 if (stype == BGP_CLEAR_SOFT_NONE)
333 bgp->update_delay_over = 0;
334
335 return CMD_SUCCESS;
336 }
337
338 /* Clear specified neighbors. */
339 if (sort == clear_peer)
340 {
341 union sockunion su;
342 int ret;
343
344 /* Make sockunion for lookup. */
345 ret = str2sockunion (arg, &su);
346 if (ret < 0)
347 {
348 peer = peer_lookup_by_conf_if (bgp, arg);
349 if (!peer)
350 {
351 peer = peer_lookup_by_hostname(bgp, arg);
352 if (!peer)
353 {
354 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
355 return CMD_WARNING;
356 }
357 }
358 }
359 else
360 {
361 peer = peer_lookup (bgp, &su);
362 if (! peer)
363 {
364 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
365 return CMD_WARNING;
366 }
367 }
368
369 if (stype == BGP_CLEAR_SOFT_NONE)
370 ret = peer_clear (peer, NULL);
371 else
372 ret = peer_clear_soft (peer, afi, safi, stype);
373
374 if (ret < 0)
375 bgp_clear_vty_error (vty, peer, afi, safi, ret);
376
377 return CMD_SUCCESS;
378 }
379
380 /* Clear all peer-group members. */
381 if (sort == clear_group)
382 {
383 struct peer_group *group;
384
385 group = peer_group_lookup (bgp, arg);
386 if (! group)
387 {
388 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
389 return CMD_WARNING;
390 }
391
392 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
393 {
394 if (stype == BGP_CLEAR_SOFT_NONE)
395 {
396 ret = peer_clear (peer, NULL);
397 continue;
398 }
399
400 if (! peer->afc[afi][safi])
401 continue;
402
403 ret = peer_clear_soft (peer, afi, safi, stype);
404
405 if (ret < 0)
406 bgp_clear_vty_error (vty, peer, afi, safi, ret);
407 }
408 return CMD_SUCCESS;
409 }
410
411 if (sort == clear_external)
412 {
413 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
414 {
415 if (peer->sort == BGP_PEER_IBGP)
416 continue;
417
418 if (stype == BGP_CLEAR_SOFT_NONE)
419 ret = peer_clear (peer, &nnode);
420 else
421 ret = peer_clear_soft (peer, afi, safi, stype);
422
423 if (ret < 0)
424 bgp_clear_vty_error (vty, peer, afi, safi, ret);
425 }
426 return CMD_SUCCESS;
427 }
428
429 if (sort == clear_as)
430 {
431 as_t as;
432 int find = 0;
433
434 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
435
436 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
437 {
438 if (peer->as != as)
439 continue;
440
441 find = 1;
442 if (stype == BGP_CLEAR_SOFT_NONE)
443 ret = peer_clear (peer, &nnode);
444 else
445 ret = peer_clear_soft (peer, afi, safi, stype);
446
447 if (ret < 0)
448 bgp_clear_vty_error (vty, peer, afi, safi, ret);
449 }
450 if (! find)
451 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
452 VTY_NEWLINE);
453 return CMD_SUCCESS;
454 }
455
456 return CMD_SUCCESS;
457 }
458
459 static int
460 bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
461 enum clear_sort sort, enum bgp_clear_type stype,
462 const char *arg)
463 {
464 struct bgp *bgp;
465
466 /* BGP structure lookup. */
467 if (name)
468 {
469 bgp = bgp_lookup_by_name (name);
470 if (bgp == NULL)
471 {
472 vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE);
473 return CMD_WARNING;
474 }
475 }
476 else
477 {
478 bgp = bgp_get_default ();
479 if (bgp == NULL)
480 {
481 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
482 return CMD_WARNING;
483 }
484 }
485
486 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
487 }
488
489 /* clear soft inbound */
490 static void
491 bgp_clear_star_soft_in (struct vty *vty)
492 {
493 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
494 BGP_CLEAR_SOFT_IN, NULL);
495 #ifdef HAVE_IPV6
496 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
497 BGP_CLEAR_SOFT_IN, NULL);
498 #endif /* HAVE_IPV6 */
499 }
500
501 /* clear soft outbound */
502 static void
503 bgp_clear_star_soft_out (struct vty *vty)
504 {
505 bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
506 BGP_CLEAR_SOFT_OUT, NULL);
507 #ifdef HAVE_IPV6
508 bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
509 BGP_CLEAR_SOFT_OUT, NULL);
510 #endif /* HAVE_IPV6 */
511 }
512
513
514 /* BGP global configuration. */
515
516 DEFUN (bgp_multiple_instance_func,
517 bgp_multiple_instance_cmd,
518 "bgp multiple-instance",
519 BGP_STR
520 "Enable bgp multiple instance\n")
521 {
522 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
523 return CMD_SUCCESS;
524 }
525
526 DEFUN (no_bgp_multiple_instance,
527 no_bgp_multiple_instance_cmd,
528 "no bgp multiple-instance",
529 NO_STR
530 BGP_STR
531 "BGP multiple instance\n")
532 {
533 int ret;
534
535 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
536 if (ret < 0)
537 {
538 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
539 return CMD_WARNING;
540 }
541 return CMD_SUCCESS;
542 }
543
544 DEFUN (bgp_config_type,
545 bgp_config_type_cmd,
546 "bgp config-type (cisco|zebra)",
547 BGP_STR
548 "Configuration type\n"
549 "cisco\n"
550 "zebra\n")
551 {
552 if (strncmp (argv[0], "c", 1) == 0)
553 bgp_option_set (BGP_OPT_CONFIG_CISCO);
554 else
555 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
556
557 return CMD_SUCCESS;
558 }
559
560 DEFUN (no_bgp_config_type,
561 no_bgp_config_type_cmd,
562 "no bgp config-type",
563 NO_STR
564 BGP_STR
565 "Display configuration type\n")
566 {
567 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
568 return CMD_SUCCESS;
569 }
570
571 ALIAS (no_bgp_config_type,
572 no_bgp_config_type_val_cmd,
573 "no bgp config-type (cisco|zebra)",
574 NO_STR
575 BGP_STR
576 "Configuration type\n"
577 "cisco\n"
578 "zebra\n")
579
580 DEFUN (no_synchronization,
581 no_synchronization_cmd,
582 "no synchronization",
583 NO_STR
584 "Perform IGP synchronization\n")
585 {
586 return CMD_SUCCESS;
587 }
588
589 DEFUN (no_auto_summary,
590 no_auto_summary_cmd,
591 "no auto-summary",
592 NO_STR
593 "Enable automatic network number summarization\n")
594 {
595 return CMD_SUCCESS;
596 }
597
598 /* "router bgp" commands. */
599 DEFUN (router_bgp,
600 router_bgp_cmd,
601 "router bgp " CMD_AS_RANGE,
602 ROUTER_STR
603 BGP_STR
604 AS_STR)
605 {
606 int ret;
607 as_t as;
608 struct bgp *bgp;
609 const char *name = NULL;
610 enum bgp_instance_type inst_type;
611
612 // "router bgp" without an ASN
613 if (argc < 1)
614 {
615 //Pending: Make VRF option available for ASN less config
616 bgp = bgp_get_default();
617
618 if (bgp == NULL)
619 {
620 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
621 return CMD_WARNING;
622 }
623
624 if (listcount(bm->bgp) > 1)
625 {
626 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
627 return CMD_WARNING;
628 }
629 }
630
631 // "router bgp X"
632 else
633 {
634 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
635
636 inst_type = BGP_INSTANCE_TYPE_DEFAULT;
637 if (argc == 3)
638 {
639 name = argv[2];
640 if (!strcmp(argv[1], "vrf"))
641 inst_type = BGP_INSTANCE_TYPE_VRF;
642 else if (!strcmp(argv[1], "view"))
643 inst_type = BGP_INSTANCE_TYPE_VIEW;
644 }
645
646 ret = bgp_get (&bgp, &as, name, inst_type);
647 switch (ret)
648 {
649 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
650 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
651 VTY_NEWLINE);
652 return CMD_WARNING;
653 case BGP_ERR_AS_MISMATCH:
654 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
655 return CMD_WARNING;
656 case BGP_ERR_INSTANCE_MISMATCH:
657 vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE);
658 vty_out (vty, "BGP instance is already running; AS is %u%s",
659 as, VTY_NEWLINE);
660 return CMD_WARNING;
661 }
662
663 /* Pending: handle when user tries to change a view to vrf n vv. */
664 }
665
666 vty->node = BGP_NODE;
667 vty->index = bgp;
668
669 return CMD_SUCCESS;
670 }
671
672 ALIAS (router_bgp,
673 router_bgp_instance_cmd,
674 "router bgp " CMD_AS_RANGE " (view|vrf) WORD",
675 ROUTER_STR
676 BGP_STR
677 AS_STR
678 "BGP view\nBGP VRF\n"
679 "View/VRF name\n")
680
681 ALIAS (router_bgp,
682 router_bgp_noasn_cmd,
683 "router bgp",
684 ROUTER_STR
685 BGP_STR)
686
687 /* "no router bgp" commands. */
688 DEFUN (no_router_bgp,
689 no_router_bgp_cmd,
690 "no router bgp " CMD_AS_RANGE,
691 NO_STR
692 ROUTER_STR
693 BGP_STR
694 AS_STR)
695 {
696 as_t as;
697 struct bgp *bgp;
698 const char *name = NULL;
699
700 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
701
702 if (argc == 3)
703 name = argv[2];
704
705 /* Lookup bgp structure. */
706 bgp = bgp_lookup (as, name);
707 if (! bgp)
708 {
709 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
710 return CMD_WARNING;
711 }
712
713 bgp_delete (bgp);
714
715 return CMD_SUCCESS;
716 }
717
718 ALIAS (no_router_bgp,
719 no_router_bgp_instance_cmd,
720 "no router bgp " CMD_AS_RANGE " (view|vrf) WORD",
721 NO_STR
722 ROUTER_STR
723 BGP_STR
724 AS_STR
725 "BGP view\nBGP VRF\n"
726 "View/VRF name\n")
727
728 /* BGP router-id. */
729
730 DEFUN (bgp_router_id,
731 bgp_router_id_cmd,
732 "bgp router-id A.B.C.D",
733 BGP_STR
734 "Override configured router identifier\n"
735 "Manually configured router identifier\n")
736 {
737 int ret;
738 struct in_addr id;
739 struct bgp *bgp;
740
741 bgp = vty->index;
742
743 ret = inet_aton (argv[0], &id);
744 if (! ret)
745 {
746 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
747 return CMD_WARNING;
748 }
749
750 if (IPV4_ADDR_SAME (&bgp->router_id_static, &id))
751 return CMD_SUCCESS;
752
753 bgp->router_id_static = id;
754 bgp_router_id_set (bgp, &id);
755
756 return CMD_SUCCESS;
757 }
758
759 DEFUN (no_bgp_router_id,
760 no_bgp_router_id_cmd,
761 "no bgp router-id",
762 NO_STR
763 BGP_STR
764 "Override configured router identifier\n")
765 {
766 int ret;
767 struct in_addr id;
768 struct bgp *bgp;
769
770 bgp = vty->index;
771
772 if (argc == 1)
773 {
774 ret = inet_aton (argv[0], &id);
775 if (! ret)
776 {
777 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
778 return CMD_WARNING;
779 }
780
781 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
782 {
783 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
784 return CMD_WARNING;
785 }
786 }
787
788 bgp->router_id_static.s_addr = 0;
789 bgp_router_id_set (bgp, &bgp->router_id_zebra);
790
791 return CMD_SUCCESS;
792 }
793
794 ALIAS (no_bgp_router_id,
795 no_bgp_router_id_val_cmd,
796 "no bgp router-id A.B.C.D",
797 NO_STR
798 BGP_STR
799 "Override configured router identifier\n"
800 "Manually configured router identifier\n")
801
802 /* BGP Cluster ID. */
803
804 DEFUN (bgp_cluster_id,
805 bgp_cluster_id_cmd,
806 "bgp cluster-id A.B.C.D",
807 BGP_STR
808 "Configure Route-Reflector Cluster-id\n"
809 "Route-Reflector Cluster-id in IP address format\n")
810 {
811 int ret;
812 struct bgp *bgp;
813 struct in_addr cluster;
814
815 bgp = vty->index;
816
817 ret = inet_aton (argv[0], &cluster);
818 if (! ret)
819 {
820 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
821 return CMD_WARNING;
822 }
823
824 bgp_cluster_id_set (bgp, &cluster);
825 bgp_clear_star_soft_out (vty);
826
827 return CMD_SUCCESS;
828 }
829
830 ALIAS (bgp_cluster_id,
831 bgp_cluster_id32_cmd,
832 "bgp cluster-id <1-4294967295>",
833 BGP_STR
834 "Configure Route-Reflector Cluster-id\n"
835 "Route-Reflector Cluster-id as 32 bit quantity\n")
836
837 DEFUN (no_bgp_cluster_id,
838 no_bgp_cluster_id_cmd,
839 "no bgp cluster-id",
840 NO_STR
841 BGP_STR
842 "Configure Route-Reflector Cluster-id\n")
843 {
844 int ret;
845 struct bgp *bgp;
846 struct in_addr cluster;
847
848 bgp = vty->index;
849
850 if (argc == 1)
851 {
852 ret = inet_aton (argv[0], &cluster);
853 if (! ret)
854 {
855 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
856 return CMD_WARNING;
857 }
858 }
859
860 bgp_cluster_id_unset (bgp);
861 bgp_clear_star_soft_out (vty);
862
863 return CMD_SUCCESS;
864 }
865
866 ALIAS (no_bgp_cluster_id,
867 no_bgp_cluster_id_ip_cmd,
868 "no bgp cluster-id A.B.C.D",
869 NO_STR
870 BGP_STR
871 "Configure Route-Reflector Cluster-id\n"
872 "Route-Reflector Cluster-id in IP address format\n")
873
874 ALIAS (no_bgp_cluster_id,
875 no_bgp_cluster_id_decimal_cmd,
876 "no bgp cluster-id <1-4294967295>",
877 NO_STR
878 BGP_STR
879 "Configure Route-Reflector Cluster-id\n"
880 "Route-Reflector Cluster-id as 32 bit quantity\n")
881
882 DEFUN (bgp_confederation_identifier,
883 bgp_confederation_identifier_cmd,
884 "bgp confederation identifier " CMD_AS_RANGE,
885 "BGP specific commands\n"
886 "AS confederation parameters\n"
887 "AS number\n"
888 "Set routing domain confederation AS\n")
889 {
890 struct bgp *bgp;
891 as_t as;
892
893 bgp = vty->index;
894
895 VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
896
897 bgp_confederation_id_set (bgp, as);
898
899 return CMD_SUCCESS;
900 }
901
902 DEFUN (no_bgp_confederation_identifier,
903 no_bgp_confederation_identifier_cmd,
904 "no bgp confederation identifier",
905 NO_STR
906 "BGP specific commands\n"
907 "AS confederation parameters\n"
908 "AS number\n")
909 {
910 struct bgp *bgp;
911
912 bgp = vty->index;
913
914 bgp_confederation_id_unset (bgp);
915
916 return CMD_SUCCESS;
917 }
918
919 ALIAS (no_bgp_confederation_identifier,
920 no_bgp_confederation_identifier_arg_cmd,
921 "no bgp confederation identifier " CMD_AS_RANGE,
922 NO_STR
923 "BGP specific commands\n"
924 "AS confederation parameters\n"
925 "AS number\n"
926 "Set routing domain confederation AS\n")
927
928 DEFUN (bgp_confederation_peers,
929 bgp_confederation_peers_cmd,
930 "bgp confederation peers ." CMD_AS_RANGE,
931 "BGP specific commands\n"
932 "AS confederation parameters\n"
933 "Peer ASs in BGP confederation\n"
934 AS_STR)
935 {
936 struct bgp *bgp;
937 as_t as;
938 int i;
939
940 bgp = vty->index;
941
942 for (i = 0; i < argc; i++)
943 {
944 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
945
946 if (bgp->as == as)
947 {
948 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
949 VTY_NEWLINE);
950 continue;
951 }
952
953 bgp_confederation_peers_add (bgp, as);
954 }
955 return CMD_SUCCESS;
956 }
957
958 DEFUN (no_bgp_confederation_peers,
959 no_bgp_confederation_peers_cmd,
960 "no bgp confederation peers ." CMD_AS_RANGE,
961 NO_STR
962 "BGP specific commands\n"
963 "AS confederation parameters\n"
964 "Peer ASs in BGP confederation\n"
965 AS_STR)
966 {
967 struct bgp *bgp;
968 as_t as;
969 int i;
970
971 bgp = vty->index;
972
973 for (i = 0; i < argc; i++)
974 {
975 VTY_GET_INTEGER_RANGE ("AS", as, argv[i], 1, BGP_AS4_MAX);
976
977 bgp_confederation_peers_remove (bgp, as);
978 }
979 return CMD_SUCCESS;
980 }
981
982 /**
983 * Central routine for maximum-paths configuration.
984 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
985 * @set: 1 for setting values, 0 for removing the max-paths config.
986 */
987 static int
988 bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
989 u_int16_t options, int set)
990 {
991 struct bgp *bgp;
992 u_int16_t maxpaths = 0;
993 int ret;
994 afi_t afi;
995 safi_t safi;
996
997 bgp = vty->index;
998 afi = bgp_node_afi (vty);
999 safi = bgp_node_safi (vty);
1000
1001 if (set)
1002 {
1003 VTY_GET_INTEGER_RANGE ("maximum-paths", maxpaths, mpaths, 1,
1004 MULTIPATH_NUM);
1005 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths,
1006 options);
1007 }
1008 else
1009 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
1010
1011 if (ret < 0)
1012 {
1013 vty_out (vty,
1014 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
1015 (set == 1) ? "" : "un",
1016 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1017 maxpaths, afi, safi, VTY_NEWLINE);
1018 return CMD_WARNING;
1019 }
1020
1021 bgp_recalculate_all_bestpaths (bgp);
1022
1023 return CMD_SUCCESS;
1024 }
1025
1026 DEFUN (bgp_maxmed_admin,
1027 bgp_maxmed_admin_cmd,
1028 "bgp max-med administrative ",
1029 BGP_STR
1030 "Advertise routes with max-med\n"
1031 "Administratively applied, for an indefinite period\n")
1032 {
1033 struct bgp *bgp;
1034
1035 bgp = vty->index;
1036
1037 bgp->v_maxmed_admin = 1;
1038 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1039
1040 bgp_maxmed_update(bgp);
1041
1042 return CMD_SUCCESS;
1043 }
1044
1045 DEFUN (bgp_maxmed_admin_medv,
1046 bgp_maxmed_admin_medv_cmd,
1047 "bgp max-med administrative <0-4294967294>",
1048 BGP_STR
1049 "Advertise routes with max-med\n"
1050 "Administratively applied, for an indefinite period\n"
1051 "Max MED value to be used\n")
1052 {
1053 struct bgp *bgp;
1054
1055 bgp = vty->index;
1056
1057 bgp->v_maxmed_admin = 1;
1058 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[0]);
1059
1060 bgp_maxmed_update(bgp);
1061
1062 return CMD_SUCCESS;
1063 }
1064
1065 DEFUN (no_bgp_maxmed_admin,
1066 no_bgp_maxmed_admin_cmd,
1067 "no bgp max-med administrative",
1068 NO_STR
1069 BGP_STR
1070 "Advertise routes with max-med\n"
1071 "Administratively applied, for an indefinite period\n")
1072 {
1073 struct bgp *bgp;
1074
1075 bgp = vty->index;
1076
1077 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1078 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1079
1080 bgp_maxmed_update(bgp);
1081
1082 return CMD_SUCCESS;
1083 }
1084
1085 ALIAS (no_bgp_maxmed_admin,
1086 no_bgp_maxmed_admin_medv_cmd,
1087 "no bgp max-med administrative <0-4294967294>",
1088 NO_STR
1089 BGP_STR
1090 "Advertise routes with max-med\n"
1091 "Administratively applied, for an indefinite period\n"
1092 "Max MED value to be used\n")
1093
1094
1095 DEFUN (bgp_maxmed_onstartup,
1096 bgp_maxmed_onstartup_cmd,
1097 "bgp max-med on-startup <5-86400>",
1098 BGP_STR
1099 "Advertise routes with max-med\n"
1100 "Effective on a startup\n"
1101 "Time (seconds) period for max-med\n")
1102 {
1103 struct bgp *bgp;
1104
1105 bgp = vty->index;
1106
1107 if (argc != 1)
1108 {
1109 vty_out (vty, "%% Must supply max-med on-startup period");
1110 return CMD_WARNING;
1111 }
1112
1113 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1114 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1115
1116 bgp_maxmed_update(bgp);
1117
1118 return CMD_SUCCESS;
1119 }
1120
1121 DEFUN (bgp_maxmed_onstartup_medv,
1122 bgp_maxmed_onstartup_medv_cmd,
1123 "bgp max-med on-startup <5-86400> <0-4294967294>",
1124 BGP_STR
1125 "Advertise routes with max-med\n"
1126 "Effective on a startup\n"
1127 "Time (seconds) period for max-med\n"
1128 "Max MED value to be used\n")
1129 {
1130 struct bgp *bgp;
1131
1132 bgp = vty->index;
1133
1134 if (argc != 2)
1135 {
1136 vty_out (vty, "%% Must supply max-med on-startup period and med value");
1137 return CMD_WARNING;
1138 }
1139
1140 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[0]);
1141 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[1]);
1142
1143 bgp_maxmed_update(bgp);
1144
1145 return CMD_SUCCESS;
1146 }
1147
1148 DEFUN (no_bgp_maxmed_onstartup,
1149 no_bgp_maxmed_onstartup_cmd,
1150 "no bgp max-med on-startup",
1151 NO_STR
1152 BGP_STR
1153 "Advertise routes with max-med\n"
1154 "Effective on a startup\n")
1155 {
1156 struct bgp *bgp;
1157
1158 bgp = vty->index;
1159
1160 /* Cancel max-med onstartup if its on */
1161 if (bgp->t_maxmed_onstartup)
1162 {
1163 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1164 bgp->maxmed_onstartup_over = 1;
1165 }
1166
1167 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1168 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1169
1170 bgp_maxmed_update(bgp);
1171
1172 return CMD_SUCCESS;
1173 }
1174
1175 ALIAS (no_bgp_maxmed_onstartup,
1176 no_bgp_maxmed_onstartup_period_cmd,
1177 "no bgp max-med on-startup <5-86400>",
1178 NO_STR
1179 BGP_STR
1180 "Advertise routes with max-med\n"
1181 "Effective on a startup\n"
1182 "Time (seconds) period for max-med\n")
1183
1184 ALIAS (no_bgp_maxmed_onstartup,
1185 no_bgp_maxmed_onstartup_period_medv_cmd,
1186 "no bgp max-med on-startup <5-86400> <0-4294967294>",
1187 NO_STR
1188 BGP_STR
1189 "Advertise routes with max-med\n"
1190 "Effective on a startup\n"
1191 "Time (seconds) period for max-med\n"
1192 "Max MED value to be used\n")
1193
1194 static int
1195 bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1196 const char *wait)
1197 {
1198 struct bgp *bgp;
1199 u_int16_t update_delay;
1200 u_int16_t establish_wait;
1201
1202
1203 bgp = vty->index;
1204
1205 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1206 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1207
1208 if (!wait) /* update-delay <delay> */
1209 {
1210 bgp->v_update_delay = update_delay;
1211 bgp->v_establish_wait = bgp->v_update_delay;
1212 return CMD_SUCCESS;
1213 }
1214
1215 /* update-delay <delay> <establish-wait> */
1216 establish_wait = atoi (wait);
1217 if (update_delay < establish_wait)
1218 {
1219 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1220 VTY_NEWLINE);
1221 return CMD_WARNING;
1222 }
1223
1224 bgp->v_update_delay = update_delay;
1225 bgp->v_establish_wait = establish_wait;
1226
1227 return CMD_SUCCESS;
1228 }
1229
1230 static int
1231 bgp_update_delay_deconfig_vty (struct vty *vty)
1232 {
1233 struct bgp *bgp;
1234
1235 bgp = vty->index;
1236
1237 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1238 bgp->v_establish_wait = bgp->v_update_delay;
1239
1240 return CMD_SUCCESS;
1241 }
1242
1243 int
1244 bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1245 {
1246 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1247 {
1248 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1249 if (bgp->v_update_delay != bgp->v_establish_wait)
1250 vty_out (vty, " %d", bgp->v_establish_wait);
1251 vty_out (vty, "%s", VTY_NEWLINE);
1252 }
1253
1254 return 0;
1255 }
1256
1257
1258 /* Update-delay configuration */
1259 DEFUN (bgp_update_delay,
1260 bgp_update_delay_cmd,
1261 "update-delay <0-3600>",
1262 "Force initial delay for best-path and updates\n"
1263 "Seconds\n")
1264 {
1265 return bgp_update_delay_config_vty(vty, argv[0], NULL);
1266 }
1267
1268 DEFUN (bgp_update_delay_establish_wait,
1269 bgp_update_delay_establish_wait_cmd,
1270 "update-delay <0-3600> <1-3600>",
1271 "Force initial delay for best-path and updates\n"
1272 "Seconds\n"
1273 "Wait for peers to be established\n"
1274 "Seconds\n")
1275 {
1276 return bgp_update_delay_config_vty(vty, argv[0], argv[1]);
1277 }
1278
1279 /* Update-delay deconfiguration */
1280 DEFUN (no_bgp_update_delay,
1281 no_bgp_update_delay_cmd,
1282 "no update-delay <0-3600>",
1283 "Force initial delay for best-path and updates\n"
1284 "Seconds\n")
1285 {
1286 return bgp_update_delay_deconfig_vty(vty);
1287 }
1288
1289 ALIAS (no_bgp_update_delay,
1290 no_bgp_update_delay_establish_wait_cmd,
1291 "no update-delay <0-3600> <1-3600>",
1292 "Force initial delay for best-path and updates\n"
1293 "Seconds\n"
1294 "Wait for peers to be established\n"
1295 "Seconds\n")
1296
1297 static int
1298 bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
1299 {
1300 struct bgp *bgp;
1301
1302 bgp = vty->index;
1303
1304 if (set)
1305 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
1306 1, 10000);
1307 else
1308 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1309
1310 return CMD_SUCCESS;
1311 }
1312
1313 int
1314 bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1315 {
1316 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1317 vty_out (vty, " write-quanta %d%s",
1318 bgp->wpkt_quanta, VTY_NEWLINE);
1319
1320 return 0;
1321 }
1322
1323
1324 /* Update-delay configuration */
1325 DEFUN (bgp_wpkt_quanta,
1326 bgp_wpkt_quanta_cmd,
1327 "write-quanta <1-10000>",
1328 "How many packets to write to peer socket per run\n"
1329 "Number of packets\n")
1330 {
1331 return bgp_wpkt_quanta_config_vty(vty, argv[0], 1);
1332 }
1333
1334 /* Update-delay deconfiguration */
1335 DEFUN (no_bgp_wpkt_quanta,
1336 no_bgp_wpkt_quanta_cmd,
1337 "no write-quanta <1-10000>",
1338 "How many packets to write to peer socket per run\n"
1339 "Number of packets\n")
1340 {
1341 return bgp_wpkt_quanta_config_vty(vty, argv[0], 0);
1342 }
1343
1344 static int
1345 bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1346 {
1347 struct bgp *bgp;
1348
1349 bgp = vty->index;
1350
1351 if (set)
1352 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1353 0, 4294967295);
1354 else
1355 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1356
1357 return CMD_SUCCESS;
1358 }
1359
1360 int
1361 bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1362 {
1363 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1364 vty_out (vty, " coalesce-time %d%s",
1365 bgp->coalesce_time, VTY_NEWLINE);
1366
1367 return 0;
1368 }
1369
1370
1371 DEFUN (bgp_coalesce_time,
1372 bgp_coalesce_time_cmd,
1373 "coalesce-time <0-4294967295>",
1374 "Subgroup coalesce timer\n"
1375 "Subgroup coalesce timer value (in ms)\n")
1376 {
1377 return bgp_coalesce_config_vty(vty, argv[0], 1);
1378 }
1379
1380 DEFUN (no_bgp_coalesce_time,
1381 no_bgp_coalesce_time_cmd,
1382 "no coalesce-time <0-4294967295>",
1383 "Subgroup coalesce timer\n"
1384 "Subgroup coalesce timer value (in ms)\n")
1385 {
1386 return bgp_coalesce_config_vty(vty, argv[0], 0);
1387 }
1388
1389 /* Maximum-paths configuration */
1390 DEFUN (bgp_maxpaths,
1391 bgp_maxpaths_cmd,
1392 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
1393 "Forward packets over multiple paths\n"
1394 "Number of paths\n")
1395 {
1396 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[0], 0, 1);
1397 }
1398
1399 DEFUN (bgp_maxpaths_ibgp,
1400 bgp_maxpaths_ibgp_cmd,
1401 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
1402 "Forward packets over multiple paths\n"
1403 "iBGP-multipath\n"
1404 "Number of paths\n")
1405 {
1406 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0], 0, 1);
1407 }
1408
1409 DEFUN (bgp_maxpaths_ibgp_cluster,
1410 bgp_maxpaths_ibgp_cluster_cmd,
1411 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
1412 "Forward packets over multiple paths\n"
1413 "iBGP-multipath\n"
1414 "Number of paths\n"
1415 "Match the cluster length\n")
1416 {
1417 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[0],
1418 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
1419 }
1420
1421 DEFUN (no_bgp_maxpaths,
1422 no_bgp_maxpaths_cmd,
1423 "no maximum-paths",
1424 NO_STR
1425 "Forward packets over multiple paths\n"
1426 "Number of paths\n")
1427 {
1428 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
1429 }
1430
1431 ALIAS (no_bgp_maxpaths,
1432 no_bgp_maxpaths_arg_cmd,
1433 "no maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM),
1434 NO_STR
1435 "Forward packets over multiple paths\n"
1436 "Number of paths\n")
1437
1438 DEFUN (no_bgp_maxpaths_ibgp,
1439 no_bgp_maxpaths_ibgp_cmd,
1440 "no maximum-paths ibgp",
1441 NO_STR
1442 "Forward packets over multiple paths\n"
1443 "iBGP-multipath\n"
1444 "Number of paths\n")
1445 {
1446 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
1447 }
1448
1449 ALIAS (no_bgp_maxpaths_ibgp,
1450 no_bgp_maxpaths_ibgp_arg_cmd,
1451 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM),
1452 NO_STR
1453 "Forward packets over multiple paths\n"
1454 "iBGP-multipath\n"
1455 "Number of paths\n")
1456
1457 ALIAS (no_bgp_maxpaths_ibgp,
1458 no_bgp_maxpaths_ibgp_cluster_cmd,
1459 "no maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length",
1460 NO_STR
1461 "Forward packets over multiple paths\n"
1462 "iBGP-multipath\n"
1463 "Number of paths\n"
1464 "Match the cluster length\n")
1465
1466 int
1467 bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1468 safi_t safi, int *write)
1469 {
1470 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
1471 {
1472 bgp_config_write_family_header (vty, afi, safi, write);
1473 vty_out (vty, " maximum-paths %d%s",
1474 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1475 }
1476
1477 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
1478 {
1479 bgp_config_write_family_header (vty, afi, safi, write);
1480 vty_out (vty, " maximum-paths ibgp %d",
1481 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1482 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1483 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1484 vty_out (vty, " equal-cluster-length");
1485 vty_out (vty, "%s", VTY_NEWLINE);
1486 }
1487
1488 return 0;
1489 }
1490
1491 /* BGP timers. */
1492
1493 DEFUN (bgp_timers,
1494 bgp_timers_cmd,
1495 "timers bgp <0-65535> <0-65535>",
1496 "Adjust routing timers\n"
1497 "BGP timers\n"
1498 "Keepalive interval\n"
1499 "Holdtime\n")
1500 {
1501 struct bgp *bgp;
1502 unsigned long keepalive = 0;
1503 unsigned long holdtime = 0;
1504
1505 bgp = vty->index;
1506
1507 VTY_GET_INTEGER ("keepalive", keepalive, argv[0]);
1508 VTY_GET_INTEGER ("holdtime", holdtime, argv[1]);
1509
1510 /* Holdtime value check. */
1511 if (holdtime < 3 && holdtime != 0)
1512 {
1513 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1514 VTY_NEWLINE);
1515 return CMD_WARNING;
1516 }
1517
1518 bgp_timers_set (bgp, keepalive, holdtime);
1519
1520 return CMD_SUCCESS;
1521 }
1522
1523 DEFUN (no_bgp_timers,
1524 no_bgp_timers_cmd,
1525 "no timers bgp",
1526 NO_STR
1527 "Adjust routing timers\n"
1528 "BGP timers\n")
1529 {
1530 struct bgp *bgp;
1531
1532 bgp = vty->index;
1533 bgp_timers_unset (bgp);
1534
1535 return CMD_SUCCESS;
1536 }
1537
1538 ALIAS (no_bgp_timers,
1539 no_bgp_timers_arg_cmd,
1540 "no timers bgp <0-65535> <0-65535>",
1541 NO_STR
1542 "Adjust routing timers\n"
1543 "BGP timers\n"
1544 "Keepalive interval\n"
1545 "Holdtime\n")
1546
1547 DEFUN (bgp_client_to_client_reflection,
1548 bgp_client_to_client_reflection_cmd,
1549 "bgp client-to-client reflection",
1550 "BGP specific commands\n"
1551 "Configure client to client route reflection\n"
1552 "reflection of routes allowed\n")
1553 {
1554 struct bgp *bgp;
1555
1556 bgp = vty->index;
1557 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1558 bgp_clear_star_soft_out (vty);
1559
1560 return CMD_SUCCESS;
1561 }
1562
1563 DEFUN (no_bgp_client_to_client_reflection,
1564 no_bgp_client_to_client_reflection_cmd,
1565 "no bgp client-to-client reflection",
1566 NO_STR
1567 "BGP specific commands\n"
1568 "Configure client to client route reflection\n"
1569 "reflection of routes allowed\n")
1570 {
1571 struct bgp *bgp;
1572
1573 bgp = vty->index;
1574 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
1575 bgp_clear_star_soft_out (vty);
1576
1577 return CMD_SUCCESS;
1578 }
1579
1580 /* "bgp always-compare-med" configuration. */
1581 DEFUN (bgp_always_compare_med,
1582 bgp_always_compare_med_cmd,
1583 "bgp always-compare-med",
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_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1591 bgp_recalculate_all_bestpaths (bgp);
1592
1593 return CMD_SUCCESS;
1594 }
1595
1596 DEFUN (no_bgp_always_compare_med,
1597 no_bgp_always_compare_med_cmd,
1598 "no bgp always-compare-med",
1599 NO_STR
1600 "BGP specific commands\n"
1601 "Allow comparing MED from different neighbors\n")
1602 {
1603 struct bgp *bgp;
1604
1605 bgp = vty->index;
1606 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
1607 bgp_recalculate_all_bestpaths (bgp);
1608
1609 return CMD_SUCCESS;
1610 }
1611
1612 /* "bgp deterministic-med" configuration. */
1613 DEFUN (bgp_deterministic_med,
1614 bgp_deterministic_med_cmd,
1615 "bgp deterministic-med",
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
1623 if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1624 {
1625 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1626 bgp_recalculate_all_bestpaths (bgp);
1627 }
1628
1629 return CMD_SUCCESS;
1630 }
1631
1632 DEFUN (no_bgp_deterministic_med,
1633 no_bgp_deterministic_med_cmd,
1634 "no bgp deterministic-med",
1635 NO_STR
1636 "BGP specific commands\n"
1637 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1638 {
1639 struct bgp *bgp;
1640 int bestpath_per_as_used;
1641 afi_t afi;
1642 safi_t safi;
1643 struct peer *peer;
1644 struct listnode *node, *nnode;
1645
1646 bgp = vty->index;
1647
1648 if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1649 {
1650 bestpath_per_as_used = 0;
1651
1652 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1653 {
1654 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1655 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1656 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
1657 {
1658 bestpath_per_as_used = 1;
1659 break;
1660 }
1661
1662 if (bestpath_per_as_used)
1663 break;
1664 }
1665
1666 if (bestpath_per_as_used)
1667 {
1668 vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s",
1669 VTY_NEWLINE);
1670 return CMD_WARNING;
1671 }
1672 else
1673 {
1674 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1675 bgp_recalculate_all_bestpaths (bgp);
1676 }
1677 }
1678
1679 return CMD_SUCCESS;
1680 }
1681
1682 /* "bgp graceful-restart" configuration. */
1683 DEFUN (bgp_graceful_restart,
1684 bgp_graceful_restart_cmd,
1685 "bgp graceful-restart",
1686 "BGP specific commands\n"
1687 "Graceful restart capability parameters\n")
1688 {
1689 struct bgp *bgp;
1690
1691 bgp = vty->index;
1692 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1693 return CMD_SUCCESS;
1694 }
1695
1696 DEFUN (no_bgp_graceful_restart,
1697 no_bgp_graceful_restart_cmd,
1698 "no bgp graceful-restart",
1699 NO_STR
1700 "BGP specific commands\n"
1701 "Graceful restart capability parameters\n")
1702 {
1703 struct bgp *bgp;
1704
1705 bgp = vty->index;
1706 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1707 return CMD_SUCCESS;
1708 }
1709
1710 DEFUN (bgp_graceful_restart_stalepath_time,
1711 bgp_graceful_restart_stalepath_time_cmd,
1712 "bgp graceful-restart stalepath-time <1-3600>",
1713 "BGP specific commands\n"
1714 "Graceful restart capability parameters\n"
1715 "Set the max time to hold onto restarting peer's stale paths\n"
1716 "Delay value (seconds)\n")
1717 {
1718 struct bgp *bgp;
1719 u_int32_t stalepath;
1720
1721 bgp = vty->index;
1722 if (! bgp)
1723 return CMD_WARNING;
1724
1725 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600);
1726 bgp->stalepath_time = stalepath;
1727 return CMD_SUCCESS;
1728 }
1729
1730 DEFUN (no_bgp_graceful_restart_stalepath_time,
1731 no_bgp_graceful_restart_stalepath_time_cmd,
1732 "no bgp graceful-restart stalepath-time",
1733 NO_STR
1734 "BGP specific commands\n"
1735 "Graceful restart capability parameters\n"
1736 "Set the max time to hold onto restarting peer's stale paths\n")
1737 {
1738 struct bgp *bgp;
1739
1740 bgp = vty->index;
1741 if (! bgp)
1742 return CMD_WARNING;
1743
1744 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1745 return CMD_SUCCESS;
1746 }
1747
1748 ALIAS (no_bgp_graceful_restart_stalepath_time,
1749 no_bgp_graceful_restart_stalepath_time_val_cmd,
1750 "no bgp graceful-restart stalepath-time <1-3600>",
1751 NO_STR
1752 "BGP specific commands\n"
1753 "Graceful restart capability parameters\n"
1754 "Set the max time to hold onto restarting peer's stale paths\n"
1755 "Delay value (seconds)\n")
1756
1757 /* "bgp fast-external-failover" configuration. */
1758 DEFUN (bgp_fast_external_failover,
1759 bgp_fast_external_failover_cmd,
1760 "bgp fast-external-failover",
1761 BGP_STR
1762 "Immediately reset session if a link to a directly connected external peer goes down\n")
1763 {
1764 struct bgp *bgp;
1765
1766 bgp = vty->index;
1767 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1768 return CMD_SUCCESS;
1769 }
1770
1771 DEFUN (no_bgp_fast_external_failover,
1772 no_bgp_fast_external_failover_cmd,
1773 "no bgp fast-external-failover",
1774 NO_STR
1775 BGP_STR
1776 "Immediately reset session if a link to a directly connected external peer goes down\n")
1777 {
1778 struct bgp *bgp;
1779
1780 bgp = vty->index;
1781 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1782 return CMD_SUCCESS;
1783 }
1784
1785 /* "bgp enforce-first-as" configuration. */
1786 DEFUN (bgp_enforce_first_as,
1787 bgp_enforce_first_as_cmd,
1788 "bgp enforce-first-as",
1789 BGP_STR
1790 "Enforce the first AS for EBGP routes\n")
1791 {
1792 struct bgp *bgp;
1793
1794 bgp = vty->index;
1795 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1796 bgp_clear_star_soft_in (vty);
1797
1798 return CMD_SUCCESS;
1799 }
1800
1801 DEFUN (no_bgp_enforce_first_as,
1802 no_bgp_enforce_first_as_cmd,
1803 "no bgp enforce-first-as",
1804 NO_STR
1805 BGP_STR
1806 "Enforce the first AS for EBGP routes\n")
1807 {
1808 struct bgp *bgp;
1809
1810 bgp = vty->index;
1811 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
1812 bgp_clear_star_soft_in (vty);
1813
1814 return CMD_SUCCESS;
1815 }
1816
1817 /* "bgp bestpath compare-routerid" configuration. */
1818 DEFUN (bgp_bestpath_compare_router_id,
1819 bgp_bestpath_compare_router_id_cmd,
1820 "bgp bestpath compare-routerid",
1821 "BGP specific commands\n"
1822 "Change the default bestpath selection\n"
1823 "Compare router-id for identical EBGP paths\n")
1824 {
1825 struct bgp *bgp;
1826
1827 bgp = vty->index;
1828 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1829 bgp_recalculate_all_bestpaths (bgp);
1830
1831 return CMD_SUCCESS;
1832 }
1833
1834 DEFUN (no_bgp_bestpath_compare_router_id,
1835 no_bgp_bestpath_compare_router_id_cmd,
1836 "no bgp bestpath compare-routerid",
1837 NO_STR
1838 "BGP specific commands\n"
1839 "Change the default bestpath selection\n"
1840 "Compare router-id for identical EBGP paths\n")
1841 {
1842 struct bgp *bgp;
1843
1844 bgp = vty->index;
1845 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
1846 bgp_recalculate_all_bestpaths (bgp);
1847
1848 return CMD_SUCCESS;
1849 }
1850
1851 /* "bgp bestpath as-path ignore" configuration. */
1852 DEFUN (bgp_bestpath_aspath_ignore,
1853 bgp_bestpath_aspath_ignore_cmd,
1854 "bgp bestpath as-path ignore",
1855 "BGP specific commands\n"
1856 "Change the default bestpath selection\n"
1857 "AS-path attribute\n"
1858 "Ignore as-path length in selecting a route\n")
1859 {
1860 struct bgp *bgp;
1861
1862 bgp = vty->index;
1863 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
1864 bgp_recalculate_all_bestpaths (bgp);
1865
1866 return CMD_SUCCESS;
1867 }
1868
1869 DEFUN (no_bgp_bestpath_aspath_ignore,
1870 no_bgp_bestpath_aspath_ignore_cmd,
1871 "no bgp bestpath as-path ignore",
1872 NO_STR
1873 "BGP specific commands\n"
1874 "Change the default bestpath selection\n"
1875 "AS-path attribute\n"
1876 "Ignore as-path length in selecting a route\n")
1877 {
1878 struct bgp *bgp;
1879
1880 bgp = vty->index;
1881 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
1882 bgp_recalculate_all_bestpaths (bgp);
1883
1884 return CMD_SUCCESS;
1885 }
1886
1887 /* "bgp bestpath as-path confed" configuration. */
1888 DEFUN (bgp_bestpath_aspath_confed,
1889 bgp_bestpath_aspath_confed_cmd,
1890 "bgp bestpath as-path confed",
1891 "BGP specific commands\n"
1892 "Change the default bestpath selection\n"
1893 "AS-path attribute\n"
1894 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1895 {
1896 struct bgp *bgp;
1897
1898 bgp = vty->index;
1899 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
1900 bgp_recalculate_all_bestpaths (bgp);
1901
1902 return CMD_SUCCESS;
1903 }
1904
1905 DEFUN (no_bgp_bestpath_aspath_confed,
1906 no_bgp_bestpath_aspath_confed_cmd,
1907 "no bgp bestpath as-path confed",
1908 NO_STR
1909 "BGP specific commands\n"
1910 "Change the default bestpath selection\n"
1911 "AS-path attribute\n"
1912 "Compare path lengths including confederation sets & sequences in selecting a route\n")
1913 {
1914 struct bgp *bgp;
1915
1916 bgp = vty->index;
1917 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
1918 bgp_recalculate_all_bestpaths (bgp);
1919
1920 return CMD_SUCCESS;
1921 }
1922
1923 /* "bgp bestpath as-path multipath-relax" configuration. */
1924 DEFUN (bgp_bestpath_aspath_multipath_relax,
1925 bgp_bestpath_aspath_multipath_relax_cmd,
1926 "bgp bestpath as-path multipath-relax {as-set|no-as-set}",
1927 "BGP specific commands\n"
1928 "Change the default bestpath selection\n"
1929 "AS-path attribute\n"
1930 "Allow load sharing across routes that have different AS paths (but same length)\n"
1931 "Generate an AS_SET\n"
1932 "Do not generate an AS_SET\n")
1933 {
1934 struct bgp *bgp;
1935
1936 bgp = vty->index;
1937 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1938
1939 /* no-as-set is now the default behavior so we can silently
1940 * ignore it */
1941 if (argv[0] != NULL && strncmp (argv[0], "a", 1) == 0)
1942 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
1943 else
1944 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ;
1945
1946 bgp_recalculate_all_bestpaths (bgp);
1947
1948 return CMD_SUCCESS;
1949 }
1950
1951 DEFUN (no_bgp_bestpath_aspath_multipath_relax,
1952 no_bgp_bestpath_aspath_multipath_relax_cmd,
1953 "no bgp bestpath as-path multipath-relax {as-set|no-as-set}",
1954 NO_STR
1955 "BGP specific commands\n"
1956 "Change the default bestpath selection\n"
1957 "AS-path attribute\n"
1958 "Allow load sharing across routes that have different AS paths (but same length)\n"
1959 "Generate an AS_SET\n"
1960 "Do not generate an AS_SET\n")
1961 {
1962 struct bgp *bgp;
1963
1964 bgp = vty->index;
1965 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
1966 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
1967 bgp_recalculate_all_bestpaths (bgp);
1968
1969 return CMD_SUCCESS;
1970 }
1971
1972 /* "bgp log-neighbor-changes" configuration. */
1973 DEFUN (bgp_log_neighbor_changes,
1974 bgp_log_neighbor_changes_cmd,
1975 "bgp log-neighbor-changes",
1976 "BGP specific commands\n"
1977 "Log neighbor up/down and reset reason\n")
1978 {
1979 struct bgp *bgp;
1980
1981 bgp = vty->index;
1982 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1983 return CMD_SUCCESS;
1984 }
1985
1986 DEFUN (no_bgp_log_neighbor_changes,
1987 no_bgp_log_neighbor_changes_cmd,
1988 "no bgp log-neighbor-changes",
1989 NO_STR
1990 "BGP specific commands\n"
1991 "Log neighbor up/down and reset reason\n")
1992 {
1993 struct bgp *bgp;
1994
1995 bgp = vty->index;
1996 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
1997 return CMD_SUCCESS;
1998 }
1999
2000 /* "bgp bestpath med" configuration. */
2001 DEFUN (bgp_bestpath_med,
2002 bgp_bestpath_med_cmd,
2003 "bgp bestpath med (confed|missing-as-worst)",
2004 "BGP specific commands\n"
2005 "Change the default bestpath selection\n"
2006 "MED attribute\n"
2007 "Compare MED among confederation paths\n"
2008 "Treat missing MED as the least preferred one\n")
2009 {
2010 struct bgp *bgp;
2011
2012 bgp = vty->index;
2013
2014 if (strncmp (argv[0], "confed", 1) == 0)
2015 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2016 else
2017 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2018
2019 bgp_recalculate_all_bestpaths (bgp);
2020
2021 return CMD_SUCCESS;
2022 }
2023
2024 DEFUN (bgp_bestpath_med2,
2025 bgp_bestpath_med2_cmd,
2026 "bgp bestpath med confed missing-as-worst",
2027 "BGP specific commands\n"
2028 "Change the default bestpath selection\n"
2029 "MED attribute\n"
2030 "Compare MED among confederation paths\n"
2031 "Treat missing MED as the least preferred one\n")
2032 {
2033 struct bgp *bgp;
2034
2035 bgp = vty->index;
2036 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2037 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2038 bgp_recalculate_all_bestpaths (bgp);
2039
2040 return CMD_SUCCESS;
2041 }
2042
2043 ALIAS (bgp_bestpath_med2,
2044 bgp_bestpath_med3_cmd,
2045 "bgp bestpath med missing-as-worst confed",
2046 "BGP specific commands\n"
2047 "Change the default bestpath selection\n"
2048 "MED attribute\n"
2049 "Treat missing MED as the least preferred one\n"
2050 "Compare MED among confederation paths\n")
2051
2052 DEFUN (no_bgp_bestpath_med,
2053 no_bgp_bestpath_med_cmd,
2054 "no bgp bestpath med (confed|missing-as-worst)",
2055 NO_STR
2056 "BGP specific commands\n"
2057 "Change the default bestpath selection\n"
2058 "MED attribute\n"
2059 "Compare MED among confederation paths\n"
2060 "Treat missing MED as the least preferred one\n")
2061 {
2062 struct bgp *bgp;
2063
2064 bgp = vty->index;
2065
2066 if (strncmp (argv[0], "confed", 1) == 0)
2067 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2068 else
2069 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2070
2071 bgp_recalculate_all_bestpaths (bgp);
2072
2073 return CMD_SUCCESS;
2074 }
2075
2076 DEFUN (no_bgp_bestpath_med2,
2077 no_bgp_bestpath_med2_cmd,
2078 "no bgp bestpath med confed missing-as-worst",
2079 NO_STR
2080 "BGP specific commands\n"
2081 "Change the default bestpath selection\n"
2082 "MED attribute\n"
2083 "Compare MED among confederation paths\n"
2084 "Treat missing MED as the least preferred one\n")
2085 {
2086 struct bgp *bgp;
2087
2088 bgp = vty->index;
2089 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
2090 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2091 bgp_recalculate_all_bestpaths (bgp);
2092
2093 return CMD_SUCCESS;
2094 }
2095
2096 ALIAS (no_bgp_bestpath_med2,
2097 no_bgp_bestpath_med3_cmd,
2098 "no bgp bestpath med missing-as-worst confed",
2099 NO_STR
2100 "BGP specific commands\n"
2101 "Change the default bestpath selection\n"
2102 "MED attribute\n"
2103 "Treat missing MED as the least preferred one\n"
2104 "Compare MED among confederation paths\n")
2105
2106 /* "no bgp default ipv4-unicast". */
2107 DEFUN (no_bgp_default_ipv4_unicast,
2108 no_bgp_default_ipv4_unicast_cmd,
2109 "no bgp default ipv4-unicast",
2110 NO_STR
2111 "BGP specific commands\n"
2112 "Configure BGP defaults\n"
2113 "Activate ipv4-unicast for a peer by default\n")
2114 {
2115 struct bgp *bgp;
2116
2117 bgp = vty->index;
2118 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2119 return CMD_SUCCESS;
2120 }
2121
2122 DEFUN (bgp_default_ipv4_unicast,
2123 bgp_default_ipv4_unicast_cmd,
2124 "bgp default ipv4-unicast",
2125 "BGP specific commands\n"
2126 "Configure BGP defaults\n"
2127 "Activate ipv4-unicast for a peer by default\n")
2128 {
2129 struct bgp *bgp;
2130
2131 bgp = vty->index;
2132 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2133 return CMD_SUCCESS;
2134 }
2135
2136 /* Display hostname in certain command outputs */
2137 DEFUN (bgp_default_show_hostname,
2138 bgp_default_show_hostname_cmd,
2139 "bgp default show-hostname",
2140 "BGP specific commands\n"
2141 "Configure BGP defaults\n"
2142 "Show hostname in certain command ouputs\n")
2143 {
2144 struct bgp *bgp;
2145
2146 bgp = vty->index;
2147 bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
2148 return CMD_SUCCESS;
2149 }
2150
2151 DEFUN (no_bgp_default_show_hostname,
2152 no_bgp_default_show_hostname_cmd,
2153 "no bgp default show-hostname",
2154 NO_STR
2155 "BGP specific commands\n"
2156 "Configure BGP defaults\n"
2157 "Show hostname in certain command ouputs\n")
2158 {
2159 struct bgp *bgp;
2160
2161 bgp = vty->index;
2162 bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
2163 return CMD_SUCCESS;
2164 }
2165
2166 /* "bgp import-check" configuration. */
2167 DEFUN (bgp_network_import_check,
2168 bgp_network_import_check_cmd,
2169 "bgp network import-check",
2170 "BGP specific commands\n"
2171 "BGP network command\n"
2172 "Check BGP network route exists in IGP\n")
2173 {
2174 struct bgp *bgp;
2175
2176 bgp = vty->index;
2177 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2178 {
2179 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
2180 bgp_static_redo_import_check(bgp);
2181 }
2182
2183 return CMD_SUCCESS;
2184 }
2185
2186 DEFUN (no_bgp_network_import_check,
2187 no_bgp_network_import_check_cmd,
2188 "no bgp network import-check",
2189 NO_STR
2190 "BGP specific commands\n"
2191 "BGP network command\n"
2192 "Check BGP network route exists in IGP\n")
2193 {
2194 struct bgp *bgp;
2195
2196 bgp = vty->index;
2197 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2198 {
2199 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
2200 bgp_static_redo_import_check(bgp);
2201 }
2202
2203 return CMD_SUCCESS;
2204 }
2205
2206 DEFUN (bgp_default_local_preference,
2207 bgp_default_local_preference_cmd,
2208 "bgp default local-preference <0-4294967295>",
2209 "BGP specific commands\n"
2210 "Configure BGP defaults\n"
2211 "local preference (higher=more preferred)\n"
2212 "Configure default local preference value\n")
2213 {
2214 struct bgp *bgp;
2215 u_int32_t local_pref;
2216
2217 bgp = vty->index;
2218
2219 VTY_GET_INTEGER ("local preference", local_pref, argv[0]);
2220
2221 bgp_default_local_preference_set (bgp, local_pref);
2222 bgp_clear_star_soft_in (vty);
2223
2224 return CMD_SUCCESS;
2225 }
2226
2227 DEFUN (no_bgp_default_local_preference,
2228 no_bgp_default_local_preference_cmd,
2229 "no bgp default local-preference",
2230 NO_STR
2231 "BGP specific commands\n"
2232 "Configure BGP defaults\n"
2233 "local preference (higher=more preferred)\n")
2234 {
2235 struct bgp *bgp;
2236
2237 bgp = vty->index;
2238 bgp_default_local_preference_unset (bgp);
2239 bgp_clear_star_soft_in (vty);
2240
2241 return CMD_SUCCESS;
2242 }
2243
2244 ALIAS (no_bgp_default_local_preference,
2245 no_bgp_default_local_preference_val_cmd,
2246 "no bgp default local-preference <0-4294967295>",
2247 NO_STR
2248 "BGP specific commands\n"
2249 "Configure BGP defaults\n"
2250 "local preference (higher=more preferred)\n"
2251 "Configure default local preference value\n")
2252
2253 DEFUN (bgp_default_subgroup_pkt_queue_max,
2254 bgp_default_subgroup_pkt_queue_max_cmd,
2255 "bgp default subgroup-pkt-queue-max <20-100>",
2256 "BGP specific commands\n"
2257 "Configure BGP defaults\n"
2258 "subgroup-pkt-queue-max\n"
2259 "Configure subgroup packet queue max\n")
2260 {
2261 struct bgp *bgp;
2262 u_int32_t max_size;
2263
2264 bgp = vty->index;
2265
2266 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[0]);
2267
2268 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2269
2270 return CMD_SUCCESS;
2271 }
2272
2273 DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2274 no_bgp_default_subgroup_pkt_queue_max_cmd,
2275 "no bgp default subgroup-pkt-queue-max",
2276 NO_STR
2277 "BGP specific commands\n"
2278 "Configure BGP defaults\n"
2279 "subgroup-pkt-queue-max\n")
2280 {
2281 struct bgp *bgp;
2282
2283 bgp = vty->index;
2284 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2285 return CMD_SUCCESS;
2286 }
2287
2288 ALIAS (no_bgp_default_subgroup_pkt_queue_max,
2289 no_bgp_default_subgroup_pkt_queue_max_val_cmd,
2290 "no bgp default subgroup-pkt-queue-max <20-100>",
2291 NO_STR
2292 "BGP specific commands\n"
2293 "Configure BGP defaults\n"
2294 "subgroup-pkt-queue-max\n"
2295 "Configure subgroup packet queue max\n")
2296
2297 DEFUN (bgp_rr_allow_outbound_policy,
2298 bgp_rr_allow_outbound_policy_cmd,
2299 "bgp route-reflector allow-outbound-policy",
2300 "BGP specific commands\n"
2301 "Allow modifications made by out route-map\n"
2302 "on ibgp neighbors\n")
2303 {
2304 struct bgp *bgp;
2305
2306 bgp = vty->index;
2307
2308 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2309 {
2310 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
2311 update_group_announce_rrclients(bgp);
2312 bgp_clear_star_soft_out (vty);
2313 }
2314
2315 return CMD_SUCCESS;
2316 }
2317
2318 DEFUN (no_bgp_rr_allow_outbound_policy,
2319 no_bgp_rr_allow_outbound_policy_cmd,
2320 "no bgp route-reflector allow-outbound-policy",
2321 NO_STR
2322 "BGP specific commands\n"
2323 "Allow modifications made by out route-map\n"
2324 "on ibgp neighbors\n")
2325 {
2326 struct bgp *bgp;
2327
2328 bgp = vty->index;
2329
2330 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2331 {
2332 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
2333 update_group_announce_rrclients(bgp);
2334 bgp_clear_star_soft_out (vty);
2335 }
2336
2337 return CMD_SUCCESS;
2338 }
2339
2340 DEFUN (bgp_listen_limit,
2341 bgp_listen_limit_cmd,
2342 "bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2343 "BGP specific commands\n"
2344 "Configure BGP defaults\n"
2345 "maximum number of BGP Dynamic Neighbors that can be created\n"
2346 "Configure Dynamic Neighbors listen limit value\n")
2347 {
2348 struct bgp *bgp;
2349 int listen_limit;
2350
2351 bgp = vty->index;
2352
2353 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[0],
2354 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2355 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2356
2357 bgp_listen_limit_set (bgp, listen_limit);
2358
2359 return CMD_SUCCESS;
2360 }
2361
2362 DEFUN (no_bgp_listen_limit,
2363 no_bgp_listen_limit_cmd,
2364 "no bgp listen limit",
2365 "BGP specific commands\n"
2366 "Configure BGP defaults\n"
2367 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2368 "Configure Dynamic Neighbors listen limit value to default\n")
2369 {
2370 struct bgp *bgp;
2371
2372 bgp = vty->index;
2373 bgp_listen_limit_unset (bgp);
2374 return CMD_SUCCESS;
2375 }
2376
2377 ALIAS (no_bgp_listen_limit,
2378 no_bgp_listen_limit_val_cmd,
2379 "no bgp listen limit " DYNAMIC_NEIGHBOR_LIMIT_RANGE,
2380 NO_STR
2381 "BGP specific commands\n"
2382 "Configure BGP defaults\n"
2383 "maximum number of BGP Dynamic Neighbors that can be created\n"
2384 "Configure Dynamic Neighbors listen limit value\n")
2385
2386 /*
2387 * Check if this listen range is already configured. Check for exact
2388 * match or overlap based on input.
2389 */
2390 static struct peer_group *
2391 listen_range_exists (struct bgp *bgp, struct prefix *range, int exact)
2392 {
2393 struct listnode *node, *nnode;
2394 struct listnode *node1, *nnode1;
2395 struct peer_group *group;
2396 struct prefix *lr;
2397 afi_t afi;
2398 int match;
2399
2400 afi = family2afi(range->family);
2401 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2402 {
2403 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1,
2404 nnode1, lr))
2405 {
2406 if (exact)
2407 match = prefix_same (range, lr);
2408 else
2409 match = (prefix_match (range, lr) || prefix_match (lr, range));
2410 if (match)
2411 return group;
2412 }
2413 }
2414
2415 return NULL;
2416 }
2417
2418 DEFUN (bgp_listen_range,
2419 bgp_listen_range_cmd,
2420 LISTEN_RANGE_CMD "peer-group WORD" ,
2421 "BGP specific commands\n"
2422 "Configure BGP Dynamic Neighbors\n"
2423 "add a listening range for Dynamic Neighbors\n"
2424 LISTEN_RANGE_ADDR_STR)
2425 {
2426 struct bgp *bgp;
2427 struct prefix range;
2428 struct peer_group *group, *existing_group;
2429 afi_t afi;
2430 int ret;
2431
2432 bgp = vty->index;
2433
2434 //VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2435
2436 /* Convert IP prefix string to struct prefix. */
2437 ret = str2prefix (argv[0], &range);
2438 if (! ret)
2439 {
2440 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2441 return CMD_WARNING;
2442 }
2443
2444 afi = family2afi(range.family);
2445
2446 #ifdef HAVE_IPV6
2447 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2448 {
2449 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2450 VTY_NEWLINE);
2451 return CMD_WARNING;
2452 }
2453 #endif /* HAVE_IPV6 */
2454
2455 apply_mask (&range);
2456
2457 /* Check if same listen range is already configured. */
2458 existing_group = listen_range_exists (bgp, &range, 1);
2459 if (existing_group)
2460 {
2461 if (strcmp (existing_group->name, argv[1]) == 0)
2462 return CMD_SUCCESS;
2463 else
2464 {
2465 vty_out (vty, "%% Same listen range is attached to peer-group %s%s",
2466 existing_group->name, VTY_NEWLINE);
2467 return CMD_WARNING;
2468 }
2469 }
2470
2471 /* Check if an overlapping listen range exists. */
2472 if (listen_range_exists (bgp, &range, 0))
2473 {
2474 vty_out (vty, "%% Listen range overlaps with existing listen range%s",
2475 VTY_NEWLINE);
2476 return CMD_WARNING;
2477 }
2478
2479 group = peer_group_lookup (bgp, argv[1]);
2480 if (! group)
2481 {
2482 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2483 return CMD_WARNING;
2484 }
2485
2486 ret = peer_group_listen_range_add(group, &range);
2487 return bgp_vty_return (vty, ret);
2488 }
2489
2490 DEFUN (no_bgp_listen_range,
2491 no_bgp_listen_range_cmd,
2492 "no bgp listen range A.B.C.D/M peer-group WORD" ,
2493 "BGP specific commands\n"
2494 "Configure BGP defaults\n"
2495 "delete a listening range for Dynamic Neighbors\n"
2496 "Remove Dynamic Neighbors listening range\n")
2497 {
2498 struct bgp *bgp;
2499 struct prefix range;
2500 struct peer_group *group;
2501 afi_t afi;
2502 int ret;
2503
2504 bgp = vty->index;
2505
2506 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[0]);
2507
2508 /* Convert IP prefix string to struct prefix. */
2509 ret = str2prefix (argv[0], &range);
2510 if (! ret)
2511 {
2512 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2513 return CMD_WARNING;
2514 }
2515
2516 afi = family2afi(range.family);
2517
2518 #ifdef HAVE_IPV6
2519 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2520 {
2521 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2522 VTY_NEWLINE);
2523 return CMD_WARNING;
2524 }
2525 #endif /* HAVE_IPV6 */
2526
2527 apply_mask (&range);
2528
2529
2530 group = peer_group_lookup (bgp, argv[1]);
2531 if (! group)
2532 {
2533 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2534 return CMD_WARNING;
2535 }
2536
2537 ret = peer_group_listen_range_del(group, &range);
2538 return bgp_vty_return (vty, ret);
2539 }
2540
2541 int
2542 bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2543 {
2544 struct peer_group *group;
2545 struct listnode *node, *nnode, *rnode, *nrnode;
2546 struct prefix *range;
2547 afi_t afi;
2548 char buf[PREFIX2STR_BUFFER];
2549
2550 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2551 vty_out (vty, " bgp listen limit %d%s",
2552 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2553
2554 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2555 {
2556 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2557 {
2558 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2559 {
2560 prefix2str(range, buf, sizeof(buf));
2561 vty_out(vty, " bgp listen range %s peer-group %s%s",
2562 buf, group->name, VTY_NEWLINE);
2563 }
2564 }
2565 }
2566
2567 return 0;
2568 }
2569
2570
2571 DEFUN (bgp_disable_connected_route_check,
2572 bgp_disable_connected_route_check_cmd,
2573 "bgp disable-ebgp-connected-route-check",
2574 "BGP specific commands\n"
2575 "Disable checking if nexthop is connected on ebgp sessions\n")
2576 {
2577 struct bgp *bgp;
2578
2579 bgp = vty->index;
2580 bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
2581 bgp_clear_star_soft_in (vty);
2582
2583 return CMD_SUCCESS;
2584 }
2585
2586 DEFUN (no_bgp_disable_connected_route_check,
2587 no_bgp_disable_connected_route_check_cmd,
2588 "no bgp disable-ebgp-connected-route-check",
2589 NO_STR
2590 "BGP specific commands\n"
2591 "Disable checking if nexthop is connected on ebgp sessions\n")
2592 {
2593 struct bgp *bgp;
2594
2595 bgp = vty->index;
2596 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
2597 bgp_clear_star_soft_in (vty);
2598
2599 return CMD_SUCCESS;
2600 }
2601
2602
2603 static int
2604 peer_remote_as_vty (struct vty *vty, const char *peer_str,
2605 const char *as_str, afi_t afi, safi_t safi)
2606 {
2607 int ret;
2608 struct bgp *bgp;
2609 as_t as;
2610 int as_type = AS_SPECIFIED;
2611 union sockunion su;
2612
2613 bgp = vty->index;
2614
2615 if (strncmp(as_str, "internal", strlen("internal")) == 0)
2616 {
2617 as = 0;
2618 as_type = AS_INTERNAL;
2619 }
2620 else if (strncmp(as_str, "external", strlen("external")) == 0)
2621 {
2622 as = 0;
2623 as_type = AS_EXTERNAL;
2624 }
2625 else
2626 {
2627 /* Get AS number. */
2628 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2629 }
2630
2631 /* If peer is peer group, call proper function. */
2632 ret = str2sockunion (peer_str, &su);
2633 if (ret < 0)
2634 {
2635 /* Check for peer by interface */
2636 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
2637 if (ret < 0)
2638 {
2639 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
2640 if (ret < 0)
2641 {
2642 vty_out (vty, "%% Create the peer-group or interface first%s",
2643 VTY_NEWLINE);
2644 return CMD_WARNING;
2645 }
2646 return CMD_SUCCESS;
2647 }
2648 }
2649 else
2650 {
2651 if (peer_address_self_check (bgp, &su))
2652 {
2653 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2654 VTY_NEWLINE);
2655 return CMD_WARNING;
2656 }
2657 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
2658 }
2659
2660 /* This peer belongs to peer group. */
2661 switch (ret)
2662 {
2663 case BGP_ERR_PEER_GROUP_MEMBER:
2664 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
2665 return CMD_WARNING;
2666 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
2667 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);
2668 return CMD_WARNING;
2669 }
2670 return bgp_vty_return (vty, ret);
2671 }
2672
2673 DEFUN (neighbor_remote_as,
2674 neighbor_remote_as_cmd,
2675 NEIGHBOR_CMD2 "remote-as (" CMD_AS_RANGE "|external|internal)",
2676 NEIGHBOR_STR
2677 NEIGHBOR_ADDR_STR2
2678 "Specify a BGP neighbor\n"
2679 AS_STR)
2680 {
2681 return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
2682 }
2683
2684 static int
2685 peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
2686 safi_t safi, int v6only, const char *peer_group_name)
2687 {
2688 as_t as;
2689 struct bgp *bgp;
2690 struct peer *peer;
2691 struct peer_group *group;
2692 int ret = 0;
2693 union sockunion su;
2694
2695 bgp = vty->index;
2696 group = peer_group_lookup (bgp, conf_if);
2697
2698 if (group)
2699 {
2700 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2701 return CMD_WARNING;
2702 }
2703
2704 peer = peer_lookup_by_conf_if (bgp, conf_if);
2705 if (!peer)
2706 {
2707 if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
2708 && afi == AFI_IP && safi == SAFI_UNICAST)
2709 peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, 0, 0, NULL);
2710 else
2711 peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, afi, safi, NULL);
2712
2713 if (peer && v6only)
2714 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2715 }
2716 else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) ||
2717 (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)))
2718 {
2719 if (v6only)
2720 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2721 else
2722 UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2723
2724 /* v6only flag changed. Reset bgp seesion */
2725 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
2726 {
2727 peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
2728 bgp_notify_send (peer, BGP_NOTIFY_CEASE,
2729 BGP_NOTIFY_CEASE_CONFIG_CHANGE);
2730 }
2731 else
2732 bgp_session_reset(peer);
2733 }
2734
2735 if (!peer)
2736 return CMD_WARNING;
2737
2738 if (peer_group_name)
2739 {
2740 group = peer_group_lookup (bgp, peer_group_name);
2741 if (! group)
2742 {
2743 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2744 return CMD_WARNING;
2745 }
2746
2747 ret = peer_group_bind (bgp, &su, peer, group, &as);
2748 }
2749
2750 return bgp_vty_return (vty, ret);
2751 }
2752
2753 DEFUN (neighbor_interface_config,
2754 neighbor_interface_config_cmd,
2755 "neighbor WORD interface",
2756 NEIGHBOR_STR
2757 "Interface name or neighbor tag\n"
2758 "Enable BGP on interface\n")
2759 {
2760 if (argc == 2)
2761 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, argv[1]);
2762 else
2763 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 0, NULL);
2764 }
2765
2766 ALIAS (neighbor_interface_config,
2767 neighbor_interface_config_peergroup_cmd,
2768 "neighbor WORD interface peer-group WORD",
2769 NEIGHBOR_STR
2770 "Interface name or neighbor tag\n"
2771 "Enable BGP on interface\n"
2772 "Member of the peer-group\n"
2773 "peer-group name\n")
2774
2775 DEFUN (neighbor_interface_config_v6only,
2776 neighbor_interface_config_v6only_cmd,
2777 "neighbor WORD interface v6only",
2778 NEIGHBOR_STR
2779 "Interface name or neighbor tag\n"
2780 "Enable BGP on interface\n"
2781 "Enable BGP with v6 link-local only\n")
2782 {
2783 if (argc == 2)
2784 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, argv[1]);
2785 else
2786 return peer_conf_interface_get (vty, argv[0], AFI_IP, SAFI_UNICAST, 1, NULL);
2787 }
2788
2789 ALIAS (neighbor_interface_config_v6only,
2790 neighbor_interface_config_v6only_peergroup_cmd,
2791 "neighbor WORD interface v6only peer-group WORD",
2792 NEIGHBOR_STR
2793 "Interface name or neighbor tag\n"
2794 "Enable BGP on interface\n"
2795 "Enable BGP with v6 link-local only\n"
2796 "Member of the peer-group\n"
2797 "peer-group name\n")
2798
2799 DEFUN (neighbor_peer_group,
2800 neighbor_peer_group_cmd,
2801 "neighbor WORD peer-group",
2802 NEIGHBOR_STR
2803 "Interface name or neighbor tag\n"
2804 "Configure peer-group\n")
2805 {
2806 struct bgp *bgp;
2807 struct peer *peer;
2808 struct peer_group *group;
2809
2810 bgp = vty->index;
2811 peer = peer_lookup_by_conf_if (bgp, argv[0]);
2812 if (peer)
2813 {
2814 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2815 return CMD_WARNING;
2816 }
2817
2818 group = peer_group_get (bgp, argv[0]);
2819 if (! group)
2820 return CMD_WARNING;
2821
2822 return CMD_SUCCESS;
2823 }
2824
2825 DEFUN (no_neighbor,
2826 no_neighbor_cmd,
2827 NO_NEIGHBOR_CMD2,
2828 NO_STR
2829 NEIGHBOR_STR
2830 NEIGHBOR_ADDR_STR2)
2831 {
2832 int ret;
2833 union sockunion su;
2834 struct peer_group *group;
2835 struct peer *peer;
2836 struct peer *other;
2837
2838 ret = str2sockunion (argv[0], &su);
2839 if (ret < 0)
2840 {
2841 /* look up for neighbor by interface name config. */
2842 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2843 if (peer)
2844 {
2845 peer_delete (peer);
2846 return CMD_SUCCESS;
2847 }
2848
2849 group = peer_group_lookup (vty->index, argv[0]);
2850 if (group)
2851 peer_group_delete (group);
2852 else
2853 {
2854 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2855 return CMD_WARNING;
2856 }
2857 }
2858 else
2859 {
2860 peer = peer_lookup (vty->index, &su);
2861 if (peer)
2862 {
2863 if (peer_dynamic_neighbor (peer))
2864 {
2865 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
2866 VTY_NEWLINE);
2867 return CMD_WARNING;
2868 }
2869
2870 other = peer->doppelganger;
2871 peer_delete (peer);
2872 if (other && other->status != Deleted)
2873 peer_delete(other);
2874 }
2875 }
2876
2877 return CMD_SUCCESS;
2878 }
2879
2880 ALIAS (no_neighbor,
2881 no_neighbor_remote_as_cmd,
2882 NO_NEIGHBOR_CMD "remote-as (" CMD_AS_RANGE "|internal|external)",
2883 NO_STR
2884 NEIGHBOR_STR
2885 NEIGHBOR_ADDR_STR
2886 "Specify a BGP neighbor\n"
2887 AS_STR)
2888
2889 DEFUN (no_neighbor_interface_config,
2890 no_neighbor_interface_config_cmd,
2891 "no neighbor WORD interface",
2892 NO_STR
2893 NEIGHBOR_STR
2894 "Interface name\n"
2895 "Configure BGP on interface\n")
2896 {
2897 struct peer *peer;
2898
2899 /* look up for neighbor by interface name config. */
2900 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2901 if (peer)
2902 {
2903 peer_delete (peer);
2904 }
2905 else
2906 {
2907 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
2908 return CMD_WARNING;
2909 }
2910 return CMD_SUCCESS;
2911 }
2912
2913 ALIAS (no_neighbor_interface_config,
2914 no_neighbor_interface_config_peergroup_cmd,
2915 "no neighbor WORD interface peer-group WORD",
2916 NO_STR
2917 NEIGHBOR_STR
2918 "Interface name\n"
2919 "Configure BGP on interface\n"
2920 "Member of the peer-group\n"
2921 "peer-group name\n")
2922
2923 ALIAS (no_neighbor_interface_config,
2924 no_neighbor_interface_config_v6only_cmd,
2925 "no neighbor WORD interface v6only",
2926 NO_STR
2927 NEIGHBOR_STR
2928 "Interface name\n"
2929 "Configure BGP on interface\n"
2930 "Enable BGP with v6 link-local only\n")
2931
2932 ALIAS (no_neighbor_interface_config,
2933 no_neighbor_interface_config_v6only_peergroup_cmd,
2934 "no neighbor WORD interface v6only peer-group WORD",
2935 NO_STR
2936 NEIGHBOR_STR
2937 "Interface name\n"
2938 "Configure BGP on interface\n"
2939 "Enable BGP with v6 link-local only\n"
2940 "Member of the peer-group\n"
2941 "peer-group name\n")
2942
2943
2944 DEFUN (no_neighbor_peer_group,
2945 no_neighbor_peer_group_cmd,
2946 "no neighbor WORD peer-group",
2947 NO_STR
2948 NEIGHBOR_STR
2949 "Neighbor tag\n"
2950 "Configure peer-group\n")
2951 {
2952 struct peer_group *group;
2953
2954 group = peer_group_lookup (vty->index, argv[0]);
2955 if (group)
2956 peer_group_delete (group);
2957 else
2958 {
2959 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
2960 return CMD_WARNING;
2961 }
2962 return CMD_SUCCESS;
2963 }
2964
2965 DEFUN (no_neighbor_interface_peer_group_remote_as,
2966 no_neighbor_interface_peer_group_remote_as_cmd,
2967 "no neighbor WORD remote-as (" CMD_AS_RANGE "|internal|external)",
2968 NO_STR
2969 NEIGHBOR_STR
2970 "Interface name or neighbor tag\n"
2971 "Specify a BGP neighbor\n"
2972 AS_STR)
2973 {
2974 struct peer_group *group;
2975 struct peer *peer;
2976
2977 /* look up for neighbor by interface name config. */
2978 peer = peer_lookup_by_conf_if (vty->index, argv[0]);
2979 if (peer)
2980 {
2981 peer_as_change (peer, 0, AS_SPECIFIED);
2982 return CMD_SUCCESS;
2983 }
2984
2985 group = peer_group_lookup (vty->index, argv[0]);
2986 if (group)
2987 peer_group_remote_as_delete (group);
2988 else
2989 {
2990 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
2991 return CMD_WARNING;
2992 }
2993 return CMD_SUCCESS;
2994 }
2995
2996 DEFUN (neighbor_local_as,
2997 neighbor_local_as_cmd,
2998 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
2999 NEIGHBOR_STR
3000 NEIGHBOR_ADDR_STR2
3001 "Specify a local-as number\n"
3002 "AS number used as local AS\n")
3003 {
3004 struct peer *peer;
3005 int ret;
3006
3007 peer = peer_and_group_lookup_vty (vty, argv[0]);
3008 if (! peer)
3009 return CMD_WARNING;
3010
3011 ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0);
3012 return bgp_vty_return (vty, ret);
3013 }
3014
3015 DEFUN (neighbor_local_as_no_prepend,
3016 neighbor_local_as_no_prepend_cmd,
3017 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
3018 NEIGHBOR_STR
3019 NEIGHBOR_ADDR_STR2
3020 "Specify a local-as number\n"
3021 "AS number used as local AS\n"
3022 "Do not prepend local-as to updates from ebgp peers\n")
3023 {
3024 struct peer *peer;
3025 int ret;
3026
3027 peer = peer_and_group_lookup_vty (vty, argv[0]);
3028 if (! peer)
3029 return CMD_WARNING;
3030
3031 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0);
3032 return bgp_vty_return (vty, ret);
3033 }
3034
3035 DEFUN (neighbor_local_as_no_prepend_replace_as,
3036 neighbor_local_as_no_prepend_replace_as_cmd,
3037 NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3038 NEIGHBOR_STR
3039 NEIGHBOR_ADDR_STR2
3040 "Specify a local-as number\n"
3041 "AS number used as local AS\n"
3042 "Do not prepend local-as to updates from ebgp peers\n"
3043 "Do not prepend local-as to updates from ibgp peers\n")
3044 {
3045 struct peer *peer;
3046 int ret;
3047
3048 peer = peer_and_group_lookup_vty (vty, argv[0]);
3049 if (! peer)
3050 return CMD_WARNING;
3051
3052 ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1);
3053 return bgp_vty_return (vty, ret);
3054 }
3055
3056
3057 DEFUN (no_neighbor_local_as,
3058 no_neighbor_local_as_cmd,
3059 NO_NEIGHBOR_CMD2 "local-as",
3060 NO_STR
3061 NEIGHBOR_STR
3062 NEIGHBOR_ADDR_STR2
3063 "Specify a local-as number\n")
3064 {
3065 struct peer *peer;
3066 int ret;
3067
3068 peer = peer_and_group_lookup_vty (vty, argv[0]);
3069 if (! peer)
3070 return CMD_WARNING;
3071
3072 ret = peer_local_as_unset (peer);
3073 return bgp_vty_return (vty, ret);
3074 }
3075
3076 ALIAS (no_neighbor_local_as,
3077 no_neighbor_local_as_val_cmd,
3078 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
3079 NO_STR
3080 NEIGHBOR_STR
3081 NEIGHBOR_ADDR_STR2
3082 "Specify a local-as number\n"
3083 "AS number used as local AS\n")
3084
3085 ALIAS (no_neighbor_local_as,
3086 no_neighbor_local_as_val2_cmd,
3087 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
3088 NO_STR
3089 NEIGHBOR_STR
3090 NEIGHBOR_ADDR_STR2
3091 "Specify a local-as number\n"
3092 "AS number used as local AS\n"
3093 "Do not prepend local-as to updates from ebgp peers\n")
3094
3095 ALIAS (no_neighbor_local_as,
3096 no_neighbor_local_as_val3_cmd,
3097 NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend replace-as",
3098 NO_STR
3099 NEIGHBOR_STR
3100 NEIGHBOR_ADDR_STR2
3101 "Specify a local-as number\n"
3102 "AS number used as local AS\n"
3103 "Do not prepend local-as to updates from ebgp peers\n"
3104 "Do not prepend local-as to updates from ibgp peers\n")
3105
3106 DEFUN (neighbor_solo,
3107 neighbor_solo_cmd,
3108 NEIGHBOR_CMD2 "solo",
3109 NEIGHBOR_STR
3110 NEIGHBOR_ADDR_STR2
3111 "Solo peer - part of its own update group\n")
3112 {
3113 struct peer *peer;
3114 int ret;
3115
3116 peer = peer_and_group_lookup_vty (vty, argv[0]);
3117 if (! peer)
3118 return CMD_WARNING;
3119
3120 ret = update_group_adjust_soloness(peer, 1);
3121 return bgp_vty_return (vty, ret);
3122 }
3123
3124 DEFUN (no_neighbor_solo,
3125 no_neighbor_solo_cmd,
3126 NO_NEIGHBOR_CMD2 "solo",
3127 NO_STR
3128 NEIGHBOR_STR
3129 NEIGHBOR_ADDR_STR2
3130 "Solo peer - part of its own update group\n")
3131 {
3132 struct peer *peer;
3133 int ret;
3134
3135 peer = peer_and_group_lookup_vty (vty, argv[0]);
3136 if (! peer)
3137 return CMD_WARNING;
3138
3139 ret = update_group_adjust_soloness(peer, 0);
3140 return bgp_vty_return (vty, ret);
3141 }
3142
3143 DEFUN (neighbor_password,
3144 neighbor_password_cmd,
3145 NEIGHBOR_CMD2 "password LINE",
3146 NEIGHBOR_STR
3147 NEIGHBOR_ADDR_STR2
3148 "Set a password\n"
3149 "The password\n")
3150 {
3151 struct peer *peer;
3152 int ret;
3153
3154 peer = peer_and_group_lookup_vty (vty, argv[0]);
3155 if (! peer)
3156 return CMD_WARNING;
3157
3158 ret = peer_password_set (peer, argv[1]);
3159 return bgp_vty_return (vty, ret);
3160 }
3161
3162 DEFUN (no_neighbor_password,
3163 no_neighbor_password_cmd,
3164 NO_NEIGHBOR_CMD2 "password",
3165 NO_STR
3166 NEIGHBOR_STR
3167 NEIGHBOR_ADDR_STR2
3168 "Set a password\n")
3169 {
3170 struct peer *peer;
3171 int ret;
3172
3173 peer = peer_and_group_lookup_vty (vty, argv[0]);
3174 if (! peer)
3175 return CMD_WARNING;
3176
3177 ret = peer_password_unset (peer);
3178 return bgp_vty_return (vty, ret);
3179 }
3180
3181 ALIAS (no_neighbor_password,
3182 no_neighbor_password_val_cmd,
3183 NO_NEIGHBOR_CMD2 "password LINE",
3184 NO_STR
3185 NEIGHBOR_STR
3186 NEIGHBOR_ADDR_STR2
3187 "Set a password\n"
3188 "The password\n")
3189
3190 DEFUN (neighbor_activate,
3191 neighbor_activate_cmd,
3192 NEIGHBOR_CMD2 "activate",
3193 NEIGHBOR_STR
3194 NEIGHBOR_ADDR_STR2
3195 "Enable the Address Family for this Neighbor\n")
3196 {
3197 int ret;
3198 struct peer *peer;
3199
3200 peer = peer_and_group_lookup_vty (vty, argv[0]);
3201 if (! peer)
3202 return CMD_WARNING;
3203
3204 ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3205
3206 if (ret)
3207 return CMD_WARNING;
3208 return CMD_SUCCESS;
3209 }
3210
3211 DEFUN (no_neighbor_activate,
3212 no_neighbor_activate_cmd,
3213 NO_NEIGHBOR_CMD2 "activate",
3214 NO_STR
3215 NEIGHBOR_STR
3216 NEIGHBOR_ADDR_STR2
3217 "Enable the Address Family for this Neighbor\n")
3218 {
3219 int ret;
3220 struct peer *peer;
3221
3222 /* Lookup peer. */
3223 peer = peer_and_group_lookup_vty (vty, argv[0]);
3224 if (! peer)
3225 return CMD_WARNING;
3226
3227 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3228
3229 if (ret)
3230 return CMD_WARNING;
3231 return CMD_SUCCESS;
3232 }
3233
3234 DEFUN (neighbor_set_peer_group,
3235 neighbor_set_peer_group_cmd,
3236 NEIGHBOR_CMD2 "peer-group WORD",
3237 NEIGHBOR_STR
3238 NEIGHBOR_ADDR_STR2
3239 "Member of the peer-group\n"
3240 "peer-group name\n")
3241 {
3242 int ret;
3243 as_t as;
3244 union sockunion su;
3245 struct bgp *bgp;
3246 struct peer *peer;
3247 struct peer_group *group;
3248
3249 bgp = vty->index;
3250 peer = NULL;
3251
3252 ret = str2sockunion (argv[0], &su);
3253 if (ret < 0)
3254 {
3255 peer = peer_lookup_by_conf_if (bgp, argv[0]);
3256 if (!peer)
3257 {
3258 vty_out (vty, "%% Malformed address or name: %s%s", argv[0], VTY_NEWLINE);
3259 return CMD_WARNING;
3260 }
3261 }
3262 else
3263 {
3264 if (peer_address_self_check (bgp, &su))
3265 {
3266 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3267 VTY_NEWLINE);
3268 return CMD_WARNING;
3269 }
3270
3271 /* Disallow for dynamic neighbor. */
3272 peer = peer_lookup (bgp, &su);
3273 if (peer && peer_dynamic_neighbor (peer))
3274 {
3275 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3276 VTY_NEWLINE);
3277 return CMD_WARNING;
3278 }
3279 }
3280
3281 group = peer_group_lookup (bgp, argv[1]);
3282 if (! group)
3283 {
3284 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3285 return CMD_WARNING;
3286 }
3287
3288 ret = peer_group_bind (bgp, &su, peer, group, &as);
3289
3290 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3291 {
3292 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);
3293 return CMD_WARNING;
3294 }
3295
3296 return bgp_vty_return (vty, ret);
3297 }
3298
3299 DEFUN (no_neighbor_set_peer_group,
3300 no_neighbor_set_peer_group_cmd,
3301 NO_NEIGHBOR_CMD2 "peer-group WORD",
3302 NO_STR
3303 NEIGHBOR_STR
3304 NEIGHBOR_ADDR_STR2
3305 "Member of the peer-group\n"
3306 "peer-group name\n")
3307 {
3308 int ret;
3309 struct bgp *bgp;
3310 struct peer *peer;
3311 struct peer_group *group;
3312
3313 bgp = vty->index;
3314
3315 peer = peer_lookup_vty (vty, argv[0]);
3316 if (! peer)
3317 return CMD_WARNING;
3318
3319 group = peer_group_lookup (bgp, argv[1]);
3320 if (! group)
3321 {
3322 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3323 return CMD_WARNING;
3324 }
3325
3326 ret = peer_group_unbind (bgp, peer, group);
3327
3328 return bgp_vty_return (vty, ret);
3329 }
3330
3331 static int
3332 peer_flag_modify_vty (struct vty *vty, const char *ip_str,
3333 u_int16_t flag, int set)
3334 {
3335 int ret;
3336 struct peer *peer;
3337
3338 peer = peer_and_group_lookup_vty (vty, ip_str);
3339 if (! peer)
3340 return CMD_WARNING;
3341
3342 if (set)
3343 ret = peer_flag_set (peer, flag);
3344 else
3345 ret = peer_flag_unset (peer, flag);
3346
3347 return bgp_vty_return (vty, ret);
3348 }
3349
3350 static int
3351 peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
3352 {
3353 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3354 }
3355
3356 static int
3357 peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
3358 {
3359 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3360 }
3361
3362 /* neighbor passive. */
3363 DEFUN (neighbor_passive,
3364 neighbor_passive_cmd,
3365 NEIGHBOR_CMD2 "passive",
3366 NEIGHBOR_STR
3367 NEIGHBOR_ADDR_STR2
3368 "Don't send open messages to this neighbor\n")
3369 {
3370 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3371 }
3372
3373 DEFUN (no_neighbor_passive,
3374 no_neighbor_passive_cmd,
3375 NO_NEIGHBOR_CMD2 "passive",
3376 NO_STR
3377 NEIGHBOR_STR
3378 NEIGHBOR_ADDR_STR2
3379 "Don't send open messages to this neighbor\n")
3380 {
3381 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
3382 }
3383
3384 /* neighbor shutdown. */
3385 DEFUN (neighbor_shutdown,
3386 neighbor_shutdown_cmd,
3387 NEIGHBOR_CMD2 "shutdown",
3388 NEIGHBOR_STR
3389 NEIGHBOR_ADDR_STR2
3390 "Administratively shut down this neighbor\n")
3391 {
3392 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3393 }
3394
3395 DEFUN (no_neighbor_shutdown,
3396 no_neighbor_shutdown_cmd,
3397 NO_NEIGHBOR_CMD2 "shutdown",
3398 NO_STR
3399 NEIGHBOR_STR
3400 NEIGHBOR_ADDR_STR2
3401 "Administratively shut down this neighbor\n")
3402 {
3403 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
3404 }
3405
3406 /* neighbor capability dynamic. */
3407 DEFUN (neighbor_capability_dynamic,
3408 neighbor_capability_dynamic_cmd,
3409 NEIGHBOR_CMD2 "capability dynamic",
3410 NEIGHBOR_STR
3411 NEIGHBOR_ADDR_STR2
3412 "Advertise capability to the peer\n"
3413 "Advertise dynamic capability to this neighbor\n")
3414 {
3415 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3416 }
3417
3418 DEFUN (no_neighbor_capability_dynamic,
3419 no_neighbor_capability_dynamic_cmd,
3420 NO_NEIGHBOR_CMD2 "capability dynamic",
3421 NO_STR
3422 NEIGHBOR_STR
3423 NEIGHBOR_ADDR_STR2
3424 "Advertise capability to the peer\n"
3425 "Advertise dynamic capability to this neighbor\n")
3426 {
3427 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
3428 }
3429
3430 /* neighbor dont-capability-negotiate */
3431 DEFUN (neighbor_dont_capability_negotiate,
3432 neighbor_dont_capability_negotiate_cmd,
3433 NEIGHBOR_CMD2 "dont-capability-negotiate",
3434 NEIGHBOR_STR
3435 NEIGHBOR_ADDR_STR2
3436 "Do not perform capability negotiation\n")
3437 {
3438 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3439 }
3440
3441 DEFUN (no_neighbor_dont_capability_negotiate,
3442 no_neighbor_dont_capability_negotiate_cmd,
3443 NO_NEIGHBOR_CMD2 "dont-capability-negotiate",
3444 NO_STR
3445 NEIGHBOR_STR
3446 NEIGHBOR_ADDR_STR2
3447 "Do not perform capability negotiation\n")
3448 {
3449 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
3450 }
3451
3452 /* neighbor capability extended next hop encoding */
3453 DEFUN (neighbor_capability_enhe,
3454 neighbor_capability_enhe_cmd,
3455 NEIGHBOR_CMD2 "capability extended-nexthop",
3456 NEIGHBOR_STR
3457 NEIGHBOR_ADDR_STR2
3458 "Advertise capability to the peer\n"
3459 "Advertise extended next-hop capability to the peer\n")
3460 {
3461 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3462 }
3463
3464 DEFUN (no_neighbor_capability_enhe,
3465 no_neighbor_capability_enhe_cmd,
3466 NO_NEIGHBOR_CMD2 "capability extended-nexthop",
3467 NO_STR
3468 NEIGHBOR_STR
3469 NEIGHBOR_ADDR_STR2
3470 "Advertise capability to the peer\n"
3471 "Advertise extended next-hop capability to the peer\n")
3472 {
3473 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_CAPABILITY_ENHE);
3474 }
3475
3476 static int
3477 peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
3478 safi_t safi, u_int32_t flag, int set)
3479 {
3480 int ret;
3481 struct peer *peer;
3482
3483 peer = peer_and_group_lookup_vty (vty, peer_str);
3484 if (! peer)
3485 return CMD_WARNING;
3486
3487 if (set)
3488 ret = peer_af_flag_set (peer, afi, safi, flag);
3489 else
3490 ret = peer_af_flag_unset (peer, afi, safi, flag);
3491
3492 return bgp_vty_return (vty, ret);
3493 }
3494
3495 static int
3496 peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
3497 safi_t safi, u_int32_t flag)
3498 {
3499 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3500 }
3501
3502 static int
3503 peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
3504 safi_t safi, u_int32_t flag)
3505 {
3506 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3507 }
3508
3509 /* neighbor capability orf prefix-list. */
3510 DEFUN (neighbor_capability_orf_prefix,
3511 neighbor_capability_orf_prefix_cmd,
3512 NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3513 NEIGHBOR_STR
3514 NEIGHBOR_ADDR_STR2
3515 "Advertise capability to the peer\n"
3516 "Advertise ORF capability to the peer\n"
3517 "Advertise prefixlist ORF capability to this neighbor\n"
3518 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3519 "Capability to RECEIVE the ORF from this neighbor\n"
3520 "Capability to SEND the ORF to this neighbor\n")
3521 {
3522 u_int16_t flag = 0;
3523
3524 if (strncmp (argv[1], "s", 1) == 0)
3525 flag = PEER_FLAG_ORF_PREFIX_SM;
3526 else if (strncmp (argv[1], "r", 1) == 0)
3527 flag = PEER_FLAG_ORF_PREFIX_RM;
3528 else if (strncmp (argv[1], "b", 1) == 0)
3529 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3530 else
3531 return CMD_WARNING;
3532
3533 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3534 bgp_node_safi (vty), flag);
3535 }
3536
3537 DEFUN (no_neighbor_capability_orf_prefix,
3538 no_neighbor_capability_orf_prefix_cmd,
3539 NO_NEIGHBOR_CMD2 "capability orf prefix-list (both|send|receive)",
3540 NO_STR
3541 NEIGHBOR_STR
3542 NEIGHBOR_ADDR_STR2
3543 "Advertise capability to the peer\n"
3544 "Advertise ORF capability to the peer\n"
3545 "Advertise prefixlist ORF capability to this neighbor\n"
3546 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3547 "Capability to RECEIVE the ORF from this neighbor\n"
3548 "Capability to SEND the ORF to this neighbor\n")
3549 {
3550 u_int16_t flag = 0;
3551
3552 if (strncmp (argv[1], "s", 1) == 0)
3553 flag = PEER_FLAG_ORF_PREFIX_SM;
3554 else if (strncmp (argv[1], "r", 1) == 0)
3555 flag = PEER_FLAG_ORF_PREFIX_RM;
3556 else if (strncmp (argv[1], "b", 1) == 0)
3557 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3558 else
3559 return CMD_WARNING;
3560
3561 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3562 bgp_node_safi (vty), flag);
3563 }
3564
3565 /* neighbor next-hop-self. */
3566 DEFUN (neighbor_nexthop_self,
3567 neighbor_nexthop_self_cmd,
3568 NEIGHBOR_CMD2 "next-hop-self",
3569 NEIGHBOR_STR
3570 NEIGHBOR_ADDR_STR2
3571 "Disable the next hop calculation for this neighbor\n")
3572 {
3573 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3574 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3575 }
3576
3577 /* neighbor next-hop-self. */
3578 DEFUN (neighbor_nexthop_self_force,
3579 neighbor_nexthop_self_force_cmd,
3580 NEIGHBOR_CMD2 "next-hop-self force",
3581 NEIGHBOR_STR
3582 NEIGHBOR_ADDR_STR2
3583 "Disable the next hop calculation for this neighbor\n"
3584 "Set the next hop to self for reflected routes\n")
3585 {
3586 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3587 bgp_node_safi (vty),
3588 PEER_FLAG_FORCE_NEXTHOP_SELF);
3589 }
3590
3591 DEFUN (no_neighbor_nexthop_self,
3592 no_neighbor_nexthop_self_cmd,
3593 NO_NEIGHBOR_CMD2 "next-hop-self",
3594 NO_STR
3595 NEIGHBOR_STR
3596 NEIGHBOR_ADDR_STR2
3597 "Disable the next hop calculation for this neighbor\n")
3598 {
3599 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3600 bgp_node_safi (vty),
3601 PEER_FLAG_NEXTHOP_SELF);
3602 }
3603
3604 DEFUN (no_neighbor_nexthop_self_force,
3605 no_neighbor_nexthop_self_force_cmd,
3606 NO_NEIGHBOR_CMD2 "next-hop-self force",
3607 NO_STR
3608 NEIGHBOR_STR
3609 NEIGHBOR_ADDR_STR2
3610 "Disable the next hop calculation for this neighbor\n"
3611 "Set the next hop to self for reflected routes\n")
3612 {
3613 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3614 bgp_node_safi (vty),
3615 PEER_FLAG_FORCE_NEXTHOP_SELF);
3616 }
3617
3618 /* neighbor as-override */
3619 DEFUN (neighbor_as_override,
3620 neighbor_as_override_cmd,
3621 NEIGHBOR_CMD2 "as-override",
3622 NEIGHBOR_STR
3623 NEIGHBOR_ADDR_STR2
3624 "Override ASNs in outbound updates if aspath equals remote-as\n")
3625 {
3626 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3627 bgp_node_safi (vty),
3628 PEER_FLAG_AS_OVERRIDE);
3629 }
3630
3631 DEFUN (no_neighbor_as_override,
3632 no_neighbor_as_override_cmd,
3633 NO_NEIGHBOR_CMD2 "as-override",
3634 NO_STR
3635 NEIGHBOR_STR
3636 NEIGHBOR_ADDR_STR2
3637 "Override ASNs in outbound updates if aspath equals remote-as\n")
3638 {
3639 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3640 bgp_node_safi (vty),
3641 PEER_FLAG_AS_OVERRIDE);
3642 }
3643
3644 /* neighbor remove-private-AS. */
3645 DEFUN (neighbor_remove_private_as,
3646 neighbor_remove_private_as_cmd,
3647 NEIGHBOR_CMD2 "remove-private-AS",
3648 NEIGHBOR_STR
3649 NEIGHBOR_ADDR_STR2
3650 "Remove private ASNs in outbound updates\n")
3651 {
3652 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3653 bgp_node_safi (vty),
3654 PEER_FLAG_REMOVE_PRIVATE_AS);
3655 }
3656
3657 DEFUN (neighbor_remove_private_as_all,
3658 neighbor_remove_private_as_all_cmd,
3659 NEIGHBOR_CMD2 "remove-private-AS all",
3660 NEIGHBOR_STR
3661 NEIGHBOR_ADDR_STR2
3662 "Remove private ASNs in outbound updates\n"
3663 "Apply to all AS numbers")
3664 {
3665 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3666 bgp_node_safi (vty),
3667 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3668 }
3669
3670 DEFUN (neighbor_remove_private_as_replace_as,
3671 neighbor_remove_private_as_replace_as_cmd,
3672 NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3673 NEIGHBOR_STR
3674 NEIGHBOR_ADDR_STR2
3675 "Remove private ASNs in outbound updates\n"
3676 "Replace private ASNs with our ASN in outbound updates\n")
3677 {
3678 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3679 bgp_node_safi (vty),
3680 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3681 }
3682
3683 DEFUN (neighbor_remove_private_as_all_replace_as,
3684 neighbor_remove_private_as_all_replace_as_cmd,
3685 NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3686 NEIGHBOR_STR
3687 NEIGHBOR_ADDR_STR2
3688 "Remove private ASNs in outbound updates\n"
3689 "Apply to all AS numbers"
3690 "Replace private ASNs with our ASN in outbound updates\n")
3691 {
3692 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3693 bgp_node_safi (vty),
3694 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
3695 }
3696
3697 DEFUN (no_neighbor_remove_private_as,
3698 no_neighbor_remove_private_as_cmd,
3699 NO_NEIGHBOR_CMD2 "remove-private-AS",
3700 NO_STR
3701 NEIGHBOR_STR
3702 NEIGHBOR_ADDR_STR2
3703 "Remove private ASNs in outbound updates\n")
3704 {
3705 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3706 bgp_node_safi (vty),
3707 PEER_FLAG_REMOVE_PRIVATE_AS);
3708 }
3709
3710 DEFUN (no_neighbor_remove_private_as_all,
3711 no_neighbor_remove_private_as_all_cmd,
3712 NO_NEIGHBOR_CMD2 "remove-private-AS all",
3713 NO_STR
3714 NEIGHBOR_STR
3715 NEIGHBOR_ADDR_STR2
3716 "Remove private ASNs in outbound updates\n"
3717 "Apply to all AS numbers")
3718 {
3719 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3720 bgp_node_safi (vty),
3721 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3722 }
3723
3724 DEFUN (no_neighbor_remove_private_as_replace_as,
3725 no_neighbor_remove_private_as_replace_as_cmd,
3726 NO_NEIGHBOR_CMD2 "remove-private-AS replace-AS",
3727 NO_STR
3728 NEIGHBOR_STR
3729 NEIGHBOR_ADDR_STR2
3730 "Remove private ASNs in outbound updates\n"
3731 "Replace private ASNs with our ASN in outbound updates\n")
3732 {
3733 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3734 bgp_node_safi (vty),
3735 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
3736 }
3737
3738 DEFUN (no_neighbor_remove_private_as_all_replace_as,
3739 no_neighbor_remove_private_as_all_replace_as_cmd,
3740 NO_NEIGHBOR_CMD2 "remove-private-AS all replace-AS",
3741 NO_STR
3742 NEIGHBOR_STR
3743 NEIGHBOR_ADDR_STR2
3744 "Remove private ASNs in outbound updates\n"
3745 "Apply to all AS numbers"
3746 "Replace private ASNs with our ASN in outbound updates\n")
3747 {
3748 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3749 bgp_node_safi (vty),
3750 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
3751 }
3752
3753
3754 /* neighbor send-community. */
3755 DEFUN (neighbor_send_community,
3756 neighbor_send_community_cmd,
3757 NEIGHBOR_CMD2 "send-community",
3758 NEIGHBOR_STR
3759 NEIGHBOR_ADDR_STR2
3760 "Send Community attribute to this neighbor\n")
3761 {
3762 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3763 bgp_node_safi (vty),
3764 PEER_FLAG_SEND_COMMUNITY);
3765 }
3766
3767 DEFUN (no_neighbor_send_community,
3768 no_neighbor_send_community_cmd,
3769 NO_NEIGHBOR_CMD2 "send-community",
3770 NO_STR
3771 NEIGHBOR_STR
3772 NEIGHBOR_ADDR_STR2
3773 "Send Community attribute to this neighbor\n")
3774 {
3775 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3776 bgp_node_safi (vty),
3777 PEER_FLAG_SEND_COMMUNITY);
3778 }
3779
3780 /* neighbor send-community extended. */
3781 DEFUN (neighbor_send_community_type,
3782 neighbor_send_community_type_cmd,
3783 NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3784 NEIGHBOR_STR
3785 NEIGHBOR_ADDR_STR2
3786 "Send Community attribute to this neighbor\n"
3787 "Send Standard and Extended Community attributes\n"
3788 "Send Extended Community attributes\n"
3789 "Send Standard Community attributes\n")
3790 {
3791 if (strncmp (argv[1], "s", 1) == 0)
3792 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3793 bgp_node_safi (vty),
3794 PEER_FLAG_SEND_COMMUNITY);
3795 if (strncmp (argv[1], "e", 1) == 0)
3796 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3797 bgp_node_safi (vty),
3798 PEER_FLAG_SEND_EXT_COMMUNITY);
3799
3800 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3801 bgp_node_safi (vty),
3802 (PEER_FLAG_SEND_COMMUNITY|
3803 PEER_FLAG_SEND_EXT_COMMUNITY));
3804 }
3805
3806 DEFUN (no_neighbor_send_community_type,
3807 no_neighbor_send_community_type_cmd,
3808 NO_NEIGHBOR_CMD2 "send-community (both|extended|standard)",
3809 NO_STR
3810 NEIGHBOR_STR
3811 NEIGHBOR_ADDR_STR2
3812 "Send Community attribute to this neighbor\n"
3813 "Send Standard and Extended Community attributes\n"
3814 "Send Extended Community attributes\n"
3815 "Send Standard Community attributes\n")
3816 {
3817 if (strncmp (argv[1], "s", 1) == 0)
3818 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3819 bgp_node_safi (vty),
3820 PEER_FLAG_SEND_COMMUNITY);
3821 if (strncmp (argv[1], "e", 1) == 0)
3822 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3823 bgp_node_safi (vty),
3824 PEER_FLAG_SEND_EXT_COMMUNITY);
3825
3826 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3827 bgp_node_safi (vty),
3828 (PEER_FLAG_SEND_COMMUNITY |
3829 PEER_FLAG_SEND_EXT_COMMUNITY));
3830 }
3831
3832 /* neighbor soft-reconfig. */
3833 DEFUN (neighbor_soft_reconfiguration,
3834 neighbor_soft_reconfiguration_cmd,
3835 NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3836 NEIGHBOR_STR
3837 NEIGHBOR_ADDR_STR2
3838 "Per neighbor soft reconfiguration\n"
3839 "Allow inbound soft reconfiguration for this neighbor\n")
3840 {
3841 return peer_af_flag_set_vty (vty, argv[0],
3842 bgp_node_afi (vty), bgp_node_safi (vty),
3843 PEER_FLAG_SOFT_RECONFIG);
3844 }
3845
3846 DEFUN (no_neighbor_soft_reconfiguration,
3847 no_neighbor_soft_reconfiguration_cmd,
3848 NO_NEIGHBOR_CMD2 "soft-reconfiguration inbound",
3849 NO_STR
3850 NEIGHBOR_STR
3851 NEIGHBOR_ADDR_STR2
3852 "Per neighbor soft reconfiguration\n"
3853 "Allow inbound soft reconfiguration for this neighbor\n")
3854 {
3855 return peer_af_flag_unset_vty (vty, argv[0],
3856 bgp_node_afi (vty), bgp_node_safi (vty),
3857 PEER_FLAG_SOFT_RECONFIG);
3858 }
3859
3860 DEFUN (neighbor_route_reflector_client,
3861 neighbor_route_reflector_client_cmd,
3862 NEIGHBOR_CMD2 "route-reflector-client",
3863 NEIGHBOR_STR
3864 NEIGHBOR_ADDR_STR2
3865 "Configure a neighbor as Route Reflector client\n")
3866 {
3867 struct peer *peer;
3868
3869
3870 peer = peer_and_group_lookup_vty (vty, argv[0]);
3871 if (! peer)
3872 return CMD_WARNING;
3873
3874 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3875 bgp_node_safi (vty),
3876 PEER_FLAG_REFLECTOR_CLIENT);
3877 }
3878
3879 DEFUN (no_neighbor_route_reflector_client,
3880 no_neighbor_route_reflector_client_cmd,
3881 NO_NEIGHBOR_CMD2 "route-reflector-client",
3882 NO_STR
3883 NEIGHBOR_STR
3884 NEIGHBOR_ADDR_STR2
3885 "Configure a neighbor as Route Reflector client\n")
3886 {
3887 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3888 bgp_node_safi (vty),
3889 PEER_FLAG_REFLECTOR_CLIENT);
3890 }
3891
3892 /* neighbor route-server-client. */
3893 DEFUN (neighbor_route_server_client,
3894 neighbor_route_server_client_cmd,
3895 NEIGHBOR_CMD2 "route-server-client",
3896 NEIGHBOR_STR
3897 NEIGHBOR_ADDR_STR2
3898 "Configure a neighbor as Route Server client\n")
3899 {
3900 struct peer *peer;
3901
3902 peer = peer_and_group_lookup_vty (vty, argv[0]);
3903 if (! peer)
3904 return CMD_WARNING;
3905 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3906 bgp_node_safi (vty),
3907 PEER_FLAG_RSERVER_CLIENT);
3908 }
3909
3910 DEFUN (no_neighbor_route_server_client,
3911 no_neighbor_route_server_client_cmd,
3912 NO_NEIGHBOR_CMD2 "route-server-client",
3913 NO_STR
3914 NEIGHBOR_STR
3915 NEIGHBOR_ADDR_STR2
3916 "Configure a neighbor as Route Server client\n")
3917 {
3918 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3919 bgp_node_safi (vty),
3920 PEER_FLAG_RSERVER_CLIENT);
3921 }
3922
3923 DEFUN (neighbor_nexthop_local_unchanged,
3924 neighbor_nexthop_local_unchanged_cmd,
3925 NEIGHBOR_CMD2 "nexthop-local unchanged",
3926 NEIGHBOR_STR
3927 NEIGHBOR_ADDR_STR2
3928 "Configure treatment of outgoing link-local nexthop attribute\n"
3929 "Leave link-local nexthop unchanged for this peer\n")
3930 {
3931 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3932 bgp_node_safi (vty),
3933 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
3934 }
3935
3936 DEFUN (no_neighbor_nexthop_local_unchanged,
3937 no_neighbor_nexthop_local_unchanged_cmd,
3938 NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
3939 NO_STR
3940 NEIGHBOR_STR
3941 NEIGHBOR_ADDR_STR2
3942 "Configure treatment of outgoing link-local-nexthop attribute\n"
3943 "Leave link-local nexthop unchanged for this peer\n")
3944 {
3945 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
3946 bgp_node_safi (vty),
3947 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
3948 }
3949
3950 DEFUN (neighbor_attr_unchanged,
3951 neighbor_attr_unchanged_cmd,
3952 NEIGHBOR_CMD2 "attribute-unchanged",
3953 NEIGHBOR_STR
3954 NEIGHBOR_ADDR_STR2
3955 "BGP attribute is propagated unchanged to this neighbor\n")
3956 {
3957 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3958 bgp_node_safi (vty),
3959 (PEER_FLAG_AS_PATH_UNCHANGED |
3960 PEER_FLAG_NEXTHOP_UNCHANGED |
3961 PEER_FLAG_MED_UNCHANGED));
3962 }
3963
3964 DEFUN (neighbor_attr_unchanged1,
3965 neighbor_attr_unchanged1_cmd,
3966 NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
3967 NEIGHBOR_STR
3968 NEIGHBOR_ADDR_STR2
3969 "BGP attribute is propagated unchanged to this neighbor\n"
3970 "As-path attribute\n"
3971 "Nexthop attribute\n"
3972 "Med attribute\n")
3973 {
3974 u_int16_t flags = 0;
3975
3976 if (strncmp (argv[1], "as-path", 1) == 0)
3977 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
3978 else if (strncmp (argv[1], "next-hop", 1) == 0)
3979 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
3980 else if (strncmp (argv[1], "med", 1) == 0)
3981 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
3982
3983 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
3984 bgp_node_safi (vty), flags);
3985 }
3986
3987 DEFUN (neighbor_attr_unchanged2,
3988 neighbor_attr_unchanged2_cmd,
3989 NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
3990 NEIGHBOR_STR
3991 NEIGHBOR_ADDR_STR2
3992 "BGP attribute is propagated unchanged to this neighbor\n"
3993 "As-path attribute\n"
3994 "Nexthop attribute\n"
3995 "Med attribute\n")
3996 {
3997 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
3998
3999 if (strncmp (argv[1], "next-hop", 1) == 0)
4000 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4001 else if (strncmp (argv[1], "med", 1) == 0)
4002 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4003
4004 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4005 bgp_node_safi (vty), flags);
4006
4007 }
4008
4009 DEFUN (neighbor_attr_unchanged3,
4010 neighbor_attr_unchanged3_cmd,
4011 NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4012 NEIGHBOR_STR
4013 NEIGHBOR_ADDR_STR2
4014 "BGP attribute is propagated unchanged to this neighbor\n"
4015 "Nexthop attribute\n"
4016 "As-path attribute\n"
4017 "Med attribute\n")
4018 {
4019 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4020
4021 if (strncmp (argv[1], "as-path", 1) == 0)
4022 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4023 else if (strncmp (argv[1], "med", 1) == 0)
4024 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4025
4026 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4027 bgp_node_safi (vty), flags);
4028 }
4029
4030 DEFUN (neighbor_attr_unchanged4,
4031 neighbor_attr_unchanged4_cmd,
4032 NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4033 NEIGHBOR_STR
4034 NEIGHBOR_ADDR_STR2
4035 "BGP attribute is propagated unchanged to this neighbor\n"
4036 "Med attribute\n"
4037 "As-path attribute\n"
4038 "Nexthop attribute\n")
4039 {
4040 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4041
4042 if (strncmp (argv[1], "as-path", 1) == 0)
4043 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4044 else if (strncmp (argv[1], "next-hop", 1) == 0)
4045 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4046
4047 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
4048 bgp_node_safi (vty), flags);
4049 }
4050
4051 ALIAS (neighbor_attr_unchanged,
4052 neighbor_attr_unchanged5_cmd,
4053 NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4054 NEIGHBOR_STR
4055 NEIGHBOR_ADDR_STR2
4056 "BGP attribute is propagated unchanged to this neighbor\n"
4057 "As-path attribute\n"
4058 "Nexthop attribute\n"
4059 "Med attribute\n")
4060
4061 ALIAS (neighbor_attr_unchanged,
4062 neighbor_attr_unchanged6_cmd,
4063 NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4064 NEIGHBOR_STR
4065 NEIGHBOR_ADDR_STR2
4066 "BGP attribute is propagated unchanged to this neighbor\n"
4067 "As-path attribute\n"
4068 "Med attribute\n"
4069 "Nexthop attribute\n")
4070
4071 ALIAS (neighbor_attr_unchanged,
4072 neighbor_attr_unchanged7_cmd,
4073 NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4074 NEIGHBOR_STR
4075 NEIGHBOR_ADDR_STR2
4076 "BGP attribute is propagated unchanged to this neighbor\n"
4077 "Nexthop attribute\n"
4078 "Med attribute\n"
4079 "As-path attribute\n")
4080
4081 ALIAS (neighbor_attr_unchanged,
4082 neighbor_attr_unchanged8_cmd,
4083 NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4084 NEIGHBOR_STR
4085 NEIGHBOR_ADDR_STR2
4086 "BGP attribute is propagated unchanged to this neighbor\n"
4087 "Nexthop attribute\n"
4088 "As-path attribute\n"
4089 "Med attribute\n")
4090
4091 ALIAS (neighbor_attr_unchanged,
4092 neighbor_attr_unchanged9_cmd,
4093 NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4094 NEIGHBOR_STR
4095 NEIGHBOR_ADDR_STR2
4096 "BGP attribute is propagated unchanged to this neighbor\n"
4097 "Med attribute\n"
4098 "Nexthop attribute\n"
4099 "As-path attribute\n")
4100
4101 ALIAS (neighbor_attr_unchanged,
4102 neighbor_attr_unchanged10_cmd,
4103 NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4104 NEIGHBOR_STR
4105 NEIGHBOR_ADDR_STR2
4106 "BGP attribute is propagated unchanged to this neighbor\n"
4107 "Med attribute\n"
4108 "As-path attribute\n"
4109 "Nexthop attribute\n")
4110
4111 DEFUN (no_neighbor_attr_unchanged,
4112 no_neighbor_attr_unchanged_cmd,
4113 NO_NEIGHBOR_CMD2 "attribute-unchanged",
4114 NO_STR
4115 NEIGHBOR_STR
4116 NEIGHBOR_ADDR_STR2
4117 "BGP attribute is propagated unchanged to this neighbor\n")
4118 {
4119 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4120 bgp_node_safi (vty),
4121 (PEER_FLAG_AS_PATH_UNCHANGED |
4122 PEER_FLAG_NEXTHOP_UNCHANGED |
4123 PEER_FLAG_MED_UNCHANGED));
4124 }
4125
4126 DEFUN (no_neighbor_attr_unchanged1,
4127 no_neighbor_attr_unchanged1_cmd,
4128 NO_NEIGHBOR_CMD2 "attribute-unchanged (as-path|next-hop|med)",
4129 NO_STR
4130 NEIGHBOR_STR
4131 NEIGHBOR_ADDR_STR2
4132 "BGP attribute is propagated unchanged to this neighbor\n"
4133 "As-path attribute\n"
4134 "Nexthop attribute\n"
4135 "Med attribute\n")
4136 {
4137 u_int16_t flags = 0;
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 else if (strncmp (argv[1], "med", 1) == 0)
4144 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4145
4146 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4147 bgp_node_safi (vty), flags);
4148 }
4149
4150 DEFUN (no_neighbor_attr_unchanged2,
4151 no_neighbor_attr_unchanged2_cmd,
4152 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path (next-hop|med)",
4153 NO_STR
4154 NEIGHBOR_STR
4155 NEIGHBOR_ADDR_STR2
4156 "BGP attribute is propagated unchanged to this neighbor\n"
4157 "As-path attribute\n"
4158 "Nexthop attribute\n"
4159 "Med attribute\n")
4160 {
4161 u_int16_t flags = PEER_FLAG_AS_PATH_UNCHANGED;
4162
4163 if (strncmp (argv[1], "next-hop", 1) == 0)
4164 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4165 else if (strncmp (argv[1], "med", 1) == 0)
4166 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4167
4168 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4169 bgp_node_safi (vty), flags);
4170 }
4171
4172 DEFUN (no_neighbor_attr_unchanged3,
4173 no_neighbor_attr_unchanged3_cmd,
4174 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop (as-path|med)",
4175 NO_STR
4176 NEIGHBOR_STR
4177 NEIGHBOR_ADDR_STR2
4178 "BGP attribute is propagated unchanged to this neighbor\n"
4179 "Nexthop attribute\n"
4180 "As-path attribute\n"
4181 "Med attribute\n")
4182 {
4183 u_int16_t flags = PEER_FLAG_NEXTHOP_UNCHANGED;
4184
4185 if (strncmp (argv[1], "as-path", 1) == 0)
4186 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4187 else if (strncmp (argv[1], "med", 1) == 0)
4188 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4189
4190 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4191 bgp_node_safi (vty), flags);
4192 }
4193
4194 DEFUN (no_neighbor_attr_unchanged4,
4195 no_neighbor_attr_unchanged4_cmd,
4196 NO_NEIGHBOR_CMD2 "attribute-unchanged med (as-path|next-hop)",
4197 NO_STR
4198 NEIGHBOR_STR
4199 NEIGHBOR_ADDR_STR2
4200 "BGP attribute is propagated unchanged to this neighbor\n"
4201 "Med attribute\n"
4202 "As-path attribute\n"
4203 "Nexthop attribute\n")
4204 {
4205 u_int16_t flags = PEER_FLAG_MED_UNCHANGED;
4206
4207 if (strncmp (argv[1], "as-path", 1) == 0)
4208 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
4209 else if (strncmp (argv[1], "next-hop", 1) == 0)
4210 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4211
4212 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
4213 bgp_node_safi (vty), flags);
4214 }
4215
4216 ALIAS (no_neighbor_attr_unchanged,
4217 no_neighbor_attr_unchanged5_cmd,
4218 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path next-hop med",
4219 NO_STR
4220 NEIGHBOR_STR
4221 NEIGHBOR_ADDR_STR2
4222 "BGP attribute is propagated unchanged to this neighbor\n"
4223 "As-path attribute\n"
4224 "Nexthop attribute\n"
4225 "Med attribute\n")
4226
4227 ALIAS (no_neighbor_attr_unchanged,
4228 no_neighbor_attr_unchanged6_cmd,
4229 NO_NEIGHBOR_CMD2 "attribute-unchanged as-path med next-hop",
4230 NO_STR
4231 NEIGHBOR_STR
4232 NEIGHBOR_ADDR_STR2
4233 "BGP attribute is propagated unchanged to this neighbor\n"
4234 "As-path attribute\n"
4235 "Med attribute\n"
4236 "Nexthop attribute\n")
4237
4238 ALIAS (no_neighbor_attr_unchanged,
4239 no_neighbor_attr_unchanged7_cmd,
4240 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop med as-path",
4241 NO_STR
4242 NEIGHBOR_STR
4243 NEIGHBOR_ADDR_STR2
4244 "BGP attribute is propagated unchanged to this neighbor\n"
4245 "Nexthop attribute\n"
4246 "Med attribute\n"
4247 "As-path attribute\n")
4248
4249 ALIAS (no_neighbor_attr_unchanged,
4250 no_neighbor_attr_unchanged8_cmd,
4251 NO_NEIGHBOR_CMD2 "attribute-unchanged next-hop as-path med",
4252 NO_STR
4253 NEIGHBOR_STR
4254 NEIGHBOR_ADDR_STR2
4255 "BGP attribute is propagated unchanged to this neighbor\n"
4256 "Nexthop attribute\n"
4257 "As-path attribute\n"
4258 "Med attribute\n")
4259
4260 ALIAS (no_neighbor_attr_unchanged,
4261 no_neighbor_attr_unchanged9_cmd,
4262 NO_NEIGHBOR_CMD2 "attribute-unchanged med next-hop as-path",
4263 NO_STR
4264 NEIGHBOR_STR
4265 NEIGHBOR_ADDR_STR2
4266 "BGP attribute is propagated unchanged to this neighbor\n"
4267 "Med attribute\n"
4268 "Nexthop attribute\n"
4269 "As-path attribute\n")
4270
4271 ALIAS (no_neighbor_attr_unchanged,
4272 no_neighbor_attr_unchanged10_cmd,
4273 NO_NEIGHBOR_CMD2 "attribute-unchanged med as-path next-hop",
4274 NO_STR
4275 NEIGHBOR_STR
4276 NEIGHBOR_ADDR_STR2
4277 "BGP attribute is propagated unchanged to this neighbor\n"
4278 "Med attribute\n"
4279 "As-path attribute\n"
4280 "Nexthop attribute\n")
4281
4282 /* EBGP multihop configuration. */
4283 static int
4284 peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
4285 const char *ttl_str)
4286 {
4287 struct peer *peer;
4288 unsigned int ttl;
4289
4290 peer = peer_and_group_lookup_vty (vty, ip_str);
4291 if (! peer)
4292 return CMD_WARNING;
4293
4294 if (! ttl_str)
4295 ttl = MAXTTL;
4296 else
4297 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
4298
4299 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
4300 }
4301
4302 static int
4303 peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
4304 {
4305 struct peer *peer;
4306
4307 peer = peer_and_group_lookup_vty (vty, ip_str);
4308 if (! peer)
4309 return CMD_WARNING;
4310
4311 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
4312 }
4313
4314 /* neighbor ebgp-multihop. */
4315 DEFUN (neighbor_ebgp_multihop,
4316 neighbor_ebgp_multihop_cmd,
4317 NEIGHBOR_CMD2 "ebgp-multihop",
4318 NEIGHBOR_STR
4319 NEIGHBOR_ADDR_STR2
4320 "Allow EBGP neighbors not on directly connected networks\n")
4321 {
4322 return peer_ebgp_multihop_set_vty (vty, argv[0], NULL);
4323 }
4324
4325 DEFUN (neighbor_ebgp_multihop_ttl,
4326 neighbor_ebgp_multihop_ttl_cmd,
4327 NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
4328 NEIGHBOR_STR
4329 NEIGHBOR_ADDR_STR2
4330 "Allow EBGP neighbors not on directly connected networks\n"
4331 "maximum hop count\n")
4332 {
4333 return peer_ebgp_multihop_set_vty (vty, argv[0], argv[1]);
4334 }
4335
4336 DEFUN (no_neighbor_ebgp_multihop,
4337 no_neighbor_ebgp_multihop_cmd,
4338 NO_NEIGHBOR_CMD2 "ebgp-multihop",
4339 NO_STR
4340 NEIGHBOR_STR
4341 NEIGHBOR_ADDR_STR2
4342 "Allow EBGP neighbors not on directly connected networks\n")
4343 {
4344 return peer_ebgp_multihop_unset_vty (vty, argv[0]);
4345 }
4346
4347 ALIAS (no_neighbor_ebgp_multihop,
4348 no_neighbor_ebgp_multihop_ttl_cmd,
4349 NO_NEIGHBOR_CMD2 "ebgp-multihop " CMD_RANGE_STR(1, MAXTTL),
4350 NO_STR
4351 NEIGHBOR_STR
4352 NEIGHBOR_ADDR_STR2
4353 "Allow EBGP neighbors not on directly connected networks\n"
4354 "maximum hop count\n")
4355
4356 /* disable-connected-check */
4357 DEFUN (neighbor_disable_connected_check,
4358 neighbor_disable_connected_check_cmd,
4359 NEIGHBOR_CMD2 "disable-connected-check",
4360 NEIGHBOR_STR
4361 NEIGHBOR_ADDR_STR2
4362 "one-hop away EBGP peer using loopback address\n")
4363 {
4364 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4365 }
4366
4367 DEFUN (no_neighbor_disable_connected_check,
4368 no_neighbor_disable_connected_check_cmd,
4369 NO_NEIGHBOR_CMD2 "disable-connected-check",
4370 NO_STR
4371 NEIGHBOR_STR
4372 NEIGHBOR_ADDR_STR2
4373 "one-hop away EBGP peer using loopback address\n")
4374 {
4375 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK);
4376 }
4377
4378 /* Enforce multihop. */
4379 ALIAS (neighbor_disable_connected_check,
4380 neighbor_enforce_multihop_cmd,
4381 NEIGHBOR_CMD2 "enforce-multihop",
4382 NEIGHBOR_STR
4383 NEIGHBOR_ADDR_STR2
4384 "Enforce EBGP neighbors perform multihop\n")
4385
4386 /* Enforce multihop. */
4387 ALIAS (no_neighbor_disable_connected_check,
4388 no_neighbor_enforce_multihop_cmd,
4389 NO_NEIGHBOR_CMD2 "enforce-multihop",
4390 NO_STR
4391 NEIGHBOR_STR
4392 NEIGHBOR_ADDR_STR2
4393 "Enforce EBGP neighbors perform multihop\n")
4394
4395 DEFUN (neighbor_description,
4396 neighbor_description_cmd,
4397 NEIGHBOR_CMD2 "description .LINE",
4398 NEIGHBOR_STR
4399 NEIGHBOR_ADDR_STR2
4400 "Neighbor specific description\n"
4401 "Up to 80 characters describing this neighbor\n")
4402 {
4403 struct peer *peer;
4404 char *str;
4405
4406 peer = peer_and_group_lookup_vty (vty, argv[0]);
4407 if (! peer)
4408 return CMD_WARNING;
4409
4410 if (argc == 1)
4411 return CMD_SUCCESS;
4412
4413 str = argv_concat(argv, argc, 1);
4414
4415 peer_description_set (peer, str);
4416
4417 XFREE (MTYPE_TMP, str);
4418
4419 return CMD_SUCCESS;
4420 }
4421
4422 DEFUN (no_neighbor_description,
4423 no_neighbor_description_cmd,
4424 NO_NEIGHBOR_CMD2 "description",
4425 NO_STR
4426 NEIGHBOR_STR
4427 NEIGHBOR_ADDR_STR2
4428 "Neighbor specific description\n")
4429 {
4430 struct peer *peer;
4431
4432 peer = peer_and_group_lookup_vty (vty, argv[0]);
4433 if (! peer)
4434 return CMD_WARNING;
4435
4436 peer_description_unset (peer);
4437
4438 return CMD_SUCCESS;
4439 }
4440
4441 ALIAS (no_neighbor_description,
4442 no_neighbor_description_val_cmd,
4443 NO_NEIGHBOR_CMD2 "description .LINE",
4444 NO_STR
4445 NEIGHBOR_STR
4446 NEIGHBOR_ADDR_STR2
4447 "Neighbor specific description\n"
4448 "Up to 80 characters describing this neighbor\n")
4449
4450 /* Neighbor update-source. */
4451 static int
4452 peer_update_source_vty (struct vty *vty, const char *peer_str,
4453 const char *source_str)
4454 {
4455 struct peer *peer;
4456
4457 peer = peer_and_group_lookup_vty (vty, peer_str);
4458 if (! peer)
4459 return CMD_WARNING;
4460
4461 if (peer->conf_if)
4462 return CMD_WARNING;
4463
4464 if (source_str)
4465 {
4466 union sockunion su;
4467 int ret = str2sockunion (source_str, &su);
4468
4469 if (ret == 0)
4470 peer_update_source_addr_set (peer, &su);
4471 else
4472 peer_update_source_if_set (peer, source_str);
4473 }
4474 else
4475 peer_update_source_unset (peer);
4476
4477 return CMD_SUCCESS;
4478 }
4479
4480 #define BGP_UPDATE_SOURCE_STR "A.B.C.D|X:X::X:X|WORD"
4481 #define BGP_UPDATE_SOURCE_REQ_STR "(" BGP_UPDATE_SOURCE_STR ")"
4482 #define BGP_UPDATE_SOURCE_OPT_STR "{" BGP_UPDATE_SOURCE_STR "}"
4483 #define BGP_UPDATE_SOURCE_HELP_STR \
4484 "IPv4 address\n" \
4485 "IPv6 address\n" \
4486 "Interface name (requires zebra to be running)\n"
4487
4488 DEFUN (neighbor_update_source,
4489 neighbor_update_source_cmd,
4490 NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_REQ_STR,
4491 NEIGHBOR_STR
4492 NEIGHBOR_ADDR_STR2
4493 "Source of routing updates\n"
4494 BGP_UPDATE_SOURCE_HELP_STR)
4495 {
4496 return peer_update_source_vty (vty, argv[0], argv[1]);
4497 }
4498
4499 DEFUN (no_neighbor_update_source,
4500 no_neighbor_update_source_cmd,
4501 NO_NEIGHBOR_CMD2 "update-source " BGP_UPDATE_SOURCE_OPT_STR,
4502 NO_STR
4503 NEIGHBOR_STR
4504 NEIGHBOR_ADDR_STR2
4505 "Source of routing updates\n"
4506 BGP_UPDATE_SOURCE_HELP_STR)
4507 {
4508 return peer_update_source_vty (vty, argv[0], NULL);
4509 }
4510
4511 static int
4512 peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4513 afi_t afi, safi_t safi,
4514 const char *rmap, int set)
4515 {
4516 int ret;
4517 struct peer *peer;
4518
4519 peer = peer_and_group_lookup_vty (vty, peer_str);
4520 if (! peer)
4521 return CMD_WARNING;
4522
4523 if (set)
4524 ret = peer_default_originate_set (peer, afi, safi, rmap);
4525 else
4526 ret = peer_default_originate_unset (peer, afi, safi);
4527
4528 return bgp_vty_return (vty, ret);
4529 }
4530
4531 /* neighbor default-originate. */
4532 DEFUN (neighbor_default_originate,
4533 neighbor_default_originate_cmd,
4534 NEIGHBOR_CMD2 "default-originate",
4535 NEIGHBOR_STR
4536 NEIGHBOR_ADDR_STR2
4537 "Originate default route to this neighbor\n")
4538 {
4539 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4540 bgp_node_safi (vty), NULL, 1);
4541 }
4542
4543 DEFUN (neighbor_default_originate_rmap,
4544 neighbor_default_originate_rmap_cmd,
4545 NEIGHBOR_CMD2 "default-originate route-map WORD",
4546 NEIGHBOR_STR
4547 NEIGHBOR_ADDR_STR2
4548 "Originate default route to this neighbor\n"
4549 "Route-map to specify criteria to originate default\n"
4550 "route-map name\n")
4551 {
4552 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4553 bgp_node_safi (vty), argv[1], 1);
4554 }
4555
4556 DEFUN (no_neighbor_default_originate,
4557 no_neighbor_default_originate_cmd,
4558 NO_NEIGHBOR_CMD2 "default-originate",
4559 NO_STR
4560 NEIGHBOR_STR
4561 NEIGHBOR_ADDR_STR2
4562 "Originate default route to this neighbor\n")
4563 {
4564 return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty),
4565 bgp_node_safi (vty), NULL, 0);
4566 }
4567
4568 ALIAS (no_neighbor_default_originate,
4569 no_neighbor_default_originate_rmap_cmd,
4570 NO_NEIGHBOR_CMD2 "default-originate route-map WORD",
4571 NO_STR
4572 NEIGHBOR_STR
4573 NEIGHBOR_ADDR_STR2
4574 "Originate default route to this neighbor\n"
4575 "Route-map to specify criteria to originate default\n"
4576 "route-map name\n")
4577
4578 /* Set neighbor's BGP port. */
4579 static int
4580 peer_port_vty (struct vty *vty, const char *ip_str, int afi,
4581 const char *port_str)
4582 {
4583 struct peer *peer;
4584 u_int16_t port;
4585 struct servent *sp;
4586
4587 peer = peer_lookup_vty (vty, ip_str);
4588 if (! peer)
4589 return CMD_WARNING;
4590
4591 if (! port_str)
4592 {
4593 sp = getservbyname ("bgp", "tcp");
4594 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4595 }
4596 else
4597 {
4598 VTY_GET_INTEGER("port", port, port_str);
4599 }
4600
4601 peer_port_set (peer, port);
4602
4603 return CMD_SUCCESS;
4604 }
4605
4606 /* Set specified peer's BGP port. */
4607 DEFUN (neighbor_port,
4608 neighbor_port_cmd,
4609 NEIGHBOR_CMD "port <0-65535>",
4610 NEIGHBOR_STR
4611 NEIGHBOR_ADDR_STR
4612 "Neighbor's BGP port\n"
4613 "TCP port number\n")
4614 {
4615 return peer_port_vty (vty, argv[0], AFI_IP, argv[1]);
4616 }
4617
4618 DEFUN (no_neighbor_port,
4619 no_neighbor_port_cmd,
4620 NO_NEIGHBOR_CMD "port",
4621 NO_STR
4622 NEIGHBOR_STR
4623 NEIGHBOR_ADDR_STR
4624 "Neighbor's BGP port\n")
4625 {
4626 return peer_port_vty (vty, argv[0], AFI_IP, NULL);
4627 }
4628
4629 ALIAS (no_neighbor_port,
4630 no_neighbor_port_val_cmd,
4631 NO_NEIGHBOR_CMD "port <0-65535>",
4632 NO_STR
4633 NEIGHBOR_STR
4634 NEIGHBOR_ADDR_STR
4635 "Neighbor's BGP port\n"
4636 "TCP port number\n")
4637
4638 /* neighbor weight. */
4639 static int
4640 peer_weight_set_vty (struct vty *vty, const char *ip_str,
4641 const char *weight_str)
4642 {
4643 struct peer *peer;
4644 unsigned long weight;
4645
4646 peer = peer_and_group_lookup_vty (vty, ip_str);
4647 if (! peer)
4648 return CMD_WARNING;
4649
4650 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4651
4652 peer_weight_set (peer, weight);
4653
4654 return CMD_SUCCESS;
4655 }
4656
4657 static int
4658 peer_weight_unset_vty (struct vty *vty, const char *ip_str)
4659 {
4660 struct peer *peer;
4661
4662 peer = peer_and_group_lookup_vty (vty, ip_str);
4663 if (! peer)
4664 return CMD_WARNING;
4665
4666 peer_weight_unset (peer);
4667
4668 return CMD_SUCCESS;
4669 }
4670
4671 DEFUN (neighbor_weight,
4672 neighbor_weight_cmd,
4673 NEIGHBOR_CMD2 "weight <0-65535>",
4674 NEIGHBOR_STR
4675 NEIGHBOR_ADDR_STR2
4676 "Set default weight for routes from this neighbor\n"
4677 "default weight\n")
4678 {
4679 return peer_weight_set_vty (vty, argv[0], argv[1]);
4680 }
4681
4682 DEFUN (no_neighbor_weight,
4683 no_neighbor_weight_cmd,
4684 NO_NEIGHBOR_CMD2 "weight",
4685 NO_STR
4686 NEIGHBOR_STR
4687 NEIGHBOR_ADDR_STR2
4688 "Set default weight for routes from this neighbor\n")
4689 {
4690 return peer_weight_unset_vty (vty, argv[0]);
4691 }
4692
4693 ALIAS (no_neighbor_weight,
4694 no_neighbor_weight_val_cmd,
4695 NO_NEIGHBOR_CMD2 "weight <0-65535>",
4696 NO_STR
4697 NEIGHBOR_STR
4698 NEIGHBOR_ADDR_STR2
4699 "Set default weight for routes from this neighbor\n"
4700 "default weight\n")
4701
4702 /* Override capability negotiation. */
4703 DEFUN (neighbor_override_capability,
4704 neighbor_override_capability_cmd,
4705 NEIGHBOR_CMD2 "override-capability",
4706 NEIGHBOR_STR
4707 NEIGHBOR_ADDR_STR2
4708 "Override capability negotiation result\n")
4709 {
4710 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4711 }
4712
4713 DEFUN (no_neighbor_override_capability,
4714 no_neighbor_override_capability_cmd,
4715 NO_NEIGHBOR_CMD2 "override-capability",
4716 NO_STR
4717 NEIGHBOR_STR
4718 NEIGHBOR_ADDR_STR2
4719 "Override capability negotiation result\n")
4720 {
4721 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
4722 }
4723
4724 DEFUN (neighbor_strict_capability,
4725 neighbor_strict_capability_cmd,
4726 NEIGHBOR_CMD "strict-capability-match",
4727 NEIGHBOR_STR
4728 NEIGHBOR_ADDR_STR
4729 "Strict capability negotiation match\n")
4730 {
4731 return peer_flag_set_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4732 }
4733
4734 DEFUN (no_neighbor_strict_capability,
4735 no_neighbor_strict_capability_cmd,
4736 NO_NEIGHBOR_CMD "strict-capability-match",
4737 NO_STR
4738 NEIGHBOR_STR
4739 NEIGHBOR_ADDR_STR
4740 "Strict capability negotiation match\n")
4741 {
4742 return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
4743 }
4744
4745 static int
4746 peer_timers_set_vty (struct vty *vty, const char *ip_str,
4747 const char *keep_str, const char *hold_str)
4748 {
4749 int ret;
4750 struct peer *peer;
4751 u_int32_t keepalive;
4752 u_int32_t holdtime;
4753
4754 peer = peer_and_group_lookup_vty (vty, ip_str);
4755 if (! peer)
4756 return CMD_WARNING;
4757
4758 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
4759 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
4760
4761 ret = peer_timers_set (peer, keepalive, holdtime);
4762
4763 return bgp_vty_return (vty, ret);
4764 }
4765
4766 static int
4767 peer_timers_unset_vty (struct vty *vty, const char *ip_str)
4768 {
4769 int ret;
4770 struct peer *peer;
4771
4772 peer = peer_lookup_vty (vty, ip_str);
4773 if (! peer)
4774 return CMD_WARNING;
4775
4776 ret = peer_timers_unset (peer);
4777
4778 return bgp_vty_return (vty, ret);
4779 }
4780
4781 DEFUN (neighbor_timers,
4782 neighbor_timers_cmd,
4783 NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4784 NEIGHBOR_STR
4785 NEIGHBOR_ADDR_STR2
4786 "BGP per neighbor timers\n"
4787 "Keepalive interval\n"
4788 "Holdtime\n")
4789 {
4790 return peer_timers_set_vty (vty, argv[0], argv[1], argv[2]);
4791 }
4792
4793 DEFUN (no_neighbor_timers,
4794 no_neighbor_timers_cmd,
4795 NO_NEIGHBOR_CMD2 "timers",
4796 NO_STR
4797 NEIGHBOR_STR
4798 NEIGHBOR_ADDR_STR2
4799 "BGP per neighbor timers\n")
4800 {
4801 return peer_timers_unset_vty (vty, argv[0]);
4802 }
4803
4804 ALIAS (no_neighbor_timers,
4805 no_neighbor_timers_val_cmd,
4806 NO_NEIGHBOR_CMD2 "timers <0-65535> <0-65535>",
4807 NO_STR
4808 NEIGHBOR_STR
4809 NEIGHBOR_ADDR_STR2
4810 "BGP per neighbor timers\n"
4811 "Keepalive interval\n"
4812 "Holdtime\n")
4813
4814 static int
4815 peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
4816 const char *time_str)
4817 {
4818 int ret;
4819 struct peer *peer;
4820 u_int32_t connect;
4821
4822 peer = peer_and_group_lookup_vty (vty, ip_str);
4823 if (! peer)
4824 return CMD_WARNING;
4825
4826 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
4827
4828 ret = peer_timers_connect_set (peer, connect);
4829
4830 return bgp_vty_return (vty, ret);
4831 }
4832
4833 static int
4834 peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
4835 {
4836 int ret;
4837 struct peer *peer;
4838
4839 peer = peer_and_group_lookup_vty (vty, ip_str);
4840 if (! peer)
4841 return CMD_WARNING;
4842
4843 ret = peer_timers_connect_unset (peer);
4844
4845 return bgp_vty_return (vty, ret);
4846 }
4847
4848 DEFUN (neighbor_timers_connect,
4849 neighbor_timers_connect_cmd,
4850 NEIGHBOR_CMD2 "timers connect <1-65535>",
4851 NEIGHBOR_STR
4852 NEIGHBOR_ADDR_STR2
4853 "BGP per neighbor timers\n"
4854 "BGP connect timer\n"
4855 "Connect timer\n")
4856 {
4857 return peer_timers_connect_set_vty (vty, argv[0], argv[1]);
4858 }
4859
4860 DEFUN (no_neighbor_timers_connect,
4861 no_neighbor_timers_connect_cmd,
4862 NO_NEIGHBOR_CMD2 "timers connect",
4863 NO_STR
4864 NEIGHBOR_STR
4865 NEIGHBOR_ADDR_STR2
4866 "BGP per neighbor timers\n"
4867 "BGP connect timer\n")
4868 {
4869 return peer_timers_connect_unset_vty (vty, argv[0]);
4870 }
4871
4872 ALIAS (no_neighbor_timers_connect,
4873 no_neighbor_timers_connect_val_cmd,
4874 NO_NEIGHBOR_CMD2 "timers connect <1-65535>",
4875 NO_STR
4876 NEIGHBOR_STR
4877 NEIGHBOR_ADDR_STR2
4878 "BGP per neighbor timers\n"
4879 "BGP connect timer\n"
4880 "Connect timer\n")
4881
4882 static int
4883 peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
4884 const char *time_str, int set)
4885 {
4886 int ret;
4887 struct peer *peer;
4888 u_int32_t routeadv = 0;
4889
4890 peer = peer_and_group_lookup_vty (vty, ip_str);
4891 if (! peer)
4892 return CMD_WARNING;
4893
4894 if (time_str)
4895 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
4896
4897 if (set)
4898 ret = peer_advertise_interval_set (peer, routeadv);
4899 else
4900 ret = peer_advertise_interval_unset (peer);
4901
4902 return bgp_vty_return (vty, ret);
4903 }
4904
4905 DEFUN (neighbor_advertise_interval,
4906 neighbor_advertise_interval_cmd,
4907 NEIGHBOR_CMD2 "advertisement-interval <0-600>",
4908 NEIGHBOR_STR
4909 NEIGHBOR_ADDR_STR2
4910 "Minimum interval between sending BGP routing updates\n"
4911 "time in seconds\n")
4912 {
4913 return peer_advertise_interval_vty (vty, argv[0], argv[1], 1);
4914 }
4915
4916 DEFUN (no_neighbor_advertise_interval,
4917 no_neighbor_advertise_interval_cmd,
4918 NO_NEIGHBOR_CMD2 "advertisement-interval",
4919 NO_STR
4920 NEIGHBOR_STR
4921 NEIGHBOR_ADDR_STR2
4922 "Minimum interval between sending BGP routing updates\n")
4923 {
4924 return peer_advertise_interval_vty (vty, argv[0], NULL, 0);
4925 }
4926
4927 ALIAS (no_neighbor_advertise_interval,
4928 no_neighbor_advertise_interval_val_cmd,
4929 NO_NEIGHBOR_CMD2 "advertisement-interval <0-600>",
4930 NO_STR
4931 NEIGHBOR_STR
4932 NEIGHBOR_ADDR_STR2
4933 "Minimum interval between sending BGP routing updates\n"
4934 "time in seconds\n")
4935
4936 /* Time to wait before processing route-map updates */
4937 DEFUN (bgp_set_route_map_delay_timer,
4938 bgp_set_route_map_delay_timer_cmd,
4939 "bgp route-map delay-timer <0-600>",
4940 SET_STR
4941 "BGP route-map delay timer\n"
4942 "Time in secs to wait before processing route-map changes\n"
4943 "0 disables the timer, no route updates happen when route-maps change\n")
4944 {
4945 u_int32_t rmap_delay_timer;
4946
4947 if (argv[0])
4948 {
4949 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
4950 bm->rmap_update_timer = rmap_delay_timer;
4951
4952 /* if the dynamic update handling is being disabled, and a timer is
4953 * running, stop the timer and act as if the timer has already fired.
4954 */
4955 if (!rmap_delay_timer && bm->t_rmap_update )
4956 {
4957 BGP_TIMER_OFF(bm->t_rmap_update);
4958 thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0);
4959 }
4960 return CMD_SUCCESS;
4961 }
4962 else
4963 return CMD_WARNING;
4964 }
4965
4966 DEFUN (no_bgp_set_route_map_delay_timer,
4967 no_bgp_set_route_map_delay_timer_cmd,
4968 "no bgp route-map delay-timer",
4969 NO_STR
4970 "Default BGP route-map delay timer\n"
4971 "Reset to default time to wait for processing route-map changes\n")
4972 {
4973
4974 bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
4975
4976 return CMD_SUCCESS;
4977 }
4978
4979 ALIAS (no_bgp_set_route_map_delay_timer,
4980 no_bgp_set_route_map_delay_timer_val_cmd,
4981 "no bgp route-map delay-timer <0-600>",
4982 NO_STR
4983 "Default BGP route-map delay timer\n"
4984 "Reset to default time to wait for processing route-map changes\n"
4985 "0 disables the timer, no route updates happen when route-maps change\n")
4986
4987 /* neighbor interface */
4988 static int
4989 peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
4990 {
4991 struct peer *peer;
4992
4993 peer = peer_lookup_vty (vty, ip_str);
4994 if (! peer || peer->conf_if)
4995 return CMD_WARNING;
4996
4997 if (str)
4998 peer_interface_set (peer, str);
4999 else
5000 peer_interface_unset (peer);
5001
5002 return CMD_SUCCESS;
5003 }
5004
5005 DEFUN (neighbor_interface,
5006 neighbor_interface_cmd,
5007 NEIGHBOR_CMD "interface WORD",
5008 NEIGHBOR_STR
5009 NEIGHBOR_ADDR_STR
5010 "Interface\n"
5011 "Interface name\n")
5012 {
5013 if (argc == 3)
5014 return peer_interface_vty (vty, argv[0], argv[1]);
5015 else
5016 return peer_interface_vty (vty, argv[0], argv[1]);
5017 }
5018
5019 DEFUN (no_neighbor_interface,
5020 no_neighbor_interface_cmd,
5021 NO_NEIGHBOR_CMD2 "interface WORD",
5022 NO_STR
5023 NEIGHBOR_STR
5024 NEIGHBOR_ADDR_STR
5025 "Interface\n"
5026 "Interface name\n")
5027 {
5028 return peer_interface_vty (vty, argv[0], NULL);
5029 }
5030
5031 /* Set distribute list to the peer. */
5032 static int
5033 peer_distribute_set_vty (struct vty *vty, const char *ip_str,
5034 afi_t afi, safi_t safi,
5035 const char *name_str, const char *direct_str)
5036 {
5037 int ret;
5038 struct peer *peer;
5039 int direct = FILTER_IN;
5040
5041 peer = peer_and_group_lookup_vty (vty, ip_str);
5042 if (! peer)
5043 return CMD_WARNING;
5044
5045 /* Check filter direction. */
5046 if (strncmp (direct_str, "i", 1) == 0)
5047 direct = FILTER_IN;
5048 else if (strncmp (direct_str, "o", 1) == 0)
5049 direct = FILTER_OUT;
5050
5051 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5052
5053 return bgp_vty_return (vty, ret);
5054 }
5055
5056 static int
5057 peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5058 safi_t safi, const char *direct_str)
5059 {
5060 int ret;
5061 struct peer *peer;
5062 int direct = FILTER_IN;
5063
5064 peer = peer_and_group_lookup_vty (vty, ip_str);
5065 if (! peer)
5066 return CMD_WARNING;
5067
5068 /* Check filter direction. */
5069 if (strncmp (direct_str, "i", 1) == 0)
5070 direct = FILTER_IN;
5071 else if (strncmp (direct_str, "o", 1) == 0)
5072 direct = FILTER_OUT;
5073
5074 ret = peer_distribute_unset (peer, afi, safi, direct);
5075
5076 return bgp_vty_return (vty, ret);
5077 }
5078
5079 DEFUN (neighbor_distribute_list,
5080 neighbor_distribute_list_cmd,
5081 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5082 NEIGHBOR_STR
5083 NEIGHBOR_ADDR_STR2
5084 "Filter updates to/from this neighbor\n"
5085 "IP access-list number\n"
5086 "IP access-list number (expanded range)\n"
5087 "IP Access-list name\n"
5088 "Filter incoming updates\n"
5089 "Filter outgoing updates\n")
5090 {
5091 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
5092 bgp_node_safi (vty), argv[1], argv[2]);
5093 }
5094
5095 DEFUN (no_neighbor_distribute_list,
5096 no_neighbor_distribute_list_cmd,
5097 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5098 NO_STR
5099 NEIGHBOR_STR
5100 NEIGHBOR_ADDR_STR2
5101 "Filter updates to/from this neighbor\n"
5102 "IP access-list number\n"
5103 "IP access-list number (expanded range)\n"
5104 "IP Access-list name\n"
5105 "Filter incoming updates\n"
5106 "Filter outgoing updates\n")
5107 {
5108 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
5109 bgp_node_safi (vty), argv[2]);
5110 }
5111
5112 /* Set prefix list to the peer. */
5113 static int
5114 peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5115 safi_t safi, const char *name_str,
5116 const char *direct_str)
5117 {
5118 int ret;
5119 struct peer *peer;
5120 int direct = FILTER_IN;
5121
5122 peer = peer_and_group_lookup_vty (vty, ip_str);
5123 if (! peer)
5124 return CMD_WARNING;
5125
5126 /* Check filter direction. */
5127 if (strncmp (direct_str, "i", 1) == 0)
5128 direct = FILTER_IN;
5129 else if (strncmp (direct_str, "o", 1) == 0)
5130 direct = FILTER_OUT;
5131
5132 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5133
5134 return bgp_vty_return (vty, ret);
5135 }
5136
5137 static int
5138 peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5139 safi_t safi, const char *direct_str)
5140 {
5141 int ret;
5142 struct peer *peer;
5143 int direct = FILTER_IN;
5144
5145 peer = peer_and_group_lookup_vty (vty, ip_str);
5146 if (! peer)
5147 return CMD_WARNING;
5148
5149 /* Check filter direction. */
5150 if (strncmp (direct_str, "i", 1) == 0)
5151 direct = FILTER_IN;
5152 else if (strncmp (direct_str, "o", 1) == 0)
5153 direct = FILTER_OUT;
5154
5155 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5156
5157 return bgp_vty_return (vty, ret);
5158 }
5159
5160 DEFUN (neighbor_prefix_list,
5161 neighbor_prefix_list_cmd,
5162 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5163 NEIGHBOR_STR
5164 NEIGHBOR_ADDR_STR2
5165 "Filter updates to/from this neighbor\n"
5166 "Name of a prefix list\n"
5167 "Filter incoming updates\n"
5168 "Filter outgoing updates\n")
5169 {
5170 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
5171 bgp_node_safi (vty), argv[1], argv[2]);
5172 }
5173
5174 DEFUN (no_neighbor_prefix_list,
5175 no_neighbor_prefix_list_cmd,
5176 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5177 NO_STR
5178 NEIGHBOR_STR
5179 NEIGHBOR_ADDR_STR2
5180 "Filter updates to/from this neighbor\n"
5181 "Name of a prefix list\n"
5182 "Filter incoming updates\n"
5183 "Filter outgoing updates\n")
5184 {
5185 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
5186 bgp_node_safi (vty), argv[2]);
5187 }
5188
5189 static int
5190 peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5191 afi_t afi, safi_t safi,
5192 const char *name_str, const char *direct_str)
5193 {
5194 int ret;
5195 struct peer *peer;
5196 int direct = FILTER_IN;
5197
5198 peer = peer_and_group_lookup_vty (vty, ip_str);
5199 if (! peer)
5200 return CMD_WARNING;
5201
5202 /* Check filter direction. */
5203 if (strncmp (direct_str, "i", 1) == 0)
5204 direct = FILTER_IN;
5205 else if (strncmp (direct_str, "o", 1) == 0)
5206 direct = FILTER_OUT;
5207
5208 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5209
5210 return bgp_vty_return (vty, ret);
5211 }
5212
5213 static int
5214 peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5215 afi_t afi, safi_t safi,
5216 const char *direct_str)
5217 {
5218 int ret;
5219 struct peer *peer;
5220 int direct = FILTER_IN;
5221
5222 peer = peer_and_group_lookup_vty (vty, ip_str);
5223 if (! peer)
5224 return CMD_WARNING;
5225
5226 /* Check filter direction. */
5227 if (strncmp (direct_str, "i", 1) == 0)
5228 direct = FILTER_IN;
5229 else if (strncmp (direct_str, "o", 1) == 0)
5230 direct = FILTER_OUT;
5231
5232 ret = peer_aslist_unset (peer, afi, safi, direct);
5233
5234 return bgp_vty_return (vty, ret);
5235 }
5236
5237 DEFUN (neighbor_filter_list,
5238 neighbor_filter_list_cmd,
5239 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5240 NEIGHBOR_STR
5241 NEIGHBOR_ADDR_STR2
5242 "Establish BGP filters\n"
5243 "AS path access-list name\n"
5244 "Filter incoming routes\n"
5245 "Filter outgoing routes\n")
5246 {
5247 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
5248 bgp_node_safi (vty), argv[1], argv[2]);
5249 }
5250
5251 DEFUN (no_neighbor_filter_list,
5252 no_neighbor_filter_list_cmd,
5253 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5254 NO_STR
5255 NEIGHBOR_STR
5256 NEIGHBOR_ADDR_STR2
5257 "Establish BGP filters\n"
5258 "AS path access-list name\n"
5259 "Filter incoming routes\n"
5260 "Filter outgoing routes\n")
5261 {
5262 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
5263 bgp_node_safi (vty), argv[2]);
5264 }
5265
5266 /* Set route-map to the peer. */
5267 static int
5268 peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5269 afi_t afi, safi_t safi,
5270 const char *name_str, const char *direct_str)
5271 {
5272 int ret;
5273 struct peer *peer;
5274 int direct = RMAP_IN;
5275
5276 peer = peer_and_group_lookup_vty (vty, ip_str);
5277 if (! peer)
5278 return CMD_WARNING;
5279
5280 /* Check filter direction. */
5281 if (strncmp (direct_str, "in", 2) == 0)
5282 direct = RMAP_IN;
5283 else if (strncmp (direct_str, "o", 1) == 0)
5284 direct = RMAP_OUT;
5285
5286 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5287
5288 return bgp_vty_return (vty, ret);
5289 }
5290
5291 static int
5292 peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5293 safi_t safi, const char *direct_str)
5294 {
5295 int ret;
5296 struct peer *peer;
5297 int direct = RMAP_IN;
5298
5299 peer = peer_and_group_lookup_vty (vty, ip_str);
5300 if (! peer)
5301 return CMD_WARNING;
5302
5303 /* Check filter direction. */
5304 if (strncmp (direct_str, "in", 2) == 0)
5305 direct = RMAP_IN;
5306 else if (strncmp (direct_str, "o", 1) == 0)
5307 direct = RMAP_OUT;
5308
5309 ret = peer_route_map_unset (peer, afi, safi, direct);
5310
5311 return bgp_vty_return (vty, ret);
5312 }
5313
5314 DEFUN (neighbor_route_map,
5315 neighbor_route_map_cmd,
5316 NEIGHBOR_CMD2 "route-map WORD (in|out)",
5317 NEIGHBOR_STR
5318 NEIGHBOR_ADDR_STR2
5319 "Apply route map to neighbor\n"
5320 "Name of route map\n"
5321 "Apply map to incoming routes\n"
5322 "Apply map to outbound routes\n")
5323 {
5324 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5325 bgp_node_safi (vty), argv[1], argv[2]);
5326 }
5327
5328 DEFUN (no_neighbor_route_map,
5329 no_neighbor_route_map_cmd,
5330 NO_NEIGHBOR_CMD2 "route-map WORD (in|out)",
5331 NO_STR
5332 NEIGHBOR_STR
5333 NEIGHBOR_ADDR_STR2
5334 "Apply route map to neighbor\n"
5335 "Name of route map\n"
5336 "Apply map to incoming routes\n"
5337 "Apply map to outbound routes\n")
5338 {
5339 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5340 bgp_node_safi (vty), argv[2]);
5341 }
5342
5343 /* Set unsuppress-map to the peer. */
5344 static int
5345 peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5346 safi_t safi, const char *name_str)
5347 {
5348 int ret;
5349 struct peer *peer;
5350
5351 peer = peer_and_group_lookup_vty (vty, ip_str);
5352 if (! peer)
5353 return CMD_WARNING;
5354
5355 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5356
5357 return bgp_vty_return (vty, ret);
5358 }
5359
5360 /* Unset route-map from the peer. */
5361 static int
5362 peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5363 safi_t safi)
5364 {
5365 int ret;
5366 struct peer *peer;
5367
5368 peer = peer_and_group_lookup_vty (vty, ip_str);
5369 if (! peer)
5370 return CMD_WARNING;
5371
5372 ret = peer_unsuppress_map_unset (peer, afi, safi);
5373
5374 return bgp_vty_return (vty, ret);
5375 }
5376
5377 DEFUN (neighbor_unsuppress_map,
5378 neighbor_unsuppress_map_cmd,
5379 NEIGHBOR_CMD2 "unsuppress-map WORD",
5380 NEIGHBOR_STR
5381 NEIGHBOR_ADDR_STR2
5382 "Route-map to selectively unsuppress suppressed routes\n"
5383 "Name of route map\n")
5384 {
5385 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5386 bgp_node_safi (vty), argv[1]);
5387 }
5388
5389 DEFUN (no_neighbor_unsuppress_map,
5390 no_neighbor_unsuppress_map_cmd,
5391 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
5392 NO_STR
5393 NEIGHBOR_STR
5394 NEIGHBOR_ADDR_STR2
5395 "Route-map to selectively unsuppress suppressed routes\n"
5396 "Name of route map\n")
5397 {
5398 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5399 bgp_node_safi (vty));
5400 }
5401
5402 static int
5403 peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5404 safi_t safi, const char *num_str,
5405 const char *threshold_str, int warning,
5406 const char *restart_str)
5407 {
5408 int ret;
5409 struct peer *peer;
5410 u_int32_t max;
5411 u_char threshold;
5412 u_int16_t restart;
5413
5414 peer = peer_and_group_lookup_vty (vty, ip_str);
5415 if (! peer)
5416 return CMD_WARNING;
5417
5418 VTY_GET_INTEGER ("maximum number", max, num_str);
5419 if (threshold_str)
5420 threshold = atoi (threshold_str);
5421 else
5422 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
5423
5424 if (restart_str)
5425 restart = atoi (restart_str);
5426 else
5427 restart = 0;
5428
5429 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
5430
5431 return bgp_vty_return (vty, ret);
5432 }
5433
5434 static int
5435 peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5436 safi_t safi)
5437 {
5438 int ret;
5439 struct peer *peer;
5440
5441 peer = peer_and_group_lookup_vty (vty, ip_str);
5442 if (! peer)
5443 return CMD_WARNING;
5444
5445 ret = peer_maximum_prefix_unset (peer, afi, safi);
5446
5447 return bgp_vty_return (vty, ret);
5448 }
5449
5450 /* Maximum number of prefix configuration. prefix count is different
5451 for each peer configuration. So this configuration can be set for
5452 each peer configuration. */
5453 DEFUN (neighbor_maximum_prefix,
5454 neighbor_maximum_prefix_cmd,
5455 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5456 NEIGHBOR_STR
5457 NEIGHBOR_ADDR_STR2
5458 "Maximum number of prefix accept from this peer\n"
5459 "maximum no. of prefix limit\n")
5460 {
5461 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5462 bgp_node_safi (vty), argv[1], NULL, 0,
5463 NULL);
5464 }
5465
5466 DEFUN (neighbor_maximum_prefix_threshold,
5467 neighbor_maximum_prefix_threshold_cmd,
5468 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5469 NEIGHBOR_STR
5470 NEIGHBOR_ADDR_STR2
5471 "Maximum number of prefix accept from this peer\n"
5472 "maximum no. of prefix limit\n"
5473 "Threshold value (%) at which to generate a warning msg\n")
5474 {
5475 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5476 bgp_node_safi (vty), argv[1], argv[2], 0,
5477 NULL);
5478 }
5479
5480 DEFUN (neighbor_maximum_prefix_warning,
5481 neighbor_maximum_prefix_warning_cmd,
5482 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5483 NEIGHBOR_STR
5484 NEIGHBOR_ADDR_STR2
5485 "Maximum number of prefix accept from this peer\n"
5486 "maximum no. of prefix limit\n"
5487 "Only give warning message when limit is exceeded\n")
5488 {
5489 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5490 bgp_node_safi (vty), argv[1], NULL, 1,
5491 NULL);
5492 }
5493
5494 DEFUN (neighbor_maximum_prefix_threshold_warning,
5495 neighbor_maximum_prefix_threshold_warning_cmd,
5496 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5497 NEIGHBOR_STR
5498 NEIGHBOR_ADDR_STR2
5499 "Maximum number of prefix accept from this peer\n"
5500 "maximum no. of prefix limit\n"
5501 "Threshold value (%) at which to generate a warning msg\n"
5502 "Only give warning message when limit is exceeded\n")
5503 {
5504 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5505 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5506 }
5507
5508 DEFUN (neighbor_maximum_prefix_restart,
5509 neighbor_maximum_prefix_restart_cmd,
5510 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5511 NEIGHBOR_STR
5512 NEIGHBOR_ADDR_STR2
5513 "Maximum number of prefix accept from this peer\n"
5514 "maximum no. of prefix limit\n"
5515 "Restart bgp connection after limit is exceeded\n"
5516 "Restart interval in minutes")
5517 {
5518 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5519 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5520 }
5521
5522 DEFUN (neighbor_maximum_prefix_threshold_restart,
5523 neighbor_maximum_prefix_threshold_restart_cmd,
5524 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
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 "Restart bgp connection after limit is exceeded\n"
5531 "Restart interval in minutes")
5532 {
5533 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5534 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5535 }
5536
5537 DEFUN (no_neighbor_maximum_prefix,
5538 no_neighbor_maximum_prefix_cmd,
5539 NO_NEIGHBOR_CMD2 "maximum-prefix",
5540 NO_STR
5541 NEIGHBOR_STR
5542 NEIGHBOR_ADDR_STR2
5543 "Maximum number of prefix accept from this peer\n")
5544 {
5545 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5546 bgp_node_safi (vty));
5547 }
5548
5549 ALIAS (no_neighbor_maximum_prefix,
5550 no_neighbor_maximum_prefix_val_cmd,
5551 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5552 NO_STR
5553 NEIGHBOR_STR
5554 NEIGHBOR_ADDR_STR2
5555 "Maximum number of prefix accept from this peer\n"
5556 "maximum no. of prefix limit\n")
5557
5558 ALIAS (no_neighbor_maximum_prefix,
5559 no_neighbor_maximum_prefix_threshold_cmd,
5560 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5561 NO_STR
5562 NEIGHBOR_STR
5563 NEIGHBOR_ADDR_STR2
5564 "Maximum number of prefix accept from this peer\n"
5565 "maximum no. of prefix limit\n"
5566 "Threshold value (%) at which to generate a warning msg\n")
5567
5568 ALIAS (no_neighbor_maximum_prefix,
5569 no_neighbor_maximum_prefix_warning_cmd,
5570 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5571 NO_STR
5572 NEIGHBOR_STR
5573 NEIGHBOR_ADDR_STR2
5574 "Maximum number of prefix accept from this peer\n"
5575 "maximum no. of prefix limit\n"
5576 "Only give warning message when limit is exceeded\n")
5577
5578 ALIAS (no_neighbor_maximum_prefix,
5579 no_neighbor_maximum_prefix_threshold_warning_cmd,
5580 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5581 NO_STR
5582 NEIGHBOR_STR
5583 NEIGHBOR_ADDR_STR2
5584 "Maximum number of prefix accept from this peer\n"
5585 "maximum no. of prefix limit\n"
5586 "Threshold value (%) at which to generate a warning msg\n"
5587 "Only give warning message when limit is exceeded\n")
5588
5589 ALIAS (no_neighbor_maximum_prefix,
5590 no_neighbor_maximum_prefix_restart_cmd,
5591 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5592 NO_STR
5593 NEIGHBOR_STR
5594 NEIGHBOR_ADDR_STR2
5595 "Maximum number of prefix accept from this peer\n"
5596 "maximum no. of prefix limit\n"
5597 "Restart bgp connection after limit is exceeded\n"
5598 "Restart interval in minutes")
5599
5600 ALIAS (no_neighbor_maximum_prefix,
5601 no_neighbor_maximum_prefix_threshold_restart_cmd,
5602 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5603 NO_STR
5604 NEIGHBOR_STR
5605 NEIGHBOR_ADDR_STR2
5606 "Maximum number of prefix accept from this peer\n"
5607 "maximum no. of prefix limit\n"
5608 "Threshold value (%) at which to generate a warning msg\n"
5609 "Restart bgp connection after limit is exceeded\n"
5610 "Restart interval in minutes")
5611
5612 /* "neighbor allowas-in" */
5613 DEFUN (neighbor_allowas_in,
5614 neighbor_allowas_in_cmd,
5615 NEIGHBOR_CMD2 "allowas-in",
5616 NEIGHBOR_STR
5617 NEIGHBOR_ADDR_STR2
5618 "Accept as-path with my AS present in it\n")
5619 {
5620 int ret;
5621 struct peer *peer;
5622 unsigned int allow_num;
5623
5624 peer = peer_and_group_lookup_vty (vty, argv[0]);
5625 if (! peer)
5626 return CMD_WARNING;
5627
5628 if (argc == 1)
5629 allow_num = 3;
5630 else
5631 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5632
5633 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5634 allow_num);
5635
5636 return bgp_vty_return (vty, ret);
5637 }
5638
5639 ALIAS (neighbor_allowas_in,
5640 neighbor_allowas_in_arg_cmd,
5641 NEIGHBOR_CMD2 "allowas-in <1-10>",
5642 NEIGHBOR_STR
5643 NEIGHBOR_ADDR_STR2
5644 "Accept as-path with my AS present in it\n"
5645 "Number of occurances of AS number\n")
5646
5647 DEFUN (no_neighbor_allowas_in,
5648 no_neighbor_allowas_in_cmd,
5649 NO_NEIGHBOR_CMD2 "allowas-in",
5650 NO_STR
5651 NEIGHBOR_STR
5652 NEIGHBOR_ADDR_STR2
5653 "allow local ASN appears in aspath attribute\n")
5654 {
5655 int ret;
5656 struct peer *peer;
5657
5658 peer = peer_and_group_lookup_vty (vty, argv[0]);
5659 if (! peer)
5660 return CMD_WARNING;
5661
5662 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5663
5664 return bgp_vty_return (vty, ret);
5665 }
5666
5667 ALIAS (no_neighbor_allowas_in,
5668 no_neighbor_allowas_in_val_cmd,
5669 NO_NEIGHBOR_CMD2 "allowas-in <1-10>",
5670 NO_STR
5671 NEIGHBOR_STR
5672 NEIGHBOR_ADDR_STR2
5673 "allow local ASN appears in aspath attribute\n"
5674 "Number of occurances of AS number\n")
5675
5676 DEFUN (neighbor_ttl_security,
5677 neighbor_ttl_security_cmd,
5678 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5679 NEIGHBOR_STR
5680 NEIGHBOR_ADDR_STR2
5681 "Specify the maximum number of hops to the BGP peer\n")
5682 {
5683 struct peer *peer;
5684 int gtsm_hops;
5685
5686 peer = peer_and_group_lookup_vty (vty, argv[0]);
5687 if (! peer)
5688 return CMD_WARNING;
5689
5690 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5691
5692 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
5693 }
5694
5695 DEFUN (no_neighbor_ttl_security,
5696 no_neighbor_ttl_security_cmd,
5697 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5698 NO_STR
5699 NEIGHBOR_STR
5700 NEIGHBOR_ADDR_STR2
5701 "Specify the maximum number of hops to the BGP peer\n")
5702 {
5703 struct peer *peer;
5704
5705 peer = peer_and_group_lookup_vty (vty, argv[0]);
5706 if (! peer)
5707 return CMD_WARNING;
5708
5709 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
5710 }
5711
5712 DEFUN (neighbor_addpath_tx_all_paths,
5713 neighbor_addpath_tx_all_paths_cmd,
5714 NEIGHBOR_CMD2 "addpath-tx-all-paths",
5715 NEIGHBOR_STR
5716 NEIGHBOR_ADDR_STR2
5717 "Use addpath to advertise all paths to a neighbor\n")
5718 {
5719 struct peer *peer;
5720
5721 peer = peer_and_group_lookup_vty (vty, argv[0]);
5722 if (! peer)
5723 return CMD_WARNING;
5724
5725 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5726 bgp_node_safi (vty),
5727 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5728 }
5729
5730 DEFUN (no_neighbor_addpath_tx_all_paths,
5731 no_neighbor_addpath_tx_all_paths_cmd,
5732 NO_NEIGHBOR_CMD2 "addpath-tx-all-paths",
5733 NO_STR
5734 NEIGHBOR_STR
5735 NEIGHBOR_ADDR_STR2
5736 "Use addpath to advertise all paths to a neighbor\n")
5737 {
5738 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5739 bgp_node_safi (vty),
5740 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5741 }
5742
5743 DEFUN (neighbor_addpath_tx_bestpath_per_as,
5744 neighbor_addpath_tx_bestpath_per_as_cmd,
5745 NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5746 NEIGHBOR_STR
5747 NEIGHBOR_ADDR_STR2
5748 "Use addpath to advertise the bestpath per each neighboring AS\n")
5749 {
5750 struct peer *peer;
5751
5752 peer = peer_and_group_lookup_vty (vty, argv[0]);
5753 if (! peer)
5754 return CMD_WARNING;
5755
5756 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5757 bgp_node_safi (vty),
5758 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5759 }
5760
5761 DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
5762 no_neighbor_addpath_tx_bestpath_per_as_cmd,
5763 NO_NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5764 NO_STR
5765 NEIGHBOR_STR
5766 NEIGHBOR_ADDR_STR2
5767 "Use addpath to advertise the bestpath per each neighboring AS\n")
5768 {
5769 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5770 bgp_node_safi (vty),
5771 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5772 }
5773
5774
5775 /* Address family configuration. */
5776 DEFUN (address_family_ipv4,
5777 address_family_ipv4_cmd,
5778 "address-family ipv4",
5779 "Enter Address Family command mode\n"
5780 "Address family\n")
5781 {
5782 vty->node = BGP_IPV4_NODE;
5783 return CMD_SUCCESS;
5784 }
5785
5786 DEFUN (address_family_ipv4_safi,
5787 address_family_ipv4_safi_cmd,
5788 "address-family ipv4 (unicast|multicast)",
5789 "Enter Address Family command mode\n"
5790 "Address family\n"
5791 "Address Family modifier\n"
5792 "Address Family modifier\n")
5793 {
5794 if (strncmp (argv[0], "m", 1) == 0)
5795 vty->node = BGP_IPV4M_NODE;
5796 else
5797 vty->node = BGP_IPV4_NODE;
5798
5799 return CMD_SUCCESS;
5800 }
5801
5802 DEFUN (address_family_ipv6,
5803 address_family_ipv6_cmd,
5804 "address-family ipv6",
5805 "Enter Address Family command mode\n"
5806 "Address family\n")
5807 {
5808 vty->node = BGP_IPV6_NODE;
5809 return CMD_SUCCESS;
5810 }
5811
5812 DEFUN (address_family_ipv6_safi,
5813 address_family_ipv6_safi_cmd,
5814 "address-family ipv6 (unicast|multicast)",
5815 "Enter Address Family command mode\n"
5816 "Address family\n"
5817 "Address Family modifier\n"
5818 "Address Family modifier\n")
5819 {
5820 if (strncmp (argv[0], "m", 1) == 0)
5821 vty->node = BGP_IPV6M_NODE;
5822 else
5823 vty->node = BGP_IPV6_NODE;
5824
5825 return CMD_SUCCESS;
5826 }
5827
5828 DEFUN (address_family_vpnv4,
5829 address_family_vpnv4_cmd,
5830 "address-family vpnv4",
5831 "Enter Address Family command mode\n"
5832 "Address family\n")
5833 {
5834 vty->node = BGP_VPNV4_NODE;
5835 return CMD_SUCCESS;
5836 }
5837
5838 ALIAS (address_family_vpnv4,
5839 address_family_vpnv4_unicast_cmd,
5840 "address-family vpnv4 unicast",
5841 "Enter Address Family command mode\n"
5842 "Address family\n"
5843 "Address Family Modifier\n")
5844
5845 DEFUN (exit_address_family,
5846 exit_address_family_cmd,
5847 "exit-address-family",
5848 "Exit from Address Family configuration mode\n")
5849 {
5850 if (vty->node == BGP_IPV4_NODE
5851 || vty->node == BGP_IPV4M_NODE
5852 || vty->node == BGP_VPNV4_NODE
5853 || vty->node == BGP_IPV6_NODE
5854 || vty->node == BGP_IPV6M_NODE)
5855 vty->node = BGP_NODE;
5856 return CMD_SUCCESS;
5857 }
5858
5859 /* Recalculate bestpath and re-advertise a prefix */
5860 static int
5861 bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str,
5862 afi_t afi, safi_t safi, struct prefix_rd *prd)
5863 {
5864 int ret;
5865 struct prefix match;
5866 struct bgp_node *rn;
5867 struct bgp_node *rm;
5868 struct bgp *bgp;
5869 struct bgp_table *table;
5870 struct bgp_table *rib;
5871
5872 /* BGP structure lookup. */
5873 if (view_name)
5874 {
5875 bgp = bgp_lookup_by_name (view_name);
5876 if (bgp == NULL)
5877 {
5878 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
5879 return CMD_WARNING;
5880 }
5881 }
5882 else
5883 {
5884 bgp = bgp_get_default ();
5885 if (bgp == NULL)
5886 {
5887 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
5888 return CMD_WARNING;
5889 }
5890 }
5891
5892 /* Check IP address argument. */
5893 ret = str2prefix (ip_str, &match);
5894 if (! ret)
5895 {
5896 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
5897 return CMD_WARNING;
5898 }
5899
5900 match.family = afi2family (afi);
5901 rib = bgp->rib[afi][safi];
5902
5903 if (safi == SAFI_MPLS_VPN)
5904 {
5905 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
5906 {
5907 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5908 continue;
5909
5910 if ((table = rn->info) != NULL)
5911 {
5912 if ((rm = bgp_node_match (table, &match)) != NULL)
5913 {
5914 if (rm->p.prefixlen == match.prefixlen)
5915 {
5916 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5917 bgp_process (bgp, rm, afi, safi);
5918 }
5919 bgp_unlock_node (rm);
5920 }
5921 }
5922 }
5923 }
5924 else
5925 {
5926 if ((rn = bgp_node_match (rib, &match)) != NULL)
5927 {
5928 if (rn->p.prefixlen == match.prefixlen)
5929 {
5930 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5931 bgp_process (bgp, rn, afi, safi);
5932 }
5933 bgp_unlock_node (rn);
5934 }
5935 }
5936
5937 return CMD_SUCCESS;
5938 }
5939
5940 DEFUN (clear_ip_bgp_all,
5941 clear_ip_bgp_all_cmd,
5942 "clear ip bgp *",
5943 CLEAR_STR
5944 IP_STR
5945 BGP_STR
5946 "Clear all peers\n")
5947 {
5948 if (argc == 2)
5949 return bgp_clear_vty (vty, argv[1], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5950
5951 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5952 }
5953
5954 ALIAS (clear_ip_bgp_all,
5955 clear_ip_bgp_instance_all_cmd,
5956 "clear ip bgp " BGP_INSTANCE_CMD " *",
5957 CLEAR_STR
5958 IP_STR
5959 BGP_STR
5960 BGP_INSTANCE_HELP_STR
5961 "Clear all peers\n")
5962
5963 ALIAS (clear_ip_bgp_all,
5964 clear_bgp_all_cmd,
5965 "clear bgp *",
5966 CLEAR_STR
5967 BGP_STR
5968 "Clear all peers\n")
5969
5970 ALIAS (clear_ip_bgp_all,
5971 clear_bgp_instance_all_cmd,
5972 "clear bgp " BGP_INSTANCE_CMD " *",
5973 CLEAR_STR
5974 BGP_STR
5975 BGP_INSTANCE_HELP_STR
5976 "Clear all peers\n")
5977
5978 ALIAS (clear_ip_bgp_all,
5979 clear_bgp_ipv6_all_cmd,
5980 "clear bgp ipv6 *",
5981 CLEAR_STR
5982 BGP_STR
5983 "Address family\n"
5984 "Clear all peers\n")
5985
5986 ALIAS (clear_ip_bgp_all,
5987 clear_bgp_instance_ipv6_all_cmd,
5988 "clear bgp " BGP_INSTANCE_CMD " ipv6 *",
5989 CLEAR_STR
5990 BGP_STR
5991 BGP_INSTANCE_HELP_STR
5992 "Address family\n"
5993 "Clear all peers\n")
5994
5995 DEFUN (clear_ip_bgp_peer,
5996 clear_ip_bgp_peer_cmd,
5997 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
5998 CLEAR_STR
5999 IP_STR
6000 BGP_STR
6001 "BGP neighbor IP address to clear\n"
6002 "BGP IPv6 neighbor to clear\n"
6003 "BGP neighbor on interface to clear\n")
6004 {
6005 if (argc == 3)
6006 return bgp_clear_vty (vty, argv[1], 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[2]);
6007
6008 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
6009 }
6010
6011 ALIAS (clear_ip_bgp_peer,
6012 clear_ip_bgp_instance_peer_cmd,
6013 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6014 CLEAR_STR
6015 IP_STR
6016 BGP_STR
6017 BGP_INSTANCE_HELP_STR
6018 "BGP neighbor IP address to clear\n"
6019 "BGP IPv6 neighbor to clear\n"
6020 "BGP neighbor on interface to clear\n")
6021
6022 ALIAS (clear_ip_bgp_peer,
6023 clear_bgp_peer_cmd,
6024 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
6025 CLEAR_STR
6026 BGP_STR
6027 "BGP neighbor address to clear\n"
6028 "BGP IPv6 neighbor to clear\n"
6029 "BGP neighbor on interface to clear\n")
6030
6031 ALIAS (clear_ip_bgp_peer,
6032 clear_bgp_instance_peer_cmd,
6033 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD)",
6034 CLEAR_STR
6035 BGP_STR
6036 BGP_INSTANCE_HELP_STR
6037 "BGP neighbor IP address to clear\n"
6038 "BGP IPv6 neighbor to clear\n"
6039 "BGP neighbor on interface to clear\n")
6040
6041 ALIAS (clear_ip_bgp_peer,
6042 clear_bgp_ipv6_peer_cmd,
6043 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
6044 CLEAR_STR
6045 BGP_STR
6046 "Address family\n"
6047 "BGP neighbor address to clear\n"
6048 "BGP IPv6 neighbor to clear\n"
6049 "BGP neighbor on interface to clear\n")
6050
6051 ALIAS (clear_ip_bgp_peer,
6052 clear_bgp_instance_ipv6_peer_cmd,
6053 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD)",
6054 CLEAR_STR
6055 BGP_STR
6056 BGP_INSTANCE_HELP_STR
6057 "Address family\n"
6058 "BGP neighbor IP address to clear\n"
6059 "BGP IPv6 neighbor to clear\n"
6060 "BGP neighbor on interface to clear\n")
6061
6062 DEFUN (clear_ip_bgp_peer_group,
6063 clear_ip_bgp_peer_group_cmd,
6064 "clear ip bgp peer-group WORD",
6065 CLEAR_STR
6066 IP_STR
6067 BGP_STR
6068 "Clear all members of peer-group\n"
6069 "BGP peer-group name\n")
6070 {
6071 if (argc == 3)
6072 return bgp_clear_vty (vty, argv[1], 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[2]);
6073
6074 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
6075 }
6076
6077 ALIAS (clear_ip_bgp_peer_group,
6078 clear_ip_bgp_instance_peer_group_cmd,
6079 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
6080 CLEAR_STR
6081 IP_STR
6082 BGP_STR
6083 BGP_INSTANCE_HELP_STR
6084 "Clear all members of peer-group\n"
6085 "BGP peer-group name\n")
6086
6087 ALIAS (clear_ip_bgp_peer_group,
6088 clear_bgp_peer_group_cmd,
6089 "clear bgp peer-group WORD",
6090 CLEAR_STR
6091 BGP_STR
6092 "Clear all members of peer-group\n"
6093 "BGP peer-group name\n")
6094
6095 ALIAS (clear_ip_bgp_peer_group,
6096 clear_bgp_instance_peer_group_cmd,
6097 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD",
6098 CLEAR_STR
6099 BGP_STR
6100 BGP_INSTANCE_HELP_STR
6101 "Clear all members of peer-group\n"
6102 "BGP peer-group name\n")
6103
6104 ALIAS (clear_ip_bgp_peer_group,
6105 clear_bgp_ipv6_peer_group_cmd,
6106 "clear bgp ipv6 peer-group WORD",
6107 CLEAR_STR
6108 BGP_STR
6109 "Address family\n"
6110 "Clear all members of peer-group\n"
6111 "BGP peer-group name\n")
6112
6113 ALIAS (clear_ip_bgp_peer_group,
6114 clear_bgp_instance_ipv6_peer_group_cmd,
6115 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD",
6116 CLEAR_STR
6117 BGP_STR
6118 BGP_INSTANCE_HELP_STR
6119 "Address family\n"
6120 "Clear all members of peer-group\n"
6121 "BGP peer-group name\n")
6122
6123 DEFUN (clear_ip_bgp_external,
6124 clear_ip_bgp_external_cmd,
6125 "clear ip bgp external",
6126 CLEAR_STR
6127 IP_STR
6128 BGP_STR
6129 "Clear all external peers\n")
6130 {
6131 if (argc == 2)
6132 return bgp_clear_vty (vty, argv[1], 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6133
6134 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6135 }
6136
6137 ALIAS (clear_ip_bgp_external,
6138 clear_ip_bgp_instance_external_cmd,
6139 "clear ip bgp " BGP_INSTANCE_CMD " external",
6140 CLEAR_STR
6141 IP_STR
6142 BGP_STR
6143 BGP_INSTANCE_HELP_STR
6144 "Clear all external peers\n")
6145
6146 ALIAS (clear_ip_bgp_external,
6147 clear_bgp_external_cmd,
6148 "clear bgp external",
6149 CLEAR_STR
6150 BGP_STR
6151 "Clear all external peers\n")
6152
6153 ALIAS (clear_ip_bgp_external,
6154 clear_bgp_instance_external_cmd,
6155 "clear bgp " BGP_INSTANCE_CMD " external",
6156 CLEAR_STR
6157 BGP_STR
6158 BGP_INSTANCE_HELP_STR
6159 "Clear all external peers\n")
6160
6161 ALIAS (clear_ip_bgp_external,
6162 clear_bgp_ipv6_external_cmd,
6163 "clear bgp ipv6 external",
6164 CLEAR_STR
6165 BGP_STR
6166 "Address family\n"
6167 "Clear all external peers\n")
6168
6169 ALIAS (clear_ip_bgp_external,
6170 clear_bgp_instance_ipv6_external_cmd,
6171 "clear bgp " BGP_INSTANCE_CMD " ipv6 external",
6172 CLEAR_STR
6173 BGP_STR
6174 BGP_INSTANCE_HELP_STR
6175 "Address family\n"
6176 "Clear all external peers\n")
6177
6178 DEFUN (clear_ip_bgp_prefix,
6179 clear_ip_bgp_prefix_cmd,
6180 "clear ip bgp prefix A.B.C.D/M",
6181 CLEAR_STR
6182 IP_STR
6183 BGP_STR
6184 "Clear bestpath and re-advertise\n"
6185 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6186 {
6187 if (argc == 3)
6188 return bgp_clear_prefix (vty, argv[1], argv[2], AFI_IP, SAFI_UNICAST, NULL);
6189
6190 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
6191 }
6192
6193 ALIAS (clear_ip_bgp_prefix,
6194 clear_ip_bgp_instance_prefix_cmd,
6195 "clear ip bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6196 CLEAR_STR
6197 IP_STR
6198 BGP_STR
6199 BGP_INSTANCE_HELP_STR
6200 "Clear bestpath and re-advertise\n"
6201 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6202
6203 ALIAS (clear_ip_bgp_prefix,
6204 clear_bgp_prefix_cmd,
6205 "clear bgp prefix A.B.C.D/M",
6206 CLEAR_STR
6207 BGP_STR
6208 "Clear bestpath and re-advertise\n"
6209 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6210
6211 ALIAS (clear_ip_bgp_prefix,
6212 clear_bgp_instance_prefix_cmd,
6213 "clear bgp " BGP_INSTANCE_CMD " prefix A.B.C.D/M",
6214 CLEAR_STR
6215 BGP_STR
6216 BGP_INSTANCE_HELP_STR
6217 "Clear bestpath and re-advertise\n"
6218 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6219
6220 DEFUN (clear_ip_bgp_as,
6221 clear_ip_bgp_as_cmd,
6222 "clear ip bgp " CMD_AS_RANGE,
6223 CLEAR_STR
6224 IP_STR
6225 BGP_STR
6226 "Clear peers with the AS number\n")
6227 {
6228 if (argc == 3)
6229 return bgp_clear_vty (vty, argv[1], 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[2]);
6230
6231 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
6232 }
6233
6234 ALIAS (clear_ip_bgp_as,
6235 clear_ip_bgp_instance_as_cmd,
6236 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6237 CLEAR_STR
6238 IP_STR
6239 BGP_STR
6240 BGP_INSTANCE_HELP_STR
6241 "Clear peers with the AS number\n")
6242
6243 ALIAS (clear_ip_bgp_as,
6244 clear_bgp_as_cmd,
6245 "clear bgp " CMD_AS_RANGE,
6246 CLEAR_STR
6247 BGP_STR
6248 "Clear peers with the AS number\n")
6249
6250 ALIAS (clear_ip_bgp_as,
6251 clear_bgp_instance_as_cmd,
6252 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE,
6253 CLEAR_STR
6254 BGP_STR
6255 BGP_INSTANCE_HELP_STR
6256 "Clear peers with the AS number\n")
6257
6258 ALIAS (clear_ip_bgp_as,
6259 clear_bgp_ipv6_as_cmd,
6260 "clear bgp ipv6 " CMD_AS_RANGE,
6261 CLEAR_STR
6262 BGP_STR
6263 "Address family\n"
6264 "Clear peers with the AS number\n")
6265
6266 ALIAS (clear_ip_bgp_as,
6267 clear_bgp_instance_ipv6_as_cmd,
6268 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE,
6269 CLEAR_STR
6270 BGP_STR
6271 BGP_INSTANCE_HELP_STR
6272 "Address family\n"
6273 "Clear peers with the AS number\n")
6274
6275 /* Outbound soft-reconfiguration */
6276 DEFUN (clear_ip_bgp_all_soft_out,
6277 clear_ip_bgp_all_soft_out_cmd,
6278 "clear ip bgp * soft out",
6279 CLEAR_STR
6280 IP_STR
6281 BGP_STR
6282 "Clear all peers\n"
6283 BGP_SOFT_STR
6284 BGP_SOFT_OUT_STR)
6285 {
6286 if (argc == 2)
6287 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6288 BGP_CLEAR_SOFT_OUT, NULL);
6289
6290 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6291 BGP_CLEAR_SOFT_OUT, NULL);
6292 }
6293
6294 ALIAS (clear_ip_bgp_all_soft_out,
6295 clear_ip_bgp_instance_all_soft_out_cmd,
6296 "clear ip bgp " BGP_INSTANCE_CMD " * soft out",
6297 CLEAR_STR
6298 IP_STR
6299 BGP_STR
6300 BGP_INSTANCE_HELP_STR
6301 "Clear all peers\n"
6302 BGP_SOFT_STR
6303 BGP_SOFT_OUT_STR)
6304
6305 ALIAS (clear_ip_bgp_all_soft_out,
6306 clear_ip_bgp_all_out_cmd,
6307 "clear ip bgp * out",
6308 CLEAR_STR
6309 IP_STR
6310 BGP_STR
6311 "Clear all peers\n"
6312 BGP_SOFT_OUT_STR)
6313
6314 ALIAS (clear_ip_bgp_all_soft_out,
6315 clear_ip_bgp_instance_all_out_cmd,
6316 "clear ip bgp " BGP_INSTANCE_CMD " * out",
6317 CLEAR_STR
6318 IP_STR
6319 BGP_STR
6320 BGP_INSTANCE_HELP_STR
6321 "Clear all peers\n"
6322 BGP_SOFT_OUT_STR)
6323
6324 DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6325 clear_ip_bgp_all_ipv4_soft_out_cmd,
6326 "clear ip bgp * ipv4 (unicast|multicast) soft out",
6327 CLEAR_STR
6328 IP_STR
6329 BGP_STR
6330 "Clear all peers\n"
6331 "Address family\n"
6332 "Address Family modifier\n"
6333 "Address Family modifier\n"
6334 BGP_SOFT_STR
6335 BGP_SOFT_OUT_STR)
6336 {
6337 if (strncmp (argv[0], "m", 1) == 0)
6338 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6339 BGP_CLEAR_SOFT_OUT, NULL);
6340
6341 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6342 BGP_CLEAR_SOFT_OUT, NULL);
6343 }
6344
6345 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6346 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
6347 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out",
6348 CLEAR_STR
6349 IP_STR
6350 BGP_STR
6351 BGP_INSTANCE_HELP_STR
6352 "Clear all peers\n"
6353 "Address family\n"
6354 "Address Family modifier\n"
6355 "Address Family modifier\n"
6356 BGP_SOFT_OUT_STR)
6357 {
6358 if (strncmp (argv[2], "m", 1) == 0)
6359 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
6360 BGP_CLEAR_SOFT_OUT, NULL);
6361
6362 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6363 BGP_CLEAR_SOFT_OUT, NULL);
6364 }
6365
6366 ALIAS (clear_ip_bgp_all_ipv4_soft_out,
6367 clear_ip_bgp_all_ipv4_out_cmd,
6368 "clear ip bgp * ipv4 (unicast|multicast) out",
6369 CLEAR_STR
6370 IP_STR
6371 BGP_STR
6372 "Clear all peers\n"
6373 "Address family\n"
6374 "Address Family modifier\n"
6375 "Address Family modifier\n"
6376 BGP_SOFT_OUT_STR)
6377
6378 ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out,
6379 clear_ip_bgp_instance_all_ipv4_out_cmd,
6380 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) out",
6381 CLEAR_STR
6382 IP_STR
6383 BGP_STR
6384 BGP_INSTANCE_HELP_STR
6385 "Clear all peers\n"
6386 "Address family\n"
6387 "Address Family modifier\n"
6388 "Address Family modifier\n"
6389 BGP_SOFT_OUT_STR)
6390
6391 DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
6392 clear_ip_bgp_all_vpnv4_soft_out_cmd,
6393 "clear ip bgp * vpnv4 unicast soft out",
6394 CLEAR_STR
6395 IP_STR
6396 BGP_STR
6397 "Clear all peers\n"
6398 "Address family\n"
6399 "Address Family Modifier\n"
6400 BGP_SOFT_STR
6401 BGP_SOFT_OUT_STR)
6402 {
6403 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6404 BGP_CLEAR_SOFT_OUT, NULL);
6405 }
6406
6407 ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
6408 clear_ip_bgp_all_vpnv4_out_cmd,
6409 "clear ip bgp * vpnv4 unicast out",
6410 CLEAR_STR
6411 IP_STR
6412 BGP_STR
6413 "Clear all peers\n"
6414 "Address family\n"
6415 "Address Family Modifier\n"
6416 BGP_SOFT_OUT_STR)
6417
6418 DEFUN (clear_bgp_all_soft_out,
6419 clear_bgp_all_soft_out_cmd,
6420 "clear bgp * soft out",
6421 CLEAR_STR
6422 BGP_STR
6423 "Clear all peers\n"
6424 BGP_SOFT_STR
6425 BGP_SOFT_OUT_STR)
6426 {
6427 if (argc == 2)
6428 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
6429 BGP_CLEAR_SOFT_OUT, NULL);
6430
6431 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6432 BGP_CLEAR_SOFT_OUT, NULL);
6433 }
6434
6435 ALIAS (clear_bgp_all_soft_out,
6436 clear_bgp_instance_all_soft_out_cmd,
6437 "clear bgp " BGP_INSTANCE_CMD " * soft out",
6438 CLEAR_STR
6439 BGP_STR
6440 BGP_INSTANCE_HELP_STR
6441 "Clear all peers\n"
6442 BGP_SOFT_STR
6443 BGP_SOFT_OUT_STR)
6444
6445 ALIAS (clear_bgp_all_soft_out,
6446 clear_bgp_all_out_cmd,
6447 "clear bgp * out",
6448 CLEAR_STR
6449 BGP_STR
6450 "Clear all peers\n"
6451 BGP_SOFT_OUT_STR)
6452
6453 ALIAS (clear_bgp_all_soft_out,
6454 clear_bgp_instance_all_out_cmd,
6455 "clear bgp " BGP_INSTANCE_CMD " * out",
6456 CLEAR_STR
6457 BGP_STR
6458 BGP_INSTANCE_HELP_STR
6459 "Clear all peers\n"
6460 BGP_SOFT_OUT_STR)
6461
6462 ALIAS (clear_bgp_all_soft_out,
6463 clear_bgp_ipv6_all_soft_out_cmd,
6464 "clear bgp ipv6 * soft out",
6465 CLEAR_STR
6466 BGP_STR
6467 "Address family\n"
6468 "Clear all peers\n"
6469 BGP_SOFT_STR
6470 BGP_SOFT_OUT_STR)
6471
6472 ALIAS (clear_bgp_all_soft_out,
6473 clear_bgp_instance_ipv6_all_soft_out_cmd,
6474 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft out",
6475 CLEAR_STR
6476 BGP_STR
6477 BGP_INSTANCE_HELP_STR
6478 "Address family\n"
6479 "Clear all peers\n"
6480 BGP_SOFT_STR
6481 BGP_SOFT_OUT_STR)
6482
6483 ALIAS (clear_bgp_all_soft_out,
6484 clear_bgp_ipv6_all_out_cmd,
6485 "clear bgp ipv6 * out",
6486 CLEAR_STR
6487 BGP_STR
6488 "Address family\n"
6489 "Clear all peers\n"
6490 BGP_SOFT_OUT_STR)
6491
6492 ALIAS (clear_bgp_all_soft_out,
6493 clear_bgp_instance_ipv6_all_out_cmd,
6494 "clear bgp " BGP_INSTANCE_CMD " ipv6 * out",
6495 CLEAR_STR
6496 BGP_STR
6497 BGP_INSTANCE_HELP_STR
6498 "Address family\n"
6499 "Clear all peers\n"
6500 BGP_SOFT_OUT_STR)
6501
6502 DEFUN (clear_bgp_ipv6_safi_prefix,
6503 clear_bgp_ipv6_safi_prefix_cmd,
6504 "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
6505 CLEAR_STR
6506 BGP_STR
6507 "Address family\n"
6508 "Address Family Modifier\n"
6509 "Clear bestpath and re-advertise\n"
6510 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6511 {
6512 if (strncmp (argv[0], "m", 1) == 0)
6513 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
6514 else
6515 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
6516 }
6517
6518 DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6519 clear_bgp_instance_ipv6_safi_prefix_cmd,
6520 "clear bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) prefix X:X::X:X/M",
6521 CLEAR_STR
6522 BGP_STR
6523 BGP_INSTANCE_HELP_STR
6524 "Address family\n"
6525 "Address Family Modifier\n"
6526 "Clear bestpath and re-advertise\n"
6527 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6528 {
6529 if (strncmp (argv[2], "m", 1) == 0)
6530 return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_MULTICAST, NULL);
6531 else
6532 return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_UNICAST, NULL);
6533 }
6534
6535 DEFUN (clear_ip_bgp_peer_soft_out,
6536 clear_ip_bgp_peer_soft_out_cmd,
6537 "clear ip bgp (A.B.C.D|WORD) soft out",
6538 CLEAR_STR
6539 IP_STR
6540 BGP_STR
6541 "BGP neighbor address to clear\n"
6542 "BGP neighbor on interface to clear\n"
6543 BGP_SOFT_STR
6544 BGP_SOFT_OUT_STR)
6545 {
6546 if (argc == 3)
6547 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
6548 BGP_CLEAR_SOFT_OUT, argv[2]);
6549
6550 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6551 BGP_CLEAR_SOFT_OUT, argv[0]);
6552 }
6553
6554 ALIAS (clear_ip_bgp_peer_soft_out,
6555 clear_ip_bgp_instance_peer_soft_out_cmd,
6556 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft out",
6557 CLEAR_STR
6558 IP_STR
6559 BGP_STR
6560 BGP_INSTANCE_HELP_STR
6561 "BGP neighbor address to clear\n"
6562 "BGP neighbor on interface to clear\n"
6563 BGP_SOFT_STR
6564 BGP_SOFT_OUT_STR)
6565
6566 ALIAS (clear_ip_bgp_peer_soft_out,
6567 clear_ip_bgp_peer_out_cmd,
6568 "clear ip bgp (A.B.C.D|WORD) out",
6569 CLEAR_STR
6570 IP_STR
6571 BGP_STR
6572 "BGP neighbor address to clear\n"
6573 "BGP neighbor on interface to clear\n"
6574 BGP_SOFT_OUT_STR)
6575
6576 ALIAS (clear_ip_bgp_peer_soft_out,
6577 clear_ip_bgp_instance_peer_out_cmd,
6578 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) out",
6579 CLEAR_STR
6580 IP_STR
6581 BGP_STR
6582 BGP_INSTANCE_HELP_STR
6583 "BGP neighbor address to clear\n"
6584 "BGP neighbor on interface to clear\n"
6585 BGP_SOFT_OUT_STR)
6586
6587 DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6588 clear_ip_bgp_peer_ipv4_soft_out_cmd,
6589 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
6590 CLEAR_STR
6591 IP_STR
6592 BGP_STR
6593 "BGP neighbor address to clear\n"
6594 "BGP neighbor on interface to clear\n"
6595 "Address family\n"
6596 "Address Family modifier\n"
6597 "Address Family modifier\n"
6598 BGP_SOFT_STR
6599 BGP_SOFT_OUT_STR)
6600 {
6601 if (strncmp (argv[1], "m", 1) == 0)
6602 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6603 BGP_CLEAR_SOFT_OUT, argv[0]);
6604
6605 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6606 BGP_CLEAR_SOFT_OUT, argv[0]);
6607 }
6608
6609 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out,
6610 clear_ip_bgp_instance_peer_ipv4_soft_out_cmd,
6611 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
6612 CLEAR_STR
6613 IP_STR
6614 BGP_STR
6615 BGP_INSTANCE_HELP_STR
6616 "BGP neighbor address to clear\n"
6617 "BGP neighbor on interface to clear\n"
6618 "Address family\n"
6619 "Address Family modifier\n"
6620 "Address Family modifier\n"
6621 BGP_SOFT_STR
6622 BGP_SOFT_OUT_STR)
6623 {
6624 if (strncmp (argv[3], "m", 1) == 0)
6625 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
6626 BGP_CLEAR_SOFT_OUT, argv[2]);
6627
6628 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
6629 BGP_CLEAR_SOFT_OUT, argv[2]);
6630 }
6631
6632 ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6633 clear_ip_bgp_peer_ipv4_out_cmd,
6634 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
6635 CLEAR_STR
6636 IP_STR
6637 BGP_STR
6638 "BGP neighbor address to clear\n"
6639 "BGP neighbor on interface to clear\n"
6640 "Address family\n"
6641 "Address Family modifier\n"
6642 "Address Family modifier\n"
6643 BGP_SOFT_OUT_STR)
6644
6645 ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out,
6646 clear_ip_bgp_instance_peer_ipv4_out_cmd,
6647 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
6648 CLEAR_STR
6649 IP_STR
6650 BGP_STR
6651 BGP_INSTANCE_HELP_STR
6652 "BGP neighbor address to clear\n"
6653 "BGP neighbor on interface to clear\n"
6654 "Address family\n"
6655 "Address Family modifier\n"
6656 "Address Family modifier\n"
6657 BGP_SOFT_OUT_STR)
6658
6659 /* NOTE: WORD peers have not been tested for vpnv4 */
6660 DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6661 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
6662 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out",
6663 CLEAR_STR
6664 IP_STR
6665 BGP_STR
6666 "BGP neighbor address to clear\n"
6667 "BGP neighbor on interface to clear\n"
6668 "Address family\n"
6669 "Address Family Modifier\n"
6670 BGP_SOFT_STR
6671 BGP_SOFT_OUT_STR)
6672 {
6673 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6674 BGP_CLEAR_SOFT_OUT, argv[0]);
6675 }
6676
6677 ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
6678 clear_ip_bgp_peer_vpnv4_out_cmd,
6679 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out",
6680 CLEAR_STR
6681 IP_STR
6682 BGP_STR
6683 "BGP neighbor address to clear\n"
6684 "BGP neighbor on interface to clear\n"
6685 "Address family\n"
6686 "Address Family Modifier\n"
6687 BGP_SOFT_OUT_STR)
6688
6689 DEFUN (clear_bgp_peer_soft_out,
6690 clear_bgp_peer_soft_out_cmd,
6691 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
6692 CLEAR_STR
6693 BGP_STR
6694 "BGP neighbor address to clear\n"
6695 "BGP IPv6 neighbor to clear\n"
6696 "BGP neighbor on interface to clear\n"
6697 BGP_SOFT_STR
6698 BGP_SOFT_OUT_STR)
6699 {
6700 if (argc == 3)
6701 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
6702 BGP_CLEAR_SOFT_OUT, argv[2]);
6703
6704 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6705 BGP_CLEAR_SOFT_OUT, argv[0]);
6706 }
6707
6708 ALIAS (clear_bgp_peer_soft_out,
6709 clear_bgp_instance_peer_soft_out_cmd,
6710 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft out",
6711 CLEAR_STR
6712 BGP_STR
6713 BGP_INSTANCE_HELP_STR
6714 "BGP neighbor address to clear\n"
6715 "BGP IPv6 neighbor to clear\n"
6716 "BGP neighbor on interface to clear\n"
6717 BGP_SOFT_STR
6718 BGP_SOFT_OUT_STR)
6719
6720 ALIAS (clear_bgp_peer_soft_out,
6721 clear_bgp_ipv6_peer_soft_out_cmd,
6722 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6723 CLEAR_STR
6724 BGP_STR
6725 "Address family\n"
6726 "BGP neighbor address to clear\n"
6727 "BGP IPv6 neighbor to clear\n"
6728 "BGP neighbor on interface to clear\n"
6729 BGP_SOFT_STR
6730 BGP_SOFT_OUT_STR)
6731
6732 ALIAS (clear_bgp_peer_soft_out,
6733 clear_bgp_instance_ipv6_peer_soft_out_cmd,
6734 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6735 CLEAR_STR
6736 BGP_STR
6737 BGP_INSTANCE_HELP_STR
6738 "Address family\n"
6739 "BGP neighbor address to clear\n"
6740 "BGP IPv6 neighbor to clear\n"
6741 "BGP neighbor on interface to clear\n"
6742 BGP_SOFT_STR
6743 BGP_SOFT_OUT_STR)
6744
6745 ALIAS (clear_bgp_peer_soft_out,
6746 clear_bgp_peer_out_cmd,
6747 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
6748 CLEAR_STR
6749 BGP_STR
6750 "BGP neighbor address to clear\n"
6751 "BGP IPv6 neighbor to clear\n"
6752 "BGP neighbor on interface to clear\n"
6753 BGP_SOFT_OUT_STR)
6754
6755 ALIAS (clear_bgp_peer_soft_out,
6756 clear_bgp_instance_peer_out_cmd,
6757 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) out",
6758 CLEAR_STR
6759 BGP_STR
6760 BGP_INSTANCE_HELP_STR
6761 "BGP neighbor address to clear\n"
6762 "BGP IPv6 neighbor to clear\n"
6763 "BGP neighbor on interface to clear\n"
6764 BGP_SOFT_OUT_STR)
6765
6766 ALIAS (clear_bgp_peer_soft_out,
6767 clear_bgp_ipv6_peer_out_cmd,
6768 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
6769 CLEAR_STR
6770 BGP_STR
6771 "Address family\n"
6772 "BGP neighbor address to clear\n"
6773 "BGP IPv6 neighbor to clear\n"
6774 "BGP neighbor on interface to clear\n"
6775 BGP_SOFT_OUT_STR)
6776
6777 ALIAS (clear_bgp_peer_soft_out,
6778 clear_bgp_instance_ipv6_peer_out_cmd,
6779 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) out",
6780 CLEAR_STR
6781 BGP_STR
6782 BGP_INSTANCE_HELP_STR
6783 "Address family\n"
6784 "BGP neighbor address to clear\n"
6785 "BGP IPv6 neighbor to clear\n"
6786 "BGP neighbor on interface to clear\n"
6787 BGP_SOFT_OUT_STR)
6788
6789 DEFUN (clear_ip_bgp_peer_group_soft_out,
6790 clear_ip_bgp_peer_group_soft_out_cmd,
6791 "clear ip bgp peer-group WORD soft out",
6792 CLEAR_STR
6793 IP_STR
6794 BGP_STR
6795 "Clear all members of peer-group\n"
6796 "BGP peer-group name\n"
6797 BGP_SOFT_STR
6798 BGP_SOFT_OUT_STR)
6799 {
6800 if (argc == 3)
6801 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
6802 BGP_CLEAR_SOFT_OUT, argv[2]);
6803
6804 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6805 BGP_CLEAR_SOFT_OUT, argv[0]);
6806 }
6807
6808 ALIAS (clear_ip_bgp_peer_group_soft_out,
6809 clear_ip_bgp_instance_peer_group_soft_out_cmd,
6810 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
6811 CLEAR_STR
6812 IP_STR
6813 BGP_STR
6814 BGP_INSTANCE_HELP_STR
6815 "Clear all members of peer-group\n"
6816 "BGP peer-group name\n"
6817 BGP_SOFT_STR
6818 BGP_SOFT_OUT_STR)
6819
6820 ALIAS (clear_ip_bgp_peer_group_soft_out,
6821 clear_ip_bgp_peer_group_out_cmd,
6822 "clear ip bgp peer-group WORD out",
6823 CLEAR_STR
6824 IP_STR
6825 BGP_STR
6826 "Clear all members of peer-group\n"
6827 "BGP peer-group name\n"
6828 BGP_SOFT_OUT_STR)
6829
6830 ALIAS (clear_ip_bgp_peer_group_soft_out,
6831 clear_ip_bgp_instance_peer_group_out_cmd,
6832 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD out",
6833 CLEAR_STR
6834 IP_STR
6835 BGP_STR
6836 BGP_INSTANCE_HELP_STR
6837 "Clear all members of peer-group\n"
6838 "BGP peer-group name\n"
6839 BGP_SOFT_OUT_STR)
6840
6841 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6842 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
6843 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
6844 CLEAR_STR
6845 IP_STR
6846 BGP_STR
6847 "Clear all members of peer-group\n"
6848 "BGP peer-group name\n"
6849 "Address family\n"
6850 "Address Family modifier\n"
6851 "Address Family modifier\n"
6852 BGP_SOFT_STR
6853 BGP_SOFT_OUT_STR)
6854 {
6855 if (strncmp (argv[1], "m", 1) == 0)
6856 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6857 BGP_CLEAR_SOFT_OUT, argv[0]);
6858
6859 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6860 BGP_CLEAR_SOFT_OUT, argv[0]);
6861 }
6862
6863 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
6864 clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd,
6865 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft out",
6866 CLEAR_STR
6867 IP_STR
6868 BGP_STR
6869 BGP_INSTANCE_HELP_STR
6870 "Clear all members of peer-group\n"
6871 "BGP peer-group name\n"
6872 "Address family\n"
6873 "Address Family modifier\n"
6874 "Address Family modifier\n"
6875 BGP_SOFT_STR
6876 BGP_SOFT_OUT_STR)
6877 {
6878 if (strncmp (argv[3], "m", 1) == 0)
6879 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
6880 BGP_CLEAR_SOFT_OUT, argv[2]);
6881
6882 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
6883 BGP_CLEAR_SOFT_OUT, argv[2]);
6884 }
6885
6886 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
6887 clear_ip_bgp_peer_group_ipv4_out_cmd,
6888 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
6889 CLEAR_STR
6890 IP_STR
6891 BGP_STR
6892 "Clear all members of peer-group\n"
6893 "BGP peer-group name\n"
6894 "Address family\n"
6895 "Address Family modifier\n"
6896 "Address Family modifier\n"
6897 BGP_SOFT_OUT_STR)
6898
6899 ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out,
6900 clear_ip_bgp_instance_peer_group_ipv4_out_cmd,
6901 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) out",
6902 CLEAR_STR
6903 IP_STR
6904 BGP_STR
6905 BGP_INSTANCE_HELP_STR
6906 "Clear all members of peer-group\n"
6907 "BGP peer-group name\n"
6908 "Address family\n"
6909 "Address Family modifier\n"
6910 "Address Family modifier\n"
6911 BGP_SOFT_OUT_STR)
6912
6913 DEFUN (clear_bgp_peer_group_soft_out,
6914 clear_bgp_peer_group_soft_out_cmd,
6915 "clear bgp peer-group WORD soft out",
6916 CLEAR_STR
6917 BGP_STR
6918 "Clear all members of peer-group\n"
6919 "BGP peer-group name\n"
6920 BGP_SOFT_STR
6921 BGP_SOFT_OUT_STR)
6922 {
6923 if (argc == 3)
6924 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
6925 BGP_CLEAR_SOFT_OUT, argv[2]);
6926
6927 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6928 BGP_CLEAR_SOFT_OUT, argv[0]);
6929 }
6930
6931 ALIAS (clear_bgp_peer_group_soft_out,
6932 clear_bgp_instance_peer_group_soft_out_cmd,
6933 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft out",
6934 CLEAR_STR
6935 BGP_STR
6936 BGP_INSTANCE_HELP_STR
6937 "Clear all members of peer-group\n"
6938 "BGP peer-group name\n"
6939 BGP_SOFT_STR
6940 BGP_SOFT_OUT_STR)
6941
6942 ALIAS (clear_bgp_peer_group_soft_out,
6943 clear_bgp_ipv6_peer_group_soft_out_cmd,
6944 "clear bgp ipv6 peer-group WORD soft out",
6945 CLEAR_STR
6946 BGP_STR
6947 "Address family\n"
6948 "Clear all members of peer-group\n"
6949 "BGP peer-group name\n"
6950 BGP_SOFT_STR
6951 BGP_SOFT_OUT_STR)
6952
6953 ALIAS (clear_bgp_peer_group_soft_out,
6954 clear_bgp_instance_ipv6_peer_group_soft_out_cmd,
6955 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft out",
6956 CLEAR_STR
6957 BGP_STR
6958 BGP_INSTANCE_HELP_STR
6959 "Address family\n"
6960 "Clear all members of peer-group\n"
6961 "BGP peer-group name\n"
6962 BGP_SOFT_STR
6963 BGP_SOFT_OUT_STR)
6964
6965 ALIAS (clear_bgp_peer_group_soft_out,
6966 clear_bgp_peer_group_out_cmd,
6967 "clear bgp peer-group WORD out",
6968 CLEAR_STR
6969 BGP_STR
6970 "Clear all members of peer-group\n"
6971 "BGP peer-group name\n"
6972 BGP_SOFT_OUT_STR)
6973
6974 ALIAS (clear_bgp_peer_group_soft_out,
6975 clear_bgp_instance_peer_group_out_cmd,
6976 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD out",
6977 CLEAR_STR
6978 BGP_STR
6979 BGP_INSTANCE_HELP_STR
6980 "Clear all members of peer-group\n"
6981 "BGP peer-group name\n"
6982 BGP_SOFT_OUT_STR)
6983
6984 ALIAS (clear_bgp_peer_group_soft_out,
6985 clear_bgp_ipv6_peer_group_out_cmd,
6986 "clear bgp ipv6 peer-group WORD out",
6987 CLEAR_STR
6988 BGP_STR
6989 "Address family\n"
6990 "Clear all members of peer-group\n"
6991 "BGP peer-group name\n"
6992 BGP_SOFT_OUT_STR)
6993
6994 ALIAS (clear_bgp_peer_group_soft_out,
6995 clear_bgp_instance_ipv6_peer_group_out_cmd,
6996 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD out",
6997 CLEAR_STR
6998 BGP_STR
6999 BGP_INSTANCE_HELP_STR
7000 "Address family\n"
7001 "Clear all members of peer-group\n"
7002 "BGP peer-group name\n"
7003 BGP_SOFT_OUT_STR)
7004
7005 DEFUN (clear_ip_bgp_external_soft_out,
7006 clear_ip_bgp_external_soft_out_cmd,
7007 "clear ip bgp external soft out",
7008 CLEAR_STR
7009 IP_STR
7010 BGP_STR
7011 "Clear all external peers\n"
7012 BGP_SOFT_STR
7013 BGP_SOFT_OUT_STR)
7014 {
7015 if (argc == 2)
7016 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7017 BGP_CLEAR_SOFT_OUT, NULL);
7018
7019 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7020 BGP_CLEAR_SOFT_OUT, NULL);
7021 }
7022
7023 ALIAS (clear_ip_bgp_external_soft_out,
7024 clear_ip_bgp_instance_external_soft_out_cmd,
7025 "clear ip bgp " BGP_INSTANCE_CMD " external soft out",
7026 CLEAR_STR
7027 IP_STR
7028 BGP_STR
7029 BGP_INSTANCE_HELP_STR
7030 "Clear all external peers\n"
7031 BGP_SOFT_STR
7032 BGP_SOFT_OUT_STR)
7033
7034 ALIAS (clear_ip_bgp_external_soft_out,
7035 clear_ip_bgp_external_out_cmd,
7036 "clear ip bgp external out",
7037 CLEAR_STR
7038 IP_STR
7039 BGP_STR
7040 "Clear all external peers\n"
7041 BGP_SOFT_OUT_STR)
7042
7043 ALIAS (clear_ip_bgp_external_soft_out,
7044 clear_ip_bgp_instance_external_out_cmd,
7045 "clear ip bgp " BGP_INSTANCE_CMD " external out",
7046 CLEAR_STR
7047 IP_STR
7048 BGP_STR
7049 BGP_INSTANCE_HELP_STR
7050 "Clear all external peers\n"
7051 BGP_SOFT_OUT_STR)
7052
7053 DEFUN (clear_ip_bgp_external_ipv4_soft_out,
7054 clear_ip_bgp_external_ipv4_soft_out_cmd,
7055 "clear ip bgp external ipv4 (unicast|multicast) soft out",
7056 CLEAR_STR
7057 IP_STR
7058 BGP_STR
7059 "Clear all external peers\n"
7060 "Address family\n"
7061 "Address Family modifier\n"
7062 "Address Family modifier\n"
7063 BGP_SOFT_STR
7064 BGP_SOFT_OUT_STR)
7065 {
7066 if (strncmp (argv[0], "m", 1) == 0)
7067 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7068 BGP_CLEAR_SOFT_OUT, NULL);
7069
7070 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7071 BGP_CLEAR_SOFT_OUT, NULL);
7072 }
7073
7074 DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out,
7075 clear_ip_bgp_instance_external_ipv4_soft_out_cmd,
7076 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft out",
7077 CLEAR_STR
7078 IP_STR
7079 BGP_STR
7080 BGP_INSTANCE_HELP_STR
7081 "Clear all external peers\n"
7082 "Address family\n"
7083 "Address Family modifier\n"
7084 "Address Family modifier\n"
7085 BGP_SOFT_STR
7086 BGP_SOFT_OUT_STR)
7087 {
7088 if (strncmp (argv[2], "m", 1) == 0)
7089 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
7090 BGP_CLEAR_SOFT_OUT, NULL);
7091
7092 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
7093 BGP_CLEAR_SOFT_OUT, NULL);
7094 }
7095
7096 ALIAS (clear_ip_bgp_external_ipv4_soft_out,
7097 clear_ip_bgp_external_ipv4_out_cmd,
7098 "clear ip bgp external ipv4 (unicast|multicast) out",
7099 CLEAR_STR
7100 IP_STR
7101 BGP_STR
7102 "Clear all external peers\n"
7103 "Address family\n"
7104 "Address Family modifier\n"
7105 "Address Family modifier\n"
7106 BGP_SOFT_OUT_STR)
7107
7108 ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out,
7109 clear_ip_bgp_instance_external_ipv4_out_cmd,
7110 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) out",
7111 CLEAR_STR
7112 IP_STR
7113 BGP_STR
7114 BGP_INSTANCE_HELP_STR
7115 "Clear all external peers\n"
7116 "Address family\n"
7117 "Address Family modifier\n"
7118 "Address Family modifier\n"
7119 BGP_SOFT_OUT_STR)
7120
7121 DEFUN (clear_bgp_external_soft_out,
7122 clear_bgp_external_soft_out_cmd,
7123 "clear bgp external soft out",
7124 CLEAR_STR
7125 BGP_STR
7126 "Clear all external peers\n"
7127 BGP_SOFT_STR
7128 BGP_SOFT_OUT_STR)
7129 {
7130 if (argc == 2)
7131 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
7132 BGP_CLEAR_SOFT_OUT, NULL);
7133
7134 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7135 BGP_CLEAR_SOFT_OUT, NULL);
7136 }
7137
7138 ALIAS (clear_bgp_external_soft_out,
7139 clear_bgp_instance_external_soft_out_cmd,
7140 "clear bgp " BGP_INSTANCE_CMD " external soft out",
7141 CLEAR_STR
7142 BGP_STR
7143 BGP_INSTANCE_HELP_STR
7144 "Clear all external peers\n"
7145 BGP_SOFT_STR
7146 BGP_SOFT_OUT_STR)
7147
7148 ALIAS (clear_bgp_external_soft_out,
7149 clear_bgp_ipv6_external_soft_out_cmd,
7150 "clear bgp ipv6 external soft out",
7151 CLEAR_STR
7152 BGP_STR
7153 "Address family\n"
7154 "Clear all external peers\n"
7155 BGP_SOFT_STR
7156 BGP_SOFT_OUT_STR)
7157
7158 ALIAS (clear_bgp_external_soft_out,
7159 clear_bgp_instance_ipv6_external_soft_out_cmd,
7160 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft out",
7161 CLEAR_STR
7162 BGP_STR
7163 BGP_INSTANCE_HELP_STR
7164 "Address family\n"
7165 "Clear all external peers\n"
7166 BGP_SOFT_STR
7167 BGP_SOFT_OUT_STR)
7168
7169 ALIAS (clear_bgp_external_soft_out,
7170 clear_bgp_external_out_cmd,
7171 "clear bgp external out",
7172 CLEAR_STR
7173 BGP_STR
7174 "Clear all external peers\n"
7175 BGP_SOFT_OUT_STR)
7176
7177 ALIAS (clear_bgp_external_soft_out,
7178 clear_bgp_instance_external_out_cmd,
7179 "clear bgp " BGP_INSTANCE_CMD " external out",
7180 CLEAR_STR
7181 BGP_STR
7182 BGP_INSTANCE_HELP_STR
7183 "Clear all external peers\n"
7184 BGP_SOFT_OUT_STR)
7185
7186 ALIAS (clear_bgp_external_soft_out,
7187 clear_bgp_ipv6_external_out_cmd,
7188 "clear bgp ipv6 external WORD out",
7189 CLEAR_STR
7190 BGP_STR
7191 "Address family\n"
7192 "Clear all external peers\n"
7193 BGP_SOFT_OUT_STR)
7194
7195 ALIAS (clear_bgp_external_soft_out,
7196 clear_bgp_instance_ipv6_external_out_cmd,
7197 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD out",
7198 CLEAR_STR
7199 BGP_STR
7200 BGP_INSTANCE_HELP_STR
7201 "Address family\n"
7202 "Clear all external peers\n"
7203 BGP_SOFT_OUT_STR)
7204
7205 DEFUN (clear_ip_bgp_as_soft_out,
7206 clear_ip_bgp_as_soft_out_cmd,
7207 "clear ip bgp " CMD_AS_RANGE " soft out",
7208 CLEAR_STR
7209 IP_STR
7210 BGP_STR
7211 "Clear peers with the AS number\n"
7212 BGP_SOFT_STR
7213 BGP_SOFT_OUT_STR)
7214 {
7215 if (argc == 3)
7216 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7217 BGP_CLEAR_SOFT_OUT, argv[2]);
7218
7219 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7220 BGP_CLEAR_SOFT_OUT, argv[0]);
7221 }
7222
7223 ALIAS (clear_ip_bgp_as_soft_out,
7224 clear_ip_bgp_instance_as_soft_out_cmd,
7225 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7226 CLEAR_STR
7227 IP_STR
7228 BGP_STR
7229 BGP_INSTANCE_HELP_STR
7230 "Clear peers with the AS number\n"
7231 BGP_SOFT_STR
7232 BGP_SOFT_OUT_STR)
7233
7234 ALIAS (clear_ip_bgp_as_soft_out,
7235 clear_ip_bgp_as_out_cmd,
7236 "clear ip bgp " CMD_AS_RANGE " out",
7237 CLEAR_STR
7238 IP_STR
7239 BGP_STR
7240 "Clear peers with the AS number\n"
7241 BGP_SOFT_OUT_STR)
7242
7243 ALIAS (clear_ip_bgp_as_soft_out,
7244 clear_ip_bgp_instance_as_out_cmd,
7245 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7246 CLEAR_STR
7247 IP_STR
7248 BGP_STR
7249 BGP_INSTANCE_HELP_STR
7250 "Clear peers with the AS number\n"
7251 BGP_SOFT_OUT_STR)
7252
7253 DEFUN (clear_ip_bgp_as_ipv4_soft_out,
7254 clear_ip_bgp_as_ipv4_soft_out_cmd,
7255 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
7256 CLEAR_STR
7257 IP_STR
7258 BGP_STR
7259 "Clear peers with the AS number\n"
7260 "Address family\n"
7261 "Address Family modifier\n"
7262 "Address Family modifier\n"
7263 BGP_SOFT_STR
7264 BGP_SOFT_OUT_STR)
7265 {
7266 if (strncmp (argv[1], "m", 1) == 0)
7267 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7268 BGP_CLEAR_SOFT_OUT, argv[0]);
7269
7270 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7271 BGP_CLEAR_SOFT_OUT, argv[0]);
7272 }
7273
7274 DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out,
7275 clear_ip_bgp_instance_as_ipv4_soft_out_cmd,
7276 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
7277 CLEAR_STR
7278 IP_STR
7279 BGP_STR
7280 BGP_INSTANCE_HELP_STR
7281 "Clear peers with the AS number\n"
7282 "Address family\n"
7283 "Address Family modifier\n"
7284 "Address Family modifier\n"
7285 BGP_SOFT_STR
7286 BGP_SOFT_OUT_STR)
7287 {
7288 if (strncmp (argv[3], "m", 1) == 0)
7289 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
7290 BGP_CLEAR_SOFT_OUT, argv[2]);
7291
7292 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
7293 BGP_CLEAR_SOFT_OUT, argv[2]);
7294 }
7295
7296 ALIAS (clear_ip_bgp_as_ipv4_soft_out,
7297 clear_ip_bgp_as_ipv4_out_cmd,
7298 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
7299 CLEAR_STR
7300 IP_STR
7301 BGP_STR
7302 "Clear peers with the AS number\n"
7303 "Address family\n"
7304 "Address Family modifier\n"
7305 "Address Family modifier\n"
7306 BGP_SOFT_OUT_STR)
7307
7308 ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out,
7309 clear_ip_bgp_instance_as_ipv4_out_cmd,
7310 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
7311 CLEAR_STR
7312 IP_STR
7313 BGP_STR
7314 BGP_INSTANCE_HELP_STR
7315 "Clear peers with the AS number\n"
7316 "Address family\n"
7317 "Address Family modifier\n"
7318 "Address Family modifier\n"
7319 BGP_SOFT_OUT_STR)
7320
7321 DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
7322 clear_ip_bgp_as_vpnv4_soft_out_cmd,
7323 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
7324 CLEAR_STR
7325 IP_STR
7326 BGP_STR
7327 "Clear peers with the AS number\n"
7328 "Address family\n"
7329 "Address Family modifier\n"
7330 BGP_SOFT_STR
7331 BGP_SOFT_OUT_STR)
7332 {
7333 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7334 BGP_CLEAR_SOFT_OUT, argv[0]);
7335 }
7336
7337 ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
7338 clear_ip_bgp_as_vpnv4_out_cmd,
7339 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
7340 CLEAR_STR
7341 IP_STR
7342 BGP_STR
7343 "Clear peers with the AS number\n"
7344 "Address family\n"
7345 "Address Family modifier\n"
7346 BGP_SOFT_OUT_STR)
7347
7348 DEFUN (clear_bgp_as_soft_out,
7349 clear_bgp_as_soft_out_cmd,
7350 "clear bgp " CMD_AS_RANGE " soft out",
7351 CLEAR_STR
7352 BGP_STR
7353 "Clear peers with the AS number\n"
7354 BGP_SOFT_STR
7355 BGP_SOFT_OUT_STR)
7356 {
7357 if (argc == 3)
7358 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
7359 BGP_CLEAR_SOFT_OUT, argv[2]);
7360
7361 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7362 BGP_CLEAR_SOFT_OUT, argv[0]);
7363 }
7364
7365 ALIAS (clear_bgp_as_soft_out,
7366 clear_bgp_instance_as_soft_out_cmd,
7367 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft out",
7368 CLEAR_STR
7369 BGP_STR
7370 BGP_INSTANCE_HELP_STR
7371 "Clear peers with the AS number\n"
7372 BGP_SOFT_STR
7373 BGP_SOFT_OUT_STR)
7374
7375 ALIAS (clear_bgp_as_soft_out,
7376 clear_bgp_ipv6_as_soft_out_cmd,
7377 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
7378 CLEAR_STR
7379 BGP_STR
7380 "Address family\n"
7381 "Clear peers with the AS number\n"
7382 BGP_SOFT_STR
7383 BGP_SOFT_OUT_STR)
7384
7385 ALIAS (clear_bgp_as_soft_out,
7386 clear_bgp_instance_ipv6_as_soft_out_cmd,
7387 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft out",
7388 CLEAR_STR
7389 BGP_STR
7390 BGP_INSTANCE_HELP_STR
7391 "Address family\n"
7392 "Clear peers with the AS number\n"
7393 BGP_SOFT_STR
7394 BGP_SOFT_OUT_STR)
7395
7396 ALIAS (clear_bgp_as_soft_out,
7397 clear_bgp_as_out_cmd,
7398 "clear bgp " CMD_AS_RANGE " out",
7399 CLEAR_STR
7400 BGP_STR
7401 "Clear peers with the AS number\n"
7402 BGP_SOFT_OUT_STR)
7403
7404 ALIAS (clear_bgp_as_soft_out,
7405 clear_bgp_instance_as_out_cmd,
7406 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " out",
7407 CLEAR_STR
7408 BGP_STR
7409 BGP_INSTANCE_HELP_STR
7410 "Clear peers with the AS number\n"
7411 BGP_SOFT_OUT_STR)
7412
7413 ALIAS (clear_bgp_as_soft_out,
7414 clear_bgp_ipv6_as_out_cmd,
7415 "clear bgp ipv6 " CMD_AS_RANGE " out",
7416 CLEAR_STR
7417 BGP_STR
7418 "Address family\n"
7419 "Clear peers with the AS number\n"
7420 BGP_SOFT_OUT_STR)
7421
7422 ALIAS (clear_bgp_as_soft_out,
7423 clear_bgp_instance_ipv6_as_out_cmd,
7424 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " out",
7425 CLEAR_STR
7426 BGP_STR
7427 BGP_INSTANCE_HELP_STR
7428 "Address family\n"
7429 "Clear peers with the AS number\n"
7430 BGP_SOFT_OUT_STR)
7431
7432 /* Inbound soft-reconfiguration */
7433 DEFUN (clear_ip_bgp_all_soft_in,
7434 clear_ip_bgp_all_soft_in_cmd,
7435 "clear ip bgp * soft in",
7436 CLEAR_STR
7437 IP_STR
7438 BGP_STR
7439 "Clear all peers\n"
7440 BGP_SOFT_STR
7441 BGP_SOFT_IN_STR)
7442 {
7443 if (argc == 2)
7444 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7445 BGP_CLEAR_SOFT_IN, NULL);
7446
7447 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7448 BGP_CLEAR_SOFT_IN, NULL);
7449 }
7450
7451 ALIAS (clear_ip_bgp_all_soft_in,
7452 clear_ip_bgp_instance_all_soft_in_cmd,
7453 "clear ip bgp " BGP_INSTANCE_CMD " * soft in",
7454 CLEAR_STR
7455 IP_STR
7456 BGP_STR
7457 BGP_INSTANCE_HELP_STR
7458 "Clear all peers\n"
7459 BGP_SOFT_STR
7460 BGP_SOFT_IN_STR)
7461
7462 ALIAS (clear_ip_bgp_all_soft_in,
7463 clear_ip_bgp_all_in_cmd,
7464 "clear ip bgp * in",
7465 CLEAR_STR
7466 IP_STR
7467 BGP_STR
7468 "Clear all peers\n"
7469 BGP_SOFT_IN_STR)
7470
7471 ALIAS (clear_ip_bgp_all_soft_in,
7472 clear_ip_bgp_instance_all_in_cmd,
7473 "clear ip bgp " BGP_INSTANCE_CMD " * in",
7474 CLEAR_STR
7475 IP_STR
7476 BGP_STR
7477 BGP_INSTANCE_HELP_STR
7478 "Clear all peers\n"
7479 BGP_SOFT_IN_STR)
7480
7481 DEFUN (clear_ip_bgp_all_in_prefix_filter,
7482 clear_ip_bgp_all_in_prefix_filter_cmd,
7483 "clear ip bgp * in prefix-filter",
7484 CLEAR_STR
7485 IP_STR
7486 BGP_STR
7487 "Clear all peers\n"
7488 BGP_SOFT_IN_STR
7489 "Push out prefix-list ORF and do inbound soft reconfig\n")
7490 {
7491 if (argc== 2)
7492 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7493 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7494
7495 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7496 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7497 }
7498
7499 DEFUN (clear_ip_bgp_all_ipv4_soft_in,
7500 clear_ip_bgp_all_ipv4_soft_in_cmd,
7501 "clear ip bgp * ipv4 (unicast|multicast) soft in",
7502 CLEAR_STR
7503 IP_STR
7504 BGP_STR
7505 "Clear all peers\n"
7506 "Address family\n"
7507 "Address Family modifier\n"
7508 "Address Family modifier\n"
7509 BGP_SOFT_STR
7510 BGP_SOFT_IN_STR)
7511 {
7512 if (strncmp (argv[0], "m", 1) == 0)
7513 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7514 BGP_CLEAR_SOFT_IN, NULL);
7515
7516 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7517 BGP_CLEAR_SOFT_IN, NULL);
7518 }
7519
7520 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
7521 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
7522 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in",
7523 CLEAR_STR
7524 IP_STR
7525 BGP_STR
7526 BGP_INSTANCE_HELP_STR
7527 "Clear all peers\n"
7528 "Address family\n"
7529 "Address Family modifier\n"
7530 "Address Family modifier\n"
7531 BGP_SOFT_STR
7532 BGP_SOFT_IN_STR)
7533 {
7534 if (strncmp (argv[2], "m", 1) == 0)
7535 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
7536 BGP_CLEAR_SOFT_IN, NULL);
7537
7538 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7539 BGP_CLEAR_SOFT_IN, NULL);
7540 }
7541
7542 ALIAS (clear_ip_bgp_all_ipv4_soft_in,
7543 clear_ip_bgp_all_ipv4_in_cmd,
7544 "clear ip bgp * ipv4 (unicast|multicast) in",
7545 CLEAR_STR
7546 IP_STR
7547 BGP_STR
7548 "Clear all peers\n"
7549 "Address family\n"
7550 "Address Family modifier\n"
7551 "Address Family modifier\n"
7552 BGP_SOFT_IN_STR)
7553
7554 ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in,
7555 clear_ip_bgp_instance_all_ipv4_in_cmd,
7556 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in",
7557 CLEAR_STR
7558 IP_STR
7559 BGP_STR
7560 BGP_INSTANCE_HELP_STR
7561 "Clear all peers\n"
7562 "Address family\n"
7563 "Address Family modifier\n"
7564 "Address Family modifier\n"
7565 BGP_SOFT_IN_STR)
7566
7567 DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
7568 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
7569 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
7570 CLEAR_STR
7571 IP_STR
7572 BGP_STR
7573 "Clear all peers\n"
7574 "Address family\n"
7575 "Address Family modifier\n"
7576 "Address Family modifier\n"
7577 BGP_SOFT_IN_STR
7578 "Push out prefix-list ORF and do inbound soft reconfig\n")
7579 {
7580 if (strncmp (argv[0], "m", 1) == 0)
7581 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7582 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7583
7584 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7585 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7586 }
7587
7588 DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
7589 clear_ip_bgp_all_vpnv4_soft_in_cmd,
7590 "clear ip bgp * vpnv4 unicast soft in",
7591 CLEAR_STR
7592 IP_STR
7593 BGP_STR
7594 "Clear all peers\n"
7595 "Address family\n"
7596 "Address Family Modifier\n"
7597 BGP_SOFT_STR
7598 BGP_SOFT_IN_STR)
7599 {
7600 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7601 BGP_CLEAR_SOFT_IN, NULL);
7602 }
7603
7604 ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
7605 clear_ip_bgp_all_vpnv4_in_cmd,
7606 "clear ip bgp * vpnv4 unicast in",
7607 CLEAR_STR
7608 IP_STR
7609 BGP_STR
7610 "Clear all peers\n"
7611 "Address family\n"
7612 "Address Family Modifier\n"
7613 BGP_SOFT_IN_STR)
7614
7615 DEFUN (clear_bgp_all_soft_in,
7616 clear_bgp_all_soft_in_cmd,
7617 "clear bgp * soft in",
7618 CLEAR_STR
7619 BGP_STR
7620 "Clear all peers\n"
7621 BGP_SOFT_STR
7622 BGP_SOFT_IN_STR)
7623 {
7624 if (argc == 2)
7625 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
7626 BGP_CLEAR_SOFT_IN, NULL);
7627
7628 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7629 BGP_CLEAR_SOFT_IN, NULL);
7630 }
7631
7632 ALIAS (clear_bgp_all_soft_in,
7633 clear_bgp_instance_all_soft_in_cmd,
7634 "clear bgp " BGP_INSTANCE_CMD " * soft in",
7635 CLEAR_STR
7636 BGP_STR
7637 BGP_INSTANCE_HELP_STR
7638 "Clear all peers\n"
7639 BGP_SOFT_STR
7640 BGP_SOFT_IN_STR)
7641
7642 ALIAS (clear_bgp_all_soft_in,
7643 clear_bgp_ipv6_all_soft_in_cmd,
7644 "clear bgp ipv6 * soft in",
7645 CLEAR_STR
7646 BGP_STR
7647 "Address family\n"
7648 "Clear all peers\n"
7649 BGP_SOFT_STR
7650 BGP_SOFT_IN_STR)
7651
7652 ALIAS (clear_bgp_all_soft_in,
7653 clear_bgp_instance_ipv6_all_soft_in_cmd,
7654 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft in",
7655 CLEAR_STR
7656 BGP_STR
7657 BGP_INSTANCE_HELP_STR
7658 "Address family\n"
7659 "Clear all peers\n"
7660 BGP_SOFT_STR
7661 BGP_SOFT_IN_STR)
7662
7663 ALIAS (clear_bgp_all_soft_in,
7664 clear_bgp_all_in_cmd,
7665 "clear bgp * in",
7666 CLEAR_STR
7667 BGP_STR
7668 "Clear all peers\n"
7669 BGP_SOFT_IN_STR)
7670
7671 ALIAS (clear_bgp_all_soft_in,
7672 clear_bgp_instance_all_in_cmd,
7673 "clear bgp " BGP_INSTANCE_CMD " * in",
7674 CLEAR_STR
7675 BGP_STR
7676 BGP_INSTANCE_HELP_STR
7677 "Clear all peers\n"
7678 BGP_SOFT_IN_STR)
7679
7680 ALIAS (clear_bgp_all_soft_in,
7681 clear_bgp_ipv6_all_in_cmd,
7682 "clear bgp ipv6 * in",
7683 CLEAR_STR
7684 BGP_STR
7685 "Address family\n"
7686 "Clear all peers\n"
7687 BGP_SOFT_IN_STR)
7688
7689 ALIAS (clear_bgp_all_soft_in,
7690 clear_bgp_instance_ipv6_all_in_cmd,
7691 "clear bgp " BGP_INSTANCE_CMD " ipv6 * in",
7692 CLEAR_STR
7693 BGP_STR
7694 BGP_INSTANCE_HELP_STR
7695 "Address family\n"
7696 "Clear all peers\n"
7697 BGP_SOFT_IN_STR)
7698
7699 DEFUN (clear_bgp_all_in_prefix_filter,
7700 clear_bgp_all_in_prefix_filter_cmd,
7701 "clear bgp * in prefix-filter",
7702 CLEAR_STR
7703 BGP_STR
7704 "Clear all peers\n"
7705 BGP_SOFT_IN_STR
7706 "Push out prefix-list ORF and do inbound soft reconfig\n")
7707 {
7708 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7709 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7710 }
7711
7712 ALIAS (clear_bgp_all_in_prefix_filter,
7713 clear_bgp_ipv6_all_in_prefix_filter_cmd,
7714 "clear bgp ipv6 * in prefix-filter",
7715 CLEAR_STR
7716 BGP_STR
7717 "Address family\n"
7718 "Clear all peers\n"
7719 BGP_SOFT_IN_STR
7720 "Push out prefix-list ORF and do inbound soft reconfig\n")
7721
7722 DEFUN (clear_ip_bgp_peer_soft_in,
7723 clear_ip_bgp_peer_soft_in_cmd,
7724 "clear ip bgp (A.B.C.D|WORD) soft in",
7725 CLEAR_STR
7726 IP_STR
7727 BGP_STR
7728 "BGP neighbor address to clear\n"
7729 "BGP neighbor on interface to clear\n"
7730 BGP_SOFT_STR
7731 BGP_SOFT_IN_STR)
7732 {
7733 if (argc == 3)
7734 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
7735 BGP_CLEAR_SOFT_IN, argv[2]);
7736
7737 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7738 BGP_CLEAR_SOFT_IN, argv[0]);
7739 }
7740
7741 ALIAS (clear_ip_bgp_peer_soft_in,
7742 clear_ip_bgp_instance_peer_soft_in_cmd,
7743 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft in",
7744 CLEAR_STR
7745 IP_STR
7746 BGP_STR
7747 BGP_INSTANCE_HELP_STR
7748 "BGP neighbor address to clear\n"
7749 "BGP neighbor on interface to clear\n"
7750 BGP_SOFT_STR
7751 BGP_SOFT_IN_STR)
7752
7753 ALIAS (clear_ip_bgp_peer_soft_in,
7754 clear_ip_bgp_peer_in_cmd,
7755 "clear ip bgp (A.B.C.D|WORD) in",
7756 CLEAR_STR
7757 IP_STR
7758 BGP_STR
7759 "BGP neighbor address to clear\n"
7760 "BGP neighbor on interface to clear\n"
7761 BGP_SOFT_IN_STR)
7762
7763 ALIAS (clear_ip_bgp_peer_soft_in,
7764 clear_ip_bgp_instance_peer_in_cmd,
7765 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) in",
7766 CLEAR_STR
7767 IP_STR
7768 BGP_STR
7769 BGP_INSTANCE_HELP_STR
7770 "BGP neighbor address to clear\n"
7771 "BGP neighbor on interface to clear\n"
7772 BGP_SOFT_IN_STR)
7773
7774 DEFUN (clear_ip_bgp_peer_in_prefix_filter,
7775 clear_ip_bgp_peer_in_prefix_filter_cmd,
7776 "clear ip bgp (A.B.C.D|WORD) in prefix-filter",
7777 CLEAR_STR
7778 IP_STR
7779 BGP_STR
7780 "BGP neighbor address to clear\n"
7781 "BGP neighbor on interface to clear\n"
7782 BGP_SOFT_IN_STR
7783 "Push out the existing ORF prefix-list\n")
7784 {
7785 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7786 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7787 }
7788
7789 DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
7790 clear_ip_bgp_peer_ipv4_soft_in_cmd,
7791 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
7792 CLEAR_STR
7793 IP_STR
7794 BGP_STR
7795 "BGP neighbor address to clear\n"
7796 "BGP neighbor on interface to clear\n"
7797 "Address family\n"
7798 "Address Family modifier\n"
7799 "Address Family modifier\n"
7800 BGP_SOFT_STR
7801 BGP_SOFT_IN_STR)
7802 {
7803 if (strncmp (argv[1], "m", 1) == 0)
7804 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7805 BGP_CLEAR_SOFT_IN, argv[0]);
7806
7807 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7808 BGP_CLEAR_SOFT_IN, argv[0]);
7809 }
7810
7811 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in,
7812 clear_ip_bgp_instance_peer_ipv4_soft_in_cmd,
7813 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
7814 CLEAR_STR
7815 IP_STR
7816 BGP_STR
7817 BGP_INSTANCE_HELP_STR
7818 "BGP neighbor address to clear\n"
7819 "BGP neighbor on interface to clear\n"
7820 "Address family\n"
7821 "Address Family modifier\n"
7822 "Address Family modifier\n"
7823 BGP_SOFT_STR
7824 BGP_SOFT_IN_STR)
7825 {
7826 if (strncmp (argv[3], "m", 1) == 0)
7827 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
7828 BGP_CLEAR_SOFT_IN, argv[2]);
7829
7830 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
7831 BGP_CLEAR_SOFT_IN, argv[2]);
7832 }
7833
7834 ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
7835 clear_ip_bgp_peer_ipv4_in_cmd,
7836 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
7837 CLEAR_STR
7838 IP_STR
7839 BGP_STR
7840 "BGP neighbor address to clear\n"
7841 "BGP neighbor on interface to clear\n"
7842 "Address family\n"
7843 "Address Family modifier\n"
7844 "Address Family modifier\n"
7845 BGP_SOFT_IN_STR)
7846
7847 ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in,
7848 clear_ip_bgp_instance_peer_ipv4_in_cmd,
7849 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
7850 CLEAR_STR
7851 IP_STR
7852 BGP_STR
7853 BGP_INSTANCE_HELP_STR
7854 "BGP neighbor address to clear\n"
7855 "BGP neighbor on interface to clear\n"
7856 "Address family\n"
7857 "Address Family modifier\n"
7858 "Address Family modifier\n"
7859 BGP_SOFT_IN_STR)
7860
7861 DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
7862 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
7863 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter",
7864 CLEAR_STR
7865 IP_STR
7866 BGP_STR
7867 "BGP neighbor address to clear\n"
7868 "BGP neighbor on interface to clear\n"
7869 "Address family\n"
7870 "Address Family modifier\n"
7871 "Address Family modifier\n"
7872 BGP_SOFT_IN_STR
7873 "Push out the existing ORF prefix-list\n")
7874 {
7875 if (strncmp (argv[1], "m", 1) == 0)
7876 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7877 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7878
7879 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7880 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7881 }
7882
7883 DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
7884 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
7885 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in",
7886 CLEAR_STR
7887 IP_STR
7888 BGP_STR
7889 "BGP neighbor address to clear\n"
7890 "BGP neighbor on interface to clear\n"
7891 "Address family\n"
7892 "Address Family Modifier\n"
7893 BGP_SOFT_STR
7894 BGP_SOFT_IN_STR)
7895 {
7896 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7897 BGP_CLEAR_SOFT_IN, argv[0]);
7898 }
7899
7900 ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
7901 clear_ip_bgp_peer_vpnv4_in_cmd,
7902 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in",
7903 CLEAR_STR
7904 IP_STR
7905 BGP_STR
7906 "BGP neighbor address to clear\n"
7907 "BGP neighbor on interface to clear\n"
7908 "Address family\n"
7909 "Address Family Modifier\n"
7910 BGP_SOFT_IN_STR)
7911
7912 DEFUN (clear_bgp_peer_soft_in,
7913 clear_bgp_peer_soft_in_cmd,
7914 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
7915 CLEAR_STR
7916 BGP_STR
7917 "BGP neighbor address to clear\n"
7918 "BGP IPv6 neighbor to clear\n"
7919 "BGP neighbor on interface to clear\n"
7920 BGP_SOFT_STR
7921 BGP_SOFT_IN_STR)
7922 {
7923 if (argc == 3)
7924 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
7925 BGP_CLEAR_SOFT_IN, argv[2]);
7926
7927 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7928 BGP_CLEAR_SOFT_IN, argv[0]);
7929 }
7930
7931 ALIAS (clear_bgp_peer_soft_in,
7932 clear_bgp_instance_peer_soft_in_cmd,
7933 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft in",
7934 CLEAR_STR
7935 BGP_STR
7936 BGP_INSTANCE_HELP_STR
7937 "BGP neighbor address to clear\n"
7938 "BGP IPv6 neighbor to clear\n"
7939 "BGP neighbor on interface to clear\n"
7940 BGP_SOFT_STR
7941 BGP_SOFT_IN_STR)
7942
7943 ALIAS (clear_bgp_peer_soft_in,
7944 clear_bgp_ipv6_peer_soft_in_cmd,
7945 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
7946 CLEAR_STR
7947 BGP_STR
7948 "Address family\n"
7949 "BGP neighbor address to clear\n"
7950 "BGP IPv6 neighbor to clear\n"
7951 "BGP neighbor on interface to clear\n"
7952 BGP_SOFT_STR
7953 BGP_SOFT_IN_STR)
7954
7955 ALIAS (clear_bgp_peer_soft_in,
7956 clear_bgp_instance_ipv6_peer_soft_in_cmd,
7957 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
7958 CLEAR_STR
7959 BGP_STR
7960 BGP_INSTANCE_HELP_STR
7961 "Address family\n"
7962 "BGP neighbor address to clear\n"
7963 "BGP IPv6 neighbor to clear\n"
7964 "BGP neighbor on interface to clear\n"
7965 BGP_SOFT_STR
7966 BGP_SOFT_IN_STR)
7967
7968 ALIAS (clear_bgp_peer_soft_in,
7969 clear_bgp_peer_in_cmd,
7970 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
7971 CLEAR_STR
7972 BGP_STR
7973 "BGP neighbor address to clear\n"
7974 "BGP IPv6 neighbor to clear\n"
7975 "BGP neighbor on interface to clear\n"
7976 BGP_SOFT_IN_STR)
7977
7978 ALIAS (clear_bgp_peer_soft_in,
7979 clear_bgp_instance_peer_in_cmd,
7980 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) in",
7981 CLEAR_STR
7982 BGP_STR
7983 BGP_INSTANCE_HELP_STR
7984 "BGP neighbor address to clear\n"
7985 "BGP IPv6 neighbor to clear\n"
7986 "BGP neighbor on interface to clear\n"
7987 BGP_SOFT_IN_STR)
7988
7989 ALIAS (clear_bgp_peer_soft_in,
7990 clear_bgp_ipv6_peer_in_cmd,
7991 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
7992 CLEAR_STR
7993 BGP_STR
7994 "Address family\n"
7995 "BGP neighbor address to clear\n"
7996 "BGP IPv6 neighbor to clear\n"
7997 "BGP neighbor on interface to clear\n"
7998 BGP_SOFT_IN_STR)
7999
8000 ALIAS (clear_bgp_peer_soft_in,
8001 clear_bgp_instance_ipv6_peer_in_cmd,
8002 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) in",
8003 CLEAR_STR
8004 BGP_STR
8005 BGP_INSTANCE_HELP_STR
8006 "Address family\n"
8007 "BGP neighbor address to clear\n"
8008 "BGP IPv6 neighbor to clear\n"
8009 "BGP neighbor on interface to clear\n"
8010 BGP_SOFT_IN_STR)
8011
8012 DEFUN (clear_bgp_peer_in_prefix_filter,
8013 clear_bgp_peer_in_prefix_filter_cmd,
8014 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
8015 CLEAR_STR
8016 BGP_STR
8017 "BGP neighbor address to clear\n"
8018 "BGP IPv6 neighbor to clear\n"
8019 "BGP neighbor on interface to clear\n"
8020 BGP_SOFT_IN_STR
8021 "Push out the existing ORF prefix-list\n")
8022 {
8023 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
8024 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8025 }
8026
8027 ALIAS (clear_bgp_peer_in_prefix_filter,
8028 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
8029 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
8030 CLEAR_STR
8031 BGP_STR
8032 "Address family\n"
8033 "BGP neighbor address to clear\n"
8034 "BGP IPv6 neighbor to clear\n"
8035 "BGP neighbor on interface to clear\n"
8036 BGP_SOFT_IN_STR
8037 "Push out the existing ORF prefix-list\n")
8038
8039 DEFUN (clear_ip_bgp_peer_group_soft_in,
8040 clear_ip_bgp_peer_group_soft_in_cmd,
8041 "clear ip bgp peer-group WORD soft in",
8042 CLEAR_STR
8043 IP_STR
8044 BGP_STR
8045 "Clear all members of peer-group\n"
8046 "BGP peer-group name\n"
8047 BGP_SOFT_STR
8048 BGP_SOFT_IN_STR)
8049 {
8050 if (argc == 3)
8051 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8052 BGP_CLEAR_SOFT_IN, argv[2]);
8053
8054 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8055 BGP_CLEAR_SOFT_IN, argv[0]);
8056 }
8057
8058 ALIAS (clear_ip_bgp_peer_group_soft_in,
8059 clear_ip_bgp_instance_peer_group_soft_in_cmd,
8060 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8061 CLEAR_STR
8062 IP_STR
8063 BGP_STR
8064 BGP_INSTANCE_HELP_STR
8065 "Clear all members of peer-group\n"
8066 "BGP peer-group name\n"
8067 BGP_SOFT_STR
8068 BGP_SOFT_IN_STR)
8069
8070 ALIAS (clear_ip_bgp_peer_group_soft_in,
8071 clear_ip_bgp_peer_group_in_cmd,
8072 "clear ip bgp peer-group WORD in",
8073 CLEAR_STR
8074 IP_STR
8075 BGP_STR
8076 "Clear all members of peer-group\n"
8077 "BGP peer-group name\n"
8078 BGP_SOFT_IN_STR)
8079
8080 ALIAS (clear_ip_bgp_peer_group_soft_in,
8081 clear_ip_bgp_instance_peer_group_in_cmd,
8082 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8083 CLEAR_STR
8084 IP_STR
8085 BGP_STR
8086 BGP_INSTANCE_HELP_STR
8087 "Clear all members of peer-group\n"
8088 "BGP peer-group name\n"
8089 BGP_SOFT_IN_STR)
8090
8091 DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
8092 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
8093 "clear ip bgp peer-group WORD in prefix-filter",
8094 CLEAR_STR
8095 IP_STR
8096 BGP_STR
8097 "Clear all members of peer-group\n"
8098 "BGP peer-group name\n"
8099 BGP_SOFT_IN_STR
8100 "Push out prefix-list ORF and do inbound soft reconfig\n")
8101 {
8102 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8103 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8104 }
8105
8106 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
8107 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
8108 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
8109 CLEAR_STR
8110 IP_STR
8111 BGP_STR
8112 "Clear all members of peer-group\n"
8113 "BGP peer-group name\n"
8114 "Address family\n"
8115 "Address Family modifier\n"
8116 "Address Family modifier\n"
8117 BGP_SOFT_STR
8118 BGP_SOFT_IN_STR)
8119 {
8120 if (strncmp (argv[1], "m", 1) == 0)
8121 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
8122 BGP_CLEAR_SOFT_IN, argv[0]);
8123
8124 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8125 BGP_CLEAR_SOFT_IN, argv[0]);
8126 }
8127
8128 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8129 clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd,
8130 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft in",
8131 CLEAR_STR
8132 IP_STR
8133 BGP_STR
8134 BGP_INSTANCE_HELP_STR
8135 "Clear all members of peer-group\n"
8136 "BGP peer-group name\n"
8137 "Address family\n"
8138 "Address Family modifier\n"
8139 "Address Family modifier\n"
8140 BGP_SOFT_STR
8141 BGP_SOFT_IN_STR)
8142 {
8143 if (strncmp (argv[3], "m", 1) == 0)
8144 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
8145 BGP_CLEAR_SOFT_IN, argv[2]);
8146
8147 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
8148 BGP_CLEAR_SOFT_IN, argv[2]);
8149 }
8150
8151 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
8152 clear_ip_bgp_peer_group_ipv4_in_cmd,
8153 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
8154 CLEAR_STR
8155 IP_STR
8156 BGP_STR
8157 "Clear all members of peer-group\n"
8158 "BGP peer-group name\n"
8159 "Address family\n"
8160 "Address Family modifier\n"
8161 "Address Family modifier\n"
8162 BGP_SOFT_IN_STR)
8163
8164 ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in,
8165 clear_ip_bgp_instance_peer_group_ipv4_in_cmd,
8166 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) in",
8167 CLEAR_STR
8168 IP_STR
8169 BGP_STR
8170 BGP_INSTANCE_HELP_STR
8171 "Clear all members of peer-group\n"
8172 "BGP peer-group name\n"
8173 "Address family\n"
8174 "Address Family modifier\n"
8175 "Address Family modifier\n"
8176 BGP_SOFT_IN_STR)
8177
8178 DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
8179 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
8180 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
8181 CLEAR_STR
8182 IP_STR
8183 BGP_STR
8184 "Clear all members of peer-group\n"
8185 "BGP peer-group name\n"
8186 "Address family\n"
8187 "Address Family modifier\n"
8188 "Address Family modifier\n"
8189 BGP_SOFT_IN_STR
8190 "Push out prefix-list ORF and do inbound soft reconfig\n")
8191 {
8192 if (strncmp (argv[1], "m", 1) == 0)
8193 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
8194 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8195
8196 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
8197 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8198 }
8199
8200 DEFUN (clear_bgp_peer_group_soft_in,
8201 clear_bgp_peer_group_soft_in_cmd,
8202 "clear bgp peer-group WORD soft in",
8203 CLEAR_STR
8204 BGP_STR
8205 "Clear all members of peer-group\n"
8206 "BGP peer-group name\n"
8207 BGP_SOFT_STR
8208 BGP_SOFT_IN_STR)
8209 {
8210 if (argc == 3)
8211 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
8212 BGP_CLEAR_SOFT_IN, argv[2]);
8213
8214 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8215 BGP_CLEAR_SOFT_IN, argv[0]);
8216 }
8217
8218 ALIAS (clear_bgp_peer_group_soft_in,
8219 clear_bgp_instance_peer_group_soft_in_cmd,
8220 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft in",
8221 CLEAR_STR
8222 BGP_STR
8223 BGP_INSTANCE_HELP_STR
8224 "Clear all members of peer-group\n"
8225 "BGP peer-group name\n"
8226 BGP_SOFT_STR
8227 BGP_SOFT_IN_STR)
8228
8229 ALIAS (clear_bgp_peer_group_soft_in,
8230 clear_bgp_ipv6_peer_group_soft_in_cmd,
8231 "clear bgp ipv6 peer-group WORD soft in",
8232 CLEAR_STR
8233 BGP_STR
8234 "Address family\n"
8235 "Clear all members of peer-group\n"
8236 "BGP peer-group name\n"
8237 BGP_SOFT_STR
8238 BGP_SOFT_IN_STR)
8239
8240 ALIAS (clear_bgp_peer_group_soft_in,
8241 clear_bgp_instance_ipv6_peer_group_soft_in_cmd,
8242 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft in",
8243 CLEAR_STR
8244 BGP_STR
8245 BGP_INSTANCE_HELP_STR
8246 "Address family\n"
8247 "Clear all members of peer-group\n"
8248 "BGP peer-group name\n"
8249 BGP_SOFT_STR
8250 BGP_SOFT_IN_STR)
8251
8252 ALIAS (clear_bgp_peer_group_soft_in,
8253 clear_bgp_peer_group_in_cmd,
8254 "clear bgp peer-group WORD in",
8255 CLEAR_STR
8256 BGP_STR
8257 "Clear all members of peer-group\n"
8258 "BGP peer-group name\n"
8259 BGP_SOFT_IN_STR)
8260
8261 ALIAS (clear_bgp_peer_group_soft_in,
8262 clear_bgp_instance_peer_group_in_cmd,
8263 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD in",
8264 CLEAR_STR
8265 BGP_STR
8266 BGP_INSTANCE_HELP_STR
8267 "Clear all members of peer-group\n"
8268 "BGP peer-group name\n"
8269 BGP_SOFT_IN_STR)
8270
8271 ALIAS (clear_bgp_peer_group_soft_in,
8272 clear_bgp_ipv6_peer_group_in_cmd,
8273 "clear bgp ipv6 peer-group WORD in",
8274 CLEAR_STR
8275 BGP_STR
8276 "Address family\n"
8277 "Clear all members of peer-group\n"
8278 "BGP peer-group name\n"
8279 BGP_SOFT_IN_STR)
8280
8281 ALIAS (clear_bgp_peer_group_soft_in,
8282 clear_bgp_instance_ipv6_peer_group_in_cmd,
8283 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD in",
8284 CLEAR_STR
8285 BGP_STR
8286 BGP_INSTANCE_HELP_STR
8287 "Address family\n"
8288 "Clear all members of peer-group\n"
8289 "BGP peer-group name\n"
8290 BGP_SOFT_IN_STR)
8291
8292 DEFUN (clear_bgp_peer_group_in_prefix_filter,
8293 clear_bgp_peer_group_in_prefix_filter_cmd,
8294 "clear bgp peer-group WORD in prefix-filter",
8295 CLEAR_STR
8296 BGP_STR
8297 "Clear all members of peer-group\n"
8298 "BGP peer-group name\n"
8299 BGP_SOFT_IN_STR
8300 "Push out prefix-list ORF and do inbound soft reconfig\n")
8301 {
8302 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
8303 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8304 }
8305
8306 ALIAS (clear_bgp_peer_group_in_prefix_filter,
8307 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
8308 "clear bgp ipv6 peer-group WORD in prefix-filter",
8309 CLEAR_STR
8310 BGP_STR
8311 "Address family\n"
8312 "Clear all members of peer-group\n"
8313 "BGP peer-group name\n"
8314 BGP_SOFT_IN_STR
8315 "Push out prefix-list ORF and do inbound soft reconfig\n")
8316
8317 DEFUN (clear_ip_bgp_external_soft_in,
8318 clear_ip_bgp_external_soft_in_cmd,
8319 "clear ip bgp external soft in",
8320 CLEAR_STR
8321 IP_STR
8322 BGP_STR
8323 "Clear all external peers\n"
8324 BGP_SOFT_STR
8325 BGP_SOFT_IN_STR)
8326 {
8327 if (argc == 2)
8328 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8329 BGP_CLEAR_SOFT_IN, NULL);
8330
8331 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8332 BGP_CLEAR_SOFT_IN, NULL);
8333 }
8334
8335 ALIAS (clear_ip_bgp_external_soft_in,
8336 clear_ip_bgp_instance_external_soft_in_cmd,
8337 "clear ip bgp " BGP_INSTANCE_CMD " external soft in",
8338 CLEAR_STR
8339 IP_STR
8340 BGP_STR
8341 BGP_INSTANCE_HELP_STR
8342 "Clear all external peers\n"
8343 BGP_SOFT_STR
8344 BGP_SOFT_IN_STR)
8345
8346 ALIAS (clear_ip_bgp_external_soft_in,
8347 clear_ip_bgp_external_in_cmd,
8348 "clear ip bgp external in",
8349 CLEAR_STR
8350 IP_STR
8351 BGP_STR
8352 "Clear all external peers\n"
8353 BGP_SOFT_IN_STR)
8354
8355 ALIAS (clear_ip_bgp_external_soft_in,
8356 clear_ip_bgp_instance_external_in_cmd,
8357 "clear ip bgp " BGP_INSTANCE_CMD " external in",
8358 CLEAR_STR
8359 IP_STR
8360 BGP_STR
8361 BGP_INSTANCE_HELP_STR
8362 "Clear all external peers\n"
8363 BGP_SOFT_IN_STR)
8364
8365 DEFUN (clear_ip_bgp_external_in_prefix_filter,
8366 clear_ip_bgp_external_in_prefix_filter_cmd,
8367 "clear ip bgp external in prefix-filter",
8368 CLEAR_STR
8369 IP_STR
8370 BGP_STR
8371 "Clear all external peers\n"
8372 BGP_SOFT_IN_STR
8373 "Push out prefix-list ORF and do inbound soft reconfig\n")
8374 {
8375 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8376 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8377 }
8378
8379 DEFUN (clear_ip_bgp_external_ipv4_soft_in,
8380 clear_ip_bgp_external_ipv4_soft_in_cmd,
8381 "clear ip bgp external ipv4 (unicast|multicast) soft in",
8382 CLEAR_STR
8383 IP_STR
8384 BGP_STR
8385 "Clear all external peers\n"
8386 "Address family\n"
8387 "Address Family modifier\n"
8388 "Address Family modifier\n"
8389 BGP_SOFT_STR
8390 BGP_SOFT_IN_STR)
8391 {
8392 if (strncmp (argv[0], "m", 1) == 0)
8393 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8394 BGP_CLEAR_SOFT_IN, NULL);
8395
8396 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8397 BGP_CLEAR_SOFT_IN, NULL);
8398 }
8399
8400 DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in,
8401 clear_ip_bgp_instance_external_ipv4_soft_in_cmd,
8402 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft in",
8403 CLEAR_STR
8404 IP_STR
8405 BGP_STR
8406 BGP_INSTANCE_HELP_STR
8407 "Clear all external peers\n"
8408 "Address family\n"
8409 "Address Family modifier\n"
8410 "Address Family modifier\n"
8411 BGP_SOFT_STR
8412 BGP_SOFT_IN_STR)
8413 {
8414 if (strncmp (argv[2], "m", 1) == 0)
8415 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
8416 BGP_CLEAR_SOFT_IN, NULL);
8417
8418 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
8419 BGP_CLEAR_SOFT_IN, NULL);
8420 }
8421
8422 ALIAS (clear_ip_bgp_external_ipv4_soft_in,
8423 clear_ip_bgp_external_ipv4_in_cmd,
8424 "clear ip bgp external ipv4 (unicast|multicast) in",
8425 CLEAR_STR
8426 IP_STR
8427 BGP_STR
8428 "Clear all external peers\n"
8429 "Address family\n"
8430 "Address Family modifier\n"
8431 "Address Family modifier\n"
8432 BGP_SOFT_IN_STR)
8433
8434 ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in,
8435 clear_ip_bgp_instance_external_ipv4_in_cmd,
8436 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) in",
8437 CLEAR_STR
8438 IP_STR
8439 BGP_STR
8440 BGP_INSTANCE_HELP_STR
8441 "Clear all external peers\n"
8442 "Address family\n"
8443 "Address Family modifier\n"
8444 "Address Family modifier\n"
8445 BGP_SOFT_IN_STR)
8446
8447 DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
8448 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
8449 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
8450 CLEAR_STR
8451 IP_STR
8452 BGP_STR
8453 "Clear all external peers\n"
8454 "Address family\n"
8455 "Address Family modifier\n"
8456 "Address Family modifier\n"
8457 BGP_SOFT_IN_STR
8458 "Push out prefix-list ORF and do inbound soft reconfig\n")
8459 {
8460 if (strncmp (argv[0], "m", 1) == 0)
8461 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8462 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8463
8464 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8465 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8466 }
8467
8468 DEFUN (clear_bgp_external_soft_in,
8469 clear_bgp_external_soft_in_cmd,
8470 "clear bgp external soft in",
8471 CLEAR_STR
8472 BGP_STR
8473 "Clear all external peers\n"
8474 BGP_SOFT_STR
8475 BGP_SOFT_IN_STR)
8476 {
8477 if (argc == 2)
8478 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
8479 BGP_CLEAR_SOFT_IN, NULL);
8480
8481 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8482 BGP_CLEAR_SOFT_IN, NULL);
8483 }
8484
8485 ALIAS (clear_bgp_external_soft_in,
8486 clear_bgp_instance_external_soft_in_cmd,
8487 "clear bgp " BGP_INSTANCE_CMD " external soft in",
8488 CLEAR_STR
8489 BGP_STR
8490 BGP_INSTANCE_HELP_STR
8491 "Clear all external peers\n"
8492 BGP_SOFT_STR
8493 BGP_SOFT_IN_STR)
8494
8495 ALIAS (clear_bgp_external_soft_in,
8496 clear_bgp_ipv6_external_soft_in_cmd,
8497 "clear bgp ipv6 external soft in",
8498 CLEAR_STR
8499 BGP_STR
8500 "Address family\n"
8501 "Clear all external peers\n"
8502 BGP_SOFT_STR
8503 BGP_SOFT_IN_STR)
8504
8505 ALIAS (clear_bgp_external_soft_in,
8506 clear_bgp_instance_ipv6_external_soft_in_cmd,
8507 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft in",
8508 CLEAR_STR
8509 BGP_STR
8510 BGP_INSTANCE_HELP_STR
8511 "Address family\n"
8512 "Clear all external peers\n"
8513 BGP_SOFT_STR
8514 BGP_SOFT_IN_STR)
8515
8516 ALIAS (clear_bgp_external_soft_in,
8517 clear_bgp_external_in_cmd,
8518 "clear bgp external in",
8519 CLEAR_STR
8520 BGP_STR
8521 "Clear all external peers\n"
8522 BGP_SOFT_IN_STR)
8523
8524 ALIAS (clear_bgp_external_soft_in,
8525 clear_bgp_instance_external_in_cmd,
8526 "clear bgp " BGP_INSTANCE_CMD " external in",
8527 CLEAR_STR
8528 BGP_STR
8529 BGP_INSTANCE_HELP_STR
8530 "Clear all external peers\n"
8531 BGP_SOFT_IN_STR)
8532
8533 ALIAS (clear_bgp_external_soft_in,
8534 clear_bgp_ipv6_external_in_cmd,
8535 "clear bgp ipv6 external WORD in",
8536 CLEAR_STR
8537 BGP_STR
8538 "Address family\n"
8539 "Clear all external peers\n"
8540 BGP_SOFT_IN_STR)
8541
8542 ALIAS (clear_bgp_external_soft_in,
8543 clear_bgp_instance_ipv6_external_in_cmd,
8544 "clear bgp " BGP_INSTANCE_CMD " ipv6 external WORD in",
8545 CLEAR_STR
8546 BGP_STR
8547 BGP_INSTANCE_HELP_STR
8548 "Address family\n"
8549 "Clear all external peers\n"
8550 BGP_SOFT_IN_STR)
8551
8552 DEFUN (clear_bgp_external_in_prefix_filter,
8553 clear_bgp_external_in_prefix_filter_cmd,
8554 "clear bgp external in prefix-filter",
8555 CLEAR_STR
8556 BGP_STR
8557 "Clear all external peers\n"
8558 BGP_SOFT_IN_STR
8559 "Push out prefix-list ORF and do inbound soft reconfig\n")
8560 {
8561 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8562 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
8563 }
8564
8565 ALIAS (clear_bgp_external_in_prefix_filter,
8566 clear_bgp_ipv6_external_in_prefix_filter_cmd,
8567 "clear bgp ipv6 external in prefix-filter",
8568 CLEAR_STR
8569 BGP_STR
8570 "Address family\n"
8571 "Clear all external peers\n"
8572 BGP_SOFT_IN_STR
8573 "Push out prefix-list ORF and do inbound soft reconfig\n")
8574
8575 DEFUN (clear_ip_bgp_as_soft_in,
8576 clear_ip_bgp_as_soft_in_cmd,
8577 "clear ip bgp " CMD_AS_RANGE " soft in",
8578 CLEAR_STR
8579 IP_STR
8580 BGP_STR
8581 "Clear peers with the AS number\n"
8582 BGP_SOFT_STR
8583 BGP_SOFT_IN_STR)
8584 {
8585 if (argc == 3)
8586 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8587 BGP_CLEAR_SOFT_IN, argv[2]);
8588
8589 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8590 BGP_CLEAR_SOFT_IN, argv[0]);
8591 }
8592
8593 ALIAS (clear_ip_bgp_as_soft_in,
8594 clear_ip_bgp_instance_as_soft_in_cmd,
8595 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8596 CLEAR_STR
8597 IP_STR
8598 BGP_STR
8599 BGP_INSTANCE_HELP_STR
8600 "Clear peers with the AS number\n"
8601 BGP_SOFT_STR
8602 BGP_SOFT_IN_STR)
8603
8604 ALIAS (clear_ip_bgp_as_soft_in,
8605 clear_ip_bgp_as_in_cmd,
8606 "clear ip bgp " CMD_AS_RANGE " in",
8607 CLEAR_STR
8608 IP_STR
8609 BGP_STR
8610 "Clear peers with the AS number\n"
8611 BGP_SOFT_IN_STR)
8612
8613 ALIAS (clear_ip_bgp_as_soft_in,
8614 clear_ip_bgp_instance_as_in_cmd,
8615 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
8616 CLEAR_STR
8617 IP_STR
8618 BGP_STR
8619 BGP_INSTANCE_HELP_STR
8620 "Clear peers with the AS number\n"
8621 BGP_SOFT_IN_STR)
8622
8623 DEFUN (clear_ip_bgp_as_in_prefix_filter,
8624 clear_ip_bgp_as_in_prefix_filter_cmd,
8625 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
8626 CLEAR_STR
8627 IP_STR
8628 BGP_STR
8629 "Clear peers with the AS number\n"
8630 BGP_SOFT_IN_STR
8631 "Push out prefix-list ORF and do inbound soft reconfig\n")
8632 {
8633 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8634 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8635 }
8636
8637 DEFUN (clear_ip_bgp_as_ipv4_soft_in,
8638 clear_ip_bgp_as_ipv4_soft_in_cmd,
8639 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
8640 CLEAR_STR
8641 IP_STR
8642 BGP_STR
8643 "Clear peers with the AS number\n"
8644 "Address family\n"
8645 "Address Family modifier\n"
8646 "Address Family modifier\n"
8647 BGP_SOFT_STR
8648 BGP_SOFT_IN_STR)
8649 {
8650 if (strncmp (argv[1], "m", 1) == 0)
8651 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
8652 BGP_CLEAR_SOFT_IN, argv[0]);
8653
8654 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8655 BGP_CLEAR_SOFT_IN, argv[0]);
8656 }
8657
8658 DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in,
8659 clear_ip_bgp_instance_as_ipv4_soft_in_cmd,
8660 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
8661 CLEAR_STR
8662 IP_STR
8663 BGP_STR
8664 BGP_INSTANCE_HELP_STR
8665 "Clear peers with the AS number\n"
8666 "Address family\n"
8667 "Address Family modifier\n"
8668 "Address Family modifier\n"
8669 BGP_SOFT_STR
8670 BGP_SOFT_IN_STR)
8671 {
8672 if (strncmp (argv[3], "m", 1) == 0)
8673 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
8674 BGP_CLEAR_SOFT_IN, argv[2]);
8675
8676 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
8677 BGP_CLEAR_SOFT_IN, argv[2]);
8678 }
8679
8680 ALIAS (clear_ip_bgp_as_ipv4_soft_in,
8681 clear_ip_bgp_as_ipv4_in_cmd,
8682 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
8683 CLEAR_STR
8684 IP_STR
8685 BGP_STR
8686 "Clear peers with the AS number\n"
8687 "Address family\n"
8688 "Address Family modifier\n"
8689 "Address Family modifier\n"
8690 BGP_SOFT_IN_STR)
8691
8692 ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in,
8693 clear_ip_bgp_instance_as_ipv4_in_cmd,
8694 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
8695 CLEAR_STR
8696 IP_STR
8697 BGP_STR
8698 BGP_INSTANCE_HELP_STR
8699 "Clear peers with the AS number\n"
8700 "Address family\n"
8701 "Address Family modifier\n"
8702 "Address Family modifier\n"
8703 BGP_SOFT_IN_STR)
8704
8705 DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
8706 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
8707 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
8708 CLEAR_STR
8709 IP_STR
8710 BGP_STR
8711 "Clear peers with the AS number\n"
8712 "Address family\n"
8713 "Address Family modifier\n"
8714 "Address Family modifier\n"
8715 BGP_SOFT_IN_STR
8716 "Push out prefix-list ORF and do inbound soft reconfig\n")
8717 {
8718 if (strncmp (argv[1], "m", 1) == 0)
8719 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
8720 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8721
8722 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8723 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8724 }
8725
8726 DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
8727 clear_ip_bgp_as_vpnv4_soft_in_cmd,
8728 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
8729 CLEAR_STR
8730 IP_STR
8731 BGP_STR
8732 "Clear peers with the AS number\n"
8733 "Address family\n"
8734 "Address Family modifier\n"
8735 BGP_SOFT_STR
8736 BGP_SOFT_IN_STR)
8737 {
8738 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
8739 BGP_CLEAR_SOFT_IN, argv[0]);
8740 }
8741
8742 ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
8743 clear_ip_bgp_as_vpnv4_in_cmd,
8744 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
8745 CLEAR_STR
8746 IP_STR
8747 BGP_STR
8748 "Clear peers with the AS number\n"
8749 "Address family\n"
8750 "Address Family modifier\n"
8751 BGP_SOFT_IN_STR)
8752
8753 DEFUN (clear_bgp_as_soft_in,
8754 clear_bgp_as_soft_in_cmd,
8755 "clear bgp " CMD_AS_RANGE " soft in",
8756 CLEAR_STR
8757 BGP_STR
8758 "Clear peers with the AS number\n"
8759 BGP_SOFT_STR
8760 BGP_SOFT_IN_STR)
8761 {
8762 if (argc == 3)
8763 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
8764 BGP_CLEAR_SOFT_IN, argv[2]);
8765
8766 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8767 BGP_CLEAR_SOFT_IN, argv[0]);
8768 }
8769
8770 ALIAS (clear_bgp_as_soft_in,
8771 clear_bgp_instance_as_soft_in_cmd,
8772 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft in",
8773 CLEAR_STR
8774 BGP_STR
8775 BGP_INSTANCE_HELP_STR
8776 "Clear peers with the AS number\n"
8777 BGP_SOFT_STR
8778 BGP_SOFT_IN_STR)
8779
8780 ALIAS (clear_bgp_as_soft_in,
8781 clear_bgp_ipv6_as_soft_in_cmd,
8782 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
8783 CLEAR_STR
8784 BGP_STR
8785 "Address family\n"
8786 "Clear peers with the AS number\n"
8787 BGP_SOFT_STR
8788 BGP_SOFT_IN_STR)
8789
8790 ALIAS (clear_bgp_as_soft_in,
8791 clear_bgp_instance_ipv6_as_soft_in_cmd,
8792 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft in",
8793 CLEAR_STR
8794 BGP_STR
8795 BGP_INSTANCE_HELP_STR
8796 "Address family\n"
8797 "Clear peers with the AS number\n"
8798 BGP_SOFT_STR
8799 BGP_SOFT_IN_STR)
8800
8801 ALIAS (clear_bgp_as_soft_in,
8802 clear_bgp_as_in_cmd,
8803 "clear bgp " CMD_AS_RANGE " in",
8804 CLEAR_STR
8805 BGP_STR
8806 "Clear peers with the AS number\n"
8807 BGP_SOFT_IN_STR)
8808
8809 ALIAS (clear_bgp_as_soft_in,
8810 clear_bgp_instance_as_in_cmd,
8811 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " in",
8812 CLEAR_STR
8813 BGP_STR
8814 BGP_INSTANCE_HELP_STR
8815 "Clear peers with the AS number\n"
8816 BGP_SOFT_IN_STR)
8817
8818 ALIAS (clear_bgp_as_soft_in,
8819 clear_bgp_ipv6_as_in_cmd,
8820 "clear bgp ipv6 " CMD_AS_RANGE " in",
8821 CLEAR_STR
8822 BGP_STR
8823 "Address family\n"
8824 "Clear peers with the AS number\n"
8825 BGP_SOFT_IN_STR)
8826
8827 ALIAS (clear_bgp_as_soft_in,
8828 clear_bgp_instance_ipv6_as_in_cmd,
8829 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " in",
8830 CLEAR_STR
8831 BGP_STR
8832 BGP_INSTANCE_HELP_STR
8833 "Address family\n"
8834 "Clear peers with the AS number\n"
8835 BGP_SOFT_IN_STR)
8836
8837 DEFUN (clear_bgp_as_in_prefix_filter,
8838 clear_bgp_as_in_prefix_filter_cmd,
8839 "clear bgp " CMD_AS_RANGE " in prefix-filter",
8840 CLEAR_STR
8841 BGP_STR
8842 "Clear peers with the AS number\n"
8843 BGP_SOFT_IN_STR
8844 "Push out prefix-list ORF and do inbound soft reconfig\n")
8845 {
8846 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8847 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
8848 }
8849
8850 ALIAS (clear_bgp_as_in_prefix_filter,
8851 clear_bgp_ipv6_as_in_prefix_filter_cmd,
8852 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
8853 CLEAR_STR
8854 BGP_STR
8855 "Address family\n"
8856 "Clear peers with the AS number\n"
8857 BGP_SOFT_IN_STR
8858 "Push out prefix-list ORF and do inbound soft reconfig\n")
8859
8860 /* Both soft-reconfiguration */
8861 DEFUN (clear_ip_bgp_all_soft,
8862 clear_ip_bgp_all_soft_cmd,
8863 "clear ip bgp * soft",
8864 CLEAR_STR
8865 IP_STR
8866 BGP_STR
8867 "Clear all peers\n"
8868 BGP_SOFT_STR)
8869 {
8870 if (argc == 2)
8871 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
8872 BGP_CLEAR_SOFT_BOTH, NULL);
8873
8874 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8875 BGP_CLEAR_SOFT_BOTH, NULL);
8876 }
8877
8878 ALIAS (clear_ip_bgp_all_soft,
8879 clear_ip_bgp_instance_all_soft_cmd,
8880 "clear ip bgp " BGP_INSTANCE_CMD " * soft",
8881 CLEAR_STR
8882 IP_STR
8883 BGP_STR
8884 BGP_INSTANCE_HELP_STR
8885 "Clear all peers\n"
8886 BGP_SOFT_STR)
8887
8888
8889 DEFUN (clear_ip_bgp_all_ipv4_soft,
8890 clear_ip_bgp_all_ipv4_soft_cmd,
8891 "clear ip bgp * ipv4 (unicast|multicast) soft",
8892 CLEAR_STR
8893 IP_STR
8894 BGP_STR
8895 "Clear all peers\n"
8896 "Address family\n"
8897 "Address Family Modifier\n"
8898 "Address Family Modifier\n"
8899 BGP_SOFT_STR)
8900 {
8901 if (strncmp (argv[0], "m", 1) == 0)
8902 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
8903 BGP_CLEAR_SOFT_BOTH, NULL);
8904
8905 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8906 BGP_CLEAR_SOFT_BOTH, NULL);
8907 }
8908
8909 DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
8910 clear_ip_bgp_instance_all_ipv4_soft_cmd,
8911 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft",
8912 CLEAR_STR
8913 IP_STR
8914 BGP_STR
8915 BGP_INSTANCE_HELP_STR
8916 "Clear all peers\n"
8917 "Address family\n"
8918 "Address Family Modifier\n"
8919 "Address Family Modifier\n"
8920 BGP_SOFT_STR)
8921 {
8922 if (strncmp (argv[2], "m", 1) == 0)
8923 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
8924 BGP_CLEAR_SOFT_BOTH, NULL);
8925
8926 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
8927 BGP_CLEAR_SOFT_BOTH, NULL);
8928 }
8929
8930 DEFUN (clear_ip_bgp_all_vpnv4_soft,
8931 clear_ip_bgp_all_vpnv4_soft_cmd,
8932 "clear ip bgp * vpnv4 unicast soft",
8933 CLEAR_STR
8934 IP_STR
8935 BGP_STR
8936 "Clear all peers\n"
8937 "Address family\n"
8938 "Address Family Modifier\n"
8939 BGP_SOFT_STR)
8940 {
8941 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
8942 BGP_CLEAR_SOFT_BOTH, argv[0]);
8943 }
8944
8945 DEFUN (clear_bgp_all_soft,
8946 clear_bgp_all_soft_cmd,
8947 "clear bgp * soft",
8948 CLEAR_STR
8949 BGP_STR
8950 "Clear all peers\n"
8951 BGP_SOFT_STR)
8952 {
8953 if (argc == 2)
8954 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
8955 BGP_CLEAR_SOFT_BOTH, NULL);
8956
8957 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
8958 BGP_CLEAR_SOFT_BOTH, NULL);
8959 }
8960
8961 ALIAS (clear_bgp_all_soft,
8962 clear_bgp_instance_all_soft_cmd,
8963 "clear bgp " BGP_INSTANCE_CMD " * soft",
8964 CLEAR_STR
8965 BGP_STR
8966 BGP_INSTANCE_HELP_STR
8967 "Clear all peers\n"
8968 BGP_SOFT_STR)
8969
8970 ALIAS (clear_bgp_all_soft,
8971 clear_bgp_ipv6_all_soft_cmd,
8972 "clear bgp ipv6 * soft",
8973 CLEAR_STR
8974 BGP_STR
8975 "Address family\n"
8976 "Clear all peers\n"
8977 BGP_SOFT_STR)
8978
8979 ALIAS (clear_bgp_all_soft,
8980 clear_bgp_instance_ipv6_all_soft_cmd,
8981 "clear bgp " BGP_INSTANCE_CMD " ipv6 * soft",
8982 CLEAR_STR
8983 BGP_STR
8984 BGP_INSTANCE_HELP_STR
8985 "Address family\n"
8986 "Clear all peers\n"
8987 BGP_SOFT_STR)
8988
8989 DEFUN (clear_ip_bgp_peer_soft,
8990 clear_ip_bgp_peer_soft_cmd,
8991 "clear ip bgp (A.B.C.D|WORD) soft",
8992 CLEAR_STR
8993 IP_STR
8994 BGP_STR
8995 "BGP neighbor address to clear\n"
8996 "BGP neighbor on interface to clear\n"
8997 BGP_SOFT_STR)
8998 {
8999 if (argc == 3)
9000 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
9001 BGP_CLEAR_SOFT_BOTH, argv[2]);
9002
9003 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
9004 BGP_CLEAR_SOFT_BOTH, argv[0]);
9005 }
9006
9007 ALIAS (clear_ip_bgp_peer_soft,
9008 clear_ip_bgp_instance_peer_soft_cmd,
9009 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) soft",
9010 CLEAR_STR
9011 IP_STR
9012 BGP_STR
9013 BGP_INSTANCE_HELP_STR
9014 "BGP neighbor address to clear\n"
9015 "BGP neighbor on interface to clear\n"
9016 BGP_SOFT_STR)
9017
9018 DEFUN (clear_ip_bgp_peer_ipv4_soft,
9019 clear_ip_bgp_peer_ipv4_soft_cmd,
9020 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
9021 CLEAR_STR
9022 IP_STR
9023 BGP_STR
9024 "BGP neighbor address to clear\n"
9025 "BGP neighbor on interface to clear\n"
9026 "Address family\n"
9027 "Address Family Modifier\n"
9028 "Address Family Modifier\n"
9029 BGP_SOFT_STR)
9030 {
9031 if (strncmp (argv[1], "m", 1) == 0)
9032 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
9033 BGP_CLEAR_SOFT_BOTH, argv[0]);
9034
9035 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
9036 BGP_CLEAR_SOFT_BOTH, argv[0]);
9037 }
9038
9039 DEFUN (clear_ip_bgp_instance_peer_ipv4_soft,
9040 clear_ip_bgp_instance_peer_ipv4_soft_cmd,
9041 "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
9042 CLEAR_STR
9043 IP_STR
9044 BGP_STR
9045 BGP_INSTANCE_HELP_STR
9046 "BGP neighbor address to clear\n"
9047 "BGP neighbor on interface to clear\n"
9048 "Address family\n"
9049 "Address Family Modifier\n"
9050 "Address Family Modifier\n"
9051 BGP_SOFT_STR)
9052 {
9053 if (strncmp (argv[3], "m", 1) == 0)
9054 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer,
9055 BGP_CLEAR_SOFT_BOTH, argv[2]);
9056
9057 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer,
9058 BGP_CLEAR_SOFT_BOTH, argv[2]);
9059 }
9060
9061 DEFUN (clear_ip_bgp_peer_vpnv4_soft,
9062 clear_ip_bgp_peer_vpnv4_soft_cmd,
9063 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft",
9064 CLEAR_STR
9065 IP_STR
9066 BGP_STR
9067 "BGP neighbor address to clear\n"
9068 "BGP neighbor on interface to clear\n"
9069 "Address family\n"
9070 "Address Family Modifier\n"
9071 BGP_SOFT_STR)
9072 {
9073 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
9074 BGP_CLEAR_SOFT_BOTH, argv[0]);
9075 }
9076
9077 DEFUN (clear_bgp_peer_soft,
9078 clear_bgp_peer_soft_cmd,
9079 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
9080 CLEAR_STR
9081 BGP_STR
9082 "BGP neighbor address to clear\n"
9083 "BGP IPv6 neighbor to clear\n"
9084 "BGP neighbor on interface to clear\n"
9085 BGP_SOFT_STR)
9086 {
9087 if (argc == 3)
9088 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_peer,
9089 BGP_CLEAR_SOFT_BOTH, argv[2]);
9090
9091 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
9092 BGP_CLEAR_SOFT_BOTH, argv[0]);
9093 }
9094
9095 ALIAS (clear_bgp_peer_soft,
9096 clear_bgp_instance_peer_soft_cmd,
9097 "clear bgp " BGP_INSTANCE_CMD " (A.B.C.D|X:X::X:X|WORD) soft",
9098 CLEAR_STR
9099 BGP_STR
9100 BGP_INSTANCE_HELP_STR
9101 "BGP neighbor address to clear\n"
9102 "BGP IPv6 neighbor to clear\n"
9103 "BGP neighbor on interface to clear\n"
9104 BGP_SOFT_STR)
9105
9106 ALIAS (clear_bgp_peer_soft,
9107 clear_bgp_ipv6_peer_soft_cmd,
9108 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
9109 CLEAR_STR
9110 BGP_STR
9111 "Address family\n"
9112 "BGP neighbor address to clear\n"
9113 "BGP IPv6 neighbor to clear\n"
9114 "BGP neighbor on interface to clear\n"
9115 BGP_SOFT_STR)
9116
9117 ALIAS (clear_bgp_peer_soft,
9118 clear_bgp_instance_ipv6_peer_soft_cmd,
9119 "clear bgp " BGP_INSTANCE_CMD " ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
9120 CLEAR_STR
9121 BGP_STR
9122 BGP_INSTANCE_HELP_STR
9123 "Address family\n"
9124 "BGP neighbor address to clear\n"
9125 "BGP IPv6 neighbor to clear\n"
9126 "BGP neighbor on interface to clear\n"
9127 BGP_SOFT_STR)
9128
9129 DEFUN (clear_ip_bgp_peer_group_soft,
9130 clear_ip_bgp_peer_group_soft_cmd,
9131 "clear ip bgp peer-group WORD soft",
9132 CLEAR_STR
9133 IP_STR
9134 BGP_STR
9135 "Clear all members of peer-group\n"
9136 "BGP peer-group name\n"
9137 BGP_SOFT_STR)
9138 {
9139 if (argc == 3)
9140 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
9141 BGP_CLEAR_SOFT_BOTH, argv[2]);
9142
9143 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
9144 BGP_CLEAR_SOFT_BOTH, argv[0]);
9145 }
9146
9147 ALIAS (clear_ip_bgp_peer_group_soft,
9148 clear_ip_bgp_instance_peer_group_soft_cmd,
9149 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9150 CLEAR_STR
9151 IP_STR
9152 BGP_STR
9153 BGP_INSTANCE_HELP_STR
9154 "Clear all members of peer-group\n"
9155 "BGP peer-group name\n"
9156 BGP_SOFT_STR)
9157
9158 DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
9159 clear_ip_bgp_peer_group_ipv4_soft_cmd,
9160 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
9161 CLEAR_STR
9162 IP_STR
9163 BGP_STR
9164 "Clear all members of peer-group\n"
9165 "BGP peer-group name\n"
9166 "Address family\n"
9167 "Address Family modifier\n"
9168 "Address Family modifier\n"
9169 BGP_SOFT_STR)
9170 {
9171 if (strncmp (argv[1], "m", 1) == 0)
9172 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
9173 BGP_CLEAR_SOFT_BOTH, argv[0]);
9174
9175 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
9176 BGP_CLEAR_SOFT_BOTH, argv[0]);
9177 }
9178
9179 DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft,
9180 clear_ip_bgp_instance_peer_group_ipv4_soft_cmd,
9181 "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft",
9182 CLEAR_STR
9183 IP_STR
9184 BGP_STR
9185 BGP_INSTANCE_HELP_STR
9186 "Clear all members of peer-group\n"
9187 "BGP peer-group name\n"
9188 "Address family\n"
9189 "Address Family modifier\n"
9190 "Address Family modifier\n"
9191 BGP_SOFT_STR)
9192 {
9193 if (strncmp (argv[3], "m", 1) == 0)
9194 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group,
9195 BGP_CLEAR_SOFT_BOTH, argv[2]);
9196
9197 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group,
9198 BGP_CLEAR_SOFT_BOTH, argv[2]);
9199 }
9200
9201 DEFUN (clear_bgp_peer_group_soft,
9202 clear_bgp_peer_group_soft_cmd,
9203 "clear bgp peer-group WORD soft",
9204 CLEAR_STR
9205 BGP_STR
9206 "Clear all members of peer-group\n"
9207 "BGP peer-group name\n"
9208 BGP_SOFT_STR)
9209 {
9210 if (argc == 3)
9211 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_group,
9212 BGP_CLEAR_SOFT_BOTH, argv[2]);
9213
9214 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
9215 BGP_CLEAR_SOFT_BOTH, argv[0]);
9216 }
9217
9218 ALIAS (clear_bgp_peer_group_soft,
9219 clear_bgp_instance_peer_group_soft_cmd,
9220 "clear bgp " BGP_INSTANCE_CMD " peer-group WORD soft",
9221 CLEAR_STR
9222 BGP_STR
9223 BGP_INSTANCE_HELP_STR
9224 "Clear all members of peer-group\n"
9225 "BGP peer-group name\n"
9226 BGP_SOFT_STR)
9227
9228 ALIAS (clear_bgp_peer_group_soft,
9229 clear_bgp_ipv6_peer_group_soft_cmd,
9230 "clear bgp ipv6 peer-group WORD soft",
9231 CLEAR_STR
9232 BGP_STR
9233 "Address family\n"
9234 "Clear all members of peer-group\n"
9235 "BGP peer-group name\n"
9236 BGP_SOFT_STR)
9237
9238 ALIAS (clear_bgp_peer_group_soft,
9239 clear_bgp_instance_ipv6_peer_group_soft_cmd,
9240 "clear bgp " BGP_INSTANCE_CMD " ipv6 peer-group WORD soft",
9241 CLEAR_STR
9242 BGP_STR
9243 BGP_INSTANCE_HELP_STR
9244 "Address family\n"
9245 "Clear all members of peer-group\n"
9246 "BGP peer-group name\n"
9247 BGP_SOFT_STR)
9248
9249 DEFUN (clear_ip_bgp_external_soft,
9250 clear_ip_bgp_external_soft_cmd,
9251 "clear ip bgp external soft",
9252 CLEAR_STR
9253 IP_STR
9254 BGP_STR
9255 "Clear all external peers\n"
9256 BGP_SOFT_STR)
9257 {
9258 if (argc == 2)
9259 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
9260 BGP_CLEAR_SOFT_BOTH, NULL);
9261
9262 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
9263 BGP_CLEAR_SOFT_BOTH, NULL);
9264 }
9265
9266 ALIAS (clear_ip_bgp_external_soft,
9267 clear_ip_bgp_instance_external_soft_cmd,
9268 "clear ip bgp " BGP_INSTANCE_CMD " external soft",
9269 CLEAR_STR
9270 IP_STR
9271 BGP_STR
9272 BGP_INSTANCE_HELP_STR
9273 "Clear all external peers\n"
9274 BGP_SOFT_STR)
9275
9276 DEFUN (clear_ip_bgp_external_ipv4_soft,
9277 clear_ip_bgp_external_ipv4_soft_cmd,
9278 "clear ip bgp external ipv4 (unicast|multicast) soft",
9279 CLEAR_STR
9280 IP_STR
9281 BGP_STR
9282 "Clear all external peers\n"
9283 "Address family\n"
9284 "Address Family modifier\n"
9285 "Address Family modifier\n"
9286 BGP_SOFT_STR)
9287 {
9288 if (strncmp (argv[0], "m", 1) == 0)
9289 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
9290 BGP_CLEAR_SOFT_BOTH, NULL);
9291
9292 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
9293 BGP_CLEAR_SOFT_BOTH, NULL);
9294 }
9295
9296 DEFUN (clear_ip_bgp_instance_external_ipv4_soft,
9297 clear_ip_bgp_instance_external_ipv4_soft_cmd,
9298 "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft",
9299 CLEAR_STR
9300 IP_STR
9301 BGP_STR
9302 BGP_INSTANCE_HELP_STR
9303 "Clear all external peers\n"
9304 "Address family\n"
9305 "Address Family modifier\n"
9306 "Address Family modifier\n"
9307 BGP_SOFT_STR)
9308 {
9309 if (strncmp (argv[2], "m", 1) == 0)
9310 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external,
9311 BGP_CLEAR_SOFT_BOTH, NULL);
9312
9313 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external,
9314 BGP_CLEAR_SOFT_BOTH, NULL);
9315 }
9316
9317 DEFUN (clear_bgp_external_soft,
9318 clear_bgp_external_soft_cmd,
9319 "clear bgp external soft",
9320 CLEAR_STR
9321 BGP_STR
9322 "Clear all external peers\n"
9323 BGP_SOFT_STR)
9324 {
9325 if (argc == 2)
9326 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_external,
9327 BGP_CLEAR_SOFT_BOTH, NULL);
9328
9329 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
9330 BGP_CLEAR_SOFT_BOTH, NULL);
9331 }
9332
9333 ALIAS (clear_bgp_external_soft,
9334 clear_bgp_instance_external_soft_cmd,
9335 "clear bgp " BGP_INSTANCE_CMD " external soft",
9336 CLEAR_STR
9337 BGP_STR
9338 BGP_INSTANCE_HELP_STR
9339 "Clear all external peers\n"
9340 BGP_SOFT_STR)
9341
9342 ALIAS (clear_bgp_external_soft,
9343 clear_bgp_ipv6_external_soft_cmd,
9344 "clear bgp ipv6 external soft",
9345 CLEAR_STR
9346 BGP_STR
9347 "Address family\n"
9348 "Clear all external peers\n"
9349 BGP_SOFT_STR)
9350
9351 ALIAS (clear_bgp_external_soft,
9352 clear_bgp_instance_ipv6_external_soft_cmd,
9353 "clear bgp " BGP_INSTANCE_CMD " ipv6 external soft",
9354 CLEAR_STR
9355 BGP_STR
9356 BGP_INSTANCE_HELP_STR
9357 "Address family\n"
9358 "Clear all external peers\n"
9359 BGP_SOFT_STR)
9360
9361 DEFUN (clear_ip_bgp_as_soft,
9362 clear_ip_bgp_as_soft_cmd,
9363 "clear ip bgp " CMD_AS_RANGE " soft",
9364 CLEAR_STR
9365 IP_STR
9366 BGP_STR
9367 "Clear peers with the AS number\n"
9368 BGP_SOFT_STR)
9369 {
9370 if (argc == 3)
9371 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as,
9372 BGP_CLEAR_SOFT_BOTH, argv[2]);
9373
9374 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
9375 BGP_CLEAR_SOFT_BOTH, argv[0]);
9376 }
9377
9378 ALIAS (clear_ip_bgp_as_soft,
9379 clear_ip_bgp_instance_as_soft_cmd,
9380 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9381 CLEAR_STR
9382 IP_STR
9383 BGP_STR
9384 BGP_INSTANCE_HELP_STR
9385 "Clear peers with the AS number\n"
9386 BGP_SOFT_STR)
9387
9388 DEFUN (clear_ip_bgp_as_ipv4_soft,
9389 clear_ip_bgp_as_ipv4_soft_cmd,
9390 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
9391 CLEAR_STR
9392 IP_STR
9393 BGP_STR
9394 "Clear peers with the AS number\n"
9395 "Address family\n"
9396 "Address Family Modifier\n"
9397 "Address Family Modifier\n"
9398 BGP_SOFT_STR)
9399 {
9400 if (strncmp (argv[1], "m", 1) == 0)
9401 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
9402 BGP_CLEAR_SOFT_BOTH, argv[0]);
9403
9404 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
9405 BGP_CLEAR_SOFT_BOTH, argv[0]);
9406 }
9407
9408 DEFUN (clear_ip_bgp_instance_as_ipv4_soft,
9409 clear_ip_bgp_instance_as_ipv4_soft_cmd,
9410 "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
9411 CLEAR_STR
9412 IP_STR
9413 BGP_STR
9414 BGP_INSTANCE_HELP_STR
9415 "Clear peers with the AS number\n"
9416 "Address family\n"
9417 "Address Family Modifier\n"
9418 "Address Family Modifier\n"
9419 BGP_SOFT_STR)
9420 {
9421 if (strncmp (argv[3], "m", 1) == 0)
9422 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as,
9423 BGP_CLEAR_SOFT_BOTH, argv[2]);
9424
9425 return bgp_clear_vty (vty, argv[1],AFI_IP, SAFI_UNICAST, clear_as,
9426 BGP_CLEAR_SOFT_BOTH, argv[2]);
9427 }
9428
9429 DEFUN (clear_ip_bgp_as_vpnv4_soft,
9430 clear_ip_bgp_as_vpnv4_soft_cmd,
9431 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
9432 CLEAR_STR
9433 IP_STR
9434 BGP_STR
9435 "Clear peers with the AS number\n"
9436 "Address family\n"
9437 "Address Family Modifier\n"
9438 BGP_SOFT_STR)
9439 {
9440 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
9441 BGP_CLEAR_SOFT_BOTH, argv[0]);
9442 }
9443
9444 DEFUN (clear_bgp_as_soft,
9445 clear_bgp_as_soft_cmd,
9446 "clear bgp " CMD_AS_RANGE " soft",
9447 CLEAR_STR
9448 BGP_STR
9449 "Clear peers with the AS number\n"
9450 BGP_SOFT_STR)
9451 {
9452 if (argc == 3)
9453 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_as,
9454 BGP_CLEAR_SOFT_BOTH, argv[2]);
9455
9456 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
9457 BGP_CLEAR_SOFT_BOTH, argv[0]);
9458 }
9459
9460 ALIAS (clear_bgp_as_soft,
9461 clear_bgp_instance_as_soft_cmd,
9462 "clear bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " soft",
9463 CLEAR_STR
9464 BGP_STR
9465 BGP_INSTANCE_HELP_STR
9466 "Clear peers with the AS number\n"
9467 BGP_SOFT_STR)
9468
9469 ALIAS (clear_bgp_as_soft,
9470 clear_bgp_ipv6_as_soft_cmd,
9471 "clear bgp ipv6 " CMD_AS_RANGE " soft",
9472 CLEAR_STR
9473 BGP_STR
9474 "Address family\n"
9475 "Clear peers with the AS number\n"
9476 BGP_SOFT_STR)
9477
9478 ALIAS (clear_bgp_as_soft,
9479 clear_bgp_instance_ipv6_as_soft_cmd,
9480 "clear bgp " BGP_INSTANCE_CMD " ipv6 " CMD_AS_RANGE " soft",
9481 CLEAR_STR
9482 BGP_STR
9483 BGP_INSTANCE_HELP_STR
9484 "Address family\n"
9485 "Clear peers with the AS number\n"
9486 BGP_SOFT_STR)
9487
9488 DEFUN (show_bgp_views,
9489 show_bgp_views_cmd,
9490 "show bgp views",
9491 SHOW_STR
9492 BGP_STR
9493 "Show the defined BGP views\n")
9494 {
9495 struct list *inst = bm->bgp;
9496 struct listnode *node;
9497 struct bgp *bgp;
9498
9499 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9500 {
9501 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
9502 return CMD_WARNING;
9503 }
9504
9505 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
9506 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
9507 {
9508 /* Skip VRFs. */
9509 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
9510 continue;
9511 vty_out (vty, "\t%s (AS%u)%s",
9512 bgp->name ? bgp->name : "(null)",
9513 bgp->as, VTY_NEWLINE);
9514 }
9515
9516 return CMD_SUCCESS;
9517 }
9518
9519 DEFUN (show_bgp_vrfs,
9520 show_bgp_vrfs_cmd,
9521 "show bgp vrfs {json}",
9522 SHOW_STR
9523 BGP_STR
9524 "Show BGP VRFs\n"
9525 "JavaScript Object Notation\n")
9526 {
9527 struct list *inst = bm->bgp;
9528 struct listnode *node;
9529 struct bgp *bgp;
9530 u_char uj = use_json(argc, argv);
9531 json_object *json = NULL;
9532 json_object *json_vrfs = NULL;
9533 int count = 0;
9534 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
9535
9536 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
9537 {
9538 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
9539 return CMD_WARNING;
9540 }
9541
9542 if (uj)
9543 {
9544 json = json_object_new_object();
9545 json_vrfs = json_object_new_object();
9546 }
9547
9548 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
9549 {
9550 const char *name, *type;
9551 struct peer *peer;
9552 struct listnode *node, *nnode;
9553 int peers_cfg, peers_estb;
9554 json_object *json_vrf = NULL;
9555
9556 /* Skip Views. */
9557 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
9558 continue;
9559
9560 count++;
9561 if (!uj && count == 1)
9562 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9563
9564 peers_cfg = peers_estb = 0;
9565 if (uj)
9566 json_vrf = json_object_new_object();
9567
9568
9569 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9570 {
9571 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9572 continue;
9573 peers_cfg++;
9574 if (peer->status == Established)
9575 peers_estb++;
9576 }
9577
9578 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9579 {
9580 name = "Default";
9581 type = "DFLT";
9582 }
9583 else
9584 {
9585 name = bgp->name;
9586 type = "VRF";
9587 }
9588
9589 if (uj)
9590 {
9591 json_object_string_add(json_vrf, "type", type);
9592 json_object_int_add(json_vrf, "vrfId", bgp->vrf_id);
9593 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
9594 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
9595 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
9596
9597 json_object_object_add(json_vrfs, name, json_vrf);
9598 }
9599 else
9600 vty_out (vty, "%4s %-5u %-16s %9u %10u %s%s",
9601 type, bgp->vrf_id, inet_ntoa (bgp->router_id),
9602 peers_cfg, peers_estb, name,
9603 VTY_NEWLINE);
9604 }
9605
9606 if (uj)
9607 {
9608 json_object_object_add(json, "vrfs", json_vrfs);
9609
9610 json_object_int_add(json, "totalVrfs", count);
9611
9612 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
9613 json_object_free(json);
9614 }
9615 else
9616 {
9617 if (count)
9618 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
9619 VTY_NEWLINE, count, VTY_NEWLINE);
9620 }
9621
9622 return CMD_SUCCESS;
9623 }
9624
9625 DEFUN (show_bgp_memory,
9626 show_bgp_memory_cmd,
9627 "show bgp memory",
9628 SHOW_STR
9629 BGP_STR
9630 "Global BGP memory statistics\n")
9631 {
9632 char memstrbuf[MTYPE_MEMSTR_LEN];
9633 unsigned long count;
9634
9635 /* RIB related usage stats */
9636 count = mtype_stats_alloc (MTYPE_BGP_NODE);
9637 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
9638 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9639 count * sizeof (struct bgp_node)),
9640 VTY_NEWLINE);
9641
9642 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
9643 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
9644 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9645 count * sizeof (struct bgp_info)),
9646 VTY_NEWLINE);
9647 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
9648 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
9649 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9650 count * sizeof (struct bgp_info_extra)),
9651 VTY_NEWLINE);
9652
9653 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
9654 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
9655 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9656 count * sizeof (struct bgp_static)),
9657 VTY_NEWLINE);
9658
9659 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
9660 vty_out (vty, "%ld Packets, using %s of memory%s", count,
9661 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9662 count * sizeof (struct bpacket)),
9663 VTY_NEWLINE);
9664
9665 /* Adj-In/Out */
9666 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
9667 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
9668 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9669 count * sizeof (struct bgp_adj_in)),
9670 VTY_NEWLINE);
9671 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
9672 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
9673 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9674 count * sizeof (struct bgp_adj_out)),
9675 VTY_NEWLINE);
9676
9677 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
9678 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
9679 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9680 count * sizeof (struct bgp_nexthop_cache)),
9681 VTY_NEWLINE);
9682
9683 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
9684 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
9685 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9686 count * sizeof (struct bgp_damp_info)),
9687 VTY_NEWLINE);
9688
9689 /* Attributes */
9690 count = attr_count();
9691 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
9692 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9693 count * sizeof(struct attr)),
9694 VTY_NEWLINE);
9695 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
9696 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
9697 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9698 count * sizeof(struct attr_extra)),
9699 VTY_NEWLINE);
9700
9701 if ((count = attr_unknown_count()))
9702 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
9703
9704 /* AS_PATH attributes */
9705 count = aspath_count ();
9706 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
9707 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9708 count * sizeof (struct aspath)),
9709 VTY_NEWLINE);
9710
9711 count = mtype_stats_alloc (MTYPE_AS_SEG);
9712 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
9713 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9714 count * sizeof (struct assegment)),
9715 VTY_NEWLINE);
9716
9717 /* Other attributes */
9718 if ((count = community_count ()))
9719 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9720 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9721 count * sizeof (struct community)),
9722 VTY_NEWLINE);
9723 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
9724 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
9725 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9726 count * sizeof (struct ecommunity)),
9727 VTY_NEWLINE);
9728
9729 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
9730 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
9731 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9732 count * sizeof (struct cluster_list)),
9733 VTY_NEWLINE);
9734
9735 /* Peer related usage */
9736 count = mtype_stats_alloc (MTYPE_BGP_PEER);
9737 vty_out (vty, "%ld peers, using %s of memory%s", count,
9738 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9739 count * sizeof (struct peer)),
9740 VTY_NEWLINE);
9741
9742 if ((count = mtype_stats_alloc (MTYPE_BGP_PEER_GROUP)))
9743 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
9744 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9745 count * sizeof (struct peer_group)),
9746 VTY_NEWLINE);
9747
9748 /* Other */
9749 if ((count = mtype_stats_alloc (MTYPE_HASH)))
9750 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
9751 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9752 count * sizeof (struct hash)),
9753 VTY_NEWLINE);
9754 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
9755 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
9756 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9757 count * sizeof (struct hash_backet)),
9758 VTY_NEWLINE);
9759 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
9760 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
9761 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9762 count * sizeof (regex_t)),
9763 VTY_NEWLINE);
9764 return CMD_SUCCESS;
9765 }
9766
9767 /* Show BGP peer's summary information. */
9768 static int
9769 bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9770 u_char use_json)
9771 {
9772 struct peer *peer;
9773 struct listnode *node, *nnode;
9774 unsigned int count = 0, dn_count = 0;
9775 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
9776 int len;
9777 json_object *json = NULL;
9778 json_object *json_peer = NULL;
9779 json_object *json_peers = NULL;
9780
9781 /* Header string for each address family. */
9782 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
9783
9784 if (use_json)
9785 {
9786 json = json_object_new_object();
9787 json_peers = json_object_new_object();
9788 }
9789
9790 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
9791 {
9792 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9793 continue;
9794
9795 if (peer->afc[afi][safi])
9796 {
9797 if (!count)
9798 {
9799 unsigned long ents;
9800 char memstrbuf[MTYPE_MEMSTR_LEN];
9801
9802 /* Usage summary and header */
9803 if (use_json)
9804 {
9805 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
9806 json_object_int_add(json, "as", bgp->as);
9807
9808 if (bgp->vrf_id)
9809 json_object_int_add(json, "vrf-id", bgp->vrf_id);
9810
9811 }
9812 else
9813 {
9814 vty_out (vty,
9815 "BGP router identifier %s, local AS number %u",
9816 inet_ntoa (bgp->router_id), bgp->as);
9817
9818 if (bgp->vrf_id)
9819 vty_out (vty, " vrf-id %u", bgp->vrf_id);
9820
9821 vty_out (vty, "%s", VTY_NEWLINE);
9822 }
9823
9824 if (bgp_update_delay_configured(bgp))
9825 {
9826 if (use_json)
9827 {
9828 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
9829
9830 if (bgp->v_update_delay != bgp->v_establish_wait)
9831 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
9832
9833 if (bgp_update_delay_active(bgp))
9834 {
9835 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
9836 json_object_boolean_true_add(json, "updateDelayInProgress");
9837 }
9838 else
9839 {
9840 if (bgp->update_delay_over)
9841 {
9842 json_object_string_add(json, "updateDelayFirstNeighbor",
9843 bgp->update_delay_begin_time);
9844 json_object_string_add(json, "updateDelayBestpathResumed",
9845 bgp->update_delay_end_time);
9846 json_object_string_add(json, "updateDelayZebraUpdateResume",
9847 bgp->update_delay_zebra_resume_time);
9848 json_object_string_add(json, "updateDelayPeerUpdateResume",
9849 bgp->update_delay_peers_resume_time);
9850 }
9851 }
9852 }
9853 else
9854 {
9855 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
9856 bgp->v_update_delay, VTY_NEWLINE);
9857 if (bgp->v_update_delay != bgp->v_establish_wait)
9858 vty_out (vty, " Establish wait: %d seconds%s",
9859 bgp->v_establish_wait, VTY_NEWLINE);
9860
9861 if (bgp_update_delay_active(bgp))
9862 {
9863 vty_out (vty, " First neighbor established: %s%s",
9864 bgp->update_delay_begin_time, VTY_NEWLINE);
9865 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
9866 }
9867 else
9868 {
9869 if (bgp->update_delay_over)
9870 {
9871 vty_out (vty, " First neighbor established: %s%s",
9872 bgp->update_delay_begin_time, VTY_NEWLINE);
9873 vty_out (vty, " Best-paths resumed: %s%s",
9874 bgp->update_delay_end_time, VTY_NEWLINE);
9875 vty_out (vty, " zebra update resumed: %s%s",
9876 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
9877 vty_out (vty, " peers update resumed: %s%s",
9878 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
9879 }
9880 }
9881 }
9882 }
9883
9884 if (use_json)
9885 {
9886 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9887 json_object_boolean_true_add(json, "maxMedOnStartup");
9888 if (bgp->v_maxmed_admin)
9889 json_object_boolean_true_add(json, "maxMedAdministrative");
9890
9891 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
9892
9893 ents = bgp_table_count (bgp->rib[afi][safi]);
9894 json_object_int_add(json, "ribCount", ents);
9895 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
9896
9897 ents = listcount (bgp->peer);
9898 json_object_int_add(json, "peerCount", ents);
9899 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
9900
9901 if ((ents = listcount (bgp->group)))
9902 {
9903 json_object_int_add(json, "peerGroupCount", ents);
9904 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
9905 }
9906
9907 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9908 json_object_boolean_true_add(json, "dampeningEnabled");
9909 }
9910 else
9911 {
9912 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
9913 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
9914 if (bgp->v_maxmed_admin)
9915 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
9916
9917 vty_out(vty, "BGP table version %" PRIu64 "%s",
9918 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
9919
9920 ents = bgp_table_count (bgp->rib[afi][safi]);
9921 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
9922 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9923 ents * sizeof (struct bgp_node)),
9924 VTY_NEWLINE);
9925
9926 /* Peer related usage */
9927 ents = listcount (bgp->peer);
9928 vty_out (vty, "Peers %ld, using %s of memory%s",
9929 ents,
9930 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9931 ents * sizeof (struct peer)),
9932 VTY_NEWLINE);
9933
9934 if ((ents = listcount (bgp->group)))
9935 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
9936 mtype_memstr (memstrbuf, sizeof (memstrbuf),
9937 ents * sizeof (struct peer_group)),
9938 VTY_NEWLINE);
9939
9940 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
9941 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
9942 vty_out (vty, "%s", VTY_NEWLINE);
9943 vty_out (vty, "%s%s", header, VTY_NEWLINE);
9944 }
9945 }
9946
9947 count++;
9948
9949 if (use_json)
9950 {
9951 json_peer = json_object_new_object();
9952
9953 if (peer_dynamic_neighbor(peer))
9954 json_object_boolean_true_add(json_peer, "dynamicPeer");
9955
9956 if (peer->hostname)
9957 json_object_string_add(json_peer, "hostname", peer->hostname);
9958
9959 if (peer->domainname)
9960 json_object_string_add(json_peer, "domainname", peer->domainname);
9961
9962 json_object_int_add(json_peer, "remoteAs", peer->as);
9963 json_object_int_add(json_peer, "version", 4);
9964 json_object_int_add(json_peer, "msgRcvd",
9965 peer->open_in + peer->update_in + peer->keepalive_in
9966 + peer->notify_in + peer->refresh_in
9967 + peer->dynamic_cap_in);
9968 json_object_int_add(json_peer, "msgSent",
9969 peer->open_out + peer->update_out + peer->keepalive_out
9970 + peer->notify_out + peer->refresh_out
9971 + peer->dynamic_cap_out);
9972
9973 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
9974 json_object_int_add(json_peer, "outq", peer->obuf->count);
9975 json_object_int_add(json_peer, "inq", 0);
9976 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
9977 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
9978
9979 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
9980 json_object_string_add(json_peer, "state", "Idle (Admin)");
9981 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9982 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
9983 else
9984 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
9985
9986 if (peer->conf_if)
9987 json_object_string_add(json_peer, "idType", "interface");
9988 else if (peer->su.sa.sa_family == AF_INET)
9989 json_object_string_add(json_peer, "idType", "ipv4");
9990 else if (peer->su.sa.sa_family == AF_INET6)
9991 json_object_string_add(json_peer, "idType", "ipv6");
9992
9993 json_object_object_add(json_peers, peer->host, json_peer);
9994 }
9995 else
9996 {
9997 memset(dn_flag, '\0', sizeof(dn_flag));
9998 if (peer_dynamic_neighbor(peer))
9999 {
10000 dn_count++;
10001 dn_flag[0] = '*';
10002 }
10003
10004 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
10005 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
10006 peer->host);
10007 else
10008 len = vty_out (vty, "%s%s", dn_flag, peer->host);
10009 len = 16 - len;
10010
10011 if (len < 1)
10012 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
10013 else
10014 vty_out (vty, "%*s", len, " ");
10015
10016 vty_out (vty, "4 ");
10017
10018 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
10019 peer->as,
10020 peer->open_in + peer->update_in + peer->keepalive_in
10021 + peer->notify_in + peer->refresh_in
10022 + peer->dynamic_cap_in,
10023 peer->open_out + peer->update_out + peer->keepalive_out
10024 + peer->notify_out + peer->refresh_out
10025 + peer->dynamic_cap_out,
10026 peer->version[afi][safi],
10027 0,
10028 peer->obuf->count);
10029
10030 vty_out (vty, "%-8s",
10031 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
10032
10033 if (peer->status == Established)
10034 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
10035 else
10036 {
10037 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10038 vty_out (vty, " Idle (Admin)");
10039 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10040 vty_out (vty, " Idle (PfxCt)");
10041 else
10042 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
10043 }
10044 vty_out (vty, "%s", VTY_NEWLINE);
10045 }
10046 }
10047 }
10048
10049 if (use_json)
10050 {
10051 json_object_object_add(json, "peers", json_peers);
10052
10053 json_object_int_add(json, "totalPeers", count);
10054 json_object_int_add(json, "dynamicPeers", dn_count);
10055
10056 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
10057 json_object_free(json);
10058 }
10059 else
10060 {
10061 if (count)
10062 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
10063 count, VTY_NEWLINE);
10064 else
10065 vty_out (vty, "No %s neighbor is configured%s",
10066 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
10067
10068 if (dn_count)
10069 {
10070 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
10071 vty_out(vty,
10072 "%d dynamic neighbor(s), limit %d%s",
10073 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
10074 }
10075 }
10076
10077 return CMD_SUCCESS;
10078 }
10079
10080 static int
10081 bgp_show_summary_vty (struct vty *vty, const char *name,
10082 afi_t afi, safi_t safi, u_char use_json)
10083 {
10084 struct bgp *bgp;
10085
10086 if (name)
10087 {
10088 bgp = bgp_lookup_by_name (name);
10089
10090 if (! bgp)
10091 {
10092 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10093 return CMD_WARNING;
10094 }
10095
10096 bgp_show_summary (vty, bgp, afi, safi, use_json);
10097 return CMD_SUCCESS;
10098 }
10099
10100 bgp = bgp_get_default ();
10101
10102 if (bgp)
10103 bgp_show_summary (vty, bgp, afi, safi, use_json);
10104
10105 return CMD_SUCCESS;
10106 }
10107
10108 /* `show ip bgp summary' commands. */
10109 DEFUN (show_ip_bgp_summary,
10110 show_ip_bgp_summary_cmd,
10111 "show ip bgp summary {json}",
10112 SHOW_STR
10113 IP_STR
10114 BGP_STR
10115 "Summary of BGP neighbor status\n"
10116 "JavaScript Object Notation\n")
10117 {
10118 u_char uj = use_json(argc, argv);
10119 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
10120 }
10121
10122 DEFUN (show_ip_bgp_instance_summary,
10123 show_ip_bgp_instance_summary_cmd,
10124 "show ip bgp " BGP_INSTANCE_CMD " summary {json}",
10125 SHOW_STR
10126 IP_STR
10127 BGP_STR
10128 BGP_INSTANCE_HELP_STR
10129 "Summary of BGP neighbor status\n"
10130 "JavaScript Object Notation\n")
10131 {
10132 u_char uj = use_json(argc, argv);
10133 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj);
10134 }
10135
10136 DEFUN (show_ip_bgp_ipv4_summary,
10137 show_ip_bgp_ipv4_summary_cmd,
10138 "show ip bgp ipv4 (unicast|multicast) summary {json}",
10139 SHOW_STR
10140 IP_STR
10141 BGP_STR
10142 "Address family\n"
10143 "Address Family modifier\n"
10144 "Address Family modifier\n"
10145 "Summary of BGP neighbor status\n"
10146 "JavaScript Object Notation\n")
10147 {
10148 u_char uj = use_json(argc, argv);
10149 if (strncmp (argv[0], "m", 1) == 0)
10150 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj);
10151
10152 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
10153 }
10154
10155 ALIAS (show_ip_bgp_ipv4_summary,
10156 show_bgp_ipv4_safi_summary_cmd,
10157 "show bgp ipv4 (unicast|multicast) summary {json}",
10158 SHOW_STR
10159 BGP_STR
10160 "Address family\n"
10161 "Address Family modifier\n"
10162 "Address Family modifier\n"
10163 "Summary of BGP neighbor status\n")
10164
10165 DEFUN (show_ip_bgp_instance_ipv4_summary,
10166 show_ip_bgp_instance_ipv4_summary_cmd,
10167 "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}",
10168 SHOW_STR
10169 IP_STR
10170 BGP_STR
10171 "BGP view\n"
10172 "View name\n"
10173 "Address family\n"
10174 "Address Family modifier\n"
10175 "Address Family modifier\n"
10176 "Summary of BGP neighbor status\n"
10177 "JavaScript Object Notation\n")
10178 {
10179 u_char uj = use_json(argc, argv);
10180 if (strncmp (argv[1], "m", 1) == 0)
10181 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj);
10182 else
10183 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj);
10184 }
10185
10186 ALIAS (show_ip_bgp_instance_ipv4_summary,
10187 show_bgp_instance_ipv4_safi_summary_cmd,
10188 "show bgp view WORD ipv4 (unicast|multicast) summary {json}",
10189 SHOW_STR
10190 BGP_STR
10191 "BGP view\n"
10192 "View name\n"
10193 "Address family\n"
10194 "Address Family modifier\n"
10195 "Address Family modifier\n"
10196 "Summary of BGP neighbor status\n")
10197
10198 DEFUN (show_ip_bgp_vpnv4_all_summary,
10199 show_ip_bgp_vpnv4_all_summary_cmd,
10200 "show ip bgp vpnv4 all summary {json}",
10201 SHOW_STR
10202 IP_STR
10203 BGP_STR
10204 "Display VPNv4 NLRI specific information\n"
10205 "Display information about all VPNv4 NLRIs\n"
10206 "Summary of BGP neighbor status\n"
10207 "JavaScript Object Notation\n")
10208 {
10209 u_char uj = use_json(argc, argv);
10210 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
10211 }
10212
10213 DEFUN (show_ip_bgp_vpnv4_rd_summary,
10214 show_ip_bgp_vpnv4_rd_summary_cmd,
10215 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}",
10216 SHOW_STR
10217 IP_STR
10218 BGP_STR
10219 "Display VPNv4 NLRI specific information\n"
10220 "Display information for a route distinguisher\n"
10221 "VPN Route Distinguisher\n"
10222 "Summary of BGP neighbor status\n"
10223 "JavaScript Object Notation\n")
10224 {
10225 int ret;
10226 struct prefix_rd prd;
10227 u_char uj = use_json(argc, argv);
10228
10229 ret = str2prefix_rd (argv[0], &prd);
10230 if (! ret)
10231 {
10232 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
10233 return CMD_WARNING;
10234 }
10235
10236 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
10237 }
10238
10239 #ifdef HAVE_IPV6
10240 DEFUN (show_bgp_summary,
10241 show_bgp_summary_cmd,
10242 "show bgp summary {json}",
10243 SHOW_STR
10244 BGP_STR
10245 "Summary of BGP neighbor status\n"
10246 "JavaScript Object Notation\n")
10247 {
10248 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
10249 }
10250
10251 DEFUN (show_bgp_instance_summary,
10252 show_bgp_instance_summary_cmd,
10253 "show bgp " BGP_INSTANCE_CMD " summary {json}",
10254 SHOW_STR
10255 BGP_STR
10256 BGP_INSTANCE_HELP_STR
10257 "Summary of BGP neighbor status\n"
10258 "JavaScript Object Notation\n")
10259 {
10260 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
10261 }
10262
10263 ALIAS (show_bgp_summary,
10264 show_bgp_ipv6_summary_cmd,
10265 "show bgp ipv6 summary {json}",
10266 SHOW_STR
10267 BGP_STR
10268 "Address family\n"
10269 "Summary of BGP neighbor status\n")
10270
10271 ALIAS (show_bgp_instance_summary,
10272 show_bgp_instance_ipv6_summary_cmd,
10273 "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}",
10274 SHOW_STR
10275 BGP_STR
10276 BGP_INSTANCE_HELP_STR
10277 "Address family\n"
10278 "Summary of BGP neighbor status\n")
10279
10280 DEFUN (show_bgp_ipv6_safi_summary,
10281 show_bgp_ipv6_safi_summary_cmd,
10282 "show bgp ipv6 (unicast|multicast) summary {json}",
10283 SHOW_STR
10284 BGP_STR
10285 "Address family\n"
10286 "Address Family modifier\n"
10287 "Address Family modifier\n"
10288 "Summary of BGP neighbor status\n"
10289 "JavaScript Object Notation\n")
10290 {
10291 u_char uj = use_json(argc, argv);
10292 if (strncmp (argv[0], "m", 1) == 0)
10293 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
10294
10295 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
10296 }
10297
10298 DEFUN (show_bgp_instance_ipv6_safi_summary,
10299 show_bgp_instance_ipv6_safi_summary_cmd,
10300 "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}",
10301 SHOW_STR
10302 BGP_STR
10303 BGP_INSTANCE_HELP_STR
10304 "Address family\n"
10305 "Address Family modifier\n"
10306 "Address Family modifier\n"
10307 "Summary of BGP neighbor status\n"
10308 "JavaScript Object Notation\n")
10309 {
10310 u_char uj = use_json(argc, argv);
10311 if (strncmp (argv[2], "m", 1) == 0)
10312 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj);
10313
10314 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj);
10315 }
10316
10317 /* old command */
10318 DEFUN (show_ipv6_bgp_summary,
10319 show_ipv6_bgp_summary_cmd,
10320 "show ipv6 bgp summary {json}",
10321 SHOW_STR
10322 IPV6_STR
10323 BGP_STR
10324 "Summary of BGP neighbor status\n"
10325 "JavaScript Object Notation\n")
10326 {
10327 u_char uj = use_json(argc, argv);
10328 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
10329 }
10330
10331 /* old command */
10332 DEFUN (show_ipv6_mbgp_summary,
10333 show_ipv6_mbgp_summary_cmd,
10334 "show ipv6 mbgp summary {json}",
10335 SHOW_STR
10336 IPV6_STR
10337 MBGP_STR
10338 "Summary of BGP neighbor status\n"
10339 "JavaScript Object Notation\n")
10340 {
10341 u_char uj = use_json(argc, argv);
10342 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
10343 }
10344 #endif /* HAVE_IPV6 */
10345
10346 const char *
10347 afi_safi_print (afi_t afi, safi_t safi)
10348 {
10349 if (afi == AFI_IP && safi == SAFI_UNICAST)
10350 return "IPv4 Unicast";
10351 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
10352 return "IPv4 Multicast";
10353 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10354 return "VPNv4 Unicast";
10355 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
10356 return "IPv6 Unicast";
10357 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
10358 return "IPv6 Multicast";
10359 else
10360 return "Unknown";
10361 }
10362
10363 /* Show BGP peer's information. */
10364 enum show_type
10365 {
10366 show_all,
10367 show_peer
10368 };
10369
10370 static void
10371 bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10372 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
10373 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
10374 {
10375 /* Send-Mode */
10376 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
10377 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10378 {
10379 if (use_json)
10380 {
10381 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10382 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
10383 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10384 json_object_string_add(json_pref, "sendMode", "advertised");
10385 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10386 json_object_string_add(json_pref, "sendMode", "received");
10387 }
10388 else
10389 {
10390 vty_out (vty, " Send-mode: ");
10391 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
10392 vty_out (vty, "advertised");
10393 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
10394 vty_out (vty, "%sreceived",
10395 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
10396 ", " : "");
10397 vty_out (vty, "%s", VTY_NEWLINE);
10398 }
10399 }
10400
10401 /* Receive-Mode */
10402 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
10403 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10404 {
10405 if (use_json)
10406 {
10407 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10408 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
10409 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10410 json_object_string_add(json_pref, "recvMode", "advertised");
10411 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10412 json_object_string_add(json_pref, "recvMode", "received");
10413 }
10414 else
10415 {
10416 vty_out (vty, " Receive-mode: ");
10417 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
10418 vty_out (vty, "advertised");
10419 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
10420 vty_out (vty, "%sreceived",
10421 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
10422 ", " : "");
10423 vty_out (vty, "%s", VTY_NEWLINE);
10424 }
10425 }
10426 }
10427
10428 static void
10429 bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
10430 u_char use_json, json_object *json_neigh)
10431 {
10432 struct bgp_filter *filter;
10433 struct peer_af *paf;
10434 char orf_pfx_name[BUFSIZ];
10435 int orf_pfx_count;
10436 json_object *json_af = NULL;
10437 json_object *json_prefA = NULL;
10438 json_object *json_prefB = NULL;
10439 json_object *json_addr = NULL;
10440
10441 if (use_json)
10442 {
10443 json_addr = json_object_new_object();
10444 json_af = json_object_new_object();
10445 json_prefA = json_object_new_object();
10446 json_prefB = json_object_new_object();
10447 filter = &p->filter[afi][safi];
10448
10449 if (peer_group_active(p))
10450 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
10451
10452 paf = peer_af_find(p, afi, safi);
10453 if (paf && PAF_SUBGRP(paf))
10454 {
10455 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
10456 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
10457 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
10458 }
10459
10460 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10461 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10462 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10463 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10464 {
10465 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
10466 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10467 PEER_CAP_ORF_PREFIX_SM_ADV,
10468 PEER_CAP_ORF_PREFIX_RM_ADV,
10469 PEER_CAP_ORF_PREFIX_SM_RCV,
10470 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
10471 json_object_object_add(json_af, "orfPrefixList", json_prefA);
10472 }
10473
10474 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10475 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10476 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10477 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10478 {
10479 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
10480 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10481 PEER_CAP_ORF_PREFIX_SM_ADV,
10482 PEER_CAP_ORF_PREFIX_RM_ADV,
10483 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10484 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
10485 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
10486 }
10487
10488 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10489 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10490 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10491 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10492 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10493 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10494 json_object_object_add(json_addr, "afDependentCap", json_af);
10495
10496 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10497 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10498
10499 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10500 || orf_pfx_count)
10501 {
10502 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10503 json_object_boolean_true_add(json_neigh, "orfSent");
10504 if (orf_pfx_count)
10505 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
10506 }
10507 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10508 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
10509
10510 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10511 json_object_boolean_true_add(json_addr, "routeReflectorClient");
10512 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10513 json_object_boolean_true_add(json_addr, "routeServerClient");
10514 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10515 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
10516
10517 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10518 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
10519 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
10520 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
10521 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10522 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
10523 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10524 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
10525
10526 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10527 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
10528
10529 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10530 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
10531
10532 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10533 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
10534
10535 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10536 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10537 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
10538 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10539 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
10540 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10541 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
10542 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10543 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
10544 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10545 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10546 {
10547 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10548 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10549 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
10550 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10551 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
10552 else
10553 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
10554 }
10555 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10556 {
10557 if (p->default_rmap[afi][safi].name)
10558 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
10559
10560 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10561 json_object_boolean_true_add(json_addr, "defaultSent");
10562 else
10563 json_object_boolean_true_add(json_addr, "defaultNotSent");
10564 }
10565
10566 if (filter->plist[FILTER_IN].name
10567 || filter->dlist[FILTER_IN].name
10568 || filter->aslist[FILTER_IN].name
10569 || filter->map[RMAP_IN].name)
10570 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
10571 if (filter->plist[FILTER_OUT].name
10572 || filter->dlist[FILTER_OUT].name
10573 || filter->aslist[FILTER_OUT].name
10574 || filter->map[RMAP_OUT].name
10575 || filter->usmap.name)
10576 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
10577
10578 /* prefix-list */
10579 if (filter->plist[FILTER_IN].name)
10580 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
10581 if (filter->plist[FILTER_OUT].name)
10582 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
10583
10584 /* distribute-list */
10585 if (filter->dlist[FILTER_IN].name)
10586 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
10587 if (filter->dlist[FILTER_OUT].name)
10588 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
10589
10590 /* filter-list. */
10591 if (filter->aslist[FILTER_IN].name)
10592 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
10593 if (filter->aslist[FILTER_OUT].name)
10594 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
10595
10596 /* route-map. */
10597 if (filter->map[RMAP_IN].name)
10598 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
10599 if (filter->map[RMAP_OUT].name)
10600 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
10601
10602 /* unsuppress-map */
10603 if (filter->usmap.name)
10604 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
10605
10606 /* Receive prefix count */
10607 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
10608
10609 /* Maximum prefix */
10610 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10611 {
10612 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
10613 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
10614 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
10615 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
10616 if (p->pmax_restart[afi][safi])
10617 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
10618 }
10619 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
10620
10621 }
10622 else
10623 {
10624 filter = &p->filter[afi][safi];
10625
10626 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
10627 VTY_NEWLINE);
10628
10629 if (peer_group_active(p))
10630 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
10631
10632 paf = peer_af_find(p, afi, safi);
10633 if (paf && PAF_SUBGRP(paf))
10634 {
10635 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
10636 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
10637 vty_out (vty, " Packet Queue length %d%s",
10638 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
10639 }
10640 else
10641 {
10642 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
10643 }
10644 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10645 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10646 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10647 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10648 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
10649 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10650 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
10651
10652 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10653 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
10654 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10655 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
10656 {
10657 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10658 ORF_TYPE_PREFIX, VTY_NEWLINE);
10659 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10660 PEER_CAP_ORF_PREFIX_SM_ADV,
10661 PEER_CAP_ORF_PREFIX_RM_ADV,
10662 PEER_CAP_ORF_PREFIX_SM_RCV,
10663 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
10664 }
10665 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
10666 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
10667 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
10668 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
10669 {
10670 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
10671 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
10672 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
10673 PEER_CAP_ORF_PREFIX_SM_ADV,
10674 PEER_CAP_ORF_PREFIX_RM_ADV,
10675 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
10676 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
10677 }
10678
10679 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
10680 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
10681
10682 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
10683 || orf_pfx_count)
10684 {
10685 vty_out (vty, " Outbound Route Filter (ORF):");
10686 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
10687 vty_out (vty, " sent;");
10688 if (orf_pfx_count)
10689 vty_out (vty, " received (%d entries)", orf_pfx_count);
10690 vty_out (vty, "%s", VTY_NEWLINE);
10691 }
10692 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
10693 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
10694
10695 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
10696 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
10697 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
10698 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
10699 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
10700 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
10701
10702 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
10703 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
10704 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
10705 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
10706 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
10707 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
10708 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
10709 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
10710
10711 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
10712 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
10713
10714 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
10715 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
10716
10717 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
10718 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
10719
10720 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
10721 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
10722 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
10723 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
10724 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10725 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
10726 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10727 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
10728 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
10729 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10730 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10731 {
10732 vty_out (vty, " Community attribute sent to this neighbor");
10733 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
10734 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10735 vty_out (vty, "(both)%s", VTY_NEWLINE);
10736 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
10737 vty_out (vty, "(extended)%s", VTY_NEWLINE);
10738 else
10739 vty_out (vty, "(standard)%s", VTY_NEWLINE);
10740 }
10741 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
10742 {
10743 vty_out (vty, " Default information originate,");
10744
10745 if (p->default_rmap[afi][safi].name)
10746 vty_out (vty, " default route-map %s%s,",
10747 p->default_rmap[afi][safi].map ? "*" : "",
10748 p->default_rmap[afi][safi].name);
10749 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
10750 vty_out (vty, " default sent%s", VTY_NEWLINE);
10751 else
10752 vty_out (vty, " default not sent%s", VTY_NEWLINE);
10753 }
10754
10755 if (filter->plist[FILTER_IN].name
10756 || filter->dlist[FILTER_IN].name
10757 || filter->aslist[FILTER_IN].name
10758 || filter->map[RMAP_IN].name)
10759 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
10760 if (filter->plist[FILTER_OUT].name
10761 || filter->dlist[FILTER_OUT].name
10762 || filter->aslist[FILTER_OUT].name
10763 || filter->map[RMAP_OUT].name
10764 || filter->usmap.name)
10765 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
10766
10767 /* prefix-list */
10768 if (filter->plist[FILTER_IN].name)
10769 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
10770 filter->plist[FILTER_IN].plist ? "*" : "",
10771 filter->plist[FILTER_IN].name,
10772 VTY_NEWLINE);
10773 if (filter->plist[FILTER_OUT].name)
10774 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
10775 filter->plist[FILTER_OUT].plist ? "*" : "",
10776 filter->plist[FILTER_OUT].name,
10777 VTY_NEWLINE);
10778
10779 /* distribute-list */
10780 if (filter->dlist[FILTER_IN].name)
10781 vty_out (vty, " Incoming update network filter list is %s%s%s",
10782 filter->dlist[FILTER_IN].alist ? "*" : "",
10783 filter->dlist[FILTER_IN].name,
10784 VTY_NEWLINE);
10785 if (filter->dlist[FILTER_OUT].name)
10786 vty_out (vty, " Outgoing update network filter list is %s%s%s",
10787 filter->dlist[FILTER_OUT].alist ? "*" : "",
10788 filter->dlist[FILTER_OUT].name,
10789 VTY_NEWLINE);
10790
10791 /* filter-list. */
10792 if (filter->aslist[FILTER_IN].name)
10793 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
10794 filter->aslist[FILTER_IN].aslist ? "*" : "",
10795 filter->aslist[FILTER_IN].name,
10796 VTY_NEWLINE);
10797 if (filter->aslist[FILTER_OUT].name)
10798 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
10799 filter->aslist[FILTER_OUT].aslist ? "*" : "",
10800 filter->aslist[FILTER_OUT].name,
10801 VTY_NEWLINE);
10802
10803 /* route-map. */
10804 if (filter->map[RMAP_IN].name)
10805 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
10806 filter->map[RMAP_IN].map ? "*" : "",
10807 filter->map[RMAP_IN].name,
10808 VTY_NEWLINE);
10809 if (filter->map[RMAP_OUT].name)
10810 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
10811 filter->map[RMAP_OUT].map ? "*" : "",
10812 filter->map[RMAP_OUT].name,
10813 VTY_NEWLINE);
10814
10815 /* unsuppress-map */
10816 if (filter->usmap.name)
10817 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
10818 filter->usmap.map ? "*" : "",
10819 filter->usmap.name, VTY_NEWLINE);
10820
10821 /* Receive prefix count */
10822 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
10823
10824 /* Maximum prefix */
10825 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
10826 {
10827 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
10828 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
10829 ? " (warning-only)" : "", VTY_NEWLINE);
10830 vty_out (vty, " Threshold for warning message %d%%",
10831 p->pmax_threshold[afi][safi]);
10832 if (p->pmax_restart[afi][safi])
10833 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
10834 vty_out (vty, "%s", VTY_NEWLINE);
10835 }
10836
10837 vty_out (vty, "%s", VTY_NEWLINE);
10838 }
10839 }
10840
10841 static void
10842 bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json, json_object *json_neigh)
10843 {
10844 struct bgp *bgp;
10845 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
10846 char timebuf[BGP_UPTIME_LEN];
10847 char dn_flag[2];
10848 const char *subcode_str;
10849 const char *code_str;
10850 afi_t afi;
10851 safi_t safi;
10852 u_int16_t i;
10853 u_char *msg;
10854
10855 bgp = p->bgp;
10856
10857 if (!use_json)
10858 {
10859 if (p->conf_if) /* Configured interface name. */
10860 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
10861 BGP_PEER_SU_UNSPEC(p) ? "None" :
10862 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10863 else /* Configured IP address. */
10864 {
10865 memset(dn_flag, '\0', sizeof(dn_flag));
10866 if (peer_dynamic_neighbor(p))
10867 dn_flag[0] = '*';
10868
10869 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
10870 }
10871 }
10872
10873 if (use_json)
10874 {
10875 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
10876 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
10877 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
10878 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
10879
10880 json_object_int_add(json_neigh, "remoteAs", p->as);
10881
10882 if (p->change_local_as)
10883 json_object_int_add(json_neigh, "localAs", p->change_local_as);
10884 else
10885 json_object_int_add(json_neigh, "localAs", p->local_as);
10886
10887 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
10888 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
10889
10890 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
10891 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
10892 }
10893 else
10894 {
10895 if ((p->as_type == AS_SPECIFIED) ||
10896 (p->as_type == AS_EXTERNAL) ||
10897 (p->as_type == AS_INTERNAL))
10898 vty_out (vty, "remote AS %u, ", p->as);
10899 else
10900 vty_out (vty, "remote AS Unspecified, ");
10901 vty_out (vty, "local AS %u%s%s, ",
10902 p->change_local_as ? p->change_local_as : p->local_as,
10903 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
10904 " no-prepend" : "",
10905 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
10906 " replace-as" : "");
10907 }
10908 /* peer type internal, external, confed-internal or confed-external */
10909 if (p->as == p->local_as)
10910 {
10911 if (use_json)
10912 {
10913 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10914 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
10915 else
10916 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
10917 }
10918 else
10919 {
10920 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10921 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
10922 else
10923 vty_out (vty, "internal link%s", VTY_NEWLINE);
10924 }
10925 }
10926 else
10927 {
10928 if (use_json)
10929 {
10930 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
10931 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
10932 else
10933 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
10934 }
10935 else
10936 {
10937 if (bgp_confederation_peers_check(bgp, p->as))
10938 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
10939 else
10940 vty_out (vty, "external link%s", VTY_NEWLINE);
10941 }
10942 }
10943
10944 /* Description. */
10945 if (p->desc)
10946 {
10947 if (use_json)
10948 json_object_string_add(json_neigh, "nbrDesc", p->desc);
10949 else
10950 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
10951 }
10952
10953 if (p->hostname)
10954 {
10955 if (use_json)
10956 {
10957 if (p->hostname)
10958 json_object_string_add(json_neigh, "hostname", p->hostname);
10959
10960 if (p->domainname)
10961 json_object_string_add(json_neigh, "domainname", p->domainname);
10962 }
10963 else
10964 {
10965 if (p->domainname && (p->domainname[0] != '\0'))
10966 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
10967 VTY_NEWLINE);
10968 else
10969 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
10970 }
10971
10972 }
10973
10974 /* Peer-group */
10975 if (p->group)
10976 {
10977 if (use_json)
10978 {
10979 json_object_string_add(json_neigh, "peerGroup", p->group->name);
10980
10981 if (dn_flag[0])
10982 {
10983 struct prefix *prefix = NULL, *range = NULL;
10984
10985 prefix = sockunion2hostprefix(&(p->su));
10986 if (prefix)
10987 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
10988
10989 if (range)
10990 {
10991 prefix2str(range, buf1, sizeof(buf1));
10992 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
10993 }
10994 }
10995 }
10996 else
10997 {
10998 vty_out (vty, " Member of peer-group %s for session parameters%s",
10999 p->group->name, VTY_NEWLINE);
11000
11001 if (dn_flag[0])
11002 {
11003 struct prefix *prefix = NULL, *range = NULL;
11004
11005 prefix = sockunion2hostprefix(&(p->su));
11006 if (prefix)
11007 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
11008
11009 if (range)
11010 {
11011 prefix2str(range, buf1, sizeof(buf1));
11012 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
11013 }
11014 }
11015 }
11016 }
11017
11018 if (use_json)
11019 {
11020 /* Administrative shutdown. */
11021 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11022 json_object_boolean_true_add(json_neigh, "adminShutDown");
11023
11024 /* BGP Version. */
11025 json_object_int_add(json_neigh, "bgpVersion", 4);
11026 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
11027
11028 /* Confederation */
11029 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
11030 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
11031
11032 /* Status. */
11033 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
11034
11035 if (p->status == Established)
11036 {
11037 time_t uptime;
11038 struct tm *tm;
11039
11040 uptime = bgp_clock();
11041 uptime -= p->uptime;
11042 tm = gmtime(&uptime);
11043
11044 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11045 }
11046
11047 else if (p->status == Active)
11048 {
11049 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11050 json_object_string_add(json_neigh, "bgpStateIs", "passive");
11051 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11052 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
11053 }
11054
11055 /* read timer */
11056 time_t uptime;
11057 struct tm *tm;
11058
11059 uptime = bgp_clock();
11060 uptime -= p->readtime;
11061 tm = gmtime(&uptime);
11062 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11063
11064 uptime = bgp_clock();
11065 uptime -= p->last_write;
11066 tm = gmtime(&uptime);
11067 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11068
11069 /* Configured timer values. */
11070 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
11071 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
11072
11073 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11074 {
11075 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
11076 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
11077 }
11078 }
11079 else
11080 {
11081 /* Administrative shutdown. */
11082 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
11083 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
11084
11085 /* BGP Version. */
11086 vty_out (vty, " BGP version 4");
11087 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
11088 VTY_NEWLINE);
11089
11090 /* Confederation */
11091 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
11092 && bgp_confederation_peers_check (bgp, p->as))
11093 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
11094
11095 /* Status. */
11096 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
11097
11098 if (p->status == Established)
11099 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11100
11101 else if (p->status == Active)
11102 {
11103 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
11104 vty_out (vty, " (passive)");
11105 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
11106 vty_out (vty, " (NSF passive)");
11107 }
11108 vty_out (vty, "%s", VTY_NEWLINE);
11109
11110 /* read timer */
11111 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11112 vty_out (vty, ", Last write %s%s",
11113 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
11114
11115 /* Configured timer values. */
11116 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
11117 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
11118 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
11119 {
11120 vty_out (vty, " Configured hold time is %d", p->holdtime);
11121 vty_out (vty, ", keepalive interval is %d seconds%s",
11122 p->keepalive, VTY_NEWLINE);
11123 }
11124 }
11125 /* Capability. */
11126 if (p->status == Established)
11127 {
11128 if (p->cap
11129 || p->afc_adv[AFI_IP][SAFI_UNICAST]
11130 || p->afc_recv[AFI_IP][SAFI_UNICAST]
11131 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
11132 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
11133 #ifdef HAVE_IPV6
11134 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
11135 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
11136 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
11137 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
11138 #endif /* HAVE_IPV6 */
11139 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
11140 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
11141 {
11142 if (use_json)
11143 {
11144 json_object *json_cap = NULL;
11145
11146 json_cap = json_object_new_object();
11147
11148 /* AS4 */
11149 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11150 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11151 {
11152 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11153 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
11154 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11155 json_object_string_add(json_cap, "4byteAs", "advertised");
11156 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11157 json_object_string_add(json_cap, "4byteAs", "received");
11158 }
11159
11160 /* AddPath */
11161 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11162 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11163 {
11164 json_object *json_add = NULL;
11165 const char *print_store;
11166
11167 json_add = json_object_new_object();
11168
11169 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11170 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11171 {
11172 json_object *json_sub = NULL;
11173 json_sub = json_object_new_object();
11174 print_store = afi_safi_print (afi, safi);
11175
11176 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11177 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11178 {
11179 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))
11180 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
11181 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11182 json_object_boolean_true_add(json_sub, "txAdvertised");
11183 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11184 json_object_boolean_true_add(json_sub, "txReceived");
11185 }
11186
11187 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11188 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11189 {
11190 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))
11191 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
11192 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11193 json_object_boolean_true_add(json_sub, "rxAdvertised");
11194 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11195 json_object_boolean_true_add(json_sub, "rxReceived");
11196 }
11197
11198 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11199 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
11200 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11201 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11202 json_object_object_add(json_add, print_store, json_sub);
11203 }
11204
11205 json_object_object_add(json_cap, "addPath", json_add);
11206 }
11207
11208 /* Dynamic */
11209 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11210 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11211 {
11212 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11213 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
11214 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11215 json_object_string_add(json_cap, "dynamic", "advertised");
11216 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11217 json_object_string_add(json_cap, "dynamic", "received");
11218 }
11219
11220 /* Extended nexthop */
11221 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11222 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11223 {
11224 json_object *json_nxt = NULL;
11225 const char *print_store;
11226
11227 json_nxt = json_object_new_object();
11228
11229 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11230 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
11231 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11232 json_object_string_add(json_cap, "extendedNexthop", "advertised");
11233 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11234 json_object_string_add(json_cap, "extendedNexthop", "received");
11235
11236 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11237 {
11238 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11239 {
11240 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11241 {
11242 print_store = afi_safi_print (AFI_IP, safi);
11243 json_object_string_add(json_nxt, print_store, "recieved");
11244 }
11245 }
11246 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
11247 }
11248 }
11249
11250 /* Route Refresh */
11251 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11252 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11253 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11254 {
11255 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)))
11256 {
11257 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
11258 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
11259 else
11260 {
11261 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11262 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
11263 else
11264 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
11265 }
11266 }
11267 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11268 json_object_string_add(json_cap, "routeRefresh", "advertised");
11269 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11270 json_object_string_add(json_cap, "routeRefresh", "received");
11271 }
11272
11273 /* Multiprotocol Extensions */
11274 json_object *json_multi = NULL;
11275 json_multi = json_object_new_object();
11276
11277 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11278 {
11279 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11280 {
11281 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11282 {
11283 json_object *json_exten = NULL;
11284 json_exten = json_object_new_object();
11285
11286 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
11287 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
11288 else if (p->afc_adv[afi][safi])
11289 json_object_boolean_true_add(json_exten, "advertised");
11290 else if (p->afc_recv[afi][safi])
11291 json_object_boolean_true_add(json_exten, "received");
11292
11293 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
11294 }
11295 }
11296 }
11297 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
11298
11299 /* Gracefull Restart */
11300 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11301 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11302 {
11303 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11304 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
11305 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11306 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
11307 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11308 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
11309
11310 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11311 {
11312 int restart_af_count = 0;
11313 json_object *json_restart = NULL;
11314 json_restart = json_object_new_object();
11315
11316 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
11317
11318 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11319 {
11320 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11321 {
11322 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11323 {
11324 json_object *json_sub = NULL;
11325 json_sub = json_object_new_object();
11326
11327 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
11328 json_object_boolean_true_add(json_sub, "preserved");
11329 restart_af_count++;
11330 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
11331 }
11332 }
11333 }
11334 if (! restart_af_count)
11335 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
11336 else
11337 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
11338 }
11339 }
11340 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
11341 }
11342 else
11343 {
11344 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
11345
11346 /* AS4 */
11347 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
11348 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11349 {
11350 vty_out (vty, " 4 Byte AS:");
11351 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
11352 vty_out (vty, " advertised");
11353 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
11354 vty_out (vty, " %sreceived",
11355 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
11356 vty_out (vty, "%s", VTY_NEWLINE);
11357 }
11358
11359 /* AddPath */
11360 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
11361 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
11362 {
11363 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
11364
11365 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11366 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11367 {
11368 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
11369 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11370 {
11371 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
11372
11373 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
11374 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
11375
11376 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
11377 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
11378
11379 vty_out (vty, "%s", VTY_NEWLINE);
11380 }
11381
11382 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
11383 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11384 {
11385 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
11386
11387 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
11388 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
11389
11390 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
11391 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
11392
11393 vty_out (vty, "%s", VTY_NEWLINE);
11394 }
11395 }
11396 }
11397
11398 /* Dynamic */
11399 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
11400 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11401 {
11402 vty_out (vty, " Dynamic:");
11403 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
11404 vty_out (vty, " advertised");
11405 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
11406 vty_out (vty, " %sreceived",
11407 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
11408 vty_out (vty, "%s", VTY_NEWLINE);
11409 }
11410
11411 /* Extended nexthop */
11412 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
11413 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11414 {
11415 vty_out (vty, " Extended nexthop:");
11416 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
11417 vty_out (vty, " advertised");
11418 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11419 vty_out (vty, " %sreceived",
11420 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
11421 vty_out (vty, "%s", VTY_NEWLINE);
11422
11423 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
11424 {
11425 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11426 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11427 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
11428 vty_out (vty, " %s%s",
11429 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
11430 }
11431 }
11432
11433 /* Route Refresh */
11434 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
11435 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11436 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11437 {
11438 vty_out (vty, " Route refresh:");
11439 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
11440 vty_out (vty, " advertised");
11441 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
11442 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
11443 vty_out (vty, " %sreceived(%s)",
11444 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
11445 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
11446 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
11447 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
11448
11449 vty_out (vty, "%s", VTY_NEWLINE);
11450 }
11451
11452 /* Multiprotocol Extensions */
11453 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11454 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11455 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
11456 {
11457 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
11458 if (p->afc_adv[afi][safi])
11459 vty_out (vty, " advertised");
11460 if (p->afc_recv[afi][safi])
11461 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
11462 vty_out (vty, "%s", VTY_NEWLINE);
11463 }
11464
11465 /* Hostname capability */
11466 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
11467 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
11468 {
11469 vty_out (vty, " Hostname Capability:");
11470 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
11471 vty_out (vty, " advertised");
11472 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
11473 vty_out (vty, " %sreceived",
11474 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
11475 vty_out (vty, "%s", VTY_NEWLINE);
11476 }
11477
11478 /* Gracefull Restart */
11479 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11480 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11481 {
11482 vty_out (vty, " Graceful Restart Capabilty:");
11483 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
11484 vty_out (vty, " advertised");
11485 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11486 vty_out (vty, " %sreceived",
11487 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
11488 vty_out (vty, "%s", VTY_NEWLINE);
11489
11490 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
11491 {
11492 int restart_af_count = 0;
11493
11494 vty_out (vty, " Remote Restart timer is %d seconds%s",
11495 p->v_gr_restart, VTY_NEWLINE);
11496 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
11497
11498 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11499 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11500 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
11501 {
11502 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
11503 afi_safi_print (afi, safi),
11504 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
11505 "preserved" : "not preserved");
11506 restart_af_count++;
11507 }
11508 if (! restart_af_count)
11509 vty_out (vty, "none");
11510 vty_out (vty, "%s", VTY_NEWLINE);
11511 }
11512 }
11513 }
11514 }
11515 }
11516
11517 /* graceful restart information */
11518 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
11519 || p->t_gr_restart
11520 || p->t_gr_stale)
11521 {
11522 json_object *json_grace = NULL;
11523 json_object *json_grace_send = NULL;
11524 json_object *json_grace_recv = NULL;
11525 int eor_send_af_count = 0;
11526 int eor_receive_af_count = 0;
11527
11528 if (use_json)
11529 {
11530 json_grace = json_object_new_object();
11531 json_grace_send = json_object_new_object();
11532 json_grace_recv = json_object_new_object();
11533
11534 if (p->status == Established)
11535 {
11536 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11537 {
11538 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11539 {
11540 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11541 {
11542 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
11543 eor_send_af_count++;
11544 }
11545 }
11546 }
11547 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11548 {
11549 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11550 {
11551 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11552 {
11553 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
11554 eor_receive_af_count++;
11555 }
11556 }
11557 }
11558 }
11559
11560 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
11561 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
11562
11563 if (p->t_gr_restart)
11564 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
11565
11566 if (p->t_gr_stale)
11567 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
11568
11569 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
11570 }
11571 else
11572 {
11573 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
11574 if (p->status == Established)
11575 {
11576 vty_out (vty, " End-of-RIB send: ");
11577 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11578 {
11579 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11580 {
11581 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
11582 {
11583 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
11584 afi_safi_print (afi, safi));
11585 eor_send_af_count++;
11586 }
11587 }
11588 }
11589 vty_out (vty, "%s", VTY_NEWLINE);
11590 vty_out (vty, " End-of-RIB received: ");
11591 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11592 {
11593 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11594 {
11595 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
11596 {
11597 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
11598 afi_safi_print (afi, safi));
11599 eor_receive_af_count++;
11600 }
11601 }
11602 }
11603 vty_out (vty, "%s", VTY_NEWLINE);
11604 }
11605
11606 if (p->t_gr_restart)
11607 vty_out (vty, " The remaining time of restart timer is %ld%s",
11608 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
11609
11610 if (p->t_gr_stale)
11611 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
11612 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
11613 }
11614 }
11615 if (use_json)
11616 {
11617 json_object *json_stat = NULL;
11618 json_stat = json_object_new_object();
11619 /* Packet counts. */
11620 json_object_int_add(json_stat, "depthInq", 0);
11621 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
11622 json_object_int_add(json_stat, "opensSent", p->open_out);
11623 json_object_int_add(json_stat, "opensRecv", p->open_in);
11624 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
11625 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
11626 json_object_int_add(json_stat, "updatesSent", p->update_out);
11627 json_object_int_add(json_stat, "updatesRecv", p->update_in);
11628 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
11629 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
11630 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
11631 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
11632 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
11633 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
11634 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);
11635 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);
11636 json_object_object_add(json_neigh, "messageStats", json_stat);
11637 }
11638 else
11639 {
11640 /* Packet counts. */
11641 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
11642 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
11643 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
11644 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
11645 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
11646 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
11647 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
11648 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
11649 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
11650 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
11651 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
11652 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
11653 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
11654 p->dynamic_cap_in, VTY_NEWLINE);
11655 }
11656
11657 if (use_json)
11658 {
11659 /* advertisement-interval */
11660 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
11661
11662 /* Update-source. */
11663 if (p->update_if || p->update_source)
11664 {
11665 if (p->update_if)
11666 json_object_string_add(json_neigh, "updateSource", p->update_if);
11667 else if (p->update_source)
11668 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11669 }
11670
11671 /* Default weight */
11672 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11673 json_object_int_add(json_neigh, "defaultWeight", p->weight);
11674
11675 }
11676 else
11677 {
11678 /* advertisement-interval */
11679 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
11680 p->v_routeadv, VTY_NEWLINE);
11681
11682 /* Update-source. */
11683 if (p->update_if || p->update_source)
11684 {
11685 vty_out (vty, " Update source is ");
11686 if (p->update_if)
11687 vty_out (vty, "%s", p->update_if);
11688 else if (p->update_source)
11689 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
11690 vty_out (vty, "%s", VTY_NEWLINE);
11691 }
11692
11693 /* Default weight */
11694 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
11695 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
11696
11697 vty_out (vty, "%s", VTY_NEWLINE);
11698 }
11699
11700 /* Address Family Information */
11701 json_object *json_hold = NULL;
11702
11703 if (use_json)
11704 json_hold = json_object_new_object();
11705
11706 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
11707 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11708 if (p->afc[afi][safi])
11709 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
11710
11711 if (use_json)
11712 {
11713 json_object_int_add(json_hold, "connectionsEstablished", p->established);
11714 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
11715 }
11716 else
11717 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
11718 VTY_NEWLINE);
11719
11720 if (! p->last_reset)
11721 {
11722 if (use_json)
11723 json_object_string_add(json_hold, "lastReset", "never");
11724 else
11725 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
11726 }
11727 else
11728 {
11729 if (use_json)
11730 {
11731 time_t uptime;
11732 struct tm *tm;
11733
11734 uptime = bgp_clock();
11735 uptime -= p->resettime;
11736 tm = gmtime(&uptime);
11737 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
11738 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
11739 if (p->last_reset_cause_size)
11740 {
11741 msg = p->last_reset_cause;
11742 char adapter[BUFSIZ];
11743 sprintf(adapter, "%s", msg);
11744 json_object_string_add(json_hold, "messageReceivedThatCausedBgpNotification", adapter);
11745 }
11746 }
11747 else
11748 {
11749 vty_out (vty, " Last reset %s, ",
11750 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
11751
11752 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
11753 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
11754 {
11755 code_str = bgp_notify_code_str(p->notify.code);
11756 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
11757 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
11758 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
11759 code_str, subcode_str, VTY_NEWLINE);
11760 }
11761 else
11762 {
11763 vty_out (vty, "due to %s%s",
11764 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
11765 }
11766
11767 if (p->last_reset_cause_size)
11768 {
11769 msg = p->last_reset_cause;
11770 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
11771 for (i = 1; i <= p->last_reset_cause_size; i++)
11772 {
11773 vty_out(vty, "%02X", *msg++);
11774
11775 if (i != p->last_reset_cause_size)
11776 {
11777 if (i % 16 == 0)
11778 {
11779 vty_out(vty, "%s ", VTY_NEWLINE);
11780 }
11781 else if (i % 4 == 0)
11782 {
11783 vty_out(vty, " ");
11784 }
11785 }
11786 }
11787 vty_out(vty, "%s", VTY_NEWLINE);
11788 }
11789 }
11790 }
11791
11792 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11793 {
11794 if (use_json)
11795 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
11796 else
11797 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
11798
11799 if (p->t_pmax_restart)
11800 {
11801 if (use_json)
11802 {
11803 json_object_string_add(json_hold, "reducePrefixNumFrom", p->host);
11804 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
11805 }
11806 else
11807 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
11808 p->host, thread_timer_remain_second (p->t_pmax_restart),
11809 VTY_NEWLINE);
11810 }
11811 else
11812 {
11813 if (use_json)
11814 json_object_string_add(json_hold, "reducePrefixNumAndClearIpBgp", p->host);
11815 else
11816 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
11817 p->host, VTY_NEWLINE);
11818 }
11819 }
11820
11821 if (use_json)
11822 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
11823
11824 /* EBGP Multihop and GTSM */
11825 if (p->sort != BGP_PEER_IBGP)
11826 {
11827 if (use_json)
11828 {
11829 if (p->gtsm_hops > 0)
11830 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
11831 else if (p->ttl > 1)
11832 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
11833 }
11834 else
11835 {
11836 if (p->gtsm_hops > 0)
11837 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11838 p->gtsm_hops, VTY_NEWLINE);
11839 else if (p->ttl > 1)
11840 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
11841 p->ttl, VTY_NEWLINE);
11842 }
11843 }
11844 else
11845 {
11846 if (p->gtsm_hops > 0)
11847 {
11848 if (use_json)
11849 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
11850 else
11851 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
11852 p->gtsm_hops, VTY_NEWLINE);
11853 }
11854 }
11855
11856 /* Local address. */
11857 if (p->su_local)
11858 {
11859 if (use_json)
11860 {
11861 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
11862 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
11863 }
11864 else
11865 vty_out (vty, "Local host: %s, Local port: %d%s",
11866 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
11867 ntohs (p->su_local->sin.sin_port),
11868 VTY_NEWLINE);
11869 }
11870
11871 /* Remote address. */
11872 if (p->su_remote)
11873 {
11874 if (use_json)
11875 {
11876 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
11877 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
11878 }
11879 else
11880 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
11881 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
11882 ntohs (p->su_remote->sin.sin_port),
11883 VTY_NEWLINE);
11884 }
11885
11886 /* Nexthop display. */
11887 if (p->su_local)
11888 {
11889 if (use_json)
11890 {
11891 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
11892 #ifdef HAVE_IPV6
11893 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
11894 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
11895 if (p->shared_network)
11896 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
11897 else
11898 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
11899 #endif /* HAVE_IPV6 */
11900 }
11901 else
11902 {
11903 vty_out (vty, "Nexthop: %s%s",
11904 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
11905 VTY_NEWLINE);
11906 #ifdef HAVE_IPV6
11907 vty_out (vty, "Nexthop global: %s%s",
11908 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
11909 VTY_NEWLINE);
11910 vty_out (vty, "Nexthop local: %s%s",
11911 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
11912 VTY_NEWLINE);
11913 vty_out (vty, "BGP connection: %s%s",
11914 p->shared_network ? "shared network" : "non shared network",
11915 VTY_NEWLINE);
11916 #endif /* HAVE_IPV6 */
11917 }
11918 }
11919
11920 /* Timer information. */
11921 if (use_json)
11922 {
11923 if (p->t_start)
11924 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
11925 if (p->t_connect)
11926 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
11927 if (p->t_routeadv)
11928 {
11929 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
11930 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
11931 }
11932
11933 if (p->t_read)
11934 json_object_string_add(json_neigh, "readThread", "on");
11935 else
11936 json_object_string_add(json_neigh, "readThread", "off");
11937 if (p->t_write)
11938 json_object_string_add(json_neigh, "writeThread", "on");
11939 else
11940 json_object_string_add(json_neigh, "writeThread", "off");
11941 }
11942 else
11943 {
11944 if (p->t_start)
11945 vty_out (vty, "Next start timer due in %ld seconds%s",
11946 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
11947 if (p->t_connect)
11948 vty_out (vty, "Next connect timer due in %ld seconds%s",
11949 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
11950 if (p->t_routeadv)
11951 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
11952 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
11953 VTY_NEWLINE);
11954
11955 vty_out (vty, "Read thread: %s Write thread: %s%s",
11956 p->t_read ? "on" : "off",
11957 p->t_write ? "on" : "off",
11958 VTY_NEWLINE);
11959 }
11960
11961 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
11962 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
11963 bgp_capability_vty_out (vty, p, use_json, json_neigh);
11964
11965 if (!use_json)
11966 vty_out (vty, "%s", VTY_NEWLINE);
11967
11968 /* BFD information. */
11969 bgp_bfd_show_info(vty, p, use_json, json_neigh);
11970
11971 if (use_json)
11972 {
11973 if (p->conf_if) /* Configured interface name. */
11974 json_object_object_add(json, p->conf_if, json_neigh);
11975 else /* Configured IP address. */
11976 json_object_object_add(json, p->host, json_neigh);
11977 }
11978 }
11979
11980 static int
11981 bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
11982 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
11983 {
11984 struct listnode *node, *nnode;
11985 struct peer *peer;
11986 int find = 0;
11987 json_object *json_neigh = NULL;
11988
11989 if (use_json)
11990 json_neigh = json_object_new_object();
11991
11992 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
11993 {
11994 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
11995 continue;
11996
11997 switch (type)
11998 {
11999 case show_all:
12000 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12001 break;
12002 case show_peer:
12003 if (conf_if)
12004 {
12005 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
12006 (peer->hostname && !strcmp(peer->hostname, conf_if)))
12007 {
12008 find = 1;
12009 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12010 }
12011 }
12012 else
12013 {
12014 if (sockunion_same (&peer->su, su))
12015 {
12016 find = 1;
12017 bgp_show_peer (vty, peer, use_json, json, json_neigh);
12018 }
12019 }
12020 break;
12021 }
12022 }
12023
12024 if (type == show_peer && ! find)
12025 {
12026 if (use_json)
12027 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
12028 else
12029 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
12030 }
12031
12032 if (use_json)
12033 {
12034 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
12035 json_object_free(json);
12036 }
12037 else
12038 {
12039 vty_out (vty, "%s", VTY_NEWLINE);
12040 }
12041
12042 return CMD_SUCCESS;
12043 }
12044
12045 static int
12046 bgp_show_neighbor_vty (struct vty *vty, const char *name,
12047 enum show_type type, const char *ip_str, u_char use_json)
12048 {
12049 int ret;
12050 struct bgp *bgp;
12051 union sockunion su;
12052 json_object *json = NULL;
12053
12054 if (use_json)
12055 json = json_object_new_object();
12056
12057 if (name)
12058 {
12059 bgp = bgp_lookup_by_name (name);
12060 if (! bgp)
12061 {
12062 if (use_json)
12063 {
12064 json_object_boolean_true_add(json, "bgpNoSuchInstance");
12065 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
12066 json_object_free(json);
12067 }
12068 else
12069 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
12070
12071 return CMD_WARNING;
12072 }
12073 }
12074 else
12075 {
12076 bgp = bgp_get_default ();
12077 }
12078
12079 if (bgp)
12080 {
12081 if (ip_str)
12082 {
12083 ret = str2sockunion (ip_str, &su);
12084 if (ret < 0)
12085 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
12086 else
12087 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
12088 }
12089 else
12090 {
12091 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
12092 }
12093 }
12094
12095 return CMD_SUCCESS;
12096 }
12097
12098 /* "show ip bgp neighbors" commands. */
12099 DEFUN (show_ip_bgp_neighbors,
12100 show_ip_bgp_neighbors_cmd,
12101 "show ip bgp neighbors {json}",
12102 SHOW_STR
12103 IP_STR
12104 BGP_STR
12105 "Detailed information on TCP and BGP neighbor connections\n"
12106 "JavaScript Object Notation\n")
12107 {
12108 u_char uj = use_json(argc, argv);
12109
12110 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj);
12111 }
12112
12113 ALIAS (show_ip_bgp_neighbors,
12114 show_ip_bgp_ipv4_neighbors_cmd,
12115 "show ip bgp ipv4 (unicast|multicast) neighbors {json}",
12116 SHOW_STR
12117 IP_STR
12118 BGP_STR
12119 "Address family\n"
12120 "Address Family modifier\n"
12121 "Address Family modifier\n"
12122 "Detailed information on TCP and BGP neighbor connections\n"
12123 "JavaScript Object Notation\n")
12124
12125 ALIAS (show_ip_bgp_neighbors,
12126 show_ip_bgp_vpnv4_all_neighbors_cmd,
12127 "show ip bgp vpnv4 all neighbors {json}",
12128 SHOW_STR
12129 IP_STR
12130 BGP_STR
12131 "Display VPNv4 NLRI specific information\n"
12132 "Display information about all VPNv4 NLRIs\n"
12133 "Detailed information on TCP and BGP neighbor connections\n"
12134 "JavaScript Object Notation\n")
12135
12136 ALIAS (show_ip_bgp_neighbors,
12137 show_ip_bgp_vpnv4_rd_neighbors_cmd,
12138 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}",
12139 SHOW_STR
12140 IP_STR
12141 BGP_STR
12142 "Display VPNv4 NLRI specific information\n"
12143 "Display information for a route distinguisher\n"
12144 "VPN Route Distinguisher\n"
12145 "Detailed information on TCP and BGP neighbor connections\n"
12146 "JavaScript Object Notation\n")
12147
12148 ALIAS (show_ip_bgp_neighbors,
12149 show_bgp_neighbors_cmd,
12150 "show bgp neighbors {json}",
12151 SHOW_STR
12152 BGP_STR
12153 "Detailed information on TCP and BGP neighbor connections\n"
12154 "JavaScript Object Notation\n")
12155
12156 ALIAS (show_ip_bgp_neighbors,
12157 show_bgp_ipv6_neighbors_cmd,
12158 "show bgp ipv6 neighbors {json}",
12159 SHOW_STR
12160 BGP_STR
12161 "Address family\n"
12162 "Detailed information on TCP and BGP neighbor connections\n"
12163 "JavaScript Object Notation\n")
12164
12165 DEFUN (show_ip_bgp_neighbors_peer,
12166 show_ip_bgp_neighbors_peer_cmd,
12167 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12168 SHOW_STR
12169 IP_STR
12170 BGP_STR
12171 "Detailed information on TCP and BGP neighbor connections\n"
12172 "Neighbor to display information about\n"
12173 "Neighbor to display information about\n"
12174 "Neighbor on bgp configured interface\n"
12175 "JavaScript Object Notation\n")
12176 {
12177 u_char uj = use_json(argc, argv);
12178
12179 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj);
12180 }
12181
12182 ALIAS (show_ip_bgp_neighbors_peer,
12183 show_ip_bgp_ipv4_neighbors_peer_cmd,
12184 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12185 SHOW_STR
12186 IP_STR
12187 BGP_STR
12188 "Address family\n"
12189 "Address Family modifier\n"
12190 "Address Family modifier\n"
12191 "Detailed information on TCP and BGP neighbor connections\n"
12192 "Neighbor to display information about\n"
12193 "Neighbor to display information about\n"
12194 "Neighbor on bgp configured interface\n"
12195 "JavaScript Object Notation\n")
12196
12197 ALIAS (show_ip_bgp_neighbors_peer,
12198 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
12199 "show ip bgp vpnv4 all neighbors A.B.C.D {json}",
12200 SHOW_STR
12201 IP_STR
12202 BGP_STR
12203 "Display VPNv4 NLRI specific information\n"
12204 "Display information about all VPNv4 NLRIs\n"
12205 "Detailed information on TCP and BGP neighbor connections\n"
12206 "Neighbor to display information about\n"
12207 "JavaScript Object Notation\n")
12208
12209 ALIAS (show_ip_bgp_neighbors_peer,
12210 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
12211 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}",
12212 SHOW_STR
12213 IP_STR
12214 BGP_STR
12215 "Display VPNv4 NLRI specific information\n"
12216 "Display information about all VPNv4 NLRIs\n"
12217 "Detailed information on TCP and BGP neighbor connections\n"
12218 "Neighbor to display information about\n"
12219 "JavaScript Object Notation\n")
12220
12221 ALIAS (show_ip_bgp_neighbors_peer,
12222 show_bgp_neighbors_peer_cmd,
12223 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12224 SHOW_STR
12225 BGP_STR
12226 "Detailed information on TCP and BGP neighbor connections\n"
12227 "Neighbor to display information about\n"
12228 "Neighbor to display information about\n"
12229 "Neighbor on bgp configured interface\n"
12230 "JavaScript Object Notation\n")
12231
12232 ALIAS (show_ip_bgp_neighbors_peer,
12233 show_bgp_ipv6_neighbors_peer_cmd,
12234 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12235 SHOW_STR
12236 BGP_STR
12237 "Address family\n"
12238 "Detailed information on TCP and BGP neighbor connections\n"
12239 "Neighbor to display information about\n"
12240 "Neighbor to display information about\n"
12241 "Neighbor on bgp configured interface\n"
12242 "JavaScript Object Notation\n")
12243
12244 DEFUN (show_ip_bgp_instance_neighbors,
12245 show_ip_bgp_instance_neighbors_cmd,
12246 "show ip bgp " BGP_INSTANCE_CMD " neighbors {json}",
12247 SHOW_STR
12248 IP_STR
12249 BGP_STR
12250 BGP_INSTANCE_HELP_STR
12251 "Detailed information on TCP and BGP neighbor connections\n"
12252 "JavaScript Object Notation\n")
12253 {
12254 u_char uj = use_json(argc, argv);
12255
12256 return bgp_show_neighbor_vty (vty, argv[1], show_all, NULL, uj);
12257 }
12258
12259 ALIAS (show_ip_bgp_instance_neighbors,
12260 show_bgp_instance_neighbors_cmd,
12261 "show bgp " BGP_INSTANCE_CMD " neighbors {json}",
12262 SHOW_STR
12263 BGP_STR
12264 BGP_INSTANCE_HELP_STR
12265 "Detailed information on TCP and BGP neighbor connections\n"
12266 "JavaScript Object Notation\n")
12267
12268 ALIAS (show_ip_bgp_instance_neighbors,
12269 show_bgp_instance_ipv6_neighbors_cmd,
12270 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors {json}",
12271 SHOW_STR
12272 BGP_STR
12273 BGP_INSTANCE_HELP_STR
12274 "Address family\n"
12275 "Detailed information on TCP and BGP neighbor connections\n"
12276 "JavaScript Object Notation\n")
12277
12278 DEFUN (show_ip_bgp_instance_neighbors_peer,
12279 show_ip_bgp_instance_neighbors_peer_cmd,
12280 "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12281 SHOW_STR
12282 IP_STR
12283 BGP_STR
12284 BGP_INSTANCE_HELP_STR
12285 "Detailed information on TCP and BGP neighbor connections\n"
12286 "Neighbor to display information about\n"
12287 "Neighbor to display information about\n"
12288 "Neighbor on bgp configured interface\n"
12289 "JavaScript Object Notation\n")
12290 {
12291 u_char uj = use_json(argc, argv);
12292
12293 return bgp_show_neighbor_vty (vty, argv[1], show_peer, argv[2], uj);
12294 }
12295
12296 ALIAS (show_ip_bgp_instance_neighbors_peer,
12297 show_bgp_instance_neighbors_peer_cmd,
12298 "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12299 SHOW_STR
12300 BGP_STR
12301 BGP_INSTANCE_HELP_STR
12302 "Detailed information on TCP and BGP neighbor connections\n"
12303 "Neighbor to display information about\n"
12304 "Neighbor to display information about\n"
12305 "Neighbor on bgp configured interface\n"
12306 "JavaScript Object Notation\n")
12307
12308 ALIAS (show_ip_bgp_instance_neighbors_peer,
12309 show_bgp_instance_ipv6_neighbors_peer_cmd,
12310 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
12311 SHOW_STR
12312 BGP_STR
12313 BGP_INSTANCE_HELP_STR
12314 "Address family\n"
12315 "Detailed information on TCP and BGP neighbor connections\n"
12316 "Neighbor to display information about\n"
12317 "Neighbor to display information about\n"
12318 "Neighbor on bgp configured interface\n"
12319 "JavaScript Object Notation\n")
12320
12321 /* Show BGP's AS paths internal data. There are both `show ip bgp
12322 paths' and `show ip mbgp paths'. Those functions results are the
12323 same.*/
12324 DEFUN (show_ip_bgp_paths,
12325 show_ip_bgp_paths_cmd,
12326 "show ip bgp paths",
12327 SHOW_STR
12328 IP_STR
12329 BGP_STR
12330 "Path information\n")
12331 {
12332 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
12333 aspath_print_all_vty (vty);
12334 return CMD_SUCCESS;
12335 }
12336
12337 DEFUN (show_ip_bgp_ipv4_paths,
12338 show_ip_bgp_ipv4_paths_cmd,
12339 "show ip bgp ipv4 (unicast|multicast) paths",
12340 SHOW_STR
12341 IP_STR
12342 BGP_STR
12343 "Address family\n"
12344 "Address Family modifier\n"
12345 "Address Family modifier\n"
12346 "Path information\n")
12347 {
12348 vty_out (vty, "Address Refcnt Path\r\n");
12349 aspath_print_all_vty (vty);
12350
12351 return CMD_SUCCESS;
12352 }
12353
12354 #include "hash.h"
12355
12356 static void
12357 community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
12358 {
12359 struct community *com;
12360
12361 com = (struct community *) backet->data;
12362 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
12363 community_str (com), VTY_NEWLINE);
12364 }
12365
12366 /* Show BGP's community internal data. */
12367 DEFUN (show_ip_bgp_community_info,
12368 show_ip_bgp_community_info_cmd,
12369 "show ip bgp community-info",
12370 SHOW_STR
12371 IP_STR
12372 BGP_STR
12373 "List all bgp community information\n")
12374 {
12375 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
12376
12377 hash_iterate (community_hash (),
12378 (void (*) (struct hash_backet *, void *))
12379 community_show_all_iterator,
12380 vty);
12381
12382 return CMD_SUCCESS;
12383 }
12384
12385 DEFUN (show_ip_bgp_attr_info,
12386 show_ip_bgp_attr_info_cmd,
12387 "show ip bgp attribute-info",
12388 SHOW_STR
12389 IP_STR
12390 BGP_STR
12391 "List all bgp attribute information\n")
12392 {
12393 attr_show_all (vty);
12394 return CMD_SUCCESS;
12395 }
12396
12397 static int bgp_show_update_groups(struct vty *vty, const char *name,
12398 int afi, int safi,
12399 u_int64_t subgrp_id)
12400 {
12401 struct bgp *bgp;
12402
12403 if (name)
12404 bgp = bgp_lookup_by_name (name);
12405 else
12406 bgp = bgp_get_default ();
12407
12408 if (bgp)
12409 update_group_show(bgp, afi, safi, vty, subgrp_id);
12410 return CMD_SUCCESS;
12411 }
12412
12413 DEFUN (show_ip_bgp_updgrps,
12414 show_ip_bgp_updgrps_cmd,
12415 "show ip bgp update-groups",
12416 SHOW_STR
12417 IP_STR
12418 BGP_STR
12419 "Detailed info about dynamic update groups\n")
12420 {
12421 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
12422 }
12423
12424 DEFUN (show_ip_bgp_instance_updgrps,
12425 show_ip_bgp_instance_updgrps_cmd,
12426 "show ip bgp " BGP_INSTANCE_CMD " update-groups",
12427 SHOW_STR
12428 IP_STR
12429 BGP_STR
12430 BGP_INSTANCE_HELP_STR
12431 "Detailed info about dynamic update groups\n")
12432 {
12433 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, 0));
12434 }
12435
12436 DEFUN (show_bgp_ipv6_updgrps,
12437 show_bgp_ipv6_updgrps_cmd,
12438 "show bgp update-groups",
12439 SHOW_STR
12440 BGP_STR
12441 "Detailed info about v6 dynamic update groups\n")
12442 {
12443 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
12444 }
12445
12446 DEFUN (show_bgp_instance_ipv6_updgrps,
12447 show_bgp_instance_ipv6_updgrps_cmd,
12448 "show bgp " BGP_INSTANCE_CMD " update-groups",
12449 SHOW_STR
12450 BGP_STR
12451 BGP_INSTANCE_HELP_STR
12452 "Detailed info about v6 dynamic update groups\n")
12453 {
12454 return (bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, 0));
12455 }
12456
12457 DEFUN (show_bgp_updgrps,
12458 show_bgp_updgrps_cmd,
12459 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups",
12460 SHOW_STR
12461 BGP_STR
12462 "Address family\n"
12463 "Address family\n"
12464 "Address Family modifier\n"
12465 "Address Family modifier\n"
12466 "Detailed info about dynamic update groups\n")
12467 {
12468 afi_t afi;
12469 safi_t safi;
12470
12471 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12472 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12473 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
12474 }
12475
12476 DEFUN (show_ip_bgp_updgrps_s,
12477 show_ip_bgp_updgrps_s_cmd,
12478 "show ip bgp update-groups SUBGROUP-ID",
12479 SHOW_STR
12480 IP_STR
12481 BGP_STR
12482 "Detailed info about dynamic update groups\n"
12483 "Specific subgroup to display detailed info for\n")
12484 {
12485 u_int64_t subgrp_id;
12486
12487 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12488 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
12489 }
12490
12491 DEFUN (show_ip_bgp_instance_updgrps_s,
12492 show_ip_bgp_instance_updgrps_s_cmd,
12493 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12494 SHOW_STR
12495 IP_STR
12496 BGP_STR
12497 BGP_INSTANCE_HELP_STR
12498 "Detailed info about dynamic update groups\n"
12499 "Specific subgroup to display detailed info for\n")
12500 {
12501 u_int64_t subgrp_id;
12502
12503 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12504 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, subgrp_id));
12505 }
12506
12507 DEFUN (show_bgp_ipv6_updgrps_s,
12508 show_bgp_ipv6_updgrps_s_cmd,
12509 "show bgp update-groups SUBGROUP-ID",
12510 SHOW_STR
12511 BGP_STR
12512 "Detailed info about v6 dynamic update groups\n"
12513 "Specific subgroup to display detailed info for\n")
12514 {
12515 u_int64_t subgrp_id;
12516
12517 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12518 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
12519 }
12520
12521 DEFUN (show_bgp_instance_ipv6_updgrps_s,
12522 show_bgp_instance_ipv6_updgrps_s_cmd,
12523 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
12524 SHOW_STR
12525 BGP_STR
12526 "Detailed info about v6 dynamic update groups\n"
12527 "Specific subgroup to display detailed info for\n")
12528 {
12529 u_int64_t subgrp_id;
12530
12531 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12532 return(bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, subgrp_id));
12533 }
12534
12535 DEFUN (show_bgp_updgrps_s,
12536 show_bgp_updgrps_s_cmd,
12537 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID",
12538 SHOW_STR
12539 BGP_STR
12540 "Address family\n"
12541 "Address family\n"
12542 "Address Family modifier\n"
12543 "Address Family modifier\n"
12544 "Detailed info about v6 dynamic update groups\n"
12545 "Specific subgroup to display detailed info for")
12546 {
12547 afi_t afi;
12548 safi_t safi;
12549 u_int64_t subgrp_id;
12550
12551 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12552 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12553
12554 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12555 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
12556 }
12557
12558 DEFUN (show_bgp_updgrps_stats,
12559 show_bgp_updgrps_stats_cmd,
12560 "show bgp update-groups statistics",
12561 SHOW_STR
12562 BGP_STR
12563 "BGP update groups\n"
12564 "Statistics\n")
12565 {
12566 struct bgp *bgp;
12567
12568 bgp = bgp_get_default();
12569 if (bgp)
12570 update_group_show_stats(bgp, vty);
12571
12572 return CMD_SUCCESS;
12573 }
12574
12575 DEFUN (show_bgp_instance_updgrps_stats,
12576 show_bgp_instance_updgrps_stats_cmd,
12577 "show bgp " BGP_INSTANCE_CMD " update-groups statistics",
12578 SHOW_STR
12579 BGP_STR
12580 BGP_INSTANCE_HELP_STR
12581 "BGP update groups\n"
12582 "Statistics\n")
12583 {
12584 struct bgp *bgp;
12585
12586 bgp = bgp_lookup_by_name (argv[1]);
12587 if (bgp)
12588 update_group_show_stats(bgp, vty);
12589
12590 return CMD_SUCCESS;
12591 }
12592
12593 static void
12594 show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
12595 afi_t afi, safi_t safi,
12596 const char *what, u_int64_t subgrp_id)
12597 {
12598 struct bgp *bgp;
12599
12600 if (name)
12601 bgp = bgp_lookup_by_name (name);
12602 else
12603 bgp = bgp_get_default ();
12604
12605 if (bgp)
12606 {
12607 if (!strcmp(what, "advertise-queue"))
12608 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
12609 else if (!strcmp(what, "advertised-routes"))
12610 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
12611 else if (!strcmp(what, "packet-queue"))
12612 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
12613 }
12614 }
12615
12616 DEFUN (show_ip_bgp_updgrps_adj,
12617 show_ip_bgp_updgrps_adj_cmd,
12618 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12619 SHOW_STR
12620 IP_STR
12621 BGP_STR
12622 "BGP update groups\n"
12623 "Advertisement queue\n"
12624 "Announced routes\n"
12625 "Packet queue\n")
12626
12627 {
12628 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[0], 0);
12629 return CMD_SUCCESS;
12630 }
12631
12632 DEFUN (show_ip_bgp_instance_updgrps_adj,
12633 show_ip_bgp_instance_updgrps_adj_cmd,
12634 "show ip bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12635 SHOW_STR
12636 IP_STR
12637 BGP_STR
12638 BGP_INSTANCE_HELP_STR
12639 "BGP update groups\n"
12640 "Advertisement queue\n"
12641 "Announced routes\n"
12642 "Packet queue\n")
12643
12644 {
12645 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[2], 0);
12646 return CMD_SUCCESS;
12647 }
12648
12649 DEFUN (show_bgp_updgrps_afi_adj,
12650 show_bgp_updgrps_afi_adj_cmd,
12651 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)",
12652 SHOW_STR
12653 BGP_STR
12654 "Address family\n"
12655 "Address family\n"
12656 "Address Family modifier\n"
12657 "Address Family modifier\n"
12658 "BGP update groups\n"
12659 "Advertisement queue\n"
12660 "Announced routes\n"
12661 "Packet queue\n"
12662 "Specific subgroup info wanted for\n")
12663 {
12664 afi_t afi;
12665 safi_t safi;
12666
12667 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12668 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12669 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0);
12670 return CMD_SUCCESS;
12671 }
12672
12673 DEFUN (show_bgp_updgrps_adj,
12674 show_bgp_updgrps_adj_cmd,
12675 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
12676 SHOW_STR
12677 BGP_STR
12678 "BGP update groups\n"
12679 "Advertisement queue\n"
12680 "Announced routes\n"
12681 "Packet queue\n")
12682 {
12683 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[0], 0);
12684 return CMD_SUCCESS;
12685 }
12686
12687 DEFUN (show_bgp_instance_updgrps_adj,
12688 show_bgp_instance_updgrps_adj_cmd,
12689 "show bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
12690 SHOW_STR
12691 BGP_STR
12692 BGP_INSTANCE_HELP_STR
12693 "BGP update groups\n"
12694 "Advertisement queue\n"
12695 "Announced routes\n"
12696 "Packet queue\n")
12697 {
12698 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[2], 0);
12699 return CMD_SUCCESS;
12700 }
12701
12702 DEFUN (show_ip_bgp_updgrps_adj_s,
12703 show_ip_bgp_updgrps_adj_s_cmd,
12704 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12705 SHOW_STR
12706 IP_STR
12707 BGP_STR
12708 "BGP update groups\n"
12709 "Specific subgroup to display info for\n"
12710 "Advertisement queue\n"
12711 "Announced routes\n"
12712 "Packet queue\n")
12713
12714 {
12715 u_int64_t subgrp_id;
12716
12717 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12718
12719 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
12720 return CMD_SUCCESS;
12721 }
12722
12723 DEFUN (show_ip_bgp_instance_updgrps_adj_s,
12724 show_ip_bgp_instance_updgrps_adj_s_cmd,
12725 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12726 SHOW_STR
12727 IP_STR
12728 BGP_STR
12729 BGP_INSTANCE_HELP_STR
12730 "BGP update groups\n"
12731 "Specific subgroup to display info for\n"
12732 "Advertisement queue\n"
12733 "Announced routes\n"
12734 "Packet queue\n")
12735
12736 {
12737 u_int64_t subgrp_id;
12738
12739 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12740
12741 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
12742 return CMD_SUCCESS;
12743 }
12744
12745 DEFUN (show_bgp_updgrps_afi_adj_s,
12746 show_bgp_updgrps_afi_adj_s_cmd,
12747 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12748 SHOW_STR
12749 BGP_STR
12750 "Address family\n"
12751 "Address family\n"
12752 "Address Family modifier\n"
12753 "Address Family modifier\n"
12754 "BGP update groups\n"
12755 "Specific subgroup to display info for\n"
12756 "Advertisement queue\n"
12757 "Announced routes\n"
12758 "Packet queue\n"
12759 "Specific subgroup info wanted for\n")
12760 {
12761 afi_t afi;
12762 safi_t safi;
12763 u_int64_t subgrp_id;
12764
12765 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
12766 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12767 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12768
12769 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
12770 return CMD_SUCCESS;
12771 }
12772
12773 DEFUN (show_bgp_updgrps_adj_s,
12774 show_bgp_updgrps_adj_s_cmd,
12775 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12776 SHOW_STR
12777 BGP_STR
12778 "BGP update groups\n"
12779 "Specific subgroup to display info for\n"
12780 "Advertisement queue\n"
12781 "Announced routes\n"
12782 "Packet queue\n")
12783 {
12784 u_int64_t subgrp_id;
12785
12786 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
12787
12788 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
12789 return CMD_SUCCESS;
12790 }
12791
12792 DEFUN (show_bgp_instance_updgrps_adj_s,
12793 show_bgp_instance_updgrps_adj_s_cmd,
12794 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
12795 SHOW_STR
12796 BGP_STR
12797 BGP_INSTANCE_HELP_STR
12798 "BGP update groups\n"
12799 "Specific subgroup to display info for\n"
12800 "Advertisement queue\n"
12801 "Announced routes\n"
12802 "Packet queue\n")
12803 {
12804 u_int64_t subgrp_id;
12805
12806 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
12807
12808 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
12809 return CMD_SUCCESS;
12810 }
12811
12812
12813
12814 static int
12815 bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
12816 {
12817 struct listnode *node, *nnode;
12818 struct prefix *range;
12819 struct peer *conf;
12820 struct peer *peer;
12821 char buf[PREFIX2STR_BUFFER];
12822 afi_t afi;
12823 safi_t safi;
12824 const char *peer_status;
12825 const char *af_str;
12826 int lr_count;
12827 int dynamic;
12828 int af_cfgd;
12829
12830 conf = group->conf;
12831
12832 if (conf->as_type == AS_SPECIFIED ||
12833 conf->as_type == AS_EXTERNAL) {
12834 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
12835 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
12836 } else if (conf->as_type == AS_INTERNAL) {
12837 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
12838 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
12839 } else {
12840 vty_out (vty, "%sBGP peer-group %s%s",
12841 VTY_NEWLINE, group->name, VTY_NEWLINE);
12842 }
12843
12844 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
12845 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
12846 else
12847 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
12848
12849 /* Display AFs configured. */
12850 vty_out (vty, " Configured address-families:");
12851 for (afi = AFI_IP; afi < AFI_MAX; afi++)
12852 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
12853 {
12854 if (conf->afc[afi][safi])
12855 {
12856 af_cfgd = 1;
12857 vty_out (vty, " %s;", afi_safi_print(afi, safi));
12858 }
12859 }
12860 if (!af_cfgd)
12861 vty_out (vty, " none%s", VTY_NEWLINE);
12862 else
12863 vty_out (vty, "%s", VTY_NEWLINE);
12864
12865 /* Display listen ranges (for dynamic neighbors), if any */
12866 for (afi = AFI_IP; afi < AFI_MAX; afi++)
12867 {
12868 if (afi == AFI_IP)
12869 af_str = "IPv4";
12870 else if (afi == AFI_IP6)
12871 af_str = "IPv6";
12872 lr_count = listcount(group->listen_range[afi]);
12873 if (lr_count)
12874 {
12875 vty_out(vty,
12876 " %d %s listen range(s)%s",
12877 lr_count, af_str, VTY_NEWLINE);
12878
12879
12880 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
12881 nnode, range))
12882 {
12883 prefix2str(range, buf, sizeof(buf));
12884 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
12885 }
12886 }
12887 }
12888
12889 /* Display group members and their status */
12890 if (listcount(group->peer))
12891 {
12892 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
12893 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
12894 {
12895 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
12896 peer_status = "Idle (Admin)";
12897 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
12898 peer_status = "Idle (PfxCt)";
12899 else
12900 peer_status = LOOKUP(bgp_status_msg, peer->status);
12901
12902 dynamic = peer_dynamic_neighbor(peer);
12903 vty_out (vty, " %s %s %s %s",
12904 peer->host, dynamic ? "(dynamic)" : "",
12905 peer_status, VTY_NEWLINE);
12906 }
12907 }
12908
12909 return CMD_SUCCESS;
12910 }
12911
12912 /* Show BGP peer group's information. */
12913 enum show_group_type
12914 {
12915 show_all_groups,
12916 show_peer_group
12917 };
12918
12919 static int
12920 bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
12921 enum show_group_type type, const char *group_name)
12922 {
12923 struct listnode *node, *nnode;
12924 struct peer_group *group;
12925 int find = 0;
12926
12927 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
12928 {
12929 switch (type)
12930 {
12931 case show_all_groups:
12932 bgp_show_one_peer_group (vty, group);
12933 break;
12934 case show_peer_group:
12935 if (group_name && (strcmp(group->name, group_name) == 0))
12936 {
12937 find = 1;
12938 bgp_show_one_peer_group (vty, group);
12939 }
12940 break;
12941 }
12942 }
12943
12944 if (type == show_peer_group && ! find)
12945 vty_out (vty, "%% No such peer-groupr%s", VTY_NEWLINE);
12946
12947 return CMD_SUCCESS;
12948 }
12949
12950 static int
12951 bgp_show_peer_group_vty (struct vty *vty, const char *name,
12952 enum show_group_type type, const char *group_name)
12953 {
12954 struct bgp *bgp;
12955 int ret = CMD_SUCCESS;
12956
12957 if (name)
12958 bgp = bgp_lookup_by_name (name);
12959 else
12960 bgp = bgp_get_default ();
12961
12962 if (! bgp)
12963 {
12964 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
12965 return CMD_WARNING;
12966 }
12967
12968 ret = bgp_show_peer_group (vty, bgp, type, group_name);
12969
12970 return ret;
12971 }
12972
12973 DEFUN (show_ip_bgp_peer_groups,
12974 show_ip_bgp_peer_groups_cmd,
12975 "show ip bgp peer-group",
12976 SHOW_STR
12977 IP_STR
12978 BGP_STR
12979 "Detailed information on all BGP peer groups\n")
12980 {
12981 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
12982 }
12983
12984 DEFUN (show_ip_bgp_instance_peer_groups,
12985 show_ip_bgp_instance_peer_groups_cmd,
12986 "show ip bgp " BGP_INSTANCE_CMD " peer-group",
12987 SHOW_STR
12988 IP_STR
12989 BGP_STR
12990 BGP_INSTANCE_HELP_STR
12991 "Detailed information on all BGP peer groups\n")
12992 {
12993 return bgp_show_peer_group_vty (vty, argv[1], show_all_groups, NULL);
12994 }
12995
12996 DEFUN (show_ip_bgp_peer_group,
12997 show_ip_bgp_peer_group_cmd,
12998 "show ip bgp peer-group WORD",
12999 SHOW_STR
13000 IP_STR
13001 BGP_STR
13002 "BGP peer-group name\n"
13003 "Detailed information on a BGP peer group\n")
13004 {
13005 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
13006 }
13007
13008 DEFUN (show_ip_bgp_instance_peer_group,
13009 show_ip_bgp_instance_peer_group_cmd,
13010 "show ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
13011 SHOW_STR
13012 IP_STR
13013 BGP_STR
13014 BGP_INSTANCE_HELP_STR
13015 "BGP peer-group name\n"
13016 "Detailed information on a BGP peer group\n")
13017 {
13018 return bgp_show_peer_group_vty (vty, argv[1], show_peer_group, argv[2]);
13019 }
13020
13021 /* Redistribute VTY commands. */
13022
13023 DEFUN (bgp_redistribute_ipv4,
13024 bgp_redistribute_ipv4_cmd,
13025 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
13026 "Redistribute information from another routing protocol\n"
13027 QUAGGA_IP_REDIST_HELP_STR_BGPD)
13028 {
13029 int type;
13030
13031 type = proto_redistnum (AFI_IP, argv[0]);
13032 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13033 {
13034 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13035 return CMD_WARNING;
13036 }
13037 bgp_redist_add(vty->index, AFI_IP, type, 0);
13038 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13039 }
13040
13041 DEFUN (bgp_redistribute_ipv4_rmap,
13042 bgp_redistribute_ipv4_rmap_cmd,
13043 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
13044 "Redistribute information from another routing protocol\n"
13045 QUAGGA_IP_REDIST_HELP_STR_BGPD
13046 "Route map reference\n"
13047 "Pointer to route-map entries\n")
13048 {
13049 int type;
13050 struct bgp_redist *red;
13051
13052 type = proto_redistnum (AFI_IP, argv[0]);
13053 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13054 {
13055 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13056 return CMD_WARNING;
13057 }
13058
13059 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13060 bgp_redistribute_rmap_set (red, argv[1]);
13061 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13062 }
13063
13064 DEFUN (bgp_redistribute_ipv4_metric,
13065 bgp_redistribute_ipv4_metric_cmd,
13066 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
13067 "Redistribute information from another routing protocol\n"
13068 QUAGGA_IP_REDIST_HELP_STR_BGPD
13069 "Metric for redistributed routes\n"
13070 "Default metric\n")
13071 {
13072 int type;
13073 u_int32_t metric;
13074 struct bgp_redist *red;
13075
13076 type = proto_redistnum (AFI_IP, argv[0]);
13077 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13078 {
13079 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13080 return CMD_WARNING;
13081 }
13082 VTY_GET_INTEGER ("metric", metric, argv[1]);
13083
13084 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13085 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13086 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13087 }
13088
13089 DEFUN (bgp_redistribute_ipv4_rmap_metric,
13090 bgp_redistribute_ipv4_rmap_metric_cmd,
13091 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13092 "Redistribute information from another routing protocol\n"
13093 QUAGGA_IP_REDIST_HELP_STR_BGPD
13094 "Route map reference\n"
13095 "Pointer to route-map entries\n"
13096 "Metric for redistributed routes\n"
13097 "Default metric\n")
13098 {
13099 int type;
13100 u_int32_t metric;
13101 struct bgp_redist *red;
13102
13103 type = proto_redistnum (AFI_IP, argv[0]);
13104 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13105 {
13106 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13107 return CMD_WARNING;
13108 }
13109 VTY_GET_INTEGER ("metric", metric, argv[2]);
13110
13111 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13112 bgp_redistribute_rmap_set (red, argv[1]);
13113 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13114 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13115 }
13116
13117 DEFUN (bgp_redistribute_ipv4_metric_rmap,
13118 bgp_redistribute_ipv4_metric_rmap_cmd,
13119 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13120 "Redistribute information from another routing protocol\n"
13121 QUAGGA_IP_REDIST_HELP_STR_BGPD
13122 "Metric for redistributed routes\n"
13123 "Default metric\n"
13124 "Route map reference\n"
13125 "Pointer to route-map entries\n")
13126 {
13127 int type;
13128 u_int32_t metric;
13129 struct bgp_redist *red;
13130
13131 type = proto_redistnum (AFI_IP, argv[0]);
13132 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13133 {
13134 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13135 return CMD_WARNING;
13136 }
13137 VTY_GET_INTEGER ("metric", metric, argv[1]);
13138
13139 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
13140 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
13141 bgp_redistribute_rmap_set (red, argv[2]);
13142 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
13143 }
13144
13145 DEFUN (bgp_redistribute_ipv4_ospf,
13146 bgp_redistribute_ipv4_ospf_cmd,
13147 "redistribute (ospf|table) <1-65535>",
13148 "Redistribute information from another routing protocol\n"
13149 "Open Shortest Path First (OSPFv2)\n"
13150 "Non-main Kernel Routing Table\n"
13151 "Instance ID/Table ID\n")
13152 {
13153 u_short instance;
13154 u_short protocol;
13155
13156 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13157
13158 if (strncmp(argv[0], "o", 1) == 0)
13159 protocol = ZEBRA_ROUTE_OSPF;
13160 else
13161 protocol = ZEBRA_ROUTE_TABLE;
13162
13163 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13164 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13165 }
13166
13167 DEFUN (bgp_redistribute_ipv4_ospf_rmap,
13168 bgp_redistribute_ipv4_ospf_rmap_cmd,
13169 "redistribute (ospf|table) <1-65535> route-map WORD",
13170 "Redistribute information from another routing protocol\n"
13171 "Open Shortest Path First (OSPFv2)\n"
13172 "Non-main Kernel Routing Table\n"
13173 "Instance ID/Table ID\n"
13174 "Route map reference\n"
13175 "Pointer to route-map entries\n")
13176 {
13177 struct bgp_redist *red;
13178 u_short instance;
13179 int protocol;
13180
13181 if (strncmp(argv[0], "o", 1) == 0)
13182 protocol = ZEBRA_ROUTE_OSPF;
13183 else
13184 protocol = ZEBRA_ROUTE_TABLE;
13185
13186 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13187 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13188 bgp_redistribute_rmap_set (red, argv[2]);
13189 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13190 }
13191
13192 DEFUN (bgp_redistribute_ipv4_ospf_metric,
13193 bgp_redistribute_ipv4_ospf_metric_cmd,
13194 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
13195 "Redistribute information from another routing protocol\n"
13196 "Open Shortest Path First (OSPFv2)\n"
13197 "Non-main Kernel Routing Table\n"
13198 "Instance ID/Table ID\n"
13199 "Metric for redistributed routes\n"
13200 "Default metric\n")
13201 {
13202 u_int32_t metric;
13203 struct bgp_redist *red;
13204 u_short instance;
13205 int protocol;
13206
13207 if (strncmp(argv[0], "o", 1) == 0)
13208 protocol = ZEBRA_ROUTE_OSPF;
13209 else
13210 protocol = ZEBRA_ROUTE_TABLE;
13211
13212 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13213 VTY_GET_INTEGER ("metric", metric, argv[2]);
13214
13215 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13216 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13217 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13218 }
13219
13220 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
13221 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
13222 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
13223 "Redistribute information from another routing protocol\n"
13224 "Open Shortest Path First (OSPFv2)\n"
13225 "Non-main Kernel Routing Table\n"
13226 "Instance ID/Table ID\n"
13227 "Route map reference\n"
13228 "Pointer to route-map entries\n"
13229 "Metric for redistributed routes\n"
13230 "Default metric\n")
13231 {
13232 u_int32_t metric;
13233 struct bgp_redist *red;
13234 u_short instance;
13235 int protocol;
13236
13237 if (strncmp(argv[0], "o", 1) == 0)
13238 protocol = ZEBRA_ROUTE_OSPF;
13239 else
13240 protocol = ZEBRA_ROUTE_TABLE;
13241
13242 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13243 VTY_GET_INTEGER ("metric", metric, argv[3]);
13244
13245 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13246 bgp_redistribute_rmap_set (red, argv[2]);
13247 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13248 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13249 }
13250
13251 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
13252 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
13253 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
13254 "Redistribute information from another routing protocol\n"
13255 "Open Shortest Path First (OSPFv2)\n"
13256 "Non-main Kernel Routing Table\n"
13257 "Instance ID/Table ID\n"
13258 "Metric for redistributed routes\n"
13259 "Default metric\n"
13260 "Route map reference\n"
13261 "Pointer to route-map entries\n")
13262 {
13263 u_int32_t metric;
13264 struct bgp_redist *red;
13265 u_short instance;
13266 int protocol;
13267
13268 if (strncmp(argv[0], "o", 1) == 0)
13269 protocol = ZEBRA_ROUTE_OSPF;
13270 else
13271 protocol = ZEBRA_ROUTE_TABLE;
13272
13273 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13274 VTY_GET_INTEGER ("metric", metric, argv[2]);
13275
13276 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
13277 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
13278 bgp_redistribute_rmap_set (red, argv[3]);
13279 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
13280 }
13281
13282 DEFUN (no_bgp_redistribute_ipv4_ospf,
13283 no_bgp_redistribute_ipv4_ospf_cmd,
13284 "no redistribute (ospf|table) <1-65535>",
13285 NO_STR
13286 "Redistribute information from another routing protocol\n"
13287 "Open Shortest Path First (OSPFv2)\n"
13288 "Non-main Kernel Routing Table\n"
13289 "Instance ID/Table ID\n")
13290 {
13291 u_short instance;
13292 int protocol;
13293
13294 if (strncmp(argv[0], "o", 1) == 0)
13295 protocol = ZEBRA_ROUTE_OSPF;
13296 else
13297 protocol = ZEBRA_ROUTE_TABLE;
13298
13299 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
13300 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
13301 }
13302
13303 ALIAS (no_bgp_redistribute_ipv4_ospf,
13304 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
13305 "no redistribute (ospf|table) <1-65535> route-map WORD",
13306 NO_STR
13307 "Redistribute information from another routing protocol\n"
13308 "Open Shortest Path First (OSPFv2)\n"
13309 "Non-main Kernel Routing Table\n"
13310 "Instance ID/Table ID\n"
13311 "Route map reference\n"
13312 "Pointer to route-map entries\n")
13313
13314 ALIAS (no_bgp_redistribute_ipv4_ospf,
13315 no_bgp_redistribute_ipv4_ospf_metric_cmd,
13316 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
13317 NO_STR
13318 "Redistribute information from another routing protocol\n"
13319 "Open Shortest Path First (OSPFv2)\n"
13320 "Non-main Kernel Routing Table\n"
13321 "Instance ID/Table ID\n"
13322 "Metric for redistributed routes\n"
13323 "Default metric\n")
13324
13325 ALIAS (no_bgp_redistribute_ipv4_ospf,
13326 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
13327 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
13328 NO_STR
13329 "Redistribute information from another routing protocol\n"
13330 "Open Shortest Path First (OSPFv2)\n"
13331 "Non-main Kernel Routing Table\n"
13332 "Instance ID/Table ID\n"
13333 "Route map reference\n"
13334 "Pointer to route-map entries\n"
13335 "Metric for redistributed routes\n"
13336 "Default metric\n")
13337
13338 ALIAS (no_bgp_redistribute_ipv4_ospf,
13339 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
13340 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
13341 NO_STR
13342 "Redistribute information from another routing protocol\n"
13343 "Open Shortest Path First (OSPFv2)\n"
13344 "Non-main Kernel Routing Table\n"
13345 "Instance ID/Table ID\n"
13346 "Metric for redistributed routes\n"
13347 "Default metric\n"
13348 "Route map reference\n"
13349 "Pointer to route-map entries\n")
13350
13351 DEFUN (no_bgp_redistribute_ipv4,
13352 no_bgp_redistribute_ipv4_cmd,
13353 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
13354 NO_STR
13355 "Redistribute information from another routing protocol\n"
13356 QUAGGA_IP_REDIST_HELP_STR_BGPD)
13357 {
13358 int type;
13359
13360 type = proto_redistnum (AFI_IP, argv[0]);
13361 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13362 {
13363 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13364 return CMD_WARNING;
13365 }
13366 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
13367 }
13368
13369 ALIAS (no_bgp_redistribute_ipv4,
13370 no_bgp_redistribute_ipv4_rmap_cmd,
13371 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
13372 NO_STR
13373 "Redistribute information from another routing protocol\n"
13374 QUAGGA_IP_REDIST_HELP_STR_BGPD
13375 "Route map reference\n"
13376 "Pointer to route-map entries\n")
13377
13378 ALIAS (no_bgp_redistribute_ipv4,
13379 no_bgp_redistribute_ipv4_metric_cmd,
13380 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
13381 NO_STR
13382 "Redistribute information from another routing protocol\n"
13383 QUAGGA_IP_REDIST_HELP_STR_BGPD
13384 "Metric for redistributed routes\n"
13385 "Default metric\n")
13386
13387 ALIAS (no_bgp_redistribute_ipv4,
13388 no_bgp_redistribute_ipv4_rmap_metric_cmd,
13389 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13390 NO_STR
13391 "Redistribute information from another routing protocol\n"
13392 QUAGGA_IP_REDIST_HELP_STR_BGPD
13393 "Route map reference\n"
13394 "Pointer to route-map entries\n"
13395 "Metric for redistributed routes\n"
13396 "Default metric\n")
13397
13398 ALIAS (no_bgp_redistribute_ipv4,
13399 no_bgp_redistribute_ipv4_metric_rmap_cmd,
13400 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13401 NO_STR
13402 "Redistribute information from another routing protocol\n"
13403 QUAGGA_IP_REDIST_HELP_STR_BGPD
13404 "Metric for redistributed routes\n"
13405 "Default metric\n"
13406 "Route map reference\n"
13407 "Pointer to route-map entries\n")
13408
13409 #ifdef HAVE_IPV6
13410 DEFUN (bgp_redistribute_ipv6,
13411 bgp_redistribute_ipv6_cmd,
13412 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
13413 "Redistribute information from another routing protocol\n"
13414 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
13415 {
13416 int type;
13417
13418 type = proto_redistnum (AFI_IP6, argv[0]);
13419 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13420 {
13421 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13422 return CMD_WARNING;
13423 }
13424
13425 bgp_redist_add(vty->index, AFI_IP6, type, 0);
13426 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13427 }
13428
13429 DEFUN (bgp_redistribute_ipv6_rmap,
13430 bgp_redistribute_ipv6_rmap_cmd,
13431 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
13432 "Redistribute information from another routing protocol\n"
13433 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13434 "Route map reference\n"
13435 "Pointer to route-map entries\n")
13436 {
13437 int type;
13438 struct bgp_redist *red;
13439
13440 type = proto_redistnum (AFI_IP6, argv[0]);
13441 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13442 {
13443 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13444 return CMD_WARNING;
13445 }
13446
13447 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13448 bgp_redistribute_rmap_set (red, argv[1]);
13449 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13450 }
13451
13452 DEFUN (bgp_redistribute_ipv6_metric,
13453 bgp_redistribute_ipv6_metric_cmd,
13454 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
13455 "Redistribute information from another routing protocol\n"
13456 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13457 "Metric for redistributed routes\n"
13458 "Default metric\n")
13459 {
13460 int type;
13461 u_int32_t metric;
13462 struct bgp_redist *red;
13463
13464 type = proto_redistnum (AFI_IP6, argv[0]);
13465 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13466 {
13467 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13468 return CMD_WARNING;
13469 }
13470 VTY_GET_INTEGER ("metric", metric, argv[1]);
13471
13472 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13473 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
13474 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13475 }
13476
13477 DEFUN (bgp_redistribute_ipv6_rmap_metric,
13478 bgp_redistribute_ipv6_rmap_metric_cmd,
13479 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13480 "Redistribute information from another routing protocol\n"
13481 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13482 "Route map reference\n"
13483 "Pointer to route-map entries\n"
13484 "Metric for redistributed routes\n"
13485 "Default metric\n")
13486 {
13487 int type;
13488 u_int32_t metric;
13489 struct bgp_redist *red;
13490
13491 type = proto_redistnum (AFI_IP6, argv[0]);
13492 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13493 {
13494 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13495 return CMD_WARNING;
13496 }
13497 VTY_GET_INTEGER ("metric", metric, argv[2]);
13498
13499 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13500 bgp_redistribute_rmap_set (red, argv[1]);
13501 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
13502 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13503 }
13504
13505 DEFUN (bgp_redistribute_ipv6_metric_rmap,
13506 bgp_redistribute_ipv6_metric_rmap_cmd,
13507 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13508 "Redistribute information from another routing protocol\n"
13509 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13510 "Metric for redistributed routes\n"
13511 "Default metric\n"
13512 "Route map reference\n"
13513 "Pointer to route-map entries\n")
13514 {
13515 int type;
13516 u_int32_t metric;
13517 struct bgp_redist *red;
13518
13519 type = proto_redistnum (AFI_IP6, argv[0]);
13520 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13521 {
13522 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13523 return CMD_WARNING;
13524 }
13525 VTY_GET_INTEGER ("metric", metric, argv[1]);
13526
13527 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
13528 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
13529 bgp_redistribute_rmap_set (red, argv[2]);
13530 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
13531 }
13532
13533 DEFUN (no_bgp_redistribute_ipv6,
13534 no_bgp_redistribute_ipv6_cmd,
13535 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
13536 NO_STR
13537 "Redistribute information from another routing protocol\n"
13538 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
13539 {
13540 int type;
13541
13542 type = proto_redistnum (AFI_IP6, argv[0]);
13543 if (type < 0 || type == ZEBRA_ROUTE_BGP)
13544 {
13545 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
13546 return CMD_WARNING;
13547 }
13548
13549 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
13550 }
13551
13552 ALIAS (no_bgp_redistribute_ipv6,
13553 no_bgp_redistribute_ipv6_rmap_cmd,
13554 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
13555 NO_STR
13556 "Redistribute information from another routing protocol\n"
13557 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13558 "Route map reference\n"
13559 "Pointer to route-map entries\n")
13560
13561 ALIAS (no_bgp_redistribute_ipv6,
13562 no_bgp_redistribute_ipv6_metric_cmd,
13563 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
13564 NO_STR
13565 "Redistribute information from another routing protocol\n"
13566 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13567 "Metric for redistributed routes\n"
13568 "Default metric\n")
13569
13570 ALIAS (no_bgp_redistribute_ipv6,
13571 no_bgp_redistribute_ipv6_rmap_metric_cmd,
13572 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
13573 NO_STR
13574 "Redistribute information from another routing protocol\n"
13575 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13576 "Route map reference\n"
13577 "Pointer to route-map entries\n"
13578 "Metric for redistributed routes\n"
13579 "Default metric\n")
13580
13581 ALIAS (no_bgp_redistribute_ipv6,
13582 no_bgp_redistribute_ipv6_metric_rmap_cmd,
13583 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
13584 NO_STR
13585 "Redistribute information from another routing protocol\n"
13586 QUAGGA_IP6_REDIST_HELP_STR_BGPD
13587 "Metric for redistributed routes\n"
13588 "Default metric\n"
13589 "Route map reference\n"
13590 "Pointer to route-map entries\n")
13591 #endif /* HAVE_IPV6 */
13592
13593 int
13594 bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
13595 safi_t safi, int *write)
13596 {
13597 int i;
13598
13599 /* Unicast redistribution only. */
13600 if (safi != SAFI_UNICAST)
13601 return 0;
13602
13603 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
13604 {
13605 /* Redistribute BGP does not make sense. */
13606 if (i != ZEBRA_ROUTE_BGP)
13607 {
13608 struct list *red_list;
13609 struct listnode *node;
13610 struct bgp_redist *red;
13611
13612 red_list = bgp->redist[afi][i];
13613 if (!red_list)
13614 continue;
13615
13616 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
13617 {
13618 /* Display "address-family" when it is not yet diplayed. */
13619 bgp_config_write_family_header (vty, afi, safi, write);
13620
13621 /* "redistribute" configuration. */
13622 vty_out (vty, " redistribute %s", zebra_route_string(i));
13623 if (red->instance)
13624 vty_out (vty, " %d", red->instance);
13625 if (red->redist_metric_flag)
13626 vty_out (vty, " metric %u", red->redist_metric);
13627 if (red->rmap.name)
13628 vty_out (vty, " route-map %s", red->rmap.name);
13629 vty_out (vty, "%s", VTY_NEWLINE);
13630 }
13631 }
13632 }
13633 return *write;
13634 }
13635
13636 /* BGP node structure. */
13637 static struct cmd_node bgp_node =
13638 {
13639 BGP_NODE,
13640 "%s(config-router)# ",
13641 1,
13642 };
13643
13644 static struct cmd_node bgp_ipv4_unicast_node =
13645 {
13646 BGP_IPV4_NODE,
13647 "%s(config-router-af)# ",
13648 1,
13649 };
13650
13651 static struct cmd_node bgp_ipv4_multicast_node =
13652 {
13653 BGP_IPV4M_NODE,
13654 "%s(config-router-af)# ",
13655 1,
13656 };
13657
13658 static struct cmd_node bgp_ipv6_unicast_node =
13659 {
13660 BGP_IPV6_NODE,
13661 "%s(config-router-af)# ",
13662 1,
13663 };
13664
13665 static struct cmd_node bgp_ipv6_multicast_node =
13666 {
13667 BGP_IPV6M_NODE,
13668 "%s(config-router-af)# ",
13669 1,
13670 };
13671
13672 static struct cmd_node bgp_vpnv4_node =
13673 {
13674 BGP_VPNV4_NODE,
13675 "%s(config-router-af)# ",
13676 1
13677 };
13678
13679 static void community_list_vty (void);
13680
13681 void
13682 bgp_vty_init (void)
13683 {
13684 /* Install bgp top node. */
13685 install_node (&bgp_node, bgp_config_write);
13686 install_node (&bgp_ipv4_unicast_node, NULL);
13687 install_node (&bgp_ipv4_multicast_node, NULL);
13688 install_node (&bgp_ipv6_unicast_node, NULL);
13689 install_node (&bgp_ipv6_multicast_node, NULL);
13690 install_node (&bgp_vpnv4_node, NULL);
13691
13692 /* Install default VTY commands to new nodes. */
13693 install_default (BGP_NODE);
13694 install_default (BGP_IPV4_NODE);
13695 install_default (BGP_IPV4M_NODE);
13696 install_default (BGP_IPV6_NODE);
13697 install_default (BGP_IPV6M_NODE);
13698 install_default (BGP_VPNV4_NODE);
13699
13700 /* "bgp multiple-instance" commands. */
13701 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
13702 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
13703
13704 /* "bgp config-type" commands. */
13705 install_element (CONFIG_NODE, &bgp_config_type_cmd);
13706 install_element (CONFIG_NODE, &no_bgp_config_type_val_cmd);
13707
13708 /* bgp route-map delay-timer commands. */
13709 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
13710 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
13711 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
13712
13713 /* Dummy commands (Currently not supported) */
13714 install_element (BGP_NODE, &no_synchronization_cmd);
13715 install_element (BGP_NODE, &no_auto_summary_cmd);
13716
13717 /* "router bgp" commands. */
13718 install_element (CONFIG_NODE, &router_bgp_cmd);
13719 install_element (CONFIG_NODE, &router_bgp_instance_cmd);
13720 install_element (CONFIG_NODE, &router_bgp_noasn_cmd);
13721
13722 /* "no router bgp" commands. */
13723 install_element (CONFIG_NODE, &no_router_bgp_cmd);
13724 install_element (CONFIG_NODE, &no_router_bgp_instance_cmd);
13725
13726 /* "bgp router-id" commands. */
13727 install_element (BGP_NODE, &bgp_router_id_cmd);
13728 install_element (BGP_NODE, &no_bgp_router_id_cmd);
13729 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
13730
13731 /* "bgp cluster-id" commands. */
13732 install_element (BGP_NODE, &bgp_cluster_id_cmd);
13733 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
13734 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
13735 install_element (BGP_NODE, &no_bgp_cluster_id_ip_cmd);
13736 install_element (BGP_NODE, &no_bgp_cluster_id_decimal_cmd);
13737
13738 /* "bgp confederation" commands. */
13739 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
13740 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
13741 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
13742
13743 /* "bgp confederation peers" commands. */
13744 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
13745 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
13746
13747 /* bgp max-med command */
13748 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
13749 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
13750 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
13751 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
13752 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
13753 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
13754 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
13755 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
13756 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
13757
13758 /* bgp disable-ebgp-connected-nh-check */
13759 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
13760 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
13761
13762 /* bgp update-delay command */
13763 install_element (BGP_NODE, &bgp_update_delay_cmd);
13764 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
13765 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
13766 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
13767
13768 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
13769 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
13770
13771 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
13772 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
13773
13774 /* "maximum-paths" commands. */
13775 install_element (BGP_NODE, &bgp_maxpaths_cmd);
13776 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
13777 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
13778 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
13779 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
13780 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
13781 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
13782 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
13783 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
13784 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
13785 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
13786 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
13787 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
13788 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
13789 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
13790 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
13791 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
13792 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
13793 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
13794 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
13795 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
13796 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
13797 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
13798 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
13799
13800 /* "timers bgp" commands. */
13801 install_element (BGP_NODE, &bgp_timers_cmd);
13802 install_element (BGP_NODE, &no_bgp_timers_cmd);
13803 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
13804
13805 /* route-map delay-timer commands - per instance for backwards compat. */
13806 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
13807 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
13808 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
13809
13810 /* "bgp client-to-client reflection" commands */
13811 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
13812 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
13813
13814 /* "bgp always-compare-med" commands */
13815 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
13816 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
13817
13818 /* "bgp deterministic-med" commands */
13819 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
13820 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
13821
13822 /* "bgp graceful-restart" commands */
13823 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
13824 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
13825 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
13826 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
13827 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
13828
13829 /* "bgp fast-external-failover" commands */
13830 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
13831 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
13832
13833 /* "bgp enforce-first-as" commands */
13834 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
13835 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
13836
13837 /* "bgp bestpath compare-routerid" commands */
13838 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
13839 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
13840
13841 /* "bgp bestpath as-path ignore" commands */
13842 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
13843 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
13844
13845 /* "bgp bestpath as-path confed" commands */
13846 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
13847 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
13848
13849 /* "bgp bestpath as-path multipath-relax" commands */
13850 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
13851 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
13852
13853 /* "bgp log-neighbor-changes" commands */
13854 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
13855 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
13856
13857 /* "bgp bestpath med" commands */
13858 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
13859 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
13860 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
13861 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
13862 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
13863 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
13864
13865 /* "no bgp default ipv4-unicast" commands. */
13866 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
13867 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
13868
13869 /* "bgp network import-check" commands. */
13870 install_element (BGP_NODE, &bgp_network_import_check_cmd);
13871 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
13872
13873 /* "bgp default local-preference" commands. */
13874 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
13875 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
13876 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
13877
13878 /* bgp default show-hostname */
13879 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
13880 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
13881
13882 /* "bgp default subgroup-pkt-queue-max" commands. */
13883 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
13884 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
13885 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_val_cmd);
13886
13887 /* bgp ibgp-allow-policy-mods command */
13888 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
13889 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
13890
13891 /* "bgp listen limit" commands. */
13892 install_element (BGP_NODE, &bgp_listen_limit_cmd);
13893 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
13894 install_element (BGP_NODE, &no_bgp_listen_limit_val_cmd);
13895
13896 /* "bgp listen range" commands. */
13897 install_element (BGP_NODE, &bgp_listen_range_cmd);
13898 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
13899
13900 /* "neighbor remote-as" commands. */
13901 install_element (BGP_NODE, &neighbor_remote_as_cmd);
13902 install_element (BGP_NODE, &neighbor_interface_config_cmd);
13903 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
13904 install_element (BGP_NODE, &neighbor_interface_config_peergroup_cmd);
13905 install_element (BGP_NODE, &neighbor_interface_config_v6only_peergroup_cmd);
13906 install_element (BGP_NODE, &no_neighbor_cmd);
13907 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
13908 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
13909 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_cmd);
13910 install_element (BGP_NODE, &no_neighbor_interface_config_peergroup_cmd);
13911 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_peergroup_cmd);
13912
13913 /* "neighbor peer-group" commands. */
13914 install_element (BGP_NODE, &neighbor_peer_group_cmd);
13915 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
13916 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
13917
13918 /* "neighbor local-as" commands. */
13919 install_element (BGP_NODE, &neighbor_local_as_cmd);
13920 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
13921 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
13922 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
13923 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
13924 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
13925 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
13926
13927 /* "neighbor solo" commands. */
13928 install_element (BGP_NODE, &neighbor_solo_cmd);
13929 install_element (BGP_NODE, &no_neighbor_solo_cmd);
13930
13931 /* "neighbor password" commands. */
13932 install_element (BGP_NODE, &neighbor_password_cmd);
13933 install_element (BGP_NODE, &no_neighbor_password_cmd);
13934 install_element (BGP_NODE, &no_neighbor_password_val_cmd);
13935
13936 /* "neighbor activate" commands. */
13937 install_element (BGP_NODE, &neighbor_activate_cmd);
13938 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
13939 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
13940 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
13941 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
13942 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
13943
13944 /* "no neighbor activate" commands. */
13945 install_element (BGP_NODE, &no_neighbor_activate_cmd);
13946 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
13947 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
13948 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
13949 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
13950 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
13951
13952 /* "neighbor peer-group" set commands.
13953 * Long term we should only accept this command under BGP_NODE and not all of
13954 * the afi/safi sub-contexts. For now though we need to accept it for backwards
13955 * compatibility. This changed when we stopped requiring that peers be assigned
13956 * to their peer-group under each address-family sub-context.
13957 */
13958 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
13959 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
13960 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
13961 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
13962 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
13963 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
13964
13965 /* "no neighbor peer-group unset" commands. */
13966 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
13967 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
13968 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
13969 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
13970 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
13971 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
13972
13973 /* "neighbor softreconfiguration inbound" commands.*/
13974 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
13975 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
13976 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
13977 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
13978 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
13979 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
13980 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
13981 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
13982 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
13983 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
13984 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
13985 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
13986
13987 /* "neighbor attribute-unchanged" commands. */
13988 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
13989 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
13990 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
13991 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
13992 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
13993 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
13994 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
13995 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
13996 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
13997 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
13998 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
13999 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
14000 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
14001 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
14002 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
14003 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
14004 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
14005 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
14006 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
14007 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
14008 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
14009 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
14010 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
14011 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
14012 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
14013 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
14014 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
14015 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
14016 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
14017 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
14018 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
14019 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
14020 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
14021 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
14022 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14023 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14024 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14025 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14026 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14027 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14028 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14029 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14030 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14031 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14032 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
14033 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
14034 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
14035 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
14036 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
14037 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
14038 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
14039 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
14040 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
14041 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
14042 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
14043 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
14044 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
14045 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
14046 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
14047 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
14048 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
14049 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
14050 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
14051 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
14052 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
14053 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
14054 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
14055 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
14056 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
14057 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
14058 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
14059 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
14060 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
14061 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
14062 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
14063 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
14064 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
14065 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
14066 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
14067 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
14068 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
14069 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
14070 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
14071 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
14072 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
14073 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
14074 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
14075 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
14076 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
14077 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
14078 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
14079 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
14080 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
14081 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
14082 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
14083 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
14084 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
14085 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
14086 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
14087 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
14088 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
14089 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
14090 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
14091 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
14092 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
14093 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
14094 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
14095 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
14096 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
14097 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
14098 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
14099 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
14100 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
14101 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
14102 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
14103 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
14104 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
14105 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
14106 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
14107 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
14108 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
14109 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
14110 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
14111 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
14112 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
14113 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
14114 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
14115 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
14116 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
14117 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
14118 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
14119 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
14120
14121 /* "nexthop-local unchanged" commands */
14122 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
14123 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
14124
14125 /* "neighbor next-hop-self" commands. */
14126 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
14127 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
14128 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
14129 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
14130 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
14131 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
14132 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
14133 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
14134 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
14135 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
14136 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
14137 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
14138
14139 /* "neighbor next-hop-self force" commands. */
14140 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
14141 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
14142 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
14143 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14144 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
14145 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
14146 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
14147 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
14148 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
14149 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
14150 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
14151 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
14152
14153 /* "neighbor as-override" commands. */
14154 install_element (BGP_NODE, &neighbor_as_override_cmd);
14155 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
14156 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
14157 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
14158 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
14159 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
14160 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
14161 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
14162 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
14163 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
14164 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
14165 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
14166
14167 /* "neighbor remove-private-AS" commands. */
14168 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
14169 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
14170 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
14171 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
14172 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
14173 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14174 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14175 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14176 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
14177 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
14178 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
14179 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14180 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14181 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14182 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14183 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14184 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
14185 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
14186 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
14187 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
14188 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14189 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14190 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14191 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14192 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
14193 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
14194 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
14195 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
14196 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
14197 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14198 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14199 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14200 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
14201 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
14202 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
14203 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
14204 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
14205 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14206 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14207 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14208 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
14209 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
14210 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
14211 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
14212 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
14213 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
14214 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
14215 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
14216
14217 /* "neighbor send-community" commands.*/
14218 install_element (BGP_NODE, &neighbor_send_community_cmd);
14219 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
14220 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
14221 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
14222 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
14223 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
14224 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
14225 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
14226 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
14227 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
14228 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
14229 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
14230 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
14231 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
14232 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
14233 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
14234 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
14235 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
14236 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
14237 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
14238 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
14239 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
14240 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
14241 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
14242
14243 /* "neighbor route-reflector" commands.*/
14244 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
14245 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
14246 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
14247 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
14248 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
14249 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
14250 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
14251 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
14252 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
14253 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
14254 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
14255 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
14256
14257 /* "neighbor route-server" commands.*/
14258 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
14259 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
14260 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
14261 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
14262 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
14263 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
14264 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
14265 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
14266 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
14267 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
14268 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
14269 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
14270
14271 /* "neighbor addpath-tx-all-paths" commands.*/
14272 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
14273 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14274 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14275 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14276 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14277 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14278 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
14279 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14280 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
14281 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14282 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
14283 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
14284
14285 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
14286 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14287 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14288 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14289 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14290 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14291 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14292 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14293 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14294 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14295 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14296 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
14297 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
14298
14299 /* "neighbor passive" commands. */
14300 install_element (BGP_NODE, &neighbor_passive_cmd);
14301 install_element (BGP_NODE, &no_neighbor_passive_cmd);
14302
14303
14304 /* "neighbor shutdown" commands. */
14305 install_element (BGP_NODE, &neighbor_shutdown_cmd);
14306 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
14307
14308 /* "neighbor capability extended-nexthop" commands.*/
14309 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
14310 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
14311
14312 /* "neighbor capability orf prefix-list" commands.*/
14313 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
14314 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
14315 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
14316 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
14317 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
14318 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14319 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
14320 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
14321 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
14322 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
14323
14324 /* "neighbor capability dynamic" commands.*/
14325 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
14326 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
14327
14328 /* "neighbor dont-capability-negotiate" commands. */
14329 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
14330 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
14331
14332 /* "neighbor ebgp-multihop" commands. */
14333 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
14334 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
14335 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
14336 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
14337
14338 /* "neighbor disable-connected-check" commands. */
14339 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
14340 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
14341 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
14342 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
14343
14344 /* "neighbor description" commands. */
14345 install_element (BGP_NODE, &neighbor_description_cmd);
14346 install_element (BGP_NODE, &no_neighbor_description_cmd);
14347 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
14348
14349 /* "neighbor update-source" commands. "*/
14350 install_element (BGP_NODE, &neighbor_update_source_cmd);
14351 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
14352
14353 /* "neighbor default-originate" commands. */
14354 install_element (BGP_NODE, &neighbor_default_originate_cmd);
14355 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
14356 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
14357 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
14358 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
14359 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
14360 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
14361 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
14362 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
14363 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
14364 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
14365 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
14366 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
14367 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
14368 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
14369 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
14370 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
14371 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
14372 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
14373 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
14374
14375 /* "neighbor port" commands. */
14376 install_element (BGP_NODE, &neighbor_port_cmd);
14377 install_element (BGP_NODE, &no_neighbor_port_cmd);
14378 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
14379
14380 /* "neighbor weight" commands. */
14381 install_element (BGP_NODE, &neighbor_weight_cmd);
14382 install_element (BGP_NODE, &no_neighbor_weight_cmd);
14383 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
14384
14385 /* "neighbor override-capability" commands. */
14386 install_element (BGP_NODE, &neighbor_override_capability_cmd);
14387 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
14388
14389 /* "neighbor strict-capability-match" commands. */
14390 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
14391 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
14392
14393 /* "neighbor timers" commands. */
14394 install_element (BGP_NODE, &neighbor_timers_cmd);
14395 install_element (BGP_NODE, &no_neighbor_timers_cmd);
14396 install_element (BGP_NODE, &no_neighbor_timers_val_cmd);
14397
14398 /* "neighbor timers connect" commands. */
14399 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
14400 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
14401 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
14402
14403 /* "neighbor advertisement-interval" commands. */
14404 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
14405 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
14406 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
14407
14408 /* "neighbor interface" commands. */
14409 install_element (BGP_NODE, &neighbor_interface_cmd);
14410 install_element (BGP_NODE, &no_neighbor_interface_cmd);
14411
14412 /* "neighbor distribute" commands. */
14413 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
14414 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
14415 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
14416 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
14417 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
14418 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
14419 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
14420 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
14421 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
14422 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
14423 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
14424 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
14425
14426 /* "neighbor prefix-list" commands. */
14427 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
14428 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
14429 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
14430 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
14431 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
14432 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
14433 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
14434 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
14435 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
14436 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
14437 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
14438 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
14439
14440 /* "neighbor filter-list" commands. */
14441 install_element (BGP_NODE, &neighbor_filter_list_cmd);
14442 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
14443 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
14444 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
14445 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
14446 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
14447 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
14448 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
14449 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
14450 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
14451 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
14452 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
14453
14454 /* "neighbor route-map" commands. */
14455 install_element (BGP_NODE, &neighbor_route_map_cmd);
14456 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
14457 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
14458 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
14459 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
14460 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
14461 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
14462 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
14463 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
14464 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
14465 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
14466 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
14467
14468 /* "neighbor unsuppress-map" commands. */
14469 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
14470 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
14471 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
14472 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
14473 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
14474 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
14475 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
14476 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
14477 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
14478 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
14479 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
14480 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
14481
14482 /* "neighbor maximum-prefix" commands. */
14483 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
14484 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
14485 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
14486 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14487 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
14488 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14489 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
14490 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
14491 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14492 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14493 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14494 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14495 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14496 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
14497 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
14498 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
14499 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14500 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14501 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14502 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
14503 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
14504 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14505 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14506 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14507 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14508 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14509 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
14510 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
14511 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
14512 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14513 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
14514 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14515 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
14516 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
14517 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14518 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14519 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14520 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14521 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14522 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
14523 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
14524 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
14525 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14526 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
14527 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14528 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
14529 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
14530 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14531 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14532 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14533 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14534 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14535 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
14536 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
14537 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
14538 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14539 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
14540 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14541 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
14542 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
14543 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14544 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14545 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14546 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14547 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14548 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
14549 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
14550 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
14551 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
14552 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
14553 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
14554 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
14555 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
14556 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
14557 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
14558 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
14559 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
14560 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
14561
14562 /* "neighbor allowas-in" */
14563 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
14564 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
14565 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
14566 install_element (BGP_NODE, &no_neighbor_allowas_in_val_cmd);
14567 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
14568 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
14569 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
14570 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_val_cmd);
14571 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
14572 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
14573 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
14574 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_val_cmd);
14575 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
14576 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
14577 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
14578 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_val_cmd);
14579 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
14580 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
14581 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
14582 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_val_cmd);
14583 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
14584 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
14585 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
14586 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_val_cmd);
14587
14588 /* address-family commands. */
14589 install_element (BGP_NODE, &address_family_ipv4_cmd);
14590 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
14591 #ifdef HAVE_IPV6
14592 install_element (BGP_NODE, &address_family_ipv6_cmd);
14593 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
14594 #endif /* HAVE_IPV6 */
14595 install_element (BGP_NODE, &address_family_vpnv4_cmd);
14596 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
14597
14598 /* "exit-address-family" command. */
14599 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
14600 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
14601 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
14602 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
14603 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
14604
14605 /* "clear ip bgp commands" */
14606 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
14607 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
14608 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
14609 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_cmd);
14610 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
14611 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_cmd);
14612 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
14613 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_cmd);
14614 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
14615 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_cmd);
14616
14617 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
14618 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
14619 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
14620 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_cmd);
14621 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
14622 install_element (ENABLE_NODE, &clear_bgp_instance_peer_cmd);
14623 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
14624 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_cmd);
14625 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
14626 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_cmd);
14627 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
14628 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_cmd);
14629 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
14630 install_element (ENABLE_NODE, &clear_bgp_instance_external_cmd);
14631 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
14632 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_cmd);
14633 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
14634 install_element (ENABLE_NODE, &clear_bgp_instance_as_cmd);
14635 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
14636 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_cmd);
14637
14638 /* "clear ip bgp neighbor soft in" */
14639 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
14640 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
14641 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
14642 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_cmd);
14643 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
14644 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
14645 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_in_cmd);
14646 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
14647 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_in_cmd);
14648 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
14649 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
14650 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_in_cmd);
14651 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
14652 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_in_cmd);
14653 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
14654 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
14655 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_in_cmd);
14656 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
14657 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_in_cmd);
14658 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
14659 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
14660 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_in_cmd);
14661 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
14662 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_in_cmd);
14663 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
14664 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
14665 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
14666 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
14667 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_cmd);
14668 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
14669 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
14670 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_in_cmd);
14671 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
14672 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_in_cmd);
14673 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
14674 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
14675 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd);
14676 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
14677 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_in_cmd);
14678 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
14679 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
14680 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_in_cmd);
14681 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
14682 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_in_cmd);
14683 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
14684 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
14685 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_in_cmd);
14686 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
14687 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd);
14688 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
14689 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
14690 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
14691 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
14692 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
14693 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
14694 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
14695
14696 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
14697 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
14698 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
14699 install_element (ENABLE_NODE, &clear_bgp_instance_all_in_cmd);
14700 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
14701 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
14702 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_in_cmd);
14703 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
14704 install_element (ENABLE_NODE, &clear_bgp_instance_peer_in_cmd);
14705 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
14706 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
14707 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_in_cmd);
14708 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
14709 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_in_cmd);
14710 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
14711 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
14712 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_in_cmd);
14713 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
14714 install_element (ENABLE_NODE, &clear_bgp_instance_external_in_cmd);
14715 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
14716 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
14717 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_in_cmd);
14718 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
14719 install_element (ENABLE_NODE, &clear_bgp_instance_as_in_cmd);
14720 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
14721 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
14722 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_in_cmd);
14723 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
14724 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_in_cmd);
14725 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
14726 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
14727 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_in_cmd);
14728 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
14729 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_in_cmd);
14730 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
14731 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
14732 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_in_cmd);
14733 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
14734 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_in_cmd);
14735 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
14736 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
14737 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_in_cmd);
14738 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
14739 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_in_cmd);
14740 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
14741 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
14742 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_in_cmd);
14743 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
14744 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_in_cmd);
14745 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
14746
14747 /* clear ip bgp prefix */
14748 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
14749 install_element (ENABLE_NODE, &clear_ip_bgp_instance_prefix_cmd);
14750 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
14751 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
14752
14753 /* "clear ip bgp neighbor soft out" */
14754 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
14755 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
14756 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
14757 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_out_cmd);
14758 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
14759 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_out_cmd);
14760 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
14761 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_out_cmd);
14762 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
14763 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_out_cmd);
14764 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
14765 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_out_cmd);
14766 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
14767 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_out_cmd);
14768 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
14769 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_out_cmd);
14770 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
14771 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_out_cmd);
14772 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
14773 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_out_cmd);
14774 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
14775 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
14776 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
14777 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_out_cmd);
14778 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
14779 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_out_cmd);
14780 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
14781 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_out_cmd);
14782 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
14783 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd);
14784 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
14785 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_out_cmd);
14786 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
14787 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_out_cmd);
14788 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
14789 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_out_cmd);
14790 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
14791 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd);
14792 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
14793 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd);
14794 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
14795 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
14796 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
14797 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
14798 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
14799 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
14800
14801 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
14802 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
14803 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
14804 install_element (ENABLE_NODE, &clear_bgp_instance_all_out_cmd);
14805 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
14806 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_out_cmd);
14807 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
14808 install_element (ENABLE_NODE, &clear_bgp_instance_peer_out_cmd);
14809 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
14810 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_out_cmd);
14811 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
14812 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_out_cmd);
14813 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
14814 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_out_cmd);
14815 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
14816 install_element (ENABLE_NODE, &clear_bgp_instance_external_out_cmd);
14817 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
14818 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_out_cmd);
14819 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
14820 install_element (ENABLE_NODE, &clear_bgp_instance_as_out_cmd);
14821 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
14822 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_out_cmd);
14823 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
14824 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_out_cmd);
14825 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
14826 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_out_cmd);
14827 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
14828 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_out_cmd);
14829 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
14830 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_out_cmd);
14831 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
14832 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_out_cmd);
14833 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
14834 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_out_cmd);
14835 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
14836 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_out_cmd);
14837 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
14838 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_out_cmd);
14839 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
14840 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_out_cmd);
14841
14842 /* "clear ip bgp neighbor soft" */
14843 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
14844 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
14845 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
14846 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_soft_cmd);
14847 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
14848 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_soft_cmd);
14849 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
14850 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_soft_cmd);
14851 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
14852 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_soft_cmd);
14853 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
14854 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
14855 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
14856 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_ipv4_soft_cmd);
14857 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
14858 install_element (ENABLE_NODE, &clear_ip_bgp_instance_peer_group_ipv4_soft_cmd);
14859 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
14860 install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd);
14861 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
14862 install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd);
14863 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
14864 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
14865 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
14866
14867 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
14868 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
14869 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
14870 install_element (ENABLE_NODE, &clear_bgp_instance_peer_soft_cmd);
14871 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
14872 install_element (ENABLE_NODE, &clear_bgp_instance_peer_group_soft_cmd);
14873 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
14874 install_element (ENABLE_NODE, &clear_bgp_instance_external_soft_cmd);
14875 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
14876 install_element (ENABLE_NODE, &clear_bgp_instance_as_soft_cmd);
14877 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
14878 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_all_soft_cmd);
14879 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
14880 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_soft_cmd);
14881 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
14882 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_peer_group_soft_cmd);
14883 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
14884 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_external_soft_cmd);
14885 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
14886 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_as_soft_cmd);
14887
14888 /* "show ip bgp summary" commands. */
14889 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
14890 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
14891 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
14892 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
14893 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
14894 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
14895 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
14896 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
14897 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
14898 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
14899 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
14900 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
14901 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
14902 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
14903 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
14904 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
14905 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
14906 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
14907 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
14908 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
14909 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
14910 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
14911 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
14912 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
14913 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14914 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
14915 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14916 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14917 #ifdef HAVE_IPV6
14918 install_element (VIEW_NODE, &show_bgp_summary_cmd);
14919 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
14920 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
14921 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
14922 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
14923 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
14924 #endif /* HAVE_IPV6 */
14925 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
14926 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
14927 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd);
14928 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
14929 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
14930 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
14931 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
14932 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
14933 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
14934 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
14935 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
14936 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
14937 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
14938 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
14939 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_cmd);
14940 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
14941 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
14942 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
14943 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
14944 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
14945 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
14946 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
14947 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
14948 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
14949 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14950 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
14951 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14952 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14953 #ifdef HAVE_IPV6
14954 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
14955 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
14956 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
14957 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
14958 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
14959 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
14960 #endif /* HAVE_IPV6 */
14961 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
14962 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
14963 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd);
14964 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
14965 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
14966 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
14967 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
14968 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
14969 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
14970 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
14971 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
14972 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
14973 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
14974 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
14975 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_cmd);
14976 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
14977 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
14978 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
14979 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
14980 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
14981 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
14982 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
14983 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
14984 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
14985 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
14986 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
14987 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
14988 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
14989 #ifdef HAVE_IPV6
14990 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
14991 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
14992 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
14993 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
14994 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
14995 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
14996 #endif /* HAVE_IPV6 */
14997
14998 /* "show ip bgp neighbors" commands. */
14999 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
15000 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
15001 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
15002 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15003 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
15004 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
15005 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15006 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15007 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
15008 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
15009 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
15010 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15011 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15012 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15013 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
15014 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
15015 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
15016 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
15017 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
15018 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
15019 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
15020 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
15021 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
15022 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
15023 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
15024
15025 #ifdef HAVE_IPV6
15026 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
15027 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
15028 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
15029 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
15030 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
15031 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
15032 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
15033 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
15034 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
15035 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
15036 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
15037 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
15038 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
15039 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
15040 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
15041 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
15042 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
15043 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
15044 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
15045 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
15046
15047 /* Old commands. */
15048 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
15049 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
15050 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
15051 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
15052 #endif /* HAVE_IPV6 */
15053
15054 /* "show ip bgp peer-group" commands. */
15055 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
15056 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
15057 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
15058 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
15059 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
15060 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
15061 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
15062 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
15063
15064 /* "show ip bgp paths" commands. */
15065 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
15066 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
15067 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
15068 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
15069
15070 /* "show ip bgp community" commands. */
15071 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
15072 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
15073
15074 /* "show ip bgp attribute-info" commands. */
15075 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
15076 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
15077
15078 /* "redistribute" commands. */
15079 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
15080 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
15081 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15082 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15083 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
15084 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15085 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15086 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15087 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15088 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
15089 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15090 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15091 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15092 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15093 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15094 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15095 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15096 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15097 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15098 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15099 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
15100 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
15101 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
15102 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
15103 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
15104 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
15105 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
15106 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
15107 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
15108 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
15109 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
15110 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
15111 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
15112 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
15113 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
15114 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
15115 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15116 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
15117 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15118 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
15119 #ifdef HAVE_IPV6
15120 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
15121 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
15122 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
15123 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
15124 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
15125 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
15126 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
15127 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
15128 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
15129 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
15130 #endif /* HAVE_IPV6 */
15131
15132 /* ttl_security commands */
15133 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
15134 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
15135
15136 /* "show bgp memory" commands. */
15137 install_element (VIEW_NODE, &show_bgp_memory_cmd);
15138 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
15139 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
15140
15141 /* "show bgp views" commands. */
15142 install_element (VIEW_NODE, &show_bgp_views_cmd);
15143 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
15144 install_element (ENABLE_NODE, &show_bgp_views_cmd);
15145
15146 /* "show bgp vrfs" commands. */
15147 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
15148 install_element (RESTRICTED_NODE, &show_bgp_vrfs_cmd);
15149 install_element (ENABLE_NODE, &show_bgp_vrfs_cmd);
15150
15151 /* Community-list. */
15152 community_list_vty ();
15153 }
15154
15155 #include "memory.h"
15156 #include "bgp_regex.h"
15157 #include "bgp_clist.h"
15158 #include "bgp_ecommunity.h"
15159
15160 /* VTY functions. */
15161
15162 /* Direction value to string conversion. */
15163 static const char *
15164 community_direct_str (int direct)
15165 {
15166 switch (direct)
15167 {
15168 case COMMUNITY_DENY:
15169 return "deny";
15170 case COMMUNITY_PERMIT:
15171 return "permit";
15172 default:
15173 return "unknown";
15174 }
15175 }
15176
15177 /* Display error string. */
15178 static void
15179 community_list_perror (struct vty *vty, int ret)
15180 {
15181 switch (ret)
15182 {
15183 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
15184 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
15185 break;
15186 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
15187 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
15188 break;
15189 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
15190 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
15191 break;
15192 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
15193 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
15194 break;
15195 }
15196 }
15197
15198 /* VTY interface for community_set() function. */
15199 static int
15200 community_list_set_vty (struct vty *vty, int argc, const char **argv,
15201 int style, int reject_all_digit_name)
15202 {
15203 int ret;
15204 int direct;
15205 char *str;
15206
15207 /* Check the list type. */
15208 if (strncmp (argv[1], "p", 1) == 0)
15209 direct = COMMUNITY_PERMIT;
15210 else if (strncmp (argv[1], "d", 1) == 0)
15211 direct = COMMUNITY_DENY;
15212 else
15213 {
15214 vty_out (vty, "%% Matching condition must be permit or deny%s",
15215 VTY_NEWLINE);
15216 return CMD_WARNING;
15217 }
15218
15219 /* All digit name check. */
15220 if (reject_all_digit_name && all_digit (argv[0]))
15221 {
15222 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15223 return CMD_WARNING;
15224 }
15225
15226 /* Concat community string argument. */
15227 if (argc > 1)
15228 str = argv_concat (argv, argc, 2);
15229 else
15230 str = NULL;
15231
15232 /* When community_list_set() return nevetive value, it means
15233 malformed community string. */
15234 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
15235
15236 /* Free temporary community list string allocated by
15237 argv_concat(). */
15238 if (str)
15239 XFREE (MTYPE_TMP, str);
15240
15241 if (ret < 0)
15242 {
15243 /* Display error string. */
15244 community_list_perror (vty, ret);
15245 return CMD_WARNING;
15246 }
15247
15248 return CMD_SUCCESS;
15249 }
15250
15251 /* Communiyt-list entry delete. */
15252 static int
15253 community_list_unset_vty (struct vty *vty, int argc, const char **argv,
15254 int style, int delete_all)
15255 {
15256 int ret;
15257 int direct = 0;
15258 char *str = NULL;
15259
15260 if (argc > 1)
15261 {
15262 /* Check the list direct. */
15263 if (strncmp (argv[1], "p", 1) == 0)
15264 direct = COMMUNITY_PERMIT;
15265 else if (strncmp (argv[1], "d", 1) == 0)
15266 direct = COMMUNITY_DENY;
15267 else
15268 {
15269 vty_out (vty, "%% Matching condition must be permit or deny%s",
15270 VTY_NEWLINE);
15271 return CMD_WARNING;
15272 }
15273
15274 /* Concat community string argument. */
15275 str = argv_concat (argv, argc, 2);
15276 }
15277
15278 /* Unset community list. */
15279 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
15280
15281 /* Free temporary community list string allocated by
15282 argv_concat(). */
15283 if (str)
15284 XFREE (MTYPE_TMP, str);
15285
15286 if (ret < 0)
15287 {
15288 community_list_perror (vty, ret);
15289 return CMD_WARNING;
15290 }
15291
15292 return CMD_SUCCESS;
15293 }
15294
15295 /* "community-list" keyword help string. */
15296 #define COMMUNITY_LIST_STR "Add a community list entry\n"
15297 #define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
15298
15299 DEFUN (ip_community_list_standard,
15300 ip_community_list_standard_cmd,
15301 "ip community-list <1-99> (deny|permit) .AA:NN",
15302 IP_STR
15303 COMMUNITY_LIST_STR
15304 "Community list number (standard)\n"
15305 "Specify community to reject\n"
15306 "Specify community to accept\n"
15307 COMMUNITY_VAL_STR)
15308 {
15309 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15310 }
15311
15312 ALIAS (ip_community_list_standard,
15313 ip_community_list_standard2_cmd,
15314 "ip community-list <1-99> (deny|permit)",
15315 IP_STR
15316 COMMUNITY_LIST_STR
15317 "Community list number (standard)\n"
15318 "Specify community to reject\n"
15319 "Specify community to accept\n")
15320
15321 DEFUN (ip_community_list_expanded,
15322 ip_community_list_expanded_cmd,
15323 "ip community-list <100-500> (deny|permit) .LINE",
15324 IP_STR
15325 COMMUNITY_LIST_STR
15326 "Community list number (expanded)\n"
15327 "Specify community to reject\n"
15328 "Specify community to accept\n"
15329 "An ordered list as a regular-expression\n")
15330 {
15331 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15332 }
15333
15334 DEFUN (ip_community_list_name_standard,
15335 ip_community_list_name_standard_cmd,
15336 "ip community-list standard WORD (deny|permit) .AA:NN",
15337 IP_STR
15338 COMMUNITY_LIST_STR
15339 "Add a standard community-list entry\n"
15340 "Community list name\n"
15341 "Specify community to reject\n"
15342 "Specify community to accept\n"
15343 COMMUNITY_VAL_STR)
15344 {
15345 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15346 }
15347
15348 ALIAS (ip_community_list_name_standard,
15349 ip_community_list_name_standard2_cmd,
15350 "ip community-list standard WORD (deny|permit)",
15351 IP_STR
15352 COMMUNITY_LIST_STR
15353 "Add a standard community-list entry\n"
15354 "Community list name\n"
15355 "Specify community to reject\n"
15356 "Specify community to accept\n")
15357
15358 DEFUN (ip_community_list_name_expanded,
15359 ip_community_list_name_expanded_cmd,
15360 "ip community-list expanded WORD (deny|permit) .LINE",
15361 IP_STR
15362 COMMUNITY_LIST_STR
15363 "Add an expanded community-list entry\n"
15364 "Community list name\n"
15365 "Specify community to reject\n"
15366 "Specify community to accept\n"
15367 "An ordered list as a regular-expression\n")
15368 {
15369 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15370 }
15371
15372 DEFUN (no_ip_community_list_standard_all,
15373 no_ip_community_list_standard_all_cmd,
15374 "no ip community-list <1-99>",
15375 NO_STR
15376 IP_STR
15377 COMMUNITY_LIST_STR
15378 "Community list number (standard)\n")
15379 {
15380 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15381 }
15382
15383 DEFUN (no_ip_community_list_standard_direction,
15384 no_ip_community_list_standard_direction_cmd,
15385 "no ip community-list <1-99> (deny|permit)",
15386 NO_STR
15387 IP_STR
15388 COMMUNITY_LIST_STR
15389 "Community list number (standard)\n"
15390 "Specify community to reject\n"
15391 "Specify community to accept\n")
15392 {
15393 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15394 }
15395
15396
15397 DEFUN (no_ip_community_list_expanded_all,
15398 no_ip_community_list_expanded_all_cmd,
15399 "no ip community-list <100-500>",
15400 NO_STR
15401 IP_STR
15402 COMMUNITY_LIST_STR
15403 "Community list number (expanded)\n")
15404 {
15405 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15406 }
15407
15408 DEFUN (no_ip_community_list_name_standard_all,
15409 no_ip_community_list_name_standard_all_cmd,
15410 "no ip community-list standard WORD",
15411 NO_STR
15412 IP_STR
15413 COMMUNITY_LIST_STR
15414 "Add a standard community-list entry\n"
15415 "Community list name\n")
15416 {
15417 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
15418 }
15419
15420 DEFUN (no_ip_community_list_name_expanded_all,
15421 no_ip_community_list_name_expanded_all_cmd,
15422 "no ip community-list expanded WORD",
15423 NO_STR
15424 IP_STR
15425 COMMUNITY_LIST_STR
15426 "Add an expanded community-list entry\n"
15427 "Community list name\n")
15428 {
15429 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
15430 }
15431
15432 DEFUN (no_ip_community_list_standard,
15433 no_ip_community_list_standard_cmd,
15434 "no ip community-list <1-99> (deny|permit) .AA:NN",
15435 NO_STR
15436 IP_STR
15437 COMMUNITY_LIST_STR
15438 "Community list number (standard)\n"
15439 "Specify community to reject\n"
15440 "Specify community to accept\n"
15441 COMMUNITY_VAL_STR)
15442 {
15443 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15444 }
15445
15446 DEFUN (no_ip_community_list_expanded,
15447 no_ip_community_list_expanded_cmd,
15448 "no ip community-list <100-500> (deny|permit) .LINE",
15449 NO_STR
15450 IP_STR
15451 COMMUNITY_LIST_STR
15452 "Community list number (expanded)\n"
15453 "Specify community to reject\n"
15454 "Specify community to accept\n"
15455 "An ordered list as a regular-expression\n")
15456 {
15457 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15458 }
15459
15460 DEFUN (no_ip_community_list_name_standard,
15461 no_ip_community_list_name_standard_cmd,
15462 "no ip community-list standard WORD (deny|permit) .AA:NN",
15463 NO_STR
15464 IP_STR
15465 COMMUNITY_LIST_STR
15466 "Specify a standard community-list\n"
15467 "Community list name\n"
15468 "Specify community to reject\n"
15469 "Specify community to accept\n"
15470 COMMUNITY_VAL_STR)
15471 {
15472 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15473 }
15474
15475 DEFUN (no_ip_community_list_name_standard_brief,
15476 no_ip_community_list_name_standard_brief_cmd,
15477 "no ip community-list standard WORD (deny|permit)",
15478 NO_STR
15479 IP_STR
15480 COMMUNITY_LIST_STR
15481 "Specify a standard community-list\n"
15482 "Community list name\n"
15483 "Specify community to reject\n"
15484 "Specify community to accept\n")
15485 {
15486 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
15487 }
15488
15489 DEFUN (no_ip_community_list_name_expanded,
15490 no_ip_community_list_name_expanded_cmd,
15491 "no ip community-list expanded WORD (deny|permit) .LINE",
15492 NO_STR
15493 IP_STR
15494 COMMUNITY_LIST_STR
15495 "Specify an expanded community-list\n"
15496 "Community list name\n"
15497 "Specify community to reject\n"
15498 "Specify community to accept\n"
15499 "An ordered list as a regular-expression\n")
15500 {
15501 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
15502 }
15503
15504 static void
15505 community_list_show (struct vty *vty, struct community_list *list)
15506 {
15507 struct community_entry *entry;
15508
15509 for (entry = list->head; entry; entry = entry->next)
15510 {
15511 if (entry == list->head)
15512 {
15513 if (all_digit (list->name))
15514 vty_out (vty, "Community %s list %s%s",
15515 entry->style == COMMUNITY_LIST_STANDARD ?
15516 "standard" : "(expanded) access",
15517 list->name, VTY_NEWLINE);
15518 else
15519 vty_out (vty, "Named Community %s list %s%s",
15520 entry->style == COMMUNITY_LIST_STANDARD ?
15521 "standard" : "expanded",
15522 list->name, VTY_NEWLINE);
15523 }
15524 if (entry->any)
15525 vty_out (vty, " %s%s",
15526 community_direct_str (entry->direct), VTY_NEWLINE);
15527 else
15528 vty_out (vty, " %s %s%s",
15529 community_direct_str (entry->direct),
15530 entry->style == COMMUNITY_LIST_STANDARD
15531 ? community_str (entry->u.com) : entry->config,
15532 VTY_NEWLINE);
15533 }
15534 }
15535
15536 DEFUN (show_ip_community_list,
15537 show_ip_community_list_cmd,
15538 "show ip community-list",
15539 SHOW_STR
15540 IP_STR
15541 "List community-list\n")
15542 {
15543 struct community_list *list;
15544 struct community_list_master *cm;
15545
15546 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
15547 if (! cm)
15548 return CMD_SUCCESS;
15549
15550 for (list = cm->num.head; list; list = list->next)
15551 community_list_show (vty, list);
15552
15553 for (list = cm->str.head; list; list = list->next)
15554 community_list_show (vty, list);
15555
15556 return CMD_SUCCESS;
15557 }
15558
15559 DEFUN (show_ip_community_list_arg,
15560 show_ip_community_list_arg_cmd,
15561 "show ip community-list (<1-500>|WORD)",
15562 SHOW_STR
15563 IP_STR
15564 "List community-list\n"
15565 "Community-list number\n"
15566 "Community-list name\n")
15567 {
15568 struct community_list *list;
15569
15570 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
15571 if (! list)
15572 {
15573 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
15574 return CMD_WARNING;
15575 }
15576
15577 community_list_show (vty, list);
15578
15579 return CMD_SUCCESS;
15580 }
15581
15582 static int
15583 extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
15584 int style, int reject_all_digit_name)
15585 {
15586 int ret;
15587 int direct;
15588 char *str;
15589
15590 /* Check the list type. */
15591 if (strncmp (argv[1], "p", 1) == 0)
15592 direct = COMMUNITY_PERMIT;
15593 else if (strncmp (argv[1], "d", 1) == 0)
15594 direct = COMMUNITY_DENY;
15595 else
15596 {
15597 vty_out (vty, "%% Matching condition must be permit or deny%s",
15598 VTY_NEWLINE);
15599 return CMD_WARNING;
15600 }
15601
15602 /* All digit name check. */
15603 if (reject_all_digit_name && all_digit (argv[0]))
15604 {
15605 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
15606 return CMD_WARNING;
15607 }
15608
15609 /* Concat community string argument. */
15610 if (argc > 1)
15611 str = argv_concat (argv, argc, 2);
15612 else
15613 str = NULL;
15614
15615 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
15616
15617 /* Free temporary community list string allocated by
15618 argv_concat(). */
15619 if (str)
15620 XFREE (MTYPE_TMP, str);
15621
15622 if (ret < 0)
15623 {
15624 community_list_perror (vty, ret);
15625 return CMD_WARNING;
15626 }
15627 return CMD_SUCCESS;
15628 }
15629
15630 static int
15631 extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
15632 int style, int delete_all)
15633 {
15634 int ret;
15635 int direct = 0;
15636 char *str = NULL;
15637
15638 if (argc > 1)
15639 {
15640 /* Check the list direct. */
15641 if (strncmp (argv[1], "p", 1) == 0)
15642 direct = COMMUNITY_PERMIT;
15643 else if (strncmp (argv[1], "d", 1) == 0)
15644 direct = COMMUNITY_DENY;
15645 else
15646 {
15647 vty_out (vty, "%% Matching condition must be permit or deny%s",
15648 VTY_NEWLINE);
15649 return CMD_WARNING;
15650 }
15651
15652 /* Concat community string argument. */
15653 str = argv_concat (argv, argc, 2);
15654 }
15655
15656 /* Unset community list. */
15657 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
15658
15659 /* Free temporary community list string allocated by
15660 argv_concat(). */
15661 if (str)
15662 XFREE (MTYPE_TMP, str);
15663
15664 if (ret < 0)
15665 {
15666 community_list_perror (vty, ret);
15667 return CMD_WARNING;
15668 }
15669
15670 return CMD_SUCCESS;
15671 }
15672
15673 /* "extcommunity-list" keyword help string. */
15674 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15675 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15676
15677 DEFUN (ip_extcommunity_list_standard,
15678 ip_extcommunity_list_standard_cmd,
15679 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
15680 IP_STR
15681 EXTCOMMUNITY_LIST_STR
15682 "Extended Community list number (standard)\n"
15683 "Specify community to reject\n"
15684 "Specify community to accept\n"
15685 EXTCOMMUNITY_VAL_STR)
15686 {
15687 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15688 }
15689
15690 ALIAS (ip_extcommunity_list_standard,
15691 ip_extcommunity_list_standard2_cmd,
15692 "ip extcommunity-list <1-99> (deny|permit)",
15693 IP_STR
15694 EXTCOMMUNITY_LIST_STR
15695 "Extended Community list number (standard)\n"
15696 "Specify community to reject\n"
15697 "Specify community to accept\n")
15698
15699 DEFUN (ip_extcommunity_list_expanded,
15700 ip_extcommunity_list_expanded_cmd,
15701 "ip extcommunity-list <100-500> (deny|permit) .LINE",
15702 IP_STR
15703 EXTCOMMUNITY_LIST_STR
15704 "Extended Community list number (expanded)\n"
15705 "Specify community to reject\n"
15706 "Specify community to accept\n"
15707 "An ordered list as a regular-expression\n")
15708 {
15709 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
15710 }
15711
15712 DEFUN (ip_extcommunity_list_name_standard,
15713 ip_extcommunity_list_name_standard_cmd,
15714 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
15715 IP_STR
15716 EXTCOMMUNITY_LIST_STR
15717 "Specify standard extcommunity-list\n"
15718 "Extended Community list name\n"
15719 "Specify community to reject\n"
15720 "Specify community to accept\n"
15721 EXTCOMMUNITY_VAL_STR)
15722 {
15723 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15724 }
15725
15726 ALIAS (ip_extcommunity_list_name_standard,
15727 ip_extcommunity_list_name_standard2_cmd,
15728 "ip extcommunity-list standard WORD (deny|permit)",
15729 IP_STR
15730 EXTCOMMUNITY_LIST_STR
15731 "Specify standard extcommunity-list\n"
15732 "Extended Community list name\n"
15733 "Specify community to reject\n"
15734 "Specify community to accept\n")
15735
15736 DEFUN (ip_extcommunity_list_name_expanded,
15737 ip_extcommunity_list_name_expanded_cmd,
15738 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
15739 IP_STR
15740 EXTCOMMUNITY_LIST_STR
15741 "Specify expanded extcommunity-list\n"
15742 "Extended Community list name\n"
15743 "Specify community to reject\n"
15744 "Specify community to accept\n"
15745 "An ordered list as a regular-expression\n")
15746 {
15747 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
15748 }
15749
15750 DEFUN (no_ip_extcommunity_list_standard_all,
15751 no_ip_extcommunity_list_standard_all_cmd,
15752 "no ip extcommunity-list <1-99>",
15753 NO_STR
15754 IP_STR
15755 EXTCOMMUNITY_LIST_STR
15756 "Extended Community list number (standard)\n")
15757 {
15758 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15759 }
15760
15761 DEFUN (no_ip_extcommunity_list_standard_direction,
15762 no_ip_extcommunity_list_standard_direction_cmd,
15763 "no ip extcommunity-list <1-99> (deny|permit)",
15764 NO_STR
15765 IP_STR
15766 EXTCOMMUNITY_LIST_STR
15767 "Extended Community list number (standard)\n"
15768 "Specify community to reject\n"
15769 "Specify community to accept\n")
15770 {
15771 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15772 }
15773
15774 DEFUN (no_ip_extcommunity_list_expanded_all,
15775 no_ip_extcommunity_list_expanded_all_cmd,
15776 "no ip extcommunity-list <100-500>",
15777 NO_STR
15778 IP_STR
15779 EXTCOMMUNITY_LIST_STR
15780 "Extended Community list number (expanded)\n")
15781 {
15782 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
15783 }
15784
15785 DEFUN (no_ip_extcommunity_list_name_standard_all,
15786 no_ip_extcommunity_list_name_standard_all_cmd,
15787 "no ip extcommunity-list standard WORD",
15788 NO_STR
15789 IP_STR
15790 EXTCOMMUNITY_LIST_STR
15791 "Specify standard extcommunity-list\n"
15792 "Extended Community list name\n")
15793 {
15794 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
15795 }
15796
15797 DEFUN (no_ip_extcommunity_list_name_expanded_all,
15798 no_ip_extcommunity_list_name_expanded_all_cmd,
15799 "no ip extcommunity-list expanded WORD",
15800 NO_STR
15801 IP_STR
15802 EXTCOMMUNITY_LIST_STR
15803 "Specify expanded extcommunity-list\n"
15804 "Extended Community list name\n")
15805 {
15806 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
15807 }
15808
15809 DEFUN (no_ip_extcommunity_list_standard,
15810 no_ip_extcommunity_list_standard_cmd,
15811 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
15812 NO_STR
15813 IP_STR
15814 EXTCOMMUNITY_LIST_STR
15815 "Extended Community list number (standard)\n"
15816 "Specify community to reject\n"
15817 "Specify community to accept\n"
15818 EXTCOMMUNITY_VAL_STR)
15819 {
15820 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15821 }
15822
15823 DEFUN (no_ip_extcommunity_list_expanded,
15824 no_ip_extcommunity_list_expanded_cmd,
15825 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
15826 NO_STR
15827 IP_STR
15828 EXTCOMMUNITY_LIST_STR
15829 "Extended Community list number (expanded)\n"
15830 "Specify community to reject\n"
15831 "Specify community to accept\n"
15832 "An ordered list as a regular-expression\n")
15833 {
15834 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
15835 }
15836
15837 DEFUN (no_ip_extcommunity_list_name_standard,
15838 no_ip_extcommunity_list_name_standard_cmd,
15839 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
15840 NO_STR
15841 IP_STR
15842 EXTCOMMUNITY_LIST_STR
15843 "Specify standard extcommunity-list\n"
15844 "Extended Community list name\n"
15845 "Specify community to reject\n"
15846 "Specify community to accept\n"
15847 EXTCOMMUNITY_VAL_STR)
15848 {
15849 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15850 }
15851
15852 DEFUN (no_ip_extcommunity_list_name_standard_brief,
15853 no_ip_extcommunity_list_name_standard_brief_cmd,
15854 "no ip extcommunity-list standard WORD (deny|permit)",
15855 NO_STR
15856 IP_STR
15857 EXTCOMMUNITY_LIST_STR
15858 "Specify standard extcommunity-list\n"
15859 "Extended Community list name\n"
15860 "Specify community to reject\n"
15861 "Specify community to accept\n")
15862 {
15863 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
15864 }
15865
15866 DEFUN (no_ip_extcommunity_list_name_expanded,
15867 no_ip_extcommunity_list_name_expanded_cmd,
15868 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
15869 NO_STR
15870 IP_STR
15871 EXTCOMMUNITY_LIST_STR
15872 "Specify expanded extcommunity-list\n"
15873 "Community list name\n"
15874 "Specify community to reject\n"
15875 "Specify community to accept\n"
15876 "An ordered list as a regular-expression\n")
15877 {
15878 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
15879 }
15880
15881 static void
15882 extcommunity_list_show (struct vty *vty, struct community_list *list)
15883 {
15884 struct community_entry *entry;
15885
15886 for (entry = list->head; entry; entry = entry->next)
15887 {
15888 if (entry == list->head)
15889 {
15890 if (all_digit (list->name))
15891 vty_out (vty, "Extended community %s list %s%s",
15892 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15893 "standard" : "(expanded) access",
15894 list->name, VTY_NEWLINE);
15895 else
15896 vty_out (vty, "Named extended community %s list %s%s",
15897 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15898 "standard" : "expanded",
15899 list->name, VTY_NEWLINE);
15900 }
15901 if (entry->any)
15902 vty_out (vty, " %s%s",
15903 community_direct_str (entry->direct), VTY_NEWLINE);
15904 else
15905 vty_out (vty, " %s %s%s",
15906 community_direct_str (entry->direct),
15907 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
15908 entry->u.ecom->str : entry->config,
15909 VTY_NEWLINE);
15910 }
15911 }
15912
15913 DEFUN (show_ip_extcommunity_list,
15914 show_ip_extcommunity_list_cmd,
15915 "show ip extcommunity-list",
15916 SHOW_STR
15917 IP_STR
15918 "List extended-community list\n")
15919 {
15920 struct community_list *list;
15921 struct community_list_master *cm;
15922
15923 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
15924 if (! cm)
15925 return CMD_SUCCESS;
15926
15927 for (list = cm->num.head; list; list = list->next)
15928 extcommunity_list_show (vty, list);
15929
15930 for (list = cm->str.head; list; list = list->next)
15931 extcommunity_list_show (vty, list);
15932
15933 return CMD_SUCCESS;
15934 }
15935
15936 DEFUN (show_ip_extcommunity_list_arg,
15937 show_ip_extcommunity_list_arg_cmd,
15938 "show ip extcommunity-list (<1-500>|WORD)",
15939 SHOW_STR
15940 IP_STR
15941 "List extended-community list\n"
15942 "Extcommunity-list number\n"
15943 "Extcommunity-list name\n")
15944 {
15945 struct community_list *list;
15946
15947 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
15948 if (! list)
15949 {
15950 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
15951 return CMD_WARNING;
15952 }
15953
15954 extcommunity_list_show (vty, list);
15955
15956 return CMD_SUCCESS;
15957 }
15958
15959 /* Return configuration string of community-list entry. */
15960 static const char *
15961 community_list_config_str (struct community_entry *entry)
15962 {
15963 const char *str;
15964
15965 if (entry->any)
15966 str = "";
15967 else
15968 {
15969 if (entry->style == COMMUNITY_LIST_STANDARD)
15970 str = community_str (entry->u.com);
15971 else
15972 str = entry->config;
15973 }
15974 return str;
15975 }
15976
15977 /* Display community-list and extcommunity-list configuration. */
15978 static int
15979 community_list_config_write (struct vty *vty)
15980 {
15981 struct community_list *list;
15982 struct community_entry *entry;
15983 struct community_list_master *cm;
15984 int write = 0;
15985
15986 /* Community-list. */
15987 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
15988
15989 for (list = cm->num.head; list; list = list->next)
15990 for (entry = list->head; entry; entry = entry->next)
15991 {
15992 vty_out (vty, "ip community-list %s %s %s%s",
15993 list->name, community_direct_str (entry->direct),
15994 community_list_config_str (entry),
15995 VTY_NEWLINE);
15996 write++;
15997 }
15998 for (list = cm->str.head; list; list = list->next)
15999 for (entry = list->head; entry; entry = entry->next)
16000 {
16001 vty_out (vty, "ip community-list %s %s %s %s%s",
16002 entry->style == COMMUNITY_LIST_STANDARD
16003 ? "standard" : "expanded",
16004 list->name, community_direct_str (entry->direct),
16005 community_list_config_str (entry),
16006 VTY_NEWLINE);
16007 write++;
16008 }
16009
16010 /* Extcommunity-list. */
16011 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
16012
16013 for (list = cm->num.head; list; list = list->next)
16014 for (entry = list->head; entry; entry = entry->next)
16015 {
16016 vty_out (vty, "ip extcommunity-list %s %s %s%s",
16017 list->name, community_direct_str (entry->direct),
16018 community_list_config_str (entry), VTY_NEWLINE);
16019 write++;
16020 }
16021 for (list = cm->str.head; list; list = list->next)
16022 for (entry = list->head; entry; entry = entry->next)
16023 {
16024 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
16025 entry->style == EXTCOMMUNITY_LIST_STANDARD
16026 ? "standard" : "expanded",
16027 list->name, community_direct_str (entry->direct),
16028 community_list_config_str (entry), VTY_NEWLINE);
16029 write++;
16030 }
16031 return write;
16032 }
16033
16034 static struct cmd_node community_list_node =
16035 {
16036 COMMUNITY_LIST_NODE,
16037 "",
16038 1 /* Export to vtysh. */
16039 };
16040
16041 static void
16042 community_list_vty (void)
16043 {
16044 install_node (&community_list_node, community_list_config_write);
16045
16046 /* Community-list. */
16047 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
16048 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
16049 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
16050 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
16051 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
16052 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
16053 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
16054 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
16055 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
16056 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
16057 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
16058 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
16059 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
16060 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
16061 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
16062 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
16063 install_element (VIEW_NODE, &show_ip_community_list_cmd);
16064 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
16065 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
16066 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
16067
16068 /* Extcommunity-list. */
16069 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
16070 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
16071 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
16072 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
16073 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
16074 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
16075 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
16076 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
16077 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
16078 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
16079 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
16080 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
16081 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
16082 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
16083 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
16084 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
16085 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
16086 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
16087 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
16088 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
16089 }