]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_vty.c
BGP: Update commands for VRF support
[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);
2710 else
2711 peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, afi, safi);
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 struct bgp *bgp;
4947
4948 bgp = vty->index;
4949 if (argv[0])
4950 {
4951 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
4952 bgp->rmap_update_timer = rmap_delay_timer;
4953
4954 /* if the dynamic update handling is being disabled, and a timer is
4955 * running, stop the timer and act as if the timer has already fired.
4956 */
4957 if (!rmap_delay_timer && bgp->t_rmap_update )
4958 {
4959 BGP_TIMER_OFF(bgp->t_rmap_update);
4960 thread_execute (bm->master, bgp_route_map_update_timer, &bgp, 0);
4961 }
4962 return CMD_SUCCESS;
4963 }
4964 else
4965 return CMD_WARNING;
4966 }
4967
4968 DEFUN (no_bgp_set_route_map_delay_timer,
4969 no_bgp_set_route_map_delay_timer_cmd,
4970 "no bgp route-map delay-timer",
4971 NO_STR
4972 "Default BGP route-map delay timer\n"
4973 "Reset to default time to wait for processing route-map changes\n")
4974 {
4975 struct bgp *bgp;
4976
4977 bgp = vty->index;
4978 bgp->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
4979
4980 return CMD_SUCCESS;
4981 }
4982
4983 ALIAS (no_bgp_set_route_map_delay_timer,
4984 no_bgp_set_route_map_delay_timer_val_cmd,
4985 "no bgp route-map delay-timer <0-600>",
4986 NO_STR
4987 "Default BGP route-map delay timer\n"
4988 "Reset to default time to wait for processing route-map changes\n"
4989 "0 disables the timer, no route updates happen when route-maps change\n")
4990
4991 /* neighbor interface */
4992 static int
4993 peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
4994 {
4995 struct peer *peer;
4996
4997 peer = peer_lookup_vty (vty, ip_str);
4998 if (! peer || peer->conf_if)
4999 return CMD_WARNING;
5000
5001 if (str)
5002 peer_interface_set (peer, str);
5003 else
5004 peer_interface_unset (peer);
5005
5006 return CMD_SUCCESS;
5007 }
5008
5009 DEFUN (neighbor_interface,
5010 neighbor_interface_cmd,
5011 NEIGHBOR_CMD "interface WORD",
5012 NEIGHBOR_STR
5013 NEIGHBOR_ADDR_STR
5014 "Interface\n"
5015 "Interface name\n")
5016 {
5017 if (argc == 3)
5018 return peer_interface_vty (vty, argv[0], argv[1]);
5019 else
5020 return peer_interface_vty (vty, argv[0], argv[1]);
5021 }
5022
5023 DEFUN (no_neighbor_interface,
5024 no_neighbor_interface_cmd,
5025 NO_NEIGHBOR_CMD2 "interface WORD",
5026 NO_STR
5027 NEIGHBOR_STR
5028 NEIGHBOR_ADDR_STR
5029 "Interface\n"
5030 "Interface name\n")
5031 {
5032 return peer_interface_vty (vty, argv[0], NULL);
5033 }
5034
5035 /* Set distribute list to the peer. */
5036 static int
5037 peer_distribute_set_vty (struct vty *vty, const char *ip_str,
5038 afi_t afi, safi_t safi,
5039 const char *name_str, const char *direct_str)
5040 {
5041 int ret;
5042 struct peer *peer;
5043 int direct = FILTER_IN;
5044
5045 peer = peer_and_group_lookup_vty (vty, ip_str);
5046 if (! peer)
5047 return CMD_WARNING;
5048
5049 /* Check filter direction. */
5050 if (strncmp (direct_str, "i", 1) == 0)
5051 direct = FILTER_IN;
5052 else if (strncmp (direct_str, "o", 1) == 0)
5053 direct = FILTER_OUT;
5054
5055 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5056
5057 return bgp_vty_return (vty, ret);
5058 }
5059
5060 static int
5061 peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5062 safi_t safi, const char *direct_str)
5063 {
5064 int ret;
5065 struct peer *peer;
5066 int direct = FILTER_IN;
5067
5068 peer = peer_and_group_lookup_vty (vty, ip_str);
5069 if (! peer)
5070 return CMD_WARNING;
5071
5072 /* Check filter direction. */
5073 if (strncmp (direct_str, "i", 1) == 0)
5074 direct = FILTER_IN;
5075 else if (strncmp (direct_str, "o", 1) == 0)
5076 direct = FILTER_OUT;
5077
5078 ret = peer_distribute_unset (peer, afi, safi, direct);
5079
5080 return bgp_vty_return (vty, ret);
5081 }
5082
5083 DEFUN (neighbor_distribute_list,
5084 neighbor_distribute_list_cmd,
5085 NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5086 NEIGHBOR_STR
5087 NEIGHBOR_ADDR_STR2
5088 "Filter updates to/from this neighbor\n"
5089 "IP access-list number\n"
5090 "IP access-list number (expanded range)\n"
5091 "IP Access-list name\n"
5092 "Filter incoming updates\n"
5093 "Filter outgoing updates\n")
5094 {
5095 return peer_distribute_set_vty (vty, argv[0], bgp_node_afi (vty),
5096 bgp_node_safi (vty), argv[1], argv[2]);
5097 }
5098
5099 DEFUN (no_neighbor_distribute_list,
5100 no_neighbor_distribute_list_cmd,
5101 NO_NEIGHBOR_CMD2 "distribute-list (<1-199>|<1300-2699>|WORD) (in|out)",
5102 NO_STR
5103 NEIGHBOR_STR
5104 NEIGHBOR_ADDR_STR2
5105 "Filter updates to/from this neighbor\n"
5106 "IP access-list number\n"
5107 "IP access-list number (expanded range)\n"
5108 "IP Access-list name\n"
5109 "Filter incoming updates\n"
5110 "Filter outgoing updates\n")
5111 {
5112 return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
5113 bgp_node_safi (vty), argv[2]);
5114 }
5115
5116 /* Set prefix list to the peer. */
5117 static int
5118 peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5119 safi_t safi, const char *name_str,
5120 const char *direct_str)
5121 {
5122 int ret;
5123 struct peer *peer;
5124 int direct = FILTER_IN;
5125
5126 peer = peer_and_group_lookup_vty (vty, ip_str);
5127 if (! peer)
5128 return CMD_WARNING;
5129
5130 /* Check filter direction. */
5131 if (strncmp (direct_str, "i", 1) == 0)
5132 direct = FILTER_IN;
5133 else if (strncmp (direct_str, "o", 1) == 0)
5134 direct = FILTER_OUT;
5135
5136 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5137
5138 return bgp_vty_return (vty, ret);
5139 }
5140
5141 static int
5142 peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5143 safi_t safi, const char *direct_str)
5144 {
5145 int ret;
5146 struct peer *peer;
5147 int direct = FILTER_IN;
5148
5149 peer = peer_and_group_lookup_vty (vty, ip_str);
5150 if (! peer)
5151 return CMD_WARNING;
5152
5153 /* Check filter direction. */
5154 if (strncmp (direct_str, "i", 1) == 0)
5155 direct = FILTER_IN;
5156 else if (strncmp (direct_str, "o", 1) == 0)
5157 direct = FILTER_OUT;
5158
5159 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5160
5161 return bgp_vty_return (vty, ret);
5162 }
5163
5164 DEFUN (neighbor_prefix_list,
5165 neighbor_prefix_list_cmd,
5166 NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5167 NEIGHBOR_STR
5168 NEIGHBOR_ADDR_STR2
5169 "Filter updates to/from this neighbor\n"
5170 "Name of a prefix list\n"
5171 "Filter incoming updates\n"
5172 "Filter outgoing updates\n")
5173 {
5174 return peer_prefix_list_set_vty (vty, argv[0], bgp_node_afi (vty),
5175 bgp_node_safi (vty), argv[1], argv[2]);
5176 }
5177
5178 DEFUN (no_neighbor_prefix_list,
5179 no_neighbor_prefix_list_cmd,
5180 NO_NEIGHBOR_CMD2 "prefix-list WORD (in|out)",
5181 NO_STR
5182 NEIGHBOR_STR
5183 NEIGHBOR_ADDR_STR2
5184 "Filter updates to/from this neighbor\n"
5185 "Name of a prefix list\n"
5186 "Filter incoming updates\n"
5187 "Filter outgoing updates\n")
5188 {
5189 return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
5190 bgp_node_safi (vty), argv[2]);
5191 }
5192
5193 static int
5194 peer_aslist_set_vty (struct vty *vty, const char *ip_str,
5195 afi_t afi, safi_t safi,
5196 const char *name_str, const char *direct_str)
5197 {
5198 int ret;
5199 struct peer *peer;
5200 int direct = FILTER_IN;
5201
5202 peer = peer_and_group_lookup_vty (vty, ip_str);
5203 if (! peer)
5204 return CMD_WARNING;
5205
5206 /* Check filter direction. */
5207 if (strncmp (direct_str, "i", 1) == 0)
5208 direct = FILTER_IN;
5209 else if (strncmp (direct_str, "o", 1) == 0)
5210 direct = FILTER_OUT;
5211
5212 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5213
5214 return bgp_vty_return (vty, ret);
5215 }
5216
5217 static int
5218 peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
5219 afi_t afi, safi_t safi,
5220 const char *direct_str)
5221 {
5222 int ret;
5223 struct peer *peer;
5224 int direct = FILTER_IN;
5225
5226 peer = peer_and_group_lookup_vty (vty, ip_str);
5227 if (! peer)
5228 return CMD_WARNING;
5229
5230 /* Check filter direction. */
5231 if (strncmp (direct_str, "i", 1) == 0)
5232 direct = FILTER_IN;
5233 else if (strncmp (direct_str, "o", 1) == 0)
5234 direct = FILTER_OUT;
5235
5236 ret = peer_aslist_unset (peer, afi, safi, direct);
5237
5238 return bgp_vty_return (vty, ret);
5239 }
5240
5241 DEFUN (neighbor_filter_list,
5242 neighbor_filter_list_cmd,
5243 NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5244 NEIGHBOR_STR
5245 NEIGHBOR_ADDR_STR2
5246 "Establish BGP filters\n"
5247 "AS path access-list name\n"
5248 "Filter incoming routes\n"
5249 "Filter outgoing routes\n")
5250 {
5251 return peer_aslist_set_vty (vty, argv[0], bgp_node_afi (vty),
5252 bgp_node_safi (vty), argv[1], argv[2]);
5253 }
5254
5255 DEFUN (no_neighbor_filter_list,
5256 no_neighbor_filter_list_cmd,
5257 NO_NEIGHBOR_CMD2 "filter-list WORD (in|out)",
5258 NO_STR
5259 NEIGHBOR_STR
5260 NEIGHBOR_ADDR_STR2
5261 "Establish BGP filters\n"
5262 "AS path access-list name\n"
5263 "Filter incoming routes\n"
5264 "Filter outgoing routes\n")
5265 {
5266 return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
5267 bgp_node_safi (vty), argv[2]);
5268 }
5269
5270 /* Set route-map to the peer. */
5271 static int
5272 peer_route_map_set_vty (struct vty *vty, const char *ip_str,
5273 afi_t afi, safi_t safi,
5274 const char *name_str, const char *direct_str)
5275 {
5276 int ret;
5277 struct peer *peer;
5278 int direct = RMAP_IN;
5279
5280 peer = peer_and_group_lookup_vty (vty, ip_str);
5281 if (! peer)
5282 return CMD_WARNING;
5283
5284 /* Check filter direction. */
5285 if (strncmp (direct_str, "in", 2) == 0)
5286 direct = RMAP_IN;
5287 else if (strncmp (direct_str, "o", 1) == 0)
5288 direct = RMAP_OUT;
5289
5290 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5291
5292 return bgp_vty_return (vty, ret);
5293 }
5294
5295 static int
5296 peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5297 safi_t safi, const char *direct_str)
5298 {
5299 int ret;
5300 struct peer *peer;
5301 int direct = RMAP_IN;
5302
5303 peer = peer_and_group_lookup_vty (vty, ip_str);
5304 if (! peer)
5305 return CMD_WARNING;
5306
5307 /* Check filter direction. */
5308 if (strncmp (direct_str, "in", 2) == 0)
5309 direct = RMAP_IN;
5310 else if (strncmp (direct_str, "o", 1) == 0)
5311 direct = RMAP_OUT;
5312
5313 ret = peer_route_map_unset (peer, afi, safi, direct);
5314
5315 return bgp_vty_return (vty, ret);
5316 }
5317
5318 DEFUN (neighbor_route_map,
5319 neighbor_route_map_cmd,
5320 NEIGHBOR_CMD2 "route-map WORD (in|out)",
5321 NEIGHBOR_STR
5322 NEIGHBOR_ADDR_STR2
5323 "Apply route map to neighbor\n"
5324 "Name of route map\n"
5325 "Apply map to incoming routes\n"
5326 "Apply map to outbound routes\n")
5327 {
5328 return peer_route_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5329 bgp_node_safi (vty), argv[1], argv[2]);
5330 }
5331
5332 DEFUN (no_neighbor_route_map,
5333 no_neighbor_route_map_cmd,
5334 NO_NEIGHBOR_CMD2 "route-map WORD (in|out)",
5335 NO_STR
5336 NEIGHBOR_STR
5337 NEIGHBOR_ADDR_STR2
5338 "Apply route map to neighbor\n"
5339 "Name of route map\n"
5340 "Apply map to incoming routes\n"
5341 "Apply map to outbound routes\n")
5342 {
5343 return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5344 bgp_node_safi (vty), argv[2]);
5345 }
5346
5347 /* Set unsuppress-map to the peer. */
5348 static int
5349 peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5350 safi_t safi, const char *name_str)
5351 {
5352 int ret;
5353 struct peer *peer;
5354
5355 peer = peer_and_group_lookup_vty (vty, ip_str);
5356 if (! peer)
5357 return CMD_WARNING;
5358
5359 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5360
5361 return bgp_vty_return (vty, ret);
5362 }
5363
5364 /* Unset route-map from the peer. */
5365 static int
5366 peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5367 safi_t safi)
5368 {
5369 int ret;
5370 struct peer *peer;
5371
5372 peer = peer_and_group_lookup_vty (vty, ip_str);
5373 if (! peer)
5374 return CMD_WARNING;
5375
5376 ret = peer_unsuppress_map_unset (peer, afi, safi);
5377
5378 return bgp_vty_return (vty, ret);
5379 }
5380
5381 DEFUN (neighbor_unsuppress_map,
5382 neighbor_unsuppress_map_cmd,
5383 NEIGHBOR_CMD2 "unsuppress-map WORD",
5384 NEIGHBOR_STR
5385 NEIGHBOR_ADDR_STR2
5386 "Route-map to selectively unsuppress suppressed routes\n"
5387 "Name of route map\n")
5388 {
5389 return peer_unsuppress_map_set_vty (vty, argv[0], bgp_node_afi (vty),
5390 bgp_node_safi (vty), argv[1]);
5391 }
5392
5393 DEFUN (no_neighbor_unsuppress_map,
5394 no_neighbor_unsuppress_map_cmd,
5395 NO_NEIGHBOR_CMD2 "unsuppress-map WORD",
5396 NO_STR
5397 NEIGHBOR_STR
5398 NEIGHBOR_ADDR_STR2
5399 "Route-map to selectively unsuppress suppressed routes\n"
5400 "Name of route map\n")
5401 {
5402 return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
5403 bgp_node_safi (vty));
5404 }
5405
5406 static int
5407 peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5408 safi_t safi, const char *num_str,
5409 const char *threshold_str, int warning,
5410 const char *restart_str)
5411 {
5412 int ret;
5413 struct peer *peer;
5414 u_int32_t max;
5415 u_char threshold;
5416 u_int16_t restart;
5417
5418 peer = peer_and_group_lookup_vty (vty, ip_str);
5419 if (! peer)
5420 return CMD_WARNING;
5421
5422 VTY_GET_INTEGER ("maximum number", max, num_str);
5423 if (threshold_str)
5424 threshold = atoi (threshold_str);
5425 else
5426 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
5427
5428 if (restart_str)
5429 restart = atoi (restart_str);
5430 else
5431 restart = 0;
5432
5433 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
5434
5435 return bgp_vty_return (vty, ret);
5436 }
5437
5438 static int
5439 peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5440 safi_t safi)
5441 {
5442 int ret;
5443 struct peer *peer;
5444
5445 peer = peer_and_group_lookup_vty (vty, ip_str);
5446 if (! peer)
5447 return CMD_WARNING;
5448
5449 ret = peer_maximum_prefix_unset (peer, afi, safi);
5450
5451 return bgp_vty_return (vty, ret);
5452 }
5453
5454 /* Maximum number of prefix configuration. prefix count is different
5455 for each peer configuration. So this configuration can be set for
5456 each peer configuration. */
5457 DEFUN (neighbor_maximum_prefix,
5458 neighbor_maximum_prefix_cmd,
5459 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5460 NEIGHBOR_STR
5461 NEIGHBOR_ADDR_STR2
5462 "Maximum number of prefix accept from this peer\n"
5463 "maximum no. of prefix limit\n")
5464 {
5465 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5466 bgp_node_safi (vty), argv[1], NULL, 0,
5467 NULL);
5468 }
5469
5470 DEFUN (neighbor_maximum_prefix_threshold,
5471 neighbor_maximum_prefix_threshold_cmd,
5472 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5473 NEIGHBOR_STR
5474 NEIGHBOR_ADDR_STR2
5475 "Maximum number of prefix accept from this peer\n"
5476 "maximum no. of prefix limit\n"
5477 "Threshold value (%) at which to generate a warning msg\n")
5478 {
5479 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5480 bgp_node_safi (vty), argv[1], argv[2], 0,
5481 NULL);
5482 }
5483
5484 DEFUN (neighbor_maximum_prefix_warning,
5485 neighbor_maximum_prefix_warning_cmd,
5486 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5487 NEIGHBOR_STR
5488 NEIGHBOR_ADDR_STR2
5489 "Maximum number of prefix accept from this peer\n"
5490 "maximum no. of prefix limit\n"
5491 "Only give warning message when limit is exceeded\n")
5492 {
5493 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5494 bgp_node_safi (vty), argv[1], NULL, 1,
5495 NULL);
5496 }
5497
5498 DEFUN (neighbor_maximum_prefix_threshold_warning,
5499 neighbor_maximum_prefix_threshold_warning_cmd,
5500 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5501 NEIGHBOR_STR
5502 NEIGHBOR_ADDR_STR2
5503 "Maximum number of prefix accept from this peer\n"
5504 "maximum no. of prefix limit\n"
5505 "Threshold value (%) at which to generate a warning msg\n"
5506 "Only give warning message when limit is exceeded\n")
5507 {
5508 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5509 bgp_node_safi (vty), argv[1], argv[2], 1, NULL);
5510 }
5511
5512 DEFUN (neighbor_maximum_prefix_restart,
5513 neighbor_maximum_prefix_restart_cmd,
5514 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5515 NEIGHBOR_STR
5516 NEIGHBOR_ADDR_STR2
5517 "Maximum number of prefix accept from this peer\n"
5518 "maximum no. of prefix limit\n"
5519 "Restart bgp connection after limit is exceeded\n"
5520 "Restart interval in minutes")
5521 {
5522 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5523 bgp_node_safi (vty), argv[1], NULL, 0, argv[2]);
5524 }
5525
5526 DEFUN (neighbor_maximum_prefix_threshold_restart,
5527 neighbor_maximum_prefix_threshold_restart_cmd,
5528 NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5529 NEIGHBOR_STR
5530 NEIGHBOR_ADDR_STR2
5531 "Maximum number of prefix accept from this peer\n"
5532 "maximum no. of prefix limit\n"
5533 "Threshold value (%) at which to generate a warning msg\n"
5534 "Restart bgp connection after limit is exceeded\n"
5535 "Restart interval in minutes")
5536 {
5537 return peer_maximum_prefix_set_vty (vty, argv[0], bgp_node_afi (vty),
5538 bgp_node_safi (vty), argv[1], argv[2], 0, argv[3]);
5539 }
5540
5541 DEFUN (no_neighbor_maximum_prefix,
5542 no_neighbor_maximum_prefix_cmd,
5543 NO_NEIGHBOR_CMD2 "maximum-prefix",
5544 NO_STR
5545 NEIGHBOR_STR
5546 NEIGHBOR_ADDR_STR2
5547 "Maximum number of prefix accept from this peer\n")
5548 {
5549 return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
5550 bgp_node_safi (vty));
5551 }
5552
5553 ALIAS (no_neighbor_maximum_prefix,
5554 no_neighbor_maximum_prefix_val_cmd,
5555 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
5556 NO_STR
5557 NEIGHBOR_STR
5558 NEIGHBOR_ADDR_STR2
5559 "Maximum number of prefix accept from this peer\n"
5560 "maximum no. of prefix limit\n")
5561
5562 ALIAS (no_neighbor_maximum_prefix,
5563 no_neighbor_maximum_prefix_threshold_cmd,
5564 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100>",
5565 NO_STR
5566 NEIGHBOR_STR
5567 NEIGHBOR_ADDR_STR2
5568 "Maximum number of prefix accept from this peer\n"
5569 "maximum no. of prefix limit\n"
5570 "Threshold value (%) at which to generate a warning msg\n")
5571
5572 ALIAS (no_neighbor_maximum_prefix,
5573 no_neighbor_maximum_prefix_warning_cmd,
5574 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> warning-only",
5575 NO_STR
5576 NEIGHBOR_STR
5577 NEIGHBOR_ADDR_STR2
5578 "Maximum number of prefix accept from this peer\n"
5579 "maximum no. of prefix limit\n"
5580 "Only give warning message when limit is exceeded\n")
5581
5582 ALIAS (no_neighbor_maximum_prefix,
5583 no_neighbor_maximum_prefix_threshold_warning_cmd,
5584 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> warning-only",
5585 NO_STR
5586 NEIGHBOR_STR
5587 NEIGHBOR_ADDR_STR2
5588 "Maximum number of prefix accept from this peer\n"
5589 "maximum no. of prefix limit\n"
5590 "Threshold value (%) at which to generate a warning msg\n"
5591 "Only give warning message when limit is exceeded\n")
5592
5593 ALIAS (no_neighbor_maximum_prefix,
5594 no_neighbor_maximum_prefix_restart_cmd,
5595 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> restart <1-65535>",
5596 NO_STR
5597 NEIGHBOR_STR
5598 NEIGHBOR_ADDR_STR2
5599 "Maximum number of prefix accept from this peer\n"
5600 "maximum no. of prefix limit\n"
5601 "Restart bgp connection after limit is exceeded\n"
5602 "Restart interval in minutes")
5603
5604 ALIAS (no_neighbor_maximum_prefix,
5605 no_neighbor_maximum_prefix_threshold_restart_cmd,
5606 NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295> <1-100> restart <1-65535>",
5607 NO_STR
5608 NEIGHBOR_STR
5609 NEIGHBOR_ADDR_STR2
5610 "Maximum number of prefix accept from this peer\n"
5611 "maximum no. of prefix limit\n"
5612 "Threshold value (%) at which to generate a warning msg\n"
5613 "Restart bgp connection after limit is exceeded\n"
5614 "Restart interval in minutes")
5615
5616 /* "neighbor allowas-in" */
5617 DEFUN (neighbor_allowas_in,
5618 neighbor_allowas_in_cmd,
5619 NEIGHBOR_CMD2 "allowas-in",
5620 NEIGHBOR_STR
5621 NEIGHBOR_ADDR_STR2
5622 "Accept as-path with my AS present in it\n")
5623 {
5624 int ret;
5625 struct peer *peer;
5626 unsigned int allow_num;
5627
5628 peer = peer_and_group_lookup_vty (vty, argv[0]);
5629 if (! peer)
5630 return CMD_WARNING;
5631
5632 if (argc == 1)
5633 allow_num = 3;
5634 else
5635 VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
5636
5637 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
5638 allow_num);
5639
5640 return bgp_vty_return (vty, ret);
5641 }
5642
5643 ALIAS (neighbor_allowas_in,
5644 neighbor_allowas_in_arg_cmd,
5645 NEIGHBOR_CMD2 "allowas-in <1-10>",
5646 NEIGHBOR_STR
5647 NEIGHBOR_ADDR_STR2
5648 "Accept as-path with my AS present in it\n"
5649 "Number of occurances of AS number\n")
5650
5651 DEFUN (no_neighbor_allowas_in,
5652 no_neighbor_allowas_in_cmd,
5653 NO_NEIGHBOR_CMD2 "allowas-in",
5654 NO_STR
5655 NEIGHBOR_STR
5656 NEIGHBOR_ADDR_STR2
5657 "allow local ASN appears in aspath attribute\n")
5658 {
5659 int ret;
5660 struct peer *peer;
5661
5662 peer = peer_and_group_lookup_vty (vty, argv[0]);
5663 if (! peer)
5664 return CMD_WARNING;
5665
5666 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
5667
5668 return bgp_vty_return (vty, ret);
5669 }
5670
5671 ALIAS (no_neighbor_allowas_in,
5672 no_neighbor_allowas_in_val_cmd,
5673 NO_NEIGHBOR_CMD2 "allowas-in <1-10>",
5674 NO_STR
5675 NEIGHBOR_STR
5676 NEIGHBOR_ADDR_STR2
5677 "allow local ASN appears in aspath attribute\n"
5678 "Number of occurances of AS number\n")
5679
5680 DEFUN (neighbor_ttl_security,
5681 neighbor_ttl_security_cmd,
5682 NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5683 NEIGHBOR_STR
5684 NEIGHBOR_ADDR_STR2
5685 "Specify the maximum number of hops to the BGP peer\n")
5686 {
5687 struct peer *peer;
5688 int gtsm_hops;
5689
5690 peer = peer_and_group_lookup_vty (vty, argv[0]);
5691 if (! peer)
5692 return CMD_WARNING;
5693
5694 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
5695
5696 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
5697 }
5698
5699 DEFUN (no_neighbor_ttl_security,
5700 no_neighbor_ttl_security_cmd,
5701 NO_NEIGHBOR_CMD2 "ttl-security hops <1-254>",
5702 NO_STR
5703 NEIGHBOR_STR
5704 NEIGHBOR_ADDR_STR2
5705 "Specify the maximum number of hops to the BGP peer\n")
5706 {
5707 struct peer *peer;
5708
5709 peer = peer_and_group_lookup_vty (vty, argv[0]);
5710 if (! peer)
5711 return CMD_WARNING;
5712
5713 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
5714 }
5715
5716 DEFUN (neighbor_addpath_tx_all_paths,
5717 neighbor_addpath_tx_all_paths_cmd,
5718 NEIGHBOR_CMD2 "addpath-tx-all-paths",
5719 NEIGHBOR_STR
5720 NEIGHBOR_ADDR_STR2
5721 "Use addpath to advertise all paths to a neighbor\n")
5722 {
5723 struct peer *peer;
5724
5725 peer = peer_and_group_lookup_vty (vty, argv[0]);
5726 if (! peer)
5727 return CMD_WARNING;
5728
5729 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5730 bgp_node_safi (vty),
5731 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5732 }
5733
5734 DEFUN (no_neighbor_addpath_tx_all_paths,
5735 no_neighbor_addpath_tx_all_paths_cmd,
5736 NO_NEIGHBOR_CMD2 "addpath-tx-all-paths",
5737 NO_STR
5738 NEIGHBOR_STR
5739 NEIGHBOR_ADDR_STR2
5740 "Use addpath to advertise all paths to a neighbor\n")
5741 {
5742 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5743 bgp_node_safi (vty),
5744 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
5745 }
5746
5747 DEFUN (neighbor_addpath_tx_bestpath_per_as,
5748 neighbor_addpath_tx_bestpath_per_as_cmd,
5749 NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5750 NEIGHBOR_STR
5751 NEIGHBOR_ADDR_STR2
5752 "Use addpath to advertise the bestpath per each neighboring AS\n")
5753 {
5754 struct peer *peer;
5755
5756 peer = peer_and_group_lookup_vty (vty, argv[0]);
5757 if (! peer)
5758 return CMD_WARNING;
5759
5760 return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
5761 bgp_node_safi (vty),
5762 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5763 }
5764
5765 DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
5766 no_neighbor_addpath_tx_bestpath_per_as_cmd,
5767 NO_NEIGHBOR_CMD2 "addpath-tx-bestpath-per-AS",
5768 NO_STR
5769 NEIGHBOR_STR
5770 NEIGHBOR_ADDR_STR2
5771 "Use addpath to advertise the bestpath per each neighboring AS\n")
5772 {
5773 return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
5774 bgp_node_safi (vty),
5775 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
5776 }
5777
5778
5779 /* Address family configuration. */
5780 DEFUN (address_family_ipv4,
5781 address_family_ipv4_cmd,
5782 "address-family ipv4",
5783 "Enter Address Family command mode\n"
5784 "Address family\n")
5785 {
5786 vty->node = BGP_IPV4_NODE;
5787 return CMD_SUCCESS;
5788 }
5789
5790 DEFUN (address_family_ipv4_safi,
5791 address_family_ipv4_safi_cmd,
5792 "address-family ipv4 (unicast|multicast)",
5793 "Enter Address Family command mode\n"
5794 "Address family\n"
5795 "Address Family modifier\n"
5796 "Address Family modifier\n")
5797 {
5798 if (strncmp (argv[0], "m", 1) == 0)
5799 vty->node = BGP_IPV4M_NODE;
5800 else
5801 vty->node = BGP_IPV4_NODE;
5802
5803 return CMD_SUCCESS;
5804 }
5805
5806 DEFUN (address_family_ipv6,
5807 address_family_ipv6_cmd,
5808 "address-family ipv6",
5809 "Enter Address Family command mode\n"
5810 "Address family\n")
5811 {
5812 vty->node = BGP_IPV6_NODE;
5813 return CMD_SUCCESS;
5814 }
5815
5816 DEFUN (address_family_ipv6_safi,
5817 address_family_ipv6_safi_cmd,
5818 "address-family ipv6 (unicast|multicast)",
5819 "Enter Address Family command mode\n"
5820 "Address family\n"
5821 "Address Family modifier\n"
5822 "Address Family modifier\n")
5823 {
5824 if (strncmp (argv[0], "m", 1) == 0)
5825 vty->node = BGP_IPV6M_NODE;
5826 else
5827 vty->node = BGP_IPV6_NODE;
5828
5829 return CMD_SUCCESS;
5830 }
5831
5832 DEFUN (address_family_vpnv4,
5833 address_family_vpnv4_cmd,
5834 "address-family vpnv4",
5835 "Enter Address Family command mode\n"
5836 "Address family\n")
5837 {
5838 vty->node = BGP_VPNV4_NODE;
5839 return CMD_SUCCESS;
5840 }
5841
5842 ALIAS (address_family_vpnv4,
5843 address_family_vpnv4_unicast_cmd,
5844 "address-family vpnv4 unicast",
5845 "Enter Address Family command mode\n"
5846 "Address family\n"
5847 "Address Family Modifier\n")
5848
5849 DEFUN (exit_address_family,
5850 exit_address_family_cmd,
5851 "exit-address-family",
5852 "Exit from Address Family configuration mode\n")
5853 {
5854 if (vty->node == BGP_IPV4_NODE
5855 || vty->node == BGP_IPV4M_NODE
5856 || vty->node == BGP_VPNV4_NODE
5857 || vty->node == BGP_IPV6_NODE
5858 || vty->node == BGP_IPV6M_NODE)
5859 vty->node = BGP_NODE;
5860 return CMD_SUCCESS;
5861 }
5862
5863 /* Recalculate bestpath and re-advertise a prefix */
5864 static int
5865 bgp_clear_prefix (struct vty *vty, char *view_name, const char *ip_str,
5866 afi_t afi, safi_t safi, struct prefix_rd *prd)
5867 {
5868 int ret;
5869 struct prefix match;
5870 struct bgp_node *rn;
5871 struct bgp_node *rm;
5872 struct bgp *bgp;
5873 struct bgp_table *table;
5874 struct bgp_table *rib;
5875
5876 /* BGP structure lookup. */
5877 if (view_name)
5878 {
5879 bgp = bgp_lookup_by_name (view_name);
5880 if (bgp == NULL)
5881 {
5882 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
5883 return CMD_WARNING;
5884 }
5885 }
5886 else
5887 {
5888 bgp = bgp_get_default ();
5889 if (bgp == NULL)
5890 {
5891 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
5892 return CMD_WARNING;
5893 }
5894 }
5895
5896 /* Check IP address argument. */
5897 ret = str2prefix (ip_str, &match);
5898 if (! ret)
5899 {
5900 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
5901 return CMD_WARNING;
5902 }
5903
5904 match.family = afi2family (afi);
5905 rib = bgp->rib[afi][safi];
5906
5907 if (safi == SAFI_MPLS_VPN)
5908 {
5909 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
5910 {
5911 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5912 continue;
5913
5914 if ((table = rn->info) != NULL)
5915 {
5916 if ((rm = bgp_node_match (table, &match)) != NULL)
5917 {
5918 if (rm->p.prefixlen == match.prefixlen)
5919 {
5920 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5921 bgp_process (bgp, rm, afi, safi);
5922 }
5923 bgp_unlock_node (rm);
5924 }
5925 }
5926 }
5927 }
5928 else
5929 {
5930 if ((rn = bgp_node_match (rib, &match)) != NULL)
5931 {
5932 if (rn->p.prefixlen == match.prefixlen)
5933 {
5934 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
5935 bgp_process (bgp, rn, afi, safi);
5936 }
5937 bgp_unlock_node (rn);
5938 }
5939 }
5940
5941 return CMD_SUCCESS;
5942 }
5943
5944 DEFUN (clear_ip_bgp_all,
5945 clear_ip_bgp_all_cmd,
5946 "clear ip bgp *",
5947 CLEAR_STR
5948 IP_STR
5949 BGP_STR
5950 "Clear all peers\n")
5951 {
5952 if (argc == 2)
5953 return bgp_clear_vty (vty, argv[1], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5954
5955 return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
5956 }
5957
5958 ALIAS (clear_ip_bgp_all,
5959 clear_bgp_all_cmd,
5960 "clear bgp *",
5961 CLEAR_STR
5962 BGP_STR
5963 "Clear all peers\n")
5964
5965 ALIAS (clear_ip_bgp_all,
5966 clear_bgp_ipv6_all_cmd,
5967 "clear bgp ipv6 *",
5968 CLEAR_STR
5969 BGP_STR
5970 "Address family\n"
5971 "Clear all peers\n")
5972
5973 ALIAS (clear_ip_bgp_all,
5974 clear_ip_bgp_instance_all_cmd,
5975 "clear ip bgp " BGP_INSTANCE_CMD " *",
5976 CLEAR_STR
5977 IP_STR
5978 BGP_STR
5979 BGP_INSTANCE_HELP_STR
5980 "Clear all peers\n")
5981
5982 ALIAS (clear_ip_bgp_all,
5983 clear_bgp_instance_all_cmd,
5984 "clear bgp " BGP_INSTANCE_CMD " *",
5985 CLEAR_STR
5986 BGP_STR
5987 BGP_INSTANCE_HELP_STR
5988 "Clear all peers\n")
5989
5990 DEFUN (clear_ip_bgp_peer,
5991 clear_ip_bgp_peer_cmd,
5992 "clear ip bgp (A.B.C.D|X:X::X:X|WORD)",
5993 CLEAR_STR
5994 IP_STR
5995 BGP_STR
5996 "BGP neighbor IP address to clear\n"
5997 "BGP IPv6 neighbor to clear\n"
5998 "BGP neighbor on interface to clear\n")
5999 {
6000 return bgp_clear_vty (vty, NULL, 0, 0, clear_peer, BGP_CLEAR_SOFT_NONE, argv[0]);
6001 }
6002
6003 ALIAS (clear_ip_bgp_peer,
6004 clear_bgp_peer_cmd,
6005 "clear bgp (A.B.C.D|X:X::X:X|WORD)",
6006 CLEAR_STR
6007 BGP_STR
6008 "BGP neighbor address to clear\n"
6009 "BGP IPv6 neighbor to clear\n"
6010 "BGP neighbor on interface to clear\n")
6011
6012 ALIAS (clear_ip_bgp_peer,
6013 clear_bgp_ipv6_peer_cmd,
6014 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD)",
6015 CLEAR_STR
6016 BGP_STR
6017 "Address family\n"
6018 "BGP neighbor address to clear\n"
6019 "BGP IPv6 neighbor to clear\n"
6020 "BGP neighbor on interface to clear\n")
6021
6022 DEFUN (clear_ip_bgp_peer_group,
6023 clear_ip_bgp_peer_group_cmd,
6024 "clear ip bgp peer-group WORD",
6025 CLEAR_STR
6026 IP_STR
6027 BGP_STR
6028 "Clear all members of peer-group\n"
6029 "BGP peer-group name\n")
6030 {
6031 return bgp_clear_vty (vty, NULL, 0, 0, clear_group, BGP_CLEAR_SOFT_NONE, argv[0]);
6032 }
6033
6034 ALIAS (clear_ip_bgp_peer_group,
6035 clear_bgp_peer_group_cmd,
6036 "clear bgp peer-group WORD",
6037 CLEAR_STR
6038 BGP_STR
6039 "Clear all members of peer-group\n"
6040 "BGP peer-group name\n")
6041
6042 ALIAS (clear_ip_bgp_peer_group,
6043 clear_bgp_ipv6_peer_group_cmd,
6044 "clear bgp ipv6 peer-group WORD",
6045 CLEAR_STR
6046 BGP_STR
6047 "Address family\n"
6048 "Clear all members of peer-group\n"
6049 "BGP peer-group name\n")
6050
6051 DEFUN (clear_ip_bgp_external,
6052 clear_ip_bgp_external_cmd,
6053 "clear ip bgp external",
6054 CLEAR_STR
6055 IP_STR
6056 BGP_STR
6057 "Clear all external peers\n")
6058 {
6059 return bgp_clear_vty (vty, NULL, 0, 0, clear_external, BGP_CLEAR_SOFT_NONE, NULL);
6060 }
6061
6062 ALIAS (clear_ip_bgp_external,
6063 clear_bgp_external_cmd,
6064 "clear bgp external",
6065 CLEAR_STR
6066 BGP_STR
6067 "Clear all external peers\n")
6068
6069 ALIAS (clear_ip_bgp_external,
6070 clear_bgp_ipv6_external_cmd,
6071 "clear bgp ipv6 external",
6072 CLEAR_STR
6073 BGP_STR
6074 "Address family\n"
6075 "Clear all external peers\n")
6076
6077 DEFUN (clear_ip_bgp_prefix,
6078 clear_ip_bgp_prefix_cmd,
6079 "clear ip bgp prefix A.B.C.D/M",
6080 CLEAR_STR
6081 IP_STR
6082 BGP_STR
6083 "Clear bestpath and re-advertise\n"
6084 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6085 {
6086 return bgp_clear_prefix (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL);
6087 }
6088
6089 ALIAS (clear_ip_bgp_prefix,
6090 clear_bgp_prefix_cmd,
6091 "clear bgp prefix A.B.C.D/M",
6092 CLEAR_STR
6093 BGP_STR
6094 "Clear bestpath and re-advertise\n"
6095 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6096
6097
6098 DEFUN (clear_ip_bgp_as,
6099 clear_ip_bgp_as_cmd,
6100 "clear ip bgp " CMD_AS_RANGE,
6101 CLEAR_STR
6102 IP_STR
6103 BGP_STR
6104 "Clear peers with the AS number\n")
6105 {
6106 return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
6107 }
6108
6109 ALIAS (clear_ip_bgp_as,
6110 clear_bgp_as_cmd,
6111 "clear bgp " CMD_AS_RANGE,
6112 CLEAR_STR
6113 BGP_STR
6114 "Clear peers with the AS number\n")
6115
6116 ALIAS (clear_ip_bgp_as,
6117 clear_bgp_ipv6_as_cmd,
6118 "clear bgp ipv6 " CMD_AS_RANGE,
6119 CLEAR_STR
6120 BGP_STR
6121 "Address family\n"
6122 "Clear peers with the AS number\n")
6123
6124 /* Outbound soft-reconfiguration */
6125 DEFUN (clear_ip_bgp_all_soft_out,
6126 clear_ip_bgp_all_soft_out_cmd,
6127 "clear ip bgp * soft out",
6128 CLEAR_STR
6129 IP_STR
6130 BGP_STR
6131 "Clear all peers\n"
6132 BGP_SOFT_STR
6133 BGP_SOFT_OUT_STR)
6134 {
6135 if (argc == 2)
6136 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6137 BGP_CLEAR_SOFT_OUT, NULL);
6138
6139 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6140 BGP_CLEAR_SOFT_OUT, NULL);
6141 }
6142
6143 ALIAS (clear_ip_bgp_all_soft_out,
6144 clear_ip_bgp_all_out_cmd,
6145 "clear ip bgp * out",
6146 CLEAR_STR
6147 IP_STR
6148 BGP_STR
6149 "Clear all peers\n"
6150 BGP_SOFT_OUT_STR)
6151
6152 ALIAS (clear_ip_bgp_all_soft_out,
6153 clear_ip_bgp_instance_all_soft_out_cmd,
6154 "clear ip bgp " BGP_INSTANCE_CMD " * soft out",
6155 CLEAR_STR
6156 IP_STR
6157 BGP_STR
6158 BGP_INSTANCE_HELP_STR
6159 "Clear all peers\n"
6160 BGP_SOFT_STR
6161 BGP_SOFT_OUT_STR)
6162
6163 DEFUN (clear_ip_bgp_all_ipv4_soft_out,
6164 clear_ip_bgp_all_ipv4_soft_out_cmd,
6165 "clear ip bgp * ipv4 (unicast|multicast) soft out",
6166 CLEAR_STR
6167 IP_STR
6168 BGP_STR
6169 "Clear all peers\n"
6170 "Address family\n"
6171 "Address Family modifier\n"
6172 "Address Family modifier\n"
6173 BGP_SOFT_STR
6174 BGP_SOFT_OUT_STR)
6175 {
6176 if (strncmp (argv[0], "m", 1) == 0)
6177 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6178 BGP_CLEAR_SOFT_OUT, NULL);
6179
6180 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6181 BGP_CLEAR_SOFT_OUT, NULL);
6182 }
6183
6184 ALIAS (clear_ip_bgp_all_ipv4_soft_out,
6185 clear_ip_bgp_all_ipv4_out_cmd,
6186 "clear ip bgp * ipv4 (unicast|multicast) out",
6187 CLEAR_STR
6188 IP_STR
6189 BGP_STR
6190 "Clear all peers\n"
6191 "Address family\n"
6192 "Address Family modifier\n"
6193 "Address Family modifier\n"
6194 BGP_SOFT_OUT_STR)
6195
6196 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out,
6197 clear_ip_bgp_instance_all_ipv4_soft_out_cmd,
6198 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out",
6199 CLEAR_STR
6200 IP_STR
6201 BGP_STR
6202 BGP_INSTANCE_HELP_STR
6203 "Clear all peers\n"
6204 "Address family\n"
6205 "Address Family modifier\n"
6206 "Address Family modifier\n"
6207 BGP_SOFT_OUT_STR)
6208 {
6209 if (strncmp (argv[2], "m", 1) == 0)
6210 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
6211 BGP_CLEAR_SOFT_OUT, NULL);
6212
6213 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6214 BGP_CLEAR_SOFT_OUT, NULL);
6215 }
6216
6217 DEFUN (clear_ip_bgp_all_vpnv4_soft_out,
6218 clear_ip_bgp_all_vpnv4_soft_out_cmd,
6219 "clear ip bgp * vpnv4 unicast soft out",
6220 CLEAR_STR
6221 IP_STR
6222 BGP_STR
6223 "Clear all peers\n"
6224 "Address family\n"
6225 "Address Family Modifier\n"
6226 BGP_SOFT_STR
6227 BGP_SOFT_OUT_STR)
6228 {
6229 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6230 BGP_CLEAR_SOFT_OUT, NULL);
6231 }
6232
6233 ALIAS (clear_ip_bgp_all_vpnv4_soft_out,
6234 clear_ip_bgp_all_vpnv4_out_cmd,
6235 "clear ip bgp * vpnv4 unicast out",
6236 CLEAR_STR
6237 IP_STR
6238 BGP_STR
6239 "Clear all peers\n"
6240 "Address family\n"
6241 "Address Family Modifier\n"
6242 BGP_SOFT_OUT_STR)
6243
6244 DEFUN (clear_bgp_all_soft_out,
6245 clear_bgp_all_soft_out_cmd,
6246 "clear bgp * soft out",
6247 CLEAR_STR
6248 BGP_STR
6249 "Clear all peers\n"
6250 BGP_SOFT_STR
6251 BGP_SOFT_OUT_STR)
6252 {
6253 if (argc == 2)
6254 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
6255 BGP_CLEAR_SOFT_OUT, NULL);
6256
6257 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6258 BGP_CLEAR_SOFT_OUT, NULL);
6259 }
6260
6261 ALIAS (clear_bgp_all_soft_out,
6262 clear_bgp_instance_all_soft_out_cmd,
6263 "clear bgp " BGP_INSTANCE_CMD " * soft out",
6264 CLEAR_STR
6265 BGP_STR
6266 BGP_INSTANCE_HELP_STR
6267 "Clear all peers\n"
6268 BGP_SOFT_STR
6269 BGP_SOFT_OUT_STR)
6270
6271 ALIAS (clear_bgp_all_soft_out,
6272 clear_bgp_all_out_cmd,
6273 "clear bgp * out",
6274 CLEAR_STR
6275 BGP_STR
6276 "Clear all peers\n"
6277 BGP_SOFT_OUT_STR)
6278
6279 ALIAS (clear_bgp_all_soft_out,
6280 clear_bgp_ipv6_all_soft_out_cmd,
6281 "clear bgp ipv6 * soft out",
6282 CLEAR_STR
6283 BGP_STR
6284 "Address family\n"
6285 "Clear all peers\n"
6286 BGP_SOFT_STR
6287 BGP_SOFT_OUT_STR)
6288
6289 ALIAS (clear_bgp_all_soft_out,
6290 clear_bgp_ipv6_all_out_cmd,
6291 "clear bgp ipv6 * out",
6292 CLEAR_STR
6293 BGP_STR
6294 "Address family\n"
6295 "Clear all peers\n"
6296 BGP_SOFT_OUT_STR)
6297
6298 DEFUN (clear_bgp_ipv6_safi_prefix,
6299 clear_bgp_ipv6_safi_prefix_cmd,
6300 "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M",
6301 CLEAR_STR
6302 BGP_STR
6303 "Address family\n"
6304 "Address Family Modifier\n"
6305 "Clear bestpath and re-advertise\n"
6306 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6307 {
6308 if (strncmp (argv[0], "m", 1) == 0)
6309 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL);
6310 else
6311 return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL);
6312 }
6313
6314 DEFUN (clear_ip_bgp_peer_soft_out,
6315 clear_ip_bgp_peer_soft_out_cmd,
6316 "clear ip bgp (A.B.C.D|WORD) soft out",
6317 CLEAR_STR
6318 IP_STR
6319 BGP_STR
6320 "BGP neighbor address to clear\n"
6321 "BGP neighbor on interface to clear\n"
6322 BGP_SOFT_STR
6323 BGP_SOFT_OUT_STR)
6324 {
6325 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6326 BGP_CLEAR_SOFT_OUT, argv[0]);
6327 }
6328
6329 ALIAS (clear_ip_bgp_peer_soft_out,
6330 clear_ip_bgp_peer_out_cmd,
6331 "clear ip bgp (A.B.C.D|WORD) out",
6332 CLEAR_STR
6333 IP_STR
6334 BGP_STR
6335 "BGP neighbor address to clear\n"
6336 "BGP neighbor on interface to clear\n"
6337 BGP_SOFT_OUT_STR)
6338
6339 DEFUN (clear_ip_bgp_peer_ipv4_soft_out,
6340 clear_ip_bgp_peer_ipv4_soft_out_cmd,
6341 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out",
6342 CLEAR_STR
6343 IP_STR
6344 BGP_STR
6345 "BGP neighbor address to clear\n"
6346 "BGP neighbor on interface to clear\n"
6347 "Address family\n"
6348 "Address Family modifier\n"
6349 "Address Family modifier\n"
6350 BGP_SOFT_STR
6351 BGP_SOFT_OUT_STR)
6352 {
6353 if (strncmp (argv[1], "m", 1) == 0)
6354 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
6355 BGP_CLEAR_SOFT_OUT, argv[0]);
6356
6357 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
6358 BGP_CLEAR_SOFT_OUT, argv[0]);
6359 }
6360
6361 ALIAS (clear_ip_bgp_peer_ipv4_soft_out,
6362 clear_ip_bgp_peer_ipv4_out_cmd,
6363 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out",
6364 CLEAR_STR
6365 IP_STR
6366 BGP_STR
6367 "BGP neighbor address to clear\n"
6368 "BGP neighbor on interface to clear\n"
6369 "Address family\n"
6370 "Address Family modifier\n"
6371 "Address Family modifier\n"
6372 BGP_SOFT_OUT_STR)
6373
6374 /* NOTE: WORD peers have not been tested for vpnv4 */
6375 DEFUN (clear_ip_bgp_peer_vpnv4_soft_out,
6376 clear_ip_bgp_peer_vpnv4_soft_out_cmd,
6377 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out",
6378 CLEAR_STR
6379 IP_STR
6380 BGP_STR
6381 "BGP neighbor address to clear\n"
6382 "BGP neighbor on interface to clear\n"
6383 "Address family\n"
6384 "Address Family Modifier\n"
6385 BGP_SOFT_STR
6386 BGP_SOFT_OUT_STR)
6387 {
6388 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
6389 BGP_CLEAR_SOFT_OUT, argv[0]);
6390 }
6391
6392 ALIAS (clear_ip_bgp_peer_vpnv4_soft_out,
6393 clear_ip_bgp_peer_vpnv4_out_cmd,
6394 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out",
6395 CLEAR_STR
6396 IP_STR
6397 BGP_STR
6398 "BGP neighbor address to clear\n"
6399 "BGP neighbor on interface to clear\n"
6400 "Address family\n"
6401 "Address Family Modifier\n"
6402 BGP_SOFT_OUT_STR)
6403
6404 DEFUN (clear_bgp_peer_soft_out,
6405 clear_bgp_peer_soft_out_cmd,
6406 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out",
6407 CLEAR_STR
6408 BGP_STR
6409 "BGP neighbor address to clear\n"
6410 "BGP IPv6 neighbor to clear\n"
6411 "BGP neighbor on interface to clear\n"
6412 BGP_SOFT_STR
6413 BGP_SOFT_OUT_STR)
6414 {
6415 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
6416 BGP_CLEAR_SOFT_OUT, argv[0]);
6417 }
6418
6419 ALIAS (clear_bgp_peer_soft_out,
6420 clear_bgp_ipv6_peer_soft_out_cmd,
6421 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft out",
6422 CLEAR_STR
6423 BGP_STR
6424 "Address family\n"
6425 "BGP neighbor address to clear\n"
6426 "BGP IPv6 neighbor to clear\n"
6427 "BGP neighbor on interface to clear\n"
6428 BGP_SOFT_STR
6429 BGP_SOFT_OUT_STR)
6430
6431 ALIAS (clear_bgp_peer_soft_out,
6432 clear_bgp_peer_out_cmd,
6433 "clear bgp (A.B.C.D|X:X::X:X|WORD) out",
6434 CLEAR_STR
6435 BGP_STR
6436 "BGP neighbor address to clear\n"
6437 "BGP IPv6 neighbor to clear\n"
6438 "BGP neighbor on interface to clear\n"
6439 BGP_SOFT_OUT_STR)
6440
6441 ALIAS (clear_bgp_peer_soft_out,
6442 clear_bgp_ipv6_peer_out_cmd,
6443 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) out",
6444 CLEAR_STR
6445 BGP_STR
6446 "Address family\n"
6447 "BGP neighbor address to clear\n"
6448 "BGP IPv6 neighbor to clear\n"
6449 "BGP neighbor on interface to clear\n"
6450 BGP_SOFT_OUT_STR)
6451
6452 DEFUN (clear_ip_bgp_peer_group_soft_out,
6453 clear_ip_bgp_peer_group_soft_out_cmd,
6454 "clear ip bgp peer-group WORD soft out",
6455 CLEAR_STR
6456 IP_STR
6457 BGP_STR
6458 "Clear all members of peer-group\n"
6459 "BGP peer-group name\n"
6460 BGP_SOFT_STR
6461 BGP_SOFT_OUT_STR)
6462 {
6463 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6464 BGP_CLEAR_SOFT_OUT, argv[0]);
6465 }
6466
6467 ALIAS (clear_ip_bgp_peer_group_soft_out,
6468 clear_ip_bgp_peer_group_out_cmd,
6469 "clear ip bgp peer-group WORD out",
6470 CLEAR_STR
6471 IP_STR
6472 BGP_STR
6473 "Clear all members of peer-group\n"
6474 "BGP peer-group name\n"
6475 BGP_SOFT_OUT_STR)
6476
6477 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out,
6478 clear_ip_bgp_peer_group_ipv4_soft_out_cmd,
6479 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out",
6480 CLEAR_STR
6481 IP_STR
6482 BGP_STR
6483 "Clear all members of peer-group\n"
6484 "BGP peer-group name\n"
6485 "Address family\n"
6486 "Address Family modifier\n"
6487 "Address Family modifier\n"
6488 BGP_SOFT_STR
6489 BGP_SOFT_OUT_STR)
6490 {
6491 if (strncmp (argv[1], "m", 1) == 0)
6492 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
6493 BGP_CLEAR_SOFT_OUT, argv[0]);
6494
6495 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
6496 BGP_CLEAR_SOFT_OUT, argv[0]);
6497 }
6498
6499 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out,
6500 clear_ip_bgp_peer_group_ipv4_out_cmd,
6501 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out",
6502 CLEAR_STR
6503 IP_STR
6504 BGP_STR
6505 "Clear all members of peer-group\n"
6506 "BGP peer-group name\n"
6507 "Address family\n"
6508 "Address Family modifier\n"
6509 "Address Family modifier\n"
6510 BGP_SOFT_OUT_STR)
6511
6512 DEFUN (clear_bgp_peer_group_soft_out,
6513 clear_bgp_peer_group_soft_out_cmd,
6514 "clear bgp peer-group WORD soft out",
6515 CLEAR_STR
6516 BGP_STR
6517 "Clear all members of peer-group\n"
6518 "BGP peer-group name\n"
6519 BGP_SOFT_STR
6520 BGP_SOFT_OUT_STR)
6521 {
6522 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
6523 BGP_CLEAR_SOFT_OUT, argv[0]);
6524 }
6525
6526 ALIAS (clear_bgp_peer_group_soft_out,
6527 clear_bgp_ipv6_peer_group_soft_out_cmd,
6528 "clear bgp ipv6 peer-group WORD soft out",
6529 CLEAR_STR
6530 BGP_STR
6531 "Address family\n"
6532 "Clear all members of peer-group\n"
6533 "BGP peer-group name\n"
6534 BGP_SOFT_STR
6535 BGP_SOFT_OUT_STR)
6536
6537 ALIAS (clear_bgp_peer_group_soft_out,
6538 clear_bgp_peer_group_out_cmd,
6539 "clear bgp peer-group WORD out",
6540 CLEAR_STR
6541 BGP_STR
6542 "Clear all members of peer-group\n"
6543 "BGP peer-group name\n"
6544 BGP_SOFT_OUT_STR)
6545
6546 ALIAS (clear_bgp_peer_group_soft_out,
6547 clear_bgp_ipv6_peer_group_out_cmd,
6548 "clear bgp ipv6 peer-group WORD out",
6549 CLEAR_STR
6550 BGP_STR
6551 "Address family\n"
6552 "Clear all members of peer-group\n"
6553 "BGP peer-group name\n"
6554 BGP_SOFT_OUT_STR)
6555
6556 DEFUN (clear_ip_bgp_external_soft_out,
6557 clear_ip_bgp_external_soft_out_cmd,
6558 "clear ip bgp external soft out",
6559 CLEAR_STR
6560 IP_STR
6561 BGP_STR
6562 "Clear all external peers\n"
6563 BGP_SOFT_STR
6564 BGP_SOFT_OUT_STR)
6565 {
6566 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6567 BGP_CLEAR_SOFT_OUT, NULL);
6568 }
6569
6570 ALIAS (clear_ip_bgp_external_soft_out,
6571 clear_ip_bgp_external_out_cmd,
6572 "clear ip bgp external out",
6573 CLEAR_STR
6574 IP_STR
6575 BGP_STR
6576 "Clear all external peers\n"
6577 BGP_SOFT_OUT_STR)
6578
6579 DEFUN (clear_ip_bgp_external_ipv4_soft_out,
6580 clear_ip_bgp_external_ipv4_soft_out_cmd,
6581 "clear ip bgp external ipv4 (unicast|multicast) soft out",
6582 CLEAR_STR
6583 IP_STR
6584 BGP_STR
6585 "Clear all external peers\n"
6586 "Address family\n"
6587 "Address Family modifier\n"
6588 "Address Family modifier\n"
6589 BGP_SOFT_STR
6590 BGP_SOFT_OUT_STR)
6591 {
6592 if (strncmp (argv[0], "m", 1) == 0)
6593 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
6594 BGP_CLEAR_SOFT_OUT, NULL);
6595
6596 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
6597 BGP_CLEAR_SOFT_OUT, NULL);
6598 }
6599
6600 ALIAS (clear_ip_bgp_external_ipv4_soft_out,
6601 clear_ip_bgp_external_ipv4_out_cmd,
6602 "clear ip bgp external ipv4 (unicast|multicast) out",
6603 CLEAR_STR
6604 IP_STR
6605 BGP_STR
6606 "Clear all external peers\n"
6607 "Address family\n"
6608 "Address Family modifier\n"
6609 "Address Family modifier\n"
6610 BGP_SOFT_OUT_STR)
6611
6612 DEFUN (clear_bgp_external_soft_out,
6613 clear_bgp_external_soft_out_cmd,
6614 "clear bgp external soft out",
6615 CLEAR_STR
6616 BGP_STR
6617 "Clear all external peers\n"
6618 BGP_SOFT_STR
6619 BGP_SOFT_OUT_STR)
6620 {
6621 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
6622 BGP_CLEAR_SOFT_OUT, NULL);
6623 }
6624
6625 ALIAS (clear_bgp_external_soft_out,
6626 clear_bgp_ipv6_external_soft_out_cmd,
6627 "clear bgp ipv6 external soft out",
6628 CLEAR_STR
6629 BGP_STR
6630 "Address family\n"
6631 "Clear all external peers\n"
6632 BGP_SOFT_STR
6633 BGP_SOFT_OUT_STR)
6634
6635 ALIAS (clear_bgp_external_soft_out,
6636 clear_bgp_external_out_cmd,
6637 "clear bgp external out",
6638 CLEAR_STR
6639 BGP_STR
6640 "Clear all external peers\n"
6641 BGP_SOFT_OUT_STR)
6642
6643 ALIAS (clear_bgp_external_soft_out,
6644 clear_bgp_ipv6_external_out_cmd,
6645 "clear bgp ipv6 external WORD out",
6646 CLEAR_STR
6647 BGP_STR
6648 "Address family\n"
6649 "Clear all external peers\n"
6650 BGP_SOFT_OUT_STR)
6651
6652 DEFUN (clear_ip_bgp_as_soft_out,
6653 clear_ip_bgp_as_soft_out_cmd,
6654 "clear ip bgp " CMD_AS_RANGE " soft out",
6655 CLEAR_STR
6656 IP_STR
6657 BGP_STR
6658 "Clear peers with the AS number\n"
6659 BGP_SOFT_STR
6660 BGP_SOFT_OUT_STR)
6661 {
6662 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6663 BGP_CLEAR_SOFT_OUT, argv[0]);
6664 }
6665
6666 ALIAS (clear_ip_bgp_as_soft_out,
6667 clear_ip_bgp_as_out_cmd,
6668 "clear ip bgp " CMD_AS_RANGE " out",
6669 CLEAR_STR
6670 IP_STR
6671 BGP_STR
6672 "Clear peers with the AS number\n"
6673 BGP_SOFT_OUT_STR)
6674
6675 DEFUN (clear_ip_bgp_as_ipv4_soft_out,
6676 clear_ip_bgp_as_ipv4_soft_out_cmd,
6677 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
6678 CLEAR_STR
6679 IP_STR
6680 BGP_STR
6681 "Clear peers with the AS number\n"
6682 "Address family\n"
6683 "Address Family modifier\n"
6684 "Address Family modifier\n"
6685 BGP_SOFT_STR
6686 BGP_SOFT_OUT_STR)
6687 {
6688 if (strncmp (argv[1], "m", 1) == 0)
6689 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
6690 BGP_CLEAR_SOFT_OUT, argv[0]);
6691
6692 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
6693 BGP_CLEAR_SOFT_OUT, argv[0]);
6694 }
6695
6696 ALIAS (clear_ip_bgp_as_ipv4_soft_out,
6697 clear_ip_bgp_as_ipv4_out_cmd,
6698 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
6699 CLEAR_STR
6700 IP_STR
6701 BGP_STR
6702 "Clear peers with the AS number\n"
6703 "Address family\n"
6704 "Address Family modifier\n"
6705 "Address Family modifier\n"
6706 BGP_SOFT_OUT_STR)
6707
6708 DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
6709 clear_ip_bgp_as_vpnv4_soft_out_cmd,
6710 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
6711 CLEAR_STR
6712 IP_STR
6713 BGP_STR
6714 "Clear peers with the AS number\n"
6715 "Address family\n"
6716 "Address Family modifier\n"
6717 BGP_SOFT_STR
6718 BGP_SOFT_OUT_STR)
6719 {
6720 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
6721 BGP_CLEAR_SOFT_OUT, argv[0]);
6722 }
6723
6724 ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
6725 clear_ip_bgp_as_vpnv4_out_cmd,
6726 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
6727 CLEAR_STR
6728 IP_STR
6729 BGP_STR
6730 "Clear peers with the AS number\n"
6731 "Address family\n"
6732 "Address Family modifier\n"
6733 BGP_SOFT_OUT_STR)
6734
6735 DEFUN (clear_bgp_as_soft_out,
6736 clear_bgp_as_soft_out_cmd,
6737 "clear bgp " CMD_AS_RANGE " soft out",
6738 CLEAR_STR
6739 BGP_STR
6740 "Clear peers with the AS number\n"
6741 BGP_SOFT_STR
6742 BGP_SOFT_OUT_STR)
6743 {
6744 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
6745 BGP_CLEAR_SOFT_OUT, argv[0]);
6746 }
6747
6748 ALIAS (clear_bgp_as_soft_out,
6749 clear_bgp_ipv6_as_soft_out_cmd,
6750 "clear bgp ipv6 " CMD_AS_RANGE " soft out",
6751 CLEAR_STR
6752 BGP_STR
6753 "Address family\n"
6754 "Clear peers with the AS number\n"
6755 BGP_SOFT_STR
6756 BGP_SOFT_OUT_STR)
6757
6758 ALIAS (clear_bgp_as_soft_out,
6759 clear_bgp_as_out_cmd,
6760 "clear bgp " CMD_AS_RANGE " out",
6761 CLEAR_STR
6762 BGP_STR
6763 "Clear peers with the AS number\n"
6764 BGP_SOFT_OUT_STR)
6765
6766 ALIAS (clear_bgp_as_soft_out,
6767 clear_bgp_ipv6_as_out_cmd,
6768 "clear bgp ipv6 " CMD_AS_RANGE " out",
6769 CLEAR_STR
6770 BGP_STR
6771 "Address family\n"
6772 "Clear peers with the AS number\n"
6773 BGP_SOFT_OUT_STR)
6774
6775 /* Inbound soft-reconfiguration */
6776 DEFUN (clear_ip_bgp_all_soft_in,
6777 clear_ip_bgp_all_soft_in_cmd,
6778 "clear ip bgp * soft in",
6779 CLEAR_STR
6780 IP_STR
6781 BGP_STR
6782 "Clear all peers\n"
6783 BGP_SOFT_STR
6784 BGP_SOFT_IN_STR)
6785 {
6786 if (argc == 2)
6787 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6788 BGP_CLEAR_SOFT_IN, NULL);
6789
6790 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6791 BGP_CLEAR_SOFT_IN, NULL);
6792 }
6793
6794 ALIAS (clear_ip_bgp_all_soft_in,
6795 clear_ip_bgp_instance_all_soft_in_cmd,
6796 "clear ip bgp " BGP_INSTANCE_CMD " * soft in",
6797 CLEAR_STR
6798 IP_STR
6799 BGP_STR
6800 BGP_INSTANCE_HELP_STR
6801 "Clear all peers\n"
6802 BGP_SOFT_STR
6803 BGP_SOFT_IN_STR)
6804
6805 ALIAS (clear_ip_bgp_all_soft_in,
6806 clear_ip_bgp_all_in_cmd,
6807 "clear ip bgp * in",
6808 CLEAR_STR
6809 IP_STR
6810 BGP_STR
6811 "Clear all peers\n"
6812 BGP_SOFT_IN_STR)
6813
6814 DEFUN (clear_ip_bgp_all_in_prefix_filter,
6815 clear_ip_bgp_all_in_prefix_filter_cmd,
6816 "clear ip bgp * in prefix-filter",
6817 CLEAR_STR
6818 IP_STR
6819 BGP_STR
6820 "Clear all peers\n"
6821 BGP_SOFT_IN_STR
6822 "Push out prefix-list ORF and do inbound soft reconfig\n")
6823 {
6824 if (argc== 2)
6825 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6826 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6827
6828 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6829 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6830 }
6831
6832 ALIAS (clear_ip_bgp_all_in_prefix_filter,
6833 clear_ip_bgp_instance_all_in_prefix_filter_cmd,
6834 "clear ip bgp " BGP_INSTANCE_CMD " * in prefix-filter",
6835 CLEAR_STR
6836 IP_STR
6837 BGP_STR
6838 BGP_INSTANCE_HELP_STR
6839 "Clear all peers\n"
6840 BGP_SOFT_IN_STR
6841 "Push out prefix-list ORF and do inbound soft reconfig\n")
6842
6843
6844 DEFUN (clear_ip_bgp_all_ipv4_soft_in,
6845 clear_ip_bgp_all_ipv4_soft_in_cmd,
6846 "clear ip bgp * ipv4 (unicast|multicast) soft in",
6847 CLEAR_STR
6848 IP_STR
6849 BGP_STR
6850 "Clear all peers\n"
6851 "Address family\n"
6852 "Address Family modifier\n"
6853 "Address Family modifier\n"
6854 BGP_SOFT_STR
6855 BGP_SOFT_IN_STR)
6856 {
6857 if (strncmp (argv[0], "m", 1) == 0)
6858 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6859 BGP_CLEAR_SOFT_IN, NULL);
6860
6861 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6862 BGP_CLEAR_SOFT_IN, NULL);
6863 }
6864
6865 ALIAS (clear_ip_bgp_all_ipv4_soft_in,
6866 clear_ip_bgp_all_ipv4_in_cmd,
6867 "clear ip bgp * ipv4 (unicast|multicast) in",
6868 CLEAR_STR
6869 IP_STR
6870 BGP_STR
6871 "Clear all peers\n"
6872 "Address family\n"
6873 "Address Family modifier\n"
6874 "Address Family modifier\n"
6875 BGP_SOFT_IN_STR)
6876
6877 DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in,
6878 clear_ip_bgp_instance_all_ipv4_soft_in_cmd,
6879 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in",
6880 CLEAR_STR
6881 IP_STR
6882 BGP_STR
6883 BGP_INSTANCE_HELP_STR
6884 "Clear all peers\n"
6885 "Address family\n"
6886 "Address Family modifier\n"
6887 "Address Family modifier\n"
6888 BGP_SOFT_STR
6889 BGP_SOFT_IN_STR)
6890 {
6891 if (strncmp (argv[2], "m", 1) == 0)
6892 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
6893 BGP_CLEAR_SOFT_IN, NULL);
6894
6895 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
6896 BGP_CLEAR_SOFT_IN, NULL);
6897 }
6898
6899 DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter,
6900 clear_ip_bgp_all_ipv4_in_prefix_filter_cmd,
6901 "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter",
6902 CLEAR_STR
6903 IP_STR
6904 BGP_STR
6905 "Clear all peers\n"
6906 "Address family\n"
6907 "Address Family modifier\n"
6908 "Address Family modifier\n"
6909 BGP_SOFT_IN_STR
6910 "Push out prefix-list ORF and do inbound soft reconfig\n")
6911 {
6912 if (strncmp (argv[0], "m", 1) == 0)
6913 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
6914 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6915
6916 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
6917 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6918 }
6919
6920 DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter,
6921 clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd,
6922 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in prefix-filter",
6923 CLEAR_STR
6924 IP_STR
6925 BGP_STR
6926 "Clear all peers\n"
6927 "Address family\n"
6928 "Address Family modifier\n"
6929 "Address Family modifier\n"
6930 BGP_SOFT_IN_STR
6931 "Push out prefix-list ORF and do inbound soft reconfig\n")
6932 {
6933 if (strncmp (argv[2], "m", 1) == 0)
6934 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
6935 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6936
6937 return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all,
6938 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
6939 }
6940
6941 DEFUN (clear_ip_bgp_all_vpnv4_soft_in,
6942 clear_ip_bgp_all_vpnv4_soft_in_cmd,
6943 "clear ip bgp * vpnv4 unicast soft in",
6944 CLEAR_STR
6945 IP_STR
6946 BGP_STR
6947 "Clear all peers\n"
6948 "Address family\n"
6949 "Address Family Modifier\n"
6950 BGP_SOFT_STR
6951 BGP_SOFT_IN_STR)
6952 {
6953 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
6954 BGP_CLEAR_SOFT_IN, NULL);
6955 }
6956
6957 ALIAS (clear_ip_bgp_all_vpnv4_soft_in,
6958 clear_ip_bgp_all_vpnv4_in_cmd,
6959 "clear ip bgp * vpnv4 unicast in",
6960 CLEAR_STR
6961 IP_STR
6962 BGP_STR
6963 "Clear all peers\n"
6964 "Address family\n"
6965 "Address Family Modifier\n"
6966 BGP_SOFT_IN_STR)
6967
6968 DEFUN (clear_bgp_all_soft_in,
6969 clear_bgp_all_soft_in_cmd,
6970 "clear bgp * soft in",
6971 CLEAR_STR
6972 BGP_STR
6973 "Clear all peers\n"
6974 BGP_SOFT_STR
6975 BGP_SOFT_IN_STR)
6976 {
6977 if (argc == 2)
6978 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
6979 BGP_CLEAR_SOFT_IN, NULL);
6980
6981 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
6982 BGP_CLEAR_SOFT_IN, NULL);
6983 }
6984
6985 ALIAS (clear_bgp_all_soft_in,
6986 clear_bgp_instance_all_soft_in_cmd,
6987 "clear bgp " BGP_INSTANCE_CMD " * soft in",
6988 CLEAR_STR
6989 BGP_STR
6990 BGP_INSTANCE_HELP_STR
6991 "Clear all peers\n"
6992 BGP_SOFT_STR
6993 BGP_SOFT_IN_STR)
6994
6995 ALIAS (clear_bgp_all_soft_in,
6996 clear_bgp_ipv6_all_soft_in_cmd,
6997 "clear bgp ipv6 * soft in",
6998 CLEAR_STR
6999 BGP_STR
7000 "Address family\n"
7001 "Clear all peers\n"
7002 BGP_SOFT_STR
7003 BGP_SOFT_IN_STR)
7004
7005 ALIAS (clear_bgp_all_soft_in,
7006 clear_bgp_all_in_cmd,
7007 "clear bgp * in",
7008 CLEAR_STR
7009 BGP_STR
7010 "Clear all peers\n"
7011 BGP_SOFT_IN_STR)
7012
7013 ALIAS (clear_bgp_all_soft_in,
7014 clear_bgp_ipv6_all_in_cmd,
7015 "clear bgp ipv6 * in",
7016 CLEAR_STR
7017 BGP_STR
7018 "Address family\n"
7019 "Clear all peers\n"
7020 BGP_SOFT_IN_STR)
7021
7022 DEFUN (clear_bgp_all_in_prefix_filter,
7023 clear_bgp_all_in_prefix_filter_cmd,
7024 "clear bgp * in prefix-filter",
7025 CLEAR_STR
7026 BGP_STR
7027 "Clear all peers\n"
7028 BGP_SOFT_IN_STR
7029 "Push out prefix-list ORF and do inbound soft reconfig\n")
7030 {
7031 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7032 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7033 }
7034
7035 ALIAS (clear_bgp_all_in_prefix_filter,
7036 clear_bgp_ipv6_all_in_prefix_filter_cmd,
7037 "clear bgp ipv6 * in prefix-filter",
7038 CLEAR_STR
7039 BGP_STR
7040 "Address family\n"
7041 "Clear all peers\n"
7042 BGP_SOFT_IN_STR
7043 "Push out prefix-list ORF and do inbound soft reconfig\n")
7044
7045 DEFUN (clear_ip_bgp_peer_soft_in,
7046 clear_ip_bgp_peer_soft_in_cmd,
7047 "clear ip bgp (A.B.C.D|WORD) soft in",
7048 CLEAR_STR
7049 IP_STR
7050 BGP_STR
7051 "BGP neighbor address to clear\n"
7052 "BGP neighbor on interface to clear\n"
7053 BGP_SOFT_STR
7054 BGP_SOFT_IN_STR)
7055 {
7056 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7057 BGP_CLEAR_SOFT_IN, argv[0]);
7058 }
7059
7060 ALIAS (clear_ip_bgp_peer_soft_in,
7061 clear_ip_bgp_peer_in_cmd,
7062 "clear ip bgp (A.B.C.D|WORD) in",
7063 CLEAR_STR
7064 IP_STR
7065 BGP_STR
7066 "BGP neighbor address to clear\n"
7067 "BGP neighbor on interface to clear\n"
7068 BGP_SOFT_IN_STR)
7069
7070 DEFUN (clear_ip_bgp_peer_in_prefix_filter,
7071 clear_ip_bgp_peer_in_prefix_filter_cmd,
7072 "clear ip bgp (A.B.C.D|WORD) in prefix-filter",
7073 CLEAR_STR
7074 IP_STR
7075 BGP_STR
7076 "BGP neighbor address to clear\n"
7077 "BGP neighbor on interface to clear\n"
7078 BGP_SOFT_IN_STR
7079 "Push out the existing ORF prefix-list\n")
7080 {
7081 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7082 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7083 }
7084
7085 DEFUN (clear_ip_bgp_peer_ipv4_soft_in,
7086 clear_ip_bgp_peer_ipv4_soft_in_cmd,
7087 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in",
7088 CLEAR_STR
7089 IP_STR
7090 BGP_STR
7091 "BGP neighbor address to clear\n"
7092 "BGP neighbor on interface to clear\n"
7093 "Address family\n"
7094 "Address Family modifier\n"
7095 "Address Family modifier\n"
7096 BGP_SOFT_STR
7097 BGP_SOFT_IN_STR)
7098 {
7099 if (strncmp (argv[1], "m", 1) == 0)
7100 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7101 BGP_CLEAR_SOFT_IN, argv[0]);
7102
7103 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7104 BGP_CLEAR_SOFT_IN, argv[0]);
7105 }
7106
7107 ALIAS (clear_ip_bgp_peer_ipv4_soft_in,
7108 clear_ip_bgp_peer_ipv4_in_cmd,
7109 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in",
7110 CLEAR_STR
7111 IP_STR
7112 BGP_STR
7113 "BGP neighbor address to clear\n"
7114 "BGP neighbor on interface to clear\n"
7115 "Address family\n"
7116 "Address Family modifier\n"
7117 "Address Family modifier\n"
7118 BGP_SOFT_IN_STR)
7119
7120 DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter,
7121 clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd,
7122 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter",
7123 CLEAR_STR
7124 IP_STR
7125 BGP_STR
7126 "BGP neighbor address to clear\n"
7127 "BGP neighbor on interface to clear\n"
7128 "Address family\n"
7129 "Address Family modifier\n"
7130 "Address Family modifier\n"
7131 BGP_SOFT_IN_STR
7132 "Push out the existing ORF prefix-list\n")
7133 {
7134 if (strncmp (argv[1], "m", 1) == 0)
7135 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7136 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7137
7138 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7139 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7140 }
7141
7142 DEFUN (clear_ip_bgp_peer_vpnv4_soft_in,
7143 clear_ip_bgp_peer_vpnv4_soft_in_cmd,
7144 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in",
7145 CLEAR_STR
7146 IP_STR
7147 BGP_STR
7148 "BGP neighbor address to clear\n"
7149 "BGP neighbor on interface to clear\n"
7150 "Address family\n"
7151 "Address Family Modifier\n"
7152 BGP_SOFT_STR
7153 BGP_SOFT_IN_STR)
7154 {
7155 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7156 BGP_CLEAR_SOFT_IN, argv[0]);
7157 }
7158
7159 ALIAS (clear_ip_bgp_peer_vpnv4_soft_in,
7160 clear_ip_bgp_peer_vpnv4_in_cmd,
7161 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in",
7162 CLEAR_STR
7163 IP_STR
7164 BGP_STR
7165 "BGP neighbor address to clear\n"
7166 "BGP neighbor on interface to clear\n"
7167 "Address family\n"
7168 "Address Family Modifier\n"
7169 BGP_SOFT_IN_STR)
7170
7171 DEFUN (clear_bgp_peer_soft_in,
7172 clear_bgp_peer_soft_in_cmd,
7173 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in",
7174 CLEAR_STR
7175 BGP_STR
7176 "BGP neighbor address to clear\n"
7177 "BGP IPv6 neighbor to clear\n"
7178 "BGP neighbor on interface to clear\n"
7179 BGP_SOFT_STR
7180 BGP_SOFT_IN_STR)
7181 {
7182 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7183 BGP_CLEAR_SOFT_IN, argv[0]);
7184 }
7185
7186 ALIAS (clear_bgp_peer_soft_in,
7187 clear_bgp_ipv6_peer_soft_in_cmd,
7188 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft in",
7189 CLEAR_STR
7190 BGP_STR
7191 "Address family\n"
7192 "BGP neighbor address to clear\n"
7193 "BGP IPv6 neighbor to clear\n"
7194 "BGP neighbor on interface to clear\n"
7195 BGP_SOFT_STR
7196 BGP_SOFT_IN_STR)
7197
7198 ALIAS (clear_bgp_peer_soft_in,
7199 clear_bgp_peer_in_cmd,
7200 "clear bgp (A.B.C.D|X:X::X:X|WORD) in",
7201 CLEAR_STR
7202 BGP_STR
7203 "BGP neighbor address to clear\n"
7204 "BGP IPv6 neighbor to clear\n"
7205 "BGP neighbor on interface to clear\n"
7206 BGP_SOFT_IN_STR)
7207
7208 ALIAS (clear_bgp_peer_soft_in,
7209 clear_bgp_ipv6_peer_in_cmd,
7210 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in",
7211 CLEAR_STR
7212 BGP_STR
7213 "Address family\n"
7214 "BGP neighbor address to clear\n"
7215 "BGP IPv6 neighbor to clear\n"
7216 "BGP neighbor on interface to clear\n"
7217 BGP_SOFT_IN_STR)
7218
7219 DEFUN (clear_bgp_peer_in_prefix_filter,
7220 clear_bgp_peer_in_prefix_filter_cmd,
7221 "clear bgp (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
7222 CLEAR_STR
7223 BGP_STR
7224 "BGP neighbor address to clear\n"
7225 "BGP IPv6 neighbor to clear\n"
7226 "BGP neighbor on interface to clear\n"
7227 BGP_SOFT_IN_STR
7228 "Push out the existing ORF prefix-list\n")
7229 {
7230 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7231 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7232 }
7233
7234 ALIAS (clear_bgp_peer_in_prefix_filter,
7235 clear_bgp_ipv6_peer_in_prefix_filter_cmd,
7236 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) in prefix-filter",
7237 CLEAR_STR
7238 BGP_STR
7239 "Address family\n"
7240 "BGP neighbor address to clear\n"
7241 "BGP IPv6 neighbor to clear\n"
7242 "BGP neighbor on interface to clear\n"
7243 BGP_SOFT_IN_STR
7244 "Push out the existing ORF prefix-list\n")
7245
7246 DEFUN (clear_ip_bgp_peer_group_soft_in,
7247 clear_ip_bgp_peer_group_soft_in_cmd,
7248 "clear ip bgp peer-group WORD soft in",
7249 CLEAR_STR
7250 IP_STR
7251 BGP_STR
7252 "Clear all members of peer-group\n"
7253 "BGP peer-group name\n"
7254 BGP_SOFT_STR
7255 BGP_SOFT_IN_STR)
7256 {
7257 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7258 BGP_CLEAR_SOFT_IN, argv[0]);
7259 }
7260
7261 ALIAS (clear_ip_bgp_peer_group_soft_in,
7262 clear_ip_bgp_peer_group_in_cmd,
7263 "clear ip bgp peer-group WORD in",
7264 CLEAR_STR
7265 IP_STR
7266 BGP_STR
7267 "Clear all members of peer-group\n"
7268 "BGP peer-group name\n"
7269 BGP_SOFT_IN_STR)
7270
7271 DEFUN (clear_ip_bgp_peer_group_in_prefix_filter,
7272 clear_ip_bgp_peer_group_in_prefix_filter_cmd,
7273 "clear ip bgp peer-group WORD in prefix-filter",
7274 CLEAR_STR
7275 IP_STR
7276 BGP_STR
7277 "Clear all members of peer-group\n"
7278 "BGP peer-group name\n"
7279 BGP_SOFT_IN_STR
7280 "Push out prefix-list ORF and do inbound soft reconfig\n")
7281 {
7282 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7283 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7284 }
7285
7286 DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in,
7287 clear_ip_bgp_peer_group_ipv4_soft_in_cmd,
7288 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in",
7289 CLEAR_STR
7290 IP_STR
7291 BGP_STR
7292 "Clear all members of peer-group\n"
7293 "BGP peer-group name\n"
7294 "Address family\n"
7295 "Address Family modifier\n"
7296 "Address Family modifier\n"
7297 BGP_SOFT_STR
7298 BGP_SOFT_IN_STR)
7299 {
7300 if (strncmp (argv[1], "m", 1) == 0)
7301 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7302 BGP_CLEAR_SOFT_IN, argv[0]);
7303
7304 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7305 BGP_CLEAR_SOFT_IN, argv[0]);
7306 }
7307
7308 ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in,
7309 clear_ip_bgp_peer_group_ipv4_in_cmd,
7310 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in",
7311 CLEAR_STR
7312 IP_STR
7313 BGP_STR
7314 "Clear all members of peer-group\n"
7315 "BGP peer-group name\n"
7316 "Address family\n"
7317 "Address Family modifier\n"
7318 "Address Family modifier\n"
7319 BGP_SOFT_IN_STR)
7320
7321 DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter,
7322 clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd,
7323 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter",
7324 CLEAR_STR
7325 IP_STR
7326 BGP_STR
7327 "Clear all members of peer-group\n"
7328 "BGP peer-group name\n"
7329 "Address family\n"
7330 "Address Family modifier\n"
7331 "Address Family modifier\n"
7332 BGP_SOFT_IN_STR
7333 "Push out prefix-list ORF and do inbound soft reconfig\n")
7334 {
7335 if (strncmp (argv[1], "m", 1) == 0)
7336 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7337 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7338
7339 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7340 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7341 }
7342
7343 DEFUN (clear_bgp_peer_group_soft_in,
7344 clear_bgp_peer_group_soft_in_cmd,
7345 "clear bgp peer-group WORD soft in",
7346 CLEAR_STR
7347 BGP_STR
7348 "Clear all members of peer-group\n"
7349 "BGP peer-group name\n"
7350 BGP_SOFT_STR
7351 BGP_SOFT_IN_STR)
7352 {
7353 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7354 BGP_CLEAR_SOFT_IN, argv[0]);
7355 }
7356
7357 ALIAS (clear_bgp_peer_group_soft_in,
7358 clear_bgp_ipv6_peer_group_soft_in_cmd,
7359 "clear bgp ipv6 peer-group WORD soft in",
7360 CLEAR_STR
7361 BGP_STR
7362 "Address family\n"
7363 "Clear all members of peer-group\n"
7364 "BGP peer-group name\n"
7365 BGP_SOFT_STR
7366 BGP_SOFT_IN_STR)
7367
7368 ALIAS (clear_bgp_peer_group_soft_in,
7369 clear_bgp_peer_group_in_cmd,
7370 "clear bgp peer-group WORD in",
7371 CLEAR_STR
7372 BGP_STR
7373 "Clear all members of peer-group\n"
7374 "BGP peer-group name\n"
7375 BGP_SOFT_IN_STR)
7376
7377 ALIAS (clear_bgp_peer_group_soft_in,
7378 clear_bgp_ipv6_peer_group_in_cmd,
7379 "clear bgp ipv6 peer-group WORD in",
7380 CLEAR_STR
7381 BGP_STR
7382 "Address family\n"
7383 "Clear all members of peer-group\n"
7384 "BGP peer-group name\n"
7385 BGP_SOFT_IN_STR)
7386
7387 DEFUN (clear_bgp_peer_group_in_prefix_filter,
7388 clear_bgp_peer_group_in_prefix_filter_cmd,
7389 "clear bgp peer-group WORD in prefix-filter",
7390 CLEAR_STR
7391 BGP_STR
7392 "Clear all members of peer-group\n"
7393 "BGP peer-group name\n"
7394 BGP_SOFT_IN_STR
7395 "Push out prefix-list ORF and do inbound soft reconfig\n")
7396 {
7397 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7398 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7399 }
7400
7401 ALIAS (clear_bgp_peer_group_in_prefix_filter,
7402 clear_bgp_ipv6_peer_group_in_prefix_filter_cmd,
7403 "clear bgp ipv6 peer-group WORD in prefix-filter",
7404 CLEAR_STR
7405 BGP_STR
7406 "Address family\n"
7407 "Clear all members of peer-group\n"
7408 "BGP peer-group name\n"
7409 BGP_SOFT_IN_STR
7410 "Push out prefix-list ORF and do inbound soft reconfig\n")
7411
7412 DEFUN (clear_ip_bgp_external_soft_in,
7413 clear_ip_bgp_external_soft_in_cmd,
7414 "clear ip bgp external soft in",
7415 CLEAR_STR
7416 IP_STR
7417 BGP_STR
7418 "Clear all external peers\n"
7419 BGP_SOFT_STR
7420 BGP_SOFT_IN_STR)
7421 {
7422 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7423 BGP_CLEAR_SOFT_IN, NULL);
7424 }
7425
7426 ALIAS (clear_ip_bgp_external_soft_in,
7427 clear_ip_bgp_external_in_cmd,
7428 "clear ip bgp external in",
7429 CLEAR_STR
7430 IP_STR
7431 BGP_STR
7432 "Clear all external peers\n"
7433 BGP_SOFT_IN_STR)
7434
7435 DEFUN (clear_ip_bgp_external_in_prefix_filter,
7436 clear_ip_bgp_external_in_prefix_filter_cmd,
7437 "clear ip bgp external in prefix-filter",
7438 CLEAR_STR
7439 IP_STR
7440 BGP_STR
7441 "Clear all external peers\n"
7442 BGP_SOFT_IN_STR
7443 "Push out prefix-list ORF and do inbound soft reconfig\n")
7444 {
7445 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7446 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7447 }
7448
7449 DEFUN (clear_ip_bgp_external_ipv4_soft_in,
7450 clear_ip_bgp_external_ipv4_soft_in_cmd,
7451 "clear ip bgp external ipv4 (unicast|multicast) soft in",
7452 CLEAR_STR
7453 IP_STR
7454 BGP_STR
7455 "Clear all external peers\n"
7456 "Address family\n"
7457 "Address Family modifier\n"
7458 "Address Family modifier\n"
7459 BGP_SOFT_STR
7460 BGP_SOFT_IN_STR)
7461 {
7462 if (strncmp (argv[0], "m", 1) == 0)
7463 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7464 BGP_CLEAR_SOFT_IN, NULL);
7465
7466 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7467 BGP_CLEAR_SOFT_IN, NULL);
7468 }
7469
7470 ALIAS (clear_ip_bgp_external_ipv4_soft_in,
7471 clear_ip_bgp_external_ipv4_in_cmd,
7472 "clear ip bgp external ipv4 (unicast|multicast) in",
7473 CLEAR_STR
7474 IP_STR
7475 BGP_STR
7476 "Clear all external peers\n"
7477 "Address family\n"
7478 "Address Family modifier\n"
7479 "Address Family modifier\n"
7480 BGP_SOFT_IN_STR)
7481
7482 DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter,
7483 clear_ip_bgp_external_ipv4_in_prefix_filter_cmd,
7484 "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter",
7485 CLEAR_STR
7486 IP_STR
7487 BGP_STR
7488 "Clear all external peers\n"
7489 "Address family\n"
7490 "Address Family modifier\n"
7491 "Address Family modifier\n"
7492 BGP_SOFT_IN_STR
7493 "Push out prefix-list ORF and do inbound soft reconfig\n")
7494 {
7495 if (strncmp (argv[0], "m", 1) == 0)
7496 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
7497 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7498
7499 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
7500 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7501 }
7502
7503 DEFUN (clear_bgp_external_soft_in,
7504 clear_bgp_external_soft_in_cmd,
7505 "clear bgp external soft in",
7506 CLEAR_STR
7507 BGP_STR
7508 "Clear all external peers\n"
7509 BGP_SOFT_STR
7510 BGP_SOFT_IN_STR)
7511 {
7512 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7513 BGP_CLEAR_SOFT_IN, NULL);
7514 }
7515
7516 ALIAS (clear_bgp_external_soft_in,
7517 clear_bgp_ipv6_external_soft_in_cmd,
7518 "clear bgp ipv6 external soft in",
7519 CLEAR_STR
7520 BGP_STR
7521 "Address family\n"
7522 "Clear all external peers\n"
7523 BGP_SOFT_STR
7524 BGP_SOFT_IN_STR)
7525
7526 ALIAS (clear_bgp_external_soft_in,
7527 clear_bgp_external_in_cmd,
7528 "clear bgp external in",
7529 CLEAR_STR
7530 BGP_STR
7531 "Clear all external peers\n"
7532 BGP_SOFT_IN_STR)
7533
7534 ALIAS (clear_bgp_external_soft_in,
7535 clear_bgp_ipv6_external_in_cmd,
7536 "clear bgp ipv6 external WORD in",
7537 CLEAR_STR
7538 BGP_STR
7539 "Address family\n"
7540 "Clear all external peers\n"
7541 BGP_SOFT_IN_STR)
7542
7543 DEFUN (clear_bgp_external_in_prefix_filter,
7544 clear_bgp_external_in_prefix_filter_cmd,
7545 "clear bgp external in prefix-filter",
7546 CLEAR_STR
7547 BGP_STR
7548 "Clear all external peers\n"
7549 BGP_SOFT_IN_STR
7550 "Push out prefix-list ORF and do inbound soft reconfig\n")
7551 {
7552 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
7553 BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL);
7554 }
7555
7556 ALIAS (clear_bgp_external_in_prefix_filter,
7557 clear_bgp_ipv6_external_in_prefix_filter_cmd,
7558 "clear bgp ipv6 external in prefix-filter",
7559 CLEAR_STR
7560 BGP_STR
7561 "Address family\n"
7562 "Clear all external peers\n"
7563 BGP_SOFT_IN_STR
7564 "Push out prefix-list ORF and do inbound soft reconfig\n")
7565
7566 DEFUN (clear_ip_bgp_as_soft_in,
7567 clear_ip_bgp_as_soft_in_cmd,
7568 "clear ip bgp " CMD_AS_RANGE " soft in",
7569 CLEAR_STR
7570 IP_STR
7571 BGP_STR
7572 "Clear peers with the AS number\n"
7573 BGP_SOFT_STR
7574 BGP_SOFT_IN_STR)
7575 {
7576 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7577 BGP_CLEAR_SOFT_IN, argv[0]);
7578 }
7579
7580 ALIAS (clear_ip_bgp_as_soft_in,
7581 clear_ip_bgp_as_in_cmd,
7582 "clear ip bgp " CMD_AS_RANGE " in",
7583 CLEAR_STR
7584 IP_STR
7585 BGP_STR
7586 "Clear peers with the AS number\n"
7587 BGP_SOFT_IN_STR)
7588
7589 DEFUN (clear_ip_bgp_as_in_prefix_filter,
7590 clear_ip_bgp_as_in_prefix_filter_cmd,
7591 "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
7592 CLEAR_STR
7593 IP_STR
7594 BGP_STR
7595 "Clear peers with the AS number\n"
7596 BGP_SOFT_IN_STR
7597 "Push out prefix-list ORF and do inbound soft reconfig\n")
7598 {
7599 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7600 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7601 }
7602
7603 DEFUN (clear_ip_bgp_as_ipv4_soft_in,
7604 clear_ip_bgp_as_ipv4_soft_in_cmd,
7605 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
7606 CLEAR_STR
7607 IP_STR
7608 BGP_STR
7609 "Clear peers with the AS number\n"
7610 "Address family\n"
7611 "Address Family modifier\n"
7612 "Address Family modifier\n"
7613 BGP_SOFT_STR
7614 BGP_SOFT_IN_STR)
7615 {
7616 if (strncmp (argv[1], "m", 1) == 0)
7617 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7618 BGP_CLEAR_SOFT_IN, argv[0]);
7619
7620 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7621 BGP_CLEAR_SOFT_IN, argv[0]);
7622 }
7623
7624 ALIAS (clear_ip_bgp_as_ipv4_soft_in,
7625 clear_ip_bgp_as_ipv4_in_cmd,
7626 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
7627 CLEAR_STR
7628 IP_STR
7629 BGP_STR
7630 "Clear peers with the AS number\n"
7631 "Address family\n"
7632 "Address Family modifier\n"
7633 "Address Family modifier\n"
7634 BGP_SOFT_IN_STR)
7635
7636 DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
7637 clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
7638 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
7639 CLEAR_STR
7640 IP_STR
7641 BGP_STR
7642 "Clear peers with the AS number\n"
7643 "Address family\n"
7644 "Address Family modifier\n"
7645 "Address Family modifier\n"
7646 BGP_SOFT_IN_STR
7647 "Push out prefix-list ORF and do inbound soft reconfig\n")
7648 {
7649 if (strncmp (argv[1], "m", 1) == 0)
7650 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
7651 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7652
7653 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
7654 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7655 }
7656
7657 DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
7658 clear_ip_bgp_as_vpnv4_soft_in_cmd,
7659 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
7660 CLEAR_STR
7661 IP_STR
7662 BGP_STR
7663 "Clear peers with the AS number\n"
7664 "Address family\n"
7665 "Address Family modifier\n"
7666 BGP_SOFT_STR
7667 BGP_SOFT_IN_STR)
7668 {
7669 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
7670 BGP_CLEAR_SOFT_IN, argv[0]);
7671 }
7672
7673 ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
7674 clear_ip_bgp_as_vpnv4_in_cmd,
7675 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
7676 CLEAR_STR
7677 IP_STR
7678 BGP_STR
7679 "Clear peers with the AS number\n"
7680 "Address family\n"
7681 "Address Family modifier\n"
7682 BGP_SOFT_IN_STR)
7683
7684 DEFUN (clear_bgp_as_soft_in,
7685 clear_bgp_as_soft_in_cmd,
7686 "clear bgp " CMD_AS_RANGE " soft in",
7687 CLEAR_STR
7688 BGP_STR
7689 "Clear peers with the AS number\n"
7690 BGP_SOFT_STR
7691 BGP_SOFT_IN_STR)
7692 {
7693 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7694 BGP_CLEAR_SOFT_IN, argv[0]);
7695 }
7696
7697 ALIAS (clear_bgp_as_soft_in,
7698 clear_bgp_ipv6_as_soft_in_cmd,
7699 "clear bgp ipv6 " CMD_AS_RANGE " soft in",
7700 CLEAR_STR
7701 BGP_STR
7702 "Address family\n"
7703 "Clear peers with the AS number\n"
7704 BGP_SOFT_STR
7705 BGP_SOFT_IN_STR)
7706
7707 ALIAS (clear_bgp_as_soft_in,
7708 clear_bgp_as_in_cmd,
7709 "clear bgp " CMD_AS_RANGE " in",
7710 CLEAR_STR
7711 BGP_STR
7712 "Clear peers with the AS number\n"
7713 BGP_SOFT_IN_STR)
7714
7715 ALIAS (clear_bgp_as_soft_in,
7716 clear_bgp_ipv6_as_in_cmd,
7717 "clear bgp ipv6 " CMD_AS_RANGE " in",
7718 CLEAR_STR
7719 BGP_STR
7720 "Address family\n"
7721 "Clear peers with the AS number\n"
7722 BGP_SOFT_IN_STR)
7723
7724 DEFUN (clear_bgp_as_in_prefix_filter,
7725 clear_bgp_as_in_prefix_filter_cmd,
7726 "clear bgp " CMD_AS_RANGE " in prefix-filter",
7727 CLEAR_STR
7728 BGP_STR
7729 "Clear peers with the AS number\n"
7730 BGP_SOFT_IN_STR
7731 "Push out prefix-list ORF and do inbound soft reconfig\n")
7732 {
7733 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
7734 BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]);
7735 }
7736
7737 ALIAS (clear_bgp_as_in_prefix_filter,
7738 clear_bgp_ipv6_as_in_prefix_filter_cmd,
7739 "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
7740 CLEAR_STR
7741 BGP_STR
7742 "Address family\n"
7743 "Clear peers with the AS number\n"
7744 BGP_SOFT_IN_STR
7745 "Push out prefix-list ORF and do inbound soft reconfig\n")
7746
7747 /* Both soft-reconfiguration */
7748 DEFUN (clear_ip_bgp_all_soft,
7749 clear_ip_bgp_all_soft_cmd,
7750 "clear ip bgp * soft",
7751 CLEAR_STR
7752 IP_STR
7753 BGP_STR
7754 "Clear all peers\n"
7755 BGP_SOFT_STR)
7756 {
7757 if (argc == 2)
7758 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all,
7759 BGP_CLEAR_SOFT_BOTH, NULL);
7760
7761 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7762 BGP_CLEAR_SOFT_BOTH, NULL);
7763 }
7764
7765 ALIAS (clear_ip_bgp_all_soft,
7766 clear_ip_bgp_instance_all_soft_cmd,
7767 "clear ip bgp " BGP_INSTANCE_CMD " * soft",
7768 CLEAR_STR
7769 IP_STR
7770 BGP_STR
7771 BGP_INSTANCE_HELP_STR
7772 "Clear all peers\n"
7773 BGP_SOFT_STR)
7774
7775
7776 DEFUN (clear_ip_bgp_all_ipv4_soft,
7777 clear_ip_bgp_all_ipv4_soft_cmd,
7778 "clear ip bgp * ipv4 (unicast|multicast) soft",
7779 CLEAR_STR
7780 IP_STR
7781 BGP_STR
7782 "Clear all peers\n"
7783 "Address family\n"
7784 "Address Family Modifier\n"
7785 "Address Family Modifier\n"
7786 BGP_SOFT_STR)
7787 {
7788 if (strncmp (argv[0], "m", 1) == 0)
7789 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all,
7790 BGP_CLEAR_SOFT_BOTH, NULL);
7791
7792 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7793 BGP_CLEAR_SOFT_BOTH, NULL);
7794 }
7795
7796 DEFUN (clear_ip_bgp_instance_all_ipv4_soft,
7797 clear_ip_bgp_instance_all_ipv4_soft_cmd,
7798 "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft",
7799 CLEAR_STR
7800 IP_STR
7801 BGP_STR
7802 BGP_INSTANCE_HELP_STR
7803 "Clear all peers\n"
7804 "Address family\n"
7805 "Address Family Modifier\n"
7806 "Address Family Modifier\n"
7807 BGP_SOFT_STR)
7808 {
7809 if (strncmp (argv[2], "m", 1) == 0)
7810 return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all,
7811 BGP_CLEAR_SOFT_BOTH, NULL);
7812
7813 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all,
7814 BGP_CLEAR_SOFT_BOTH, NULL);
7815 }
7816
7817 DEFUN (clear_ip_bgp_all_vpnv4_soft,
7818 clear_ip_bgp_all_vpnv4_soft_cmd,
7819 "clear ip bgp * vpnv4 unicast soft",
7820 CLEAR_STR
7821 IP_STR
7822 BGP_STR
7823 "Clear all peers\n"
7824 "Address family\n"
7825 "Address Family Modifier\n"
7826 BGP_SOFT_STR)
7827 {
7828 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all,
7829 BGP_CLEAR_SOFT_BOTH, argv[0]);
7830 }
7831
7832 DEFUN (clear_bgp_all_soft,
7833 clear_bgp_all_soft_cmd,
7834 "clear bgp * soft",
7835 CLEAR_STR
7836 BGP_STR
7837 "Clear all peers\n"
7838 BGP_SOFT_STR)
7839 {
7840 if (argc == 2)
7841 return bgp_clear_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, clear_all,
7842 BGP_CLEAR_SOFT_BOTH, argv[0]);
7843
7844 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
7845 BGP_CLEAR_SOFT_BOTH, argv[0]);
7846 }
7847
7848 ALIAS (clear_bgp_all_soft,
7849 clear_bgp_instance_all_soft_cmd,
7850 "clear bgp " BGP_INSTANCE_CMD " * soft",
7851 CLEAR_STR
7852 BGP_STR
7853 BGP_INSTANCE_HELP_STR
7854 "Clear all peers\n"
7855 BGP_SOFT_STR)
7856
7857 ALIAS (clear_bgp_all_soft,
7858 clear_bgp_ipv6_all_soft_cmd,
7859 "clear bgp ipv6 * soft",
7860 CLEAR_STR
7861 BGP_STR
7862 "Address family\n"
7863 "Clear all peers\n"
7864 BGP_SOFT_STR)
7865
7866 DEFUN (clear_ip_bgp_peer_soft,
7867 clear_ip_bgp_peer_soft_cmd,
7868 "clear ip bgp (A.B.C.D|WORD) soft",
7869 CLEAR_STR
7870 IP_STR
7871 BGP_STR
7872 "BGP neighbor address to clear\n"
7873 "BGP neighbor on interface to clear\n"
7874 BGP_SOFT_STR)
7875 {
7876 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7877 BGP_CLEAR_SOFT_BOTH, argv[0]);
7878 }
7879
7880 DEFUN (clear_ip_bgp_peer_ipv4_soft,
7881 clear_ip_bgp_peer_ipv4_soft_cmd,
7882 "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft",
7883 CLEAR_STR
7884 IP_STR
7885 BGP_STR
7886 "BGP neighbor address to clear\n"
7887 "BGP neighbor on interface to clear\n"
7888 "Address family\n"
7889 "Address Family Modifier\n"
7890 "Address Family Modifier\n"
7891 BGP_SOFT_STR)
7892 {
7893 if (strncmp (argv[1], "m", 1) == 0)
7894 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer,
7895 BGP_CLEAR_SOFT_BOTH, argv[0]);
7896
7897 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer,
7898 BGP_CLEAR_SOFT_BOTH, argv[0]);
7899 }
7900
7901 DEFUN (clear_ip_bgp_peer_vpnv4_soft,
7902 clear_ip_bgp_peer_vpnv4_soft_cmd,
7903 "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft",
7904 CLEAR_STR
7905 IP_STR
7906 BGP_STR
7907 "BGP neighbor address to clear\n"
7908 "BGP neighbor on interface to clear\n"
7909 "Address family\n"
7910 "Address Family Modifier\n"
7911 BGP_SOFT_STR)
7912 {
7913 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer,
7914 BGP_CLEAR_SOFT_BOTH, argv[0]);
7915 }
7916
7917 DEFUN (clear_bgp_peer_soft,
7918 clear_bgp_peer_soft_cmd,
7919 "clear bgp (A.B.C.D|X:X::X:X|WORD) soft",
7920 CLEAR_STR
7921 BGP_STR
7922 "BGP neighbor address to clear\n"
7923 "BGP IPv6 neighbor to clear\n"
7924 "BGP neighbor on interface to clear\n"
7925 BGP_SOFT_STR)
7926 {
7927 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_peer,
7928 BGP_CLEAR_SOFT_BOTH, argv[0]);
7929 }
7930
7931 ALIAS (clear_bgp_peer_soft,
7932 clear_bgp_ipv6_peer_soft_cmd,
7933 "clear bgp ipv6 (A.B.C.D|X:X::X:X|WORD) soft",
7934 CLEAR_STR
7935 BGP_STR
7936 "Address family\n"
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
7942 DEFUN (clear_ip_bgp_peer_group_soft,
7943 clear_ip_bgp_peer_group_soft_cmd,
7944 "clear ip bgp peer-group WORD soft",
7945 CLEAR_STR
7946 IP_STR
7947 BGP_STR
7948 "Clear all members of peer-group\n"
7949 "BGP peer-group name\n"
7950 BGP_SOFT_STR)
7951 {
7952 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7953 BGP_CLEAR_SOFT_BOTH, argv[0]);
7954 }
7955
7956 DEFUN (clear_ip_bgp_peer_group_ipv4_soft,
7957 clear_ip_bgp_peer_group_ipv4_soft_cmd,
7958 "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft",
7959 CLEAR_STR
7960 IP_STR
7961 BGP_STR
7962 "Clear all members of peer-group\n"
7963 "BGP peer-group name\n"
7964 "Address family\n"
7965 "Address Family modifier\n"
7966 "Address Family modifier\n"
7967 BGP_SOFT_STR)
7968 {
7969 if (strncmp (argv[1], "m", 1) == 0)
7970 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group,
7971 BGP_CLEAR_SOFT_BOTH, argv[0]);
7972
7973 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group,
7974 BGP_CLEAR_SOFT_BOTH, argv[0]);
7975 }
7976
7977 DEFUN (clear_bgp_peer_group_soft,
7978 clear_bgp_peer_group_soft_cmd,
7979 "clear bgp peer-group WORD soft",
7980 CLEAR_STR
7981 BGP_STR
7982 "Clear all members of peer-group\n"
7983 "BGP peer-group name\n"
7984 BGP_SOFT_STR)
7985 {
7986 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group,
7987 BGP_CLEAR_SOFT_BOTH, argv[0]);
7988 }
7989
7990 ALIAS (clear_bgp_peer_group_soft,
7991 clear_bgp_ipv6_peer_group_soft_cmd,
7992 "clear bgp ipv6 peer-group WORD soft",
7993 CLEAR_STR
7994 BGP_STR
7995 "Address family\n"
7996 "Clear all members of peer-group\n"
7997 "BGP peer-group name\n"
7998 BGP_SOFT_STR)
7999
8000 DEFUN (clear_ip_bgp_external_soft,
8001 clear_ip_bgp_external_soft_cmd,
8002 "clear ip bgp external soft",
8003 CLEAR_STR
8004 IP_STR
8005 BGP_STR
8006 "Clear all external peers\n"
8007 BGP_SOFT_STR)
8008 {
8009 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8010 BGP_CLEAR_SOFT_BOTH, NULL);
8011 }
8012
8013 DEFUN (clear_ip_bgp_external_ipv4_soft,
8014 clear_ip_bgp_external_ipv4_soft_cmd,
8015 "clear ip bgp external ipv4 (unicast|multicast) soft",
8016 CLEAR_STR
8017 IP_STR
8018 BGP_STR
8019 "Clear all external peers\n"
8020 "Address family\n"
8021 "Address Family modifier\n"
8022 "Address Family modifier\n"
8023 BGP_SOFT_STR)
8024 {
8025 if (strncmp (argv[0], "m", 1) == 0)
8026 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external,
8027 BGP_CLEAR_SOFT_BOTH, NULL);
8028
8029 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external,
8030 BGP_CLEAR_SOFT_BOTH, NULL);
8031 }
8032
8033 DEFUN (clear_bgp_external_soft,
8034 clear_bgp_external_soft_cmd,
8035 "clear bgp external soft",
8036 CLEAR_STR
8037 BGP_STR
8038 "Clear all external peers\n"
8039 BGP_SOFT_STR)
8040 {
8041 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_external,
8042 BGP_CLEAR_SOFT_BOTH, NULL);
8043 }
8044
8045 ALIAS (clear_bgp_external_soft,
8046 clear_bgp_ipv6_external_soft_cmd,
8047 "clear bgp ipv6 external soft",
8048 CLEAR_STR
8049 BGP_STR
8050 "Address family\n"
8051 "Clear all external peers\n"
8052 BGP_SOFT_STR)
8053
8054 DEFUN (clear_ip_bgp_as_soft,
8055 clear_ip_bgp_as_soft_cmd,
8056 "clear ip bgp " CMD_AS_RANGE " soft",
8057 CLEAR_STR
8058 IP_STR
8059 BGP_STR
8060 "Clear peers with the AS number\n"
8061 BGP_SOFT_STR)
8062 {
8063 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as,
8064 BGP_CLEAR_SOFT_BOTH, argv[0]);
8065 }
8066
8067 DEFUN (clear_ip_bgp_as_ipv4_soft,
8068 clear_ip_bgp_as_ipv4_soft_cmd,
8069 "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
8070 CLEAR_STR
8071 IP_STR
8072 BGP_STR
8073 "Clear peers with the AS number\n"
8074 "Address family\n"
8075 "Address Family Modifier\n"
8076 "Address Family Modifier\n"
8077 BGP_SOFT_STR)
8078 {
8079 if (strncmp (argv[1], "m", 1) == 0)
8080 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as,
8081 BGP_CLEAR_SOFT_BOTH, argv[0]);
8082
8083 return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as,
8084 BGP_CLEAR_SOFT_BOTH, argv[0]);
8085 }
8086
8087 DEFUN (clear_ip_bgp_as_vpnv4_soft,
8088 clear_ip_bgp_as_vpnv4_soft_cmd,
8089 "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
8090 CLEAR_STR
8091 IP_STR
8092 BGP_STR
8093 "Clear peers with the AS number\n"
8094 "Address family\n"
8095 "Address Family Modifier\n"
8096 BGP_SOFT_STR)
8097 {
8098 return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as,
8099 BGP_CLEAR_SOFT_BOTH, argv[0]);
8100 }
8101
8102 DEFUN (clear_bgp_as_soft,
8103 clear_bgp_as_soft_cmd,
8104 "clear bgp " CMD_AS_RANGE " soft",
8105 CLEAR_STR
8106 BGP_STR
8107 "Clear peers with the AS number\n"
8108 BGP_SOFT_STR)
8109 {
8110 return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_as,
8111 BGP_CLEAR_SOFT_BOTH, argv[0]);
8112 }
8113
8114 ALIAS (clear_bgp_as_soft,
8115 clear_bgp_ipv6_as_soft_cmd,
8116 "clear bgp ipv6 " CMD_AS_RANGE " soft",
8117 CLEAR_STR
8118 BGP_STR
8119 "Address family\n"
8120 "Clear peers with the AS number\n"
8121 BGP_SOFT_STR)
8122
8123 DEFUN (show_bgp_views,
8124 show_bgp_views_cmd,
8125 "show bgp views",
8126 SHOW_STR
8127 BGP_STR
8128 "Show the defined BGP views\n")
8129 {
8130 struct list *inst = bm->bgp;
8131 struct listnode *node;
8132 struct bgp *bgp;
8133
8134 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
8135 {
8136 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
8137 return CMD_WARNING;
8138 }
8139
8140 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
8141 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8142 {
8143 /* Skip VRFs. */
8144 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
8145 continue;
8146 vty_out (vty, "\t%s (AS%u)%s",
8147 bgp->name ? bgp->name : "(null)",
8148 bgp->as, VTY_NEWLINE);
8149 }
8150
8151 return CMD_SUCCESS;
8152 }
8153
8154 DEFUN (show_bgp_vrfs,
8155 show_bgp_vrfs_cmd,
8156 "show bgp vrfs {json}",
8157 SHOW_STR
8158 BGP_STR
8159 "Show BGP VRFs\n"
8160 "JavaScript Object Notation\n")
8161 {
8162 struct list *inst = bm->bgp;
8163 struct listnode *node;
8164 struct bgp *bgp;
8165 u_char uj = use_json(argc, argv);
8166 json_object *json = NULL;
8167 json_object *json_vrfs = NULL;
8168 int count = 0;
8169 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
8170
8171 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
8172 {
8173 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
8174 return CMD_WARNING;
8175 }
8176
8177 if (uj)
8178 {
8179 json = json_object_new_object();
8180 json_vrfs = json_object_new_object();
8181 }
8182
8183 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
8184 {
8185 const char *name, *type;
8186 struct peer *peer;
8187 struct listnode *node, *nnode;
8188 int peers_cfg, peers_estb;
8189 json_object *json_vrf = NULL;
8190
8191 /* Skip Views. */
8192 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
8193 continue;
8194
8195 count++;
8196 if (!uj && count == 1)
8197 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8198
8199 peers_cfg = peers_estb = 0;
8200 if (uj)
8201 json_vrf = json_object_new_object();
8202
8203
8204 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
8205 {
8206 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
8207 continue;
8208 peers_cfg++;
8209 if (peer->status == Established)
8210 peers_estb++;
8211 }
8212
8213 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
8214 {
8215 name = "Default";
8216 type = "DFLT";
8217 }
8218 else
8219 {
8220 name = bgp->name;
8221 type = "VRF";
8222 }
8223
8224 if (uj)
8225 {
8226 json_object_string_add(json_vrf, "type", type);
8227 json_object_int_add(json_vrf, "vrfId", bgp->vrf_id);
8228 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
8229 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
8230 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
8231
8232 json_object_object_add(json_vrfs, name, json_vrf);
8233 }
8234 else
8235 vty_out (vty, "%4s %-5u %-16s %9u %10u %s%s",
8236 type, bgp->vrf_id, inet_ntoa (bgp->router_id),
8237 peers_cfg, peers_estb, name,
8238 VTY_NEWLINE);
8239 }
8240
8241 if (uj)
8242 {
8243 json_object_object_add(json, "vrfs", json_vrfs);
8244
8245 json_object_int_add(json, "totalVrfs", count);
8246
8247 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
8248 json_object_free(json);
8249 }
8250 else
8251 {
8252 if (count)
8253 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
8254 VTY_NEWLINE, count, VTY_NEWLINE);
8255 }
8256
8257 return CMD_SUCCESS;
8258 }
8259
8260 DEFUN (show_bgp_memory,
8261 show_bgp_memory_cmd,
8262 "show bgp memory",
8263 SHOW_STR
8264 BGP_STR
8265 "Global BGP memory statistics\n")
8266 {
8267 char memstrbuf[MTYPE_MEMSTR_LEN];
8268 unsigned long count;
8269
8270 /* RIB related usage stats */
8271 count = mtype_stats_alloc (MTYPE_BGP_NODE);
8272 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
8273 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8274 count * sizeof (struct bgp_node)),
8275 VTY_NEWLINE);
8276
8277 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
8278 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
8279 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8280 count * sizeof (struct bgp_info)),
8281 VTY_NEWLINE);
8282 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
8283 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
8284 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8285 count * sizeof (struct bgp_info_extra)),
8286 VTY_NEWLINE);
8287
8288 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
8289 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
8290 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8291 count * sizeof (struct bgp_static)),
8292 VTY_NEWLINE);
8293
8294 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
8295 vty_out (vty, "%ld Packets, using %s of memory%s", count,
8296 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8297 count * sizeof (struct bpacket)),
8298 VTY_NEWLINE);
8299
8300 /* Adj-In/Out */
8301 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
8302 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
8303 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8304 count * sizeof (struct bgp_adj_in)),
8305 VTY_NEWLINE);
8306 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
8307 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
8308 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8309 count * sizeof (struct bgp_adj_out)),
8310 VTY_NEWLINE);
8311
8312 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
8313 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
8314 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8315 count * sizeof (struct bgp_nexthop_cache)),
8316 VTY_NEWLINE);
8317
8318 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
8319 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
8320 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8321 count * sizeof (struct bgp_damp_info)),
8322 VTY_NEWLINE);
8323
8324 /* Attributes */
8325 count = attr_count();
8326 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
8327 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8328 count * sizeof(struct attr)),
8329 VTY_NEWLINE);
8330 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
8331 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
8332 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8333 count * sizeof(struct attr_extra)),
8334 VTY_NEWLINE);
8335
8336 if ((count = attr_unknown_count()))
8337 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
8338
8339 /* AS_PATH attributes */
8340 count = aspath_count ();
8341 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
8342 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8343 count * sizeof (struct aspath)),
8344 VTY_NEWLINE);
8345
8346 count = mtype_stats_alloc (MTYPE_AS_SEG);
8347 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
8348 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8349 count * sizeof (struct assegment)),
8350 VTY_NEWLINE);
8351
8352 /* Other attributes */
8353 if ((count = community_count ()))
8354 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8355 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8356 count * sizeof (struct community)),
8357 VTY_NEWLINE);
8358 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
8359 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
8360 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8361 count * sizeof (struct ecommunity)),
8362 VTY_NEWLINE);
8363
8364 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
8365 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
8366 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8367 count * sizeof (struct cluster_list)),
8368 VTY_NEWLINE);
8369
8370 /* Peer related usage */
8371 count = mtype_stats_alloc (MTYPE_BGP_PEER);
8372 vty_out (vty, "%ld peers, using %s of memory%s", count,
8373 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8374 count * sizeof (struct peer)),
8375 VTY_NEWLINE);
8376
8377 if ((count = mtype_stats_alloc (MTYPE_BGP_PEER_GROUP)))
8378 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
8379 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8380 count * sizeof (struct peer_group)),
8381 VTY_NEWLINE);
8382
8383 /* Other */
8384 if ((count = mtype_stats_alloc (MTYPE_HASH)))
8385 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
8386 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8387 count * sizeof (struct hash)),
8388 VTY_NEWLINE);
8389 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
8390 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
8391 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8392 count * sizeof (struct hash_backet)),
8393 VTY_NEWLINE);
8394 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
8395 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
8396 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8397 count * sizeof (regex_t)),
8398 VTY_NEWLINE);
8399 return CMD_SUCCESS;
8400 }
8401
8402 /* Show BGP peer's summary information. */
8403 static int
8404 bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
8405 u_char use_json)
8406 {
8407 struct peer *peer;
8408 struct listnode *node, *nnode;
8409 unsigned int count = 0, dn_count = 0;
8410 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
8411 int len;
8412 json_object *json = NULL;
8413 json_object *json_peer = NULL;
8414 json_object *json_peers = NULL;
8415
8416 /* Header string for each address family. */
8417 static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
8418
8419 if (use_json)
8420 {
8421 json = json_object_new_object();
8422 json_peers = json_object_new_object();
8423 }
8424
8425 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
8426 {
8427 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
8428 continue;
8429
8430 if (peer->afc[afi][safi])
8431 {
8432 if (!count)
8433 {
8434 unsigned long ents;
8435 char memstrbuf[MTYPE_MEMSTR_LEN];
8436
8437 /* Usage summary and header */
8438 if (use_json)
8439 {
8440 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
8441 json_object_int_add(json, "as", bgp->as);
8442
8443 if (bgp->vrf_id)
8444 json_object_int_add(json, "vrf-id", bgp->vrf_id);
8445
8446 }
8447 else
8448 {
8449 vty_out (vty,
8450 "BGP router identifier %s, local AS number %u",
8451 inet_ntoa (bgp->router_id), bgp->as);
8452
8453 if (bgp->vrf_id)
8454 vty_out (vty, " vrf-id %u", bgp->vrf_id);
8455
8456 vty_out (vty, "%s", VTY_NEWLINE);
8457 }
8458
8459 if (bgp_update_delay_configured(bgp))
8460 {
8461 if (use_json)
8462 {
8463 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
8464
8465 if (bgp->v_update_delay != bgp->v_establish_wait)
8466 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
8467
8468 if (bgp_update_delay_active(bgp))
8469 {
8470 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
8471 json_object_boolean_true_add(json, "updateDelayInProgress");
8472 }
8473 else
8474 {
8475 if (bgp->update_delay_over)
8476 {
8477 json_object_string_add(json, "updateDelayFirstNeighbor",
8478 bgp->update_delay_begin_time);
8479 json_object_string_add(json, "updateDelayBestpathResumed",
8480 bgp->update_delay_end_time);
8481 json_object_string_add(json, "updateDelayZebraUpdateResume",
8482 bgp->update_delay_zebra_resume_time);
8483 json_object_string_add(json, "updateDelayPeerUpdateResume",
8484 bgp->update_delay_peers_resume_time);
8485 }
8486 }
8487 }
8488 else
8489 {
8490 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
8491 bgp->v_update_delay, VTY_NEWLINE);
8492 if (bgp->v_update_delay != bgp->v_establish_wait)
8493 vty_out (vty, " Establish wait: %d seconds%s",
8494 bgp->v_establish_wait, VTY_NEWLINE);
8495
8496 if (bgp_update_delay_active(bgp))
8497 {
8498 vty_out (vty, " First neighbor established: %s%s",
8499 bgp->update_delay_begin_time, VTY_NEWLINE);
8500 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
8501 }
8502 else
8503 {
8504 if (bgp->update_delay_over)
8505 {
8506 vty_out (vty, " First neighbor established: %s%s",
8507 bgp->update_delay_begin_time, VTY_NEWLINE);
8508 vty_out (vty, " Best-paths resumed: %s%s",
8509 bgp->update_delay_end_time, VTY_NEWLINE);
8510 vty_out (vty, " zebra update resumed: %s%s",
8511 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
8512 vty_out (vty, " peers update resumed: %s%s",
8513 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
8514 }
8515 }
8516 }
8517 }
8518
8519 if (use_json)
8520 {
8521 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
8522 json_object_boolean_true_add(json, "maxMedOnStartup");
8523 if (bgp->v_maxmed_admin)
8524 json_object_boolean_true_add(json, "maxMedAdministrative");
8525
8526 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
8527
8528 ents = bgp_table_count (bgp->rib[afi][safi]);
8529 json_object_int_add(json, "ribCount", ents);
8530 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
8531
8532 ents = listcount (bgp->peer);
8533 json_object_int_add(json, "peerCount", ents);
8534 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
8535
8536 if ((ents = listcount (bgp->group)))
8537 {
8538 json_object_int_add(json, "peerGroupCount", ents);
8539 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
8540 }
8541
8542 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
8543 json_object_boolean_true_add(json, "dampeningEnabled");
8544 }
8545 else
8546 {
8547 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
8548 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
8549 if (bgp->v_maxmed_admin)
8550 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
8551
8552 vty_out(vty, "BGP table version %" PRIu64 "%s",
8553 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
8554
8555 ents = bgp_table_count (bgp->rib[afi][safi]);
8556 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
8557 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8558 ents * sizeof (struct bgp_node)),
8559 VTY_NEWLINE);
8560
8561 /* Peer related usage */
8562 ents = listcount (bgp->peer);
8563 vty_out (vty, "Peers %ld, using %s of memory%s",
8564 ents,
8565 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8566 ents * sizeof (struct peer)),
8567 VTY_NEWLINE);
8568
8569 if ((ents = listcount (bgp->group)))
8570 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
8571 mtype_memstr (memstrbuf, sizeof (memstrbuf),
8572 ents * sizeof (struct peer_group)),
8573 VTY_NEWLINE);
8574
8575 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
8576 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
8577 vty_out (vty, "%s", VTY_NEWLINE);
8578 vty_out (vty, "%s%s", header, VTY_NEWLINE);
8579 }
8580 }
8581
8582 count++;
8583
8584 if (use_json)
8585 {
8586 json_peer = json_object_new_object();
8587
8588 if (peer_dynamic_neighbor(peer))
8589 json_object_boolean_true_add(json_peer, "dynamicPeer");
8590
8591 if (peer->hostname)
8592 json_object_string_add(json_peer, "hostname", peer->hostname);
8593
8594 if (peer->domainname)
8595 json_object_string_add(json_peer, "domainname", peer->domainname);
8596
8597 json_object_int_add(json_peer, "remoteAs", peer->as);
8598 json_object_int_add(json_peer, "version", 4);
8599 json_object_int_add(json_peer, "msgRcvd",
8600 peer->open_in + peer->update_in + peer->keepalive_in
8601 + peer->notify_in + peer->refresh_in
8602 + peer->dynamic_cap_in);
8603 json_object_int_add(json_peer, "msgSent",
8604 peer->open_out + peer->update_out + peer->keepalive_out
8605 + peer->notify_out + peer->refresh_out
8606 + peer->dynamic_cap_out);
8607
8608 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
8609 json_object_int_add(json_peer, "outq", peer->obuf->count);
8610 json_object_int_add(json_peer, "inq", 0);
8611 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
8612 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
8613
8614 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
8615 json_object_string_add(json_peer, "state", "Idle (Admin)");
8616 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8617 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
8618 else
8619 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
8620
8621 if (peer->conf_if)
8622 json_object_string_add(json_peer, "idType", "interface");
8623 else if (peer->su.sa.sa_family == AF_INET)
8624 json_object_string_add(json_peer, "idType", "ipv4");
8625 else if (peer->su.sa.sa_family == AF_INET6)
8626 json_object_string_add(json_peer, "idType", "ipv6");
8627
8628 json_object_object_add(json_peers, peer->host, json_peer);
8629 }
8630 else
8631 {
8632 memset(dn_flag, '\0', sizeof(dn_flag));
8633 if (peer_dynamic_neighbor(peer))
8634 {
8635 dn_count++;
8636 dn_flag[0] = '*';
8637 }
8638
8639 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
8640 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
8641 peer->host);
8642 else
8643 len = vty_out (vty, "%s%s", dn_flag, peer->host);
8644 len = 16 - len;
8645
8646 if (len < 1)
8647 vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
8648 else
8649 vty_out (vty, "%*s", len, " ");
8650
8651 vty_out (vty, "4 ");
8652
8653 vty_out (vty, "%5u %7d %7d %8" PRIu64 " %4d %4zd ",
8654 peer->as,
8655 peer->open_in + peer->update_in + peer->keepalive_in
8656 + peer->notify_in + peer->refresh_in
8657 + peer->dynamic_cap_in,
8658 peer->open_out + peer->update_out + peer->keepalive_out
8659 + peer->notify_out + peer->refresh_out
8660 + peer->dynamic_cap_out,
8661 peer->version[afi][safi],
8662 0,
8663 peer->obuf->count);
8664
8665 vty_out (vty, "%-8s",
8666 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8667
8668 if (peer->status == Established)
8669 vty_out (vty, " %8ld", peer->pcount[afi][safi]);
8670 else
8671 {
8672 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
8673 vty_out (vty, " Idle (Admin)");
8674 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
8675 vty_out (vty, " Idle (PfxCt)");
8676 else
8677 vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
8678 }
8679 vty_out (vty, "%s", VTY_NEWLINE);
8680 }
8681 }
8682 }
8683
8684 if (use_json)
8685 {
8686 json_object_object_add(json, "peers", json_peers);
8687
8688 json_object_int_add(json, "totalPeers", count);
8689 json_object_int_add(json, "dynamicPeers", dn_count);
8690
8691 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
8692 json_object_free(json);
8693 }
8694 else
8695 {
8696 if (count)
8697 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
8698 count, VTY_NEWLINE);
8699 else
8700 vty_out (vty, "No %s neighbor is configured%s",
8701 afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);
8702
8703 if (dn_count)
8704 {
8705 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
8706 vty_out(vty,
8707 "%d dynamic neighbor(s), limit %d%s",
8708 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
8709 }
8710 }
8711
8712 return CMD_SUCCESS;
8713 }
8714
8715 static int
8716 bgp_show_summary_vty (struct vty *vty, const char *name,
8717 afi_t afi, safi_t safi, u_char use_json)
8718 {
8719 struct bgp *bgp;
8720
8721 if (name)
8722 {
8723 bgp = bgp_lookup_by_name (name);
8724
8725 if (! bgp)
8726 {
8727 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
8728 return CMD_WARNING;
8729 }
8730
8731 bgp_show_summary (vty, bgp, afi, safi, use_json);
8732 return CMD_SUCCESS;
8733 }
8734
8735 bgp = bgp_get_default ();
8736
8737 if (bgp)
8738 bgp_show_summary (vty, bgp, afi, safi, use_json);
8739
8740 return CMD_SUCCESS;
8741 }
8742
8743 /* `show ip bgp summary' commands. */
8744 DEFUN (show_ip_bgp_summary,
8745 show_ip_bgp_summary_cmd,
8746 "show ip bgp summary {json}",
8747 SHOW_STR
8748 IP_STR
8749 BGP_STR
8750 "Summary of BGP neighbor status\n"
8751 "JavaScript Object Notation\n")
8752 {
8753 u_char uj = use_json(argc, argv);
8754 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
8755 }
8756
8757 DEFUN (show_ip_bgp_instance_summary,
8758 show_ip_bgp_instance_summary_cmd,
8759 "show ip bgp " BGP_INSTANCE_CMD " summary {json}",
8760 SHOW_STR
8761 IP_STR
8762 BGP_STR
8763 BGP_INSTANCE_HELP_STR
8764 "Summary of BGP neighbor status\n"
8765 "JavaScript Object Notation\n")
8766 {
8767 u_char uj = use_json(argc, argv);
8768 return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj);
8769 }
8770
8771 DEFUN (show_ip_bgp_ipv4_summary,
8772 show_ip_bgp_ipv4_summary_cmd,
8773 "show ip bgp ipv4 (unicast|multicast) summary {json}",
8774 SHOW_STR
8775 IP_STR
8776 BGP_STR
8777 "Address family\n"
8778 "Address Family modifier\n"
8779 "Address Family modifier\n"
8780 "Summary of BGP neighbor status\n"
8781 "JavaScript Object Notation\n")
8782 {
8783 u_char uj = use_json(argc, argv);
8784 if (strncmp (argv[0], "m", 1) == 0)
8785 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj);
8786
8787 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj);
8788 }
8789
8790 ALIAS (show_ip_bgp_ipv4_summary,
8791 show_bgp_ipv4_safi_summary_cmd,
8792 "show bgp ipv4 (unicast|multicast) summary {json}",
8793 SHOW_STR
8794 BGP_STR
8795 "Address family\n"
8796 "Address Family modifier\n"
8797 "Address Family modifier\n"
8798 "Summary of BGP neighbor status\n")
8799
8800 DEFUN (show_ip_bgp_instance_ipv4_summary,
8801 show_ip_bgp_instance_ipv4_summary_cmd,
8802 "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}",
8803 SHOW_STR
8804 IP_STR
8805 BGP_STR
8806 "BGP view\n"
8807 "View name\n"
8808 "Address family\n"
8809 "Address Family modifier\n"
8810 "Address Family modifier\n"
8811 "Summary of BGP neighbor status\n"
8812 "JavaScript Object Notation\n")
8813 {
8814 u_char uj = use_json(argc, argv);
8815 if (strncmp (argv[1], "m", 1) == 0)
8816 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj);
8817 else
8818 return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj);
8819 }
8820
8821 ALIAS (show_ip_bgp_instance_ipv4_summary,
8822 show_bgp_instance_ipv4_safi_summary_cmd,
8823 "show bgp view WORD ipv4 (unicast|multicast) summary {json}",
8824 SHOW_STR
8825 BGP_STR
8826 "BGP view\n"
8827 "View name\n"
8828 "Address family\n"
8829 "Address Family modifier\n"
8830 "Address Family modifier\n"
8831 "Summary of BGP neighbor status\n")
8832
8833 DEFUN (show_ip_bgp_vpnv4_all_summary,
8834 show_ip_bgp_vpnv4_all_summary_cmd,
8835 "show ip bgp vpnv4 all summary {json}",
8836 SHOW_STR
8837 IP_STR
8838 BGP_STR
8839 "Display VPNv4 NLRI specific information\n"
8840 "Display information about all VPNv4 NLRIs\n"
8841 "Summary of BGP neighbor status\n"
8842 "JavaScript Object Notation\n")
8843 {
8844 u_char uj = use_json(argc, argv);
8845 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
8846 }
8847
8848 DEFUN (show_ip_bgp_vpnv4_rd_summary,
8849 show_ip_bgp_vpnv4_rd_summary_cmd,
8850 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}",
8851 SHOW_STR
8852 IP_STR
8853 BGP_STR
8854 "Display VPNv4 NLRI specific information\n"
8855 "Display information for a route distinguisher\n"
8856 "VPN Route Distinguisher\n"
8857 "Summary of BGP neighbor status\n"
8858 "JavaScript Object Notation\n")
8859 {
8860 int ret;
8861 struct prefix_rd prd;
8862 u_char uj = use_json(argc, argv);
8863
8864 ret = str2prefix_rd (argv[0], &prd);
8865 if (! ret)
8866 {
8867 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
8868 return CMD_WARNING;
8869 }
8870
8871 return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj);
8872 }
8873
8874 #ifdef HAVE_IPV6
8875 DEFUN (show_bgp_summary,
8876 show_bgp_summary_cmd,
8877 "show bgp summary {json}",
8878 SHOW_STR
8879 BGP_STR
8880 "Summary of BGP neighbor status\n"
8881 "JavaScript Object Notation\n")
8882 {
8883 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
8884 }
8885
8886 DEFUN (show_bgp_instance_summary,
8887 show_bgp_instance_summary_cmd,
8888 "show bgp " BGP_INSTANCE_CMD " summary {json}",
8889 SHOW_STR
8890 BGP_STR
8891 BGP_INSTANCE_HELP_STR
8892 "Summary of BGP neighbor status\n"
8893 "JavaScript Object Notation\n")
8894 {
8895 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv));
8896 }
8897
8898 ALIAS (show_bgp_summary,
8899 show_bgp_ipv6_summary_cmd,
8900 "show bgp ipv6 summary {json}",
8901 SHOW_STR
8902 BGP_STR
8903 "Address family\n"
8904 "Summary of BGP neighbor status\n")
8905
8906 ALIAS (show_bgp_instance_summary,
8907 show_bgp_instance_ipv6_summary_cmd,
8908 "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}",
8909 SHOW_STR
8910 BGP_STR
8911 BGP_INSTANCE_HELP_STR
8912 "Address family\n"
8913 "Summary of BGP neighbor status\n")
8914
8915 DEFUN (show_bgp_ipv6_safi_summary,
8916 show_bgp_ipv6_safi_summary_cmd,
8917 "show bgp ipv6 (unicast|multicast) summary {json}",
8918 SHOW_STR
8919 BGP_STR
8920 "Address family\n"
8921 "Address Family modifier\n"
8922 "Address Family modifier\n"
8923 "Summary of BGP neighbor status\n"
8924 "JavaScript Object Notation\n")
8925 {
8926 u_char uj = use_json(argc, argv);
8927 if (strncmp (argv[0], "m", 1) == 0)
8928 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
8929
8930 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
8931 }
8932
8933 DEFUN (show_bgp_instance_ipv6_safi_summary,
8934 show_bgp_instance_ipv6_safi_summary_cmd,
8935 "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}",
8936 SHOW_STR
8937 BGP_STR
8938 BGP_INSTANCE_HELP_STR
8939 "Address family\n"
8940 "Address Family modifier\n"
8941 "Address Family modifier\n"
8942 "Summary of BGP neighbor status\n"
8943 "JavaScript Object Notation\n")
8944 {
8945 u_char uj = use_json(argc, argv);
8946 if (strncmp (argv[2], "m", 1) == 0)
8947 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj);
8948
8949 return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj);
8950 }
8951
8952 /* old command */
8953 DEFUN (show_ipv6_bgp_summary,
8954 show_ipv6_bgp_summary_cmd,
8955 "show ipv6 bgp summary {json}",
8956 SHOW_STR
8957 IPV6_STR
8958 BGP_STR
8959 "Summary of BGP neighbor status\n"
8960 "JavaScript Object Notation\n")
8961 {
8962 u_char uj = use_json(argc, argv);
8963 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj);
8964 }
8965
8966 /* old command */
8967 DEFUN (show_ipv6_mbgp_summary,
8968 show_ipv6_mbgp_summary_cmd,
8969 "show ipv6 mbgp summary {json}",
8970 SHOW_STR
8971 IPV6_STR
8972 MBGP_STR
8973 "Summary of BGP neighbor status\n"
8974 "JavaScript Object Notation\n")
8975 {
8976 u_char uj = use_json(argc, argv);
8977 return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj);
8978 }
8979 #endif /* HAVE_IPV6 */
8980
8981 const char *
8982 afi_safi_print (afi_t afi, safi_t safi)
8983 {
8984 if (afi == AFI_IP && safi == SAFI_UNICAST)
8985 return "IPv4 Unicast";
8986 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
8987 return "IPv4 Multicast";
8988 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
8989 return "VPNv4 Unicast";
8990 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
8991 return "IPv6 Unicast";
8992 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
8993 return "IPv6 Multicast";
8994 else
8995 return "Unknown";
8996 }
8997
8998 /* Show BGP peer's information. */
8999 enum show_type
9000 {
9001 show_all,
9002 show_peer
9003 };
9004
9005 static void
9006 bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
9007 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
9008 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
9009 {
9010 /* Send-Mode */
9011 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
9012 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9013 {
9014 if (use_json)
9015 {
9016 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9017 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
9018 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
9019 json_object_string_add(json_pref, "sendMode", "advertised");
9020 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9021 json_object_string_add(json_pref, "sendMode", "received");
9022 }
9023 else
9024 {
9025 vty_out (vty, " Send-mode: ");
9026 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
9027 vty_out (vty, "advertised");
9028 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
9029 vty_out (vty, "%sreceived",
9030 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
9031 ", " : "");
9032 vty_out (vty, "%s", VTY_NEWLINE);
9033 }
9034 }
9035
9036 /* Receive-Mode */
9037 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
9038 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9039 {
9040 if (use_json)
9041 {
9042 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9043 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
9044 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9045 json_object_string_add(json_pref, "recvMode", "advertised");
9046 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9047 json_object_string_add(json_pref, "recvMode", "received");
9048 }
9049 else
9050 {
9051 vty_out (vty, " Receive-mode: ");
9052 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
9053 vty_out (vty, "advertised");
9054 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
9055 vty_out (vty, "%sreceived",
9056 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
9057 ", " : "");
9058 vty_out (vty, "%s", VTY_NEWLINE);
9059 }
9060 }
9061 }
9062
9063 static void
9064 bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
9065 u_char use_json, json_object *json_neigh)
9066 {
9067 struct bgp_filter *filter;
9068 struct peer_af *paf;
9069 char orf_pfx_name[BUFSIZ];
9070 int orf_pfx_count;
9071 json_object *json_af = NULL;
9072 json_object *json_prefA = NULL;
9073 json_object *json_prefB = NULL;
9074 json_object *json_addr = NULL;
9075
9076 if (use_json)
9077 {
9078 json_addr = json_object_new_object();
9079 json_af = json_object_new_object();
9080 json_prefA = json_object_new_object();
9081 json_prefB = json_object_new_object();
9082 filter = &p->filter[afi][safi];
9083
9084 if (peer_group_active(p))
9085 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
9086
9087 paf = peer_af_find(p, afi, safi);
9088 if (paf && PAF_SUBGRP(paf))
9089 {
9090 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
9091 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
9092 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
9093 }
9094
9095 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9096 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9097 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9098 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
9099 {
9100 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
9101 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9102 PEER_CAP_ORF_PREFIX_SM_ADV,
9103 PEER_CAP_ORF_PREFIX_RM_ADV,
9104 PEER_CAP_ORF_PREFIX_SM_RCV,
9105 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
9106 json_object_object_add(json_af, "orfPrefixList", json_prefA);
9107 }
9108
9109 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9110 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9111 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9112 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9113 {
9114 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
9115 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9116 PEER_CAP_ORF_PREFIX_SM_ADV,
9117 PEER_CAP_ORF_PREFIX_RM_ADV,
9118 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
9119 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
9120 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
9121 }
9122
9123 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9124 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9125 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9126 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9127 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
9128 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9129 json_object_object_add(json_addr, "afDependentCap", json_af);
9130
9131 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
9132 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
9133
9134 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
9135 || orf_pfx_count)
9136 {
9137 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
9138 json_object_boolean_true_add(json_neigh, "orfSent");
9139 if (orf_pfx_count)
9140 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
9141 }
9142 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
9143 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
9144
9145 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
9146 json_object_boolean_true_add(json_addr, "routeReflectorClient");
9147 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9148 json_object_boolean_true_add(json_addr, "routeServerClient");
9149 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
9150 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
9151
9152 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
9153 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
9154 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
9155 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
9156 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
9157 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
9158 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
9159 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
9160
9161 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
9162 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
9163
9164 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
9165 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
9166
9167 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
9168 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
9169
9170 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
9171 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
9172 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
9173 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
9174 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
9175 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
9176 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
9177 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
9178 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
9179 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9180 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9181 {
9182 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9183 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9184 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
9185 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9186 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
9187 else
9188 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
9189 }
9190 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
9191 {
9192 if (p->default_rmap[afi][safi].name)
9193 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
9194
9195 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
9196 json_object_boolean_true_add(json_addr, "defaultSent");
9197 else
9198 json_object_boolean_true_add(json_addr, "defaultNotSent");
9199 }
9200
9201 if (filter->plist[FILTER_IN].name
9202 || filter->dlist[FILTER_IN].name
9203 || filter->aslist[FILTER_IN].name
9204 || filter->map[RMAP_IN].name)
9205 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
9206 if (filter->plist[FILTER_OUT].name
9207 || filter->dlist[FILTER_OUT].name
9208 || filter->aslist[FILTER_OUT].name
9209 || filter->map[RMAP_OUT].name
9210 || filter->usmap.name)
9211 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
9212
9213 /* prefix-list */
9214 if (filter->plist[FILTER_IN].name)
9215 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
9216 if (filter->plist[FILTER_OUT].name)
9217 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
9218
9219 /* distribute-list */
9220 if (filter->dlist[FILTER_IN].name)
9221 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
9222 if (filter->dlist[FILTER_OUT].name)
9223 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
9224
9225 /* filter-list. */
9226 if (filter->aslist[FILTER_IN].name)
9227 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
9228 if (filter->aslist[FILTER_OUT].name)
9229 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
9230
9231 /* route-map. */
9232 if (filter->map[RMAP_IN].name)
9233 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
9234 if (filter->map[RMAP_OUT].name)
9235 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
9236
9237 /* unsuppress-map */
9238 if (filter->usmap.name)
9239 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
9240
9241 /* Receive prefix count */
9242 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
9243
9244 /* Maximum prefix */
9245 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
9246 {
9247 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
9248 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
9249 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
9250 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
9251 if (p->pmax_restart[afi][safi])
9252 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
9253 }
9254 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
9255
9256 }
9257 else
9258 {
9259 filter = &p->filter[afi][safi];
9260
9261 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
9262 VTY_NEWLINE);
9263
9264 if (peer_group_active(p))
9265 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
9266
9267 paf = peer_af_find(p, afi, safi);
9268 if (paf && PAF_SUBGRP(paf))
9269 {
9270 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
9271 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
9272 vty_out (vty, " Packet Queue length %d%s",
9273 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
9274 }
9275 else
9276 {
9277 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
9278 }
9279 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9280 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9281 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9282 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9283 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
9284 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9285 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
9286
9287 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9288 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
9289 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9290 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
9291 {
9292 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
9293 ORF_TYPE_PREFIX, VTY_NEWLINE);
9294 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9295 PEER_CAP_ORF_PREFIX_SM_ADV,
9296 PEER_CAP_ORF_PREFIX_RM_ADV,
9297 PEER_CAP_ORF_PREFIX_SM_RCV,
9298 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
9299 }
9300 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
9301 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
9302 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
9303 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
9304 {
9305 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
9306 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
9307 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
9308 PEER_CAP_ORF_PREFIX_SM_ADV,
9309 PEER_CAP_ORF_PREFIX_RM_ADV,
9310 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
9311 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
9312 }
9313
9314 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
9315 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
9316
9317 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
9318 || orf_pfx_count)
9319 {
9320 vty_out (vty, " Outbound Route Filter (ORF):");
9321 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
9322 vty_out (vty, " sent;");
9323 if (orf_pfx_count)
9324 vty_out (vty, " received (%d entries)", orf_pfx_count);
9325 vty_out (vty, "%s", VTY_NEWLINE);
9326 }
9327 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
9328 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
9329
9330 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
9331 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
9332 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
9333 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
9334 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
9335 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
9336
9337 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
9338 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
9339 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
9340 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
9341 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
9342 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
9343 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
9344 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
9345
9346 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
9347 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
9348
9349 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
9350 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
9351
9352 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
9353 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
9354
9355 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
9356 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
9357 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
9358 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
9359 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9360 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
9361 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9362 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
9363 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
9364 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9365 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9366 {
9367 vty_out (vty, " Community attribute sent to this neighbor");
9368 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
9369 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9370 vty_out (vty, "(both)%s", VTY_NEWLINE);
9371 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
9372 vty_out (vty, "(extended)%s", VTY_NEWLINE);
9373 else
9374 vty_out (vty, "(standard)%s", VTY_NEWLINE);
9375 }
9376 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
9377 {
9378 vty_out (vty, " Default information originate,");
9379
9380 if (p->default_rmap[afi][safi].name)
9381 vty_out (vty, " default route-map %s%s,",
9382 p->default_rmap[afi][safi].map ? "*" : "",
9383 p->default_rmap[afi][safi].name);
9384 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
9385 vty_out (vty, " default sent%s", VTY_NEWLINE);
9386 else
9387 vty_out (vty, " default not sent%s", VTY_NEWLINE);
9388 }
9389
9390 if (filter->plist[FILTER_IN].name
9391 || filter->dlist[FILTER_IN].name
9392 || filter->aslist[FILTER_IN].name
9393 || filter->map[RMAP_IN].name)
9394 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
9395 if (filter->plist[FILTER_OUT].name
9396 || filter->dlist[FILTER_OUT].name
9397 || filter->aslist[FILTER_OUT].name
9398 || filter->map[RMAP_OUT].name
9399 || filter->usmap.name)
9400 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
9401
9402 /* prefix-list */
9403 if (filter->plist[FILTER_IN].name)
9404 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
9405 filter->plist[FILTER_IN].plist ? "*" : "",
9406 filter->plist[FILTER_IN].name,
9407 VTY_NEWLINE);
9408 if (filter->plist[FILTER_OUT].name)
9409 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
9410 filter->plist[FILTER_OUT].plist ? "*" : "",
9411 filter->plist[FILTER_OUT].name,
9412 VTY_NEWLINE);
9413
9414 /* distribute-list */
9415 if (filter->dlist[FILTER_IN].name)
9416 vty_out (vty, " Incoming update network filter list is %s%s%s",
9417 filter->dlist[FILTER_IN].alist ? "*" : "",
9418 filter->dlist[FILTER_IN].name,
9419 VTY_NEWLINE);
9420 if (filter->dlist[FILTER_OUT].name)
9421 vty_out (vty, " Outgoing update network filter list is %s%s%s",
9422 filter->dlist[FILTER_OUT].alist ? "*" : "",
9423 filter->dlist[FILTER_OUT].name,
9424 VTY_NEWLINE);
9425
9426 /* filter-list. */
9427 if (filter->aslist[FILTER_IN].name)
9428 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
9429 filter->aslist[FILTER_IN].aslist ? "*" : "",
9430 filter->aslist[FILTER_IN].name,
9431 VTY_NEWLINE);
9432 if (filter->aslist[FILTER_OUT].name)
9433 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
9434 filter->aslist[FILTER_OUT].aslist ? "*" : "",
9435 filter->aslist[FILTER_OUT].name,
9436 VTY_NEWLINE);
9437
9438 /* route-map. */
9439 if (filter->map[RMAP_IN].name)
9440 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
9441 filter->map[RMAP_IN].map ? "*" : "",
9442 filter->map[RMAP_IN].name,
9443 VTY_NEWLINE);
9444 if (filter->map[RMAP_OUT].name)
9445 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
9446 filter->map[RMAP_OUT].map ? "*" : "",
9447 filter->map[RMAP_OUT].name,
9448 VTY_NEWLINE);
9449
9450 /* unsuppress-map */
9451 if (filter->usmap.name)
9452 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
9453 filter->usmap.map ? "*" : "",
9454 filter->usmap.name, VTY_NEWLINE);
9455
9456 /* Receive prefix count */
9457 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
9458
9459 /* Maximum prefix */
9460 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
9461 {
9462 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
9463 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
9464 ? " (warning-only)" : "", VTY_NEWLINE);
9465 vty_out (vty, " Threshold for warning message %d%%",
9466 p->pmax_threshold[afi][safi]);
9467 if (p->pmax_restart[afi][safi])
9468 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
9469 vty_out (vty, "%s", VTY_NEWLINE);
9470 }
9471
9472 vty_out (vty, "%s", VTY_NEWLINE);
9473 }
9474 }
9475
9476 static void
9477 bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json, json_object *json_neigh)
9478 {
9479 struct bgp *bgp;
9480 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
9481 char timebuf[BGP_UPTIME_LEN];
9482 char dn_flag[2];
9483 const char *subcode_str;
9484 const char *code_str;
9485 afi_t afi;
9486 safi_t safi;
9487 u_int16_t i;
9488 u_char *msg;
9489
9490 bgp = p->bgp;
9491
9492 if (!use_json)
9493 {
9494 if (p->conf_if) /* Configured interface name. */
9495 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
9496 BGP_PEER_SU_UNSPEC(p) ? "None" :
9497 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
9498 else /* Configured IP address. */
9499 {
9500 memset(dn_flag, '\0', sizeof(dn_flag));
9501 if (peer_dynamic_neighbor(p))
9502 dn_flag[0] = '*';
9503
9504 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
9505 }
9506 }
9507
9508 if (use_json)
9509 {
9510 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
9511 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
9512 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
9513 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
9514
9515 json_object_int_add(json_neigh, "remoteAs", p->as);
9516
9517 if (p->change_local_as)
9518 json_object_int_add(json_neigh, "localAs", p->change_local_as);
9519 else
9520 json_object_int_add(json_neigh, "localAs", p->local_as);
9521
9522 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
9523 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
9524
9525 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
9526 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
9527 }
9528 else
9529 {
9530 if ((p->as_type == AS_SPECIFIED) ||
9531 (p->as_type == AS_EXTERNAL) ||
9532 (p->as_type == AS_INTERNAL))
9533 vty_out (vty, "remote AS %u, ", p->as);
9534 else
9535 vty_out (vty, "remote AS Unspecified, ");
9536 vty_out (vty, "local AS %u%s%s, ",
9537 p->change_local_as ? p->change_local_as : p->local_as,
9538 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
9539 " no-prepend" : "",
9540 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
9541 " replace-as" : "");
9542 }
9543 /* peer type internal, external, confed-internal or confed-external */
9544 if (p->as == p->local_as)
9545 {
9546 if (use_json)
9547 {
9548 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9549 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
9550 else
9551 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
9552 }
9553 else
9554 {
9555 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9556 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
9557 else
9558 vty_out (vty, "internal link%s", VTY_NEWLINE);
9559 }
9560 }
9561 else
9562 {
9563 if (use_json)
9564 {
9565 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
9566 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
9567 else
9568 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
9569 }
9570 else
9571 {
9572 if (bgp_confederation_peers_check(bgp, p->as))
9573 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
9574 else
9575 vty_out (vty, "external link%s", VTY_NEWLINE);
9576 }
9577 }
9578
9579 /* Description. */
9580 if (p->desc)
9581 {
9582 if (use_json)
9583 json_object_string_add(json_neigh, "nbrDesc", p->desc);
9584 else
9585 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
9586 }
9587
9588 if (p->hostname)
9589 {
9590 if (use_json)
9591 {
9592 if (p->hostname)
9593 json_object_string_add(json_neigh, "hostname", p->hostname);
9594
9595 if (p->domainname)
9596 json_object_string_add(json_neigh, "domainname", p->domainname);
9597 }
9598 else
9599 {
9600 if (p->domainname && (p->domainname[0] != '\0'))
9601 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
9602 VTY_NEWLINE);
9603 else
9604 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
9605 }
9606
9607 }
9608
9609 /* Peer-group */
9610 if (p->group)
9611 {
9612 if (use_json)
9613 {
9614 json_object_string_add(json_neigh, "peerGroup", p->group->name);
9615
9616 if (dn_flag[0])
9617 {
9618 struct prefix *prefix = NULL, *range = NULL;
9619
9620 prefix = sockunion2hostprefix(&(p->su));
9621 if (prefix)
9622 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
9623
9624 if (range)
9625 {
9626 prefix2str(range, buf1, sizeof(buf1));
9627 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
9628 }
9629 }
9630 }
9631 else
9632 {
9633 vty_out (vty, " Member of peer-group %s for session parameters%s",
9634 p->group->name, VTY_NEWLINE);
9635
9636 if (dn_flag[0])
9637 {
9638 struct prefix *prefix = NULL, *range = NULL;
9639
9640 prefix = sockunion2hostprefix(&(p->su));
9641 if (prefix)
9642 range = peer_group_lookup_dynamic_neighbor_range (p->group, prefix);
9643
9644 if (range)
9645 {
9646 prefix2str(range, buf1, sizeof(buf1));
9647 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
9648 }
9649 }
9650 }
9651 }
9652
9653 if (use_json)
9654 {
9655 /* Administrative shutdown. */
9656 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
9657 json_object_boolean_true_add(json_neigh, "adminShutDown");
9658
9659 /* BGP Version. */
9660 json_object_int_add(json_neigh, "bgpVersion", 4);
9661 json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ));
9662
9663 /* Confederation */
9664 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
9665 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
9666
9667 /* Status. */
9668 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
9669
9670 if (p->status == Established)
9671 {
9672 time_t uptime;
9673 struct tm *tm;
9674
9675 uptime = bgp_clock();
9676 uptime -= p->uptime;
9677 tm = gmtime(&uptime);
9678
9679 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9680 }
9681
9682 else if (p->status == Active)
9683 {
9684 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
9685 json_object_string_add(json_neigh, "bgpStateIs", "passive");
9686 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
9687 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
9688 }
9689
9690 /* read timer */
9691 time_t uptime;
9692 struct tm *tm;
9693
9694 uptime = bgp_clock();
9695 uptime -= p->readtime;
9696 tm = gmtime(&uptime);
9697 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9698
9699 uptime = bgp_clock();
9700 uptime -= p->last_write;
9701 tm = gmtime(&uptime);
9702 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9703
9704 /* Configured timer values. */
9705 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
9706 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
9707
9708 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
9709 {
9710 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
9711 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
9712 }
9713 }
9714 else
9715 {
9716 /* Administrative shutdown. */
9717 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
9718 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
9719
9720 /* BGP Version. */
9721 vty_out (vty, " BGP version 4");
9722 vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
9723 VTY_NEWLINE);
9724
9725 /* Confederation */
9726 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
9727 && bgp_confederation_peers_check (bgp, p->as))
9728 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
9729
9730 /* Status. */
9731 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
9732
9733 if (p->status == Established)
9734 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
9735
9736 else if (p->status == Active)
9737 {
9738 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
9739 vty_out (vty, " (passive)");
9740 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
9741 vty_out (vty, " (NSF passive)");
9742 }
9743 vty_out (vty, "%s", VTY_NEWLINE);
9744
9745 /* read timer */
9746 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
9747 vty_out (vty, ", Last write %s%s",
9748 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
9749
9750 /* Configured timer values. */
9751 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
9752 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
9753 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
9754 {
9755 vty_out (vty, " Configured hold time is %d", p->holdtime);
9756 vty_out (vty, ", keepalive interval is %d seconds%s",
9757 p->keepalive, VTY_NEWLINE);
9758 }
9759 }
9760 /* Capability. */
9761 if (p->status == Established)
9762 {
9763 if (p->cap
9764 || p->afc_adv[AFI_IP][SAFI_UNICAST]
9765 || p->afc_recv[AFI_IP][SAFI_UNICAST]
9766 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
9767 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
9768 #ifdef HAVE_IPV6
9769 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
9770 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
9771 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
9772 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
9773 #endif /* HAVE_IPV6 */
9774 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
9775 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
9776 {
9777 if (use_json)
9778 {
9779 json_object *json_cap = NULL;
9780
9781 json_cap = json_object_new_object();
9782
9783 /* AS4 */
9784 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
9785 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9786 {
9787 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9788 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
9789 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9790 json_object_string_add(json_cap, "4byteAs", "advertised");
9791 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9792 json_object_string_add(json_cap, "4byteAs", "received");
9793 }
9794
9795 /* AddPath */
9796 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
9797 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
9798 {
9799 json_object *json_add = NULL;
9800 const char *print_store;
9801
9802 json_add = json_object_new_object();
9803
9804 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9805 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9806 {
9807 json_object *json_sub = NULL;
9808 json_sub = json_object_new_object();
9809 print_store = afi_safi_print (afi, safi);
9810
9811 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9812 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9813 {
9814 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))
9815 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
9816 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
9817 json_object_boolean_true_add(json_sub, "txAdvertised");
9818 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
9819 json_object_boolean_true_add(json_sub, "txReceived");
9820 }
9821
9822 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
9823 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9824 {
9825 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))
9826 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
9827 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
9828 json_object_boolean_true_add(json_sub, "rxAdvertised");
9829 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9830 json_object_boolean_true_add(json_sub, "rxReceived");
9831 }
9832
9833 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
9834 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
9835 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
9836 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
9837 json_object_object_add(json_add, print_store, json_sub);
9838 }
9839
9840 json_object_object_add(json_cap, "addPath", json_add);
9841 }
9842
9843 /* Dynamic */
9844 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
9845 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9846 {
9847 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
9848 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
9849 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
9850 json_object_string_add(json_cap, "dynamic", "advertised");
9851 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
9852 json_object_string_add(json_cap, "dynamic", "received");
9853 }
9854
9855 /* Extended nexthop */
9856 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
9857 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
9858 {
9859 json_object *json_nxt = NULL;
9860 const char *print_store;
9861
9862 json_nxt = json_object_new_object();
9863
9864 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9865 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
9866 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
9867 json_object_string_add(json_cap, "extendedNexthop", "advertised");
9868 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9869 json_object_string_add(json_cap, "extendedNexthop", "received");
9870
9871 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
9872 {
9873 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9874 {
9875 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
9876 {
9877 print_store = afi_safi_print (AFI_IP, safi);
9878 json_object_string_add(json_nxt, print_store, "recieved");
9879 }
9880 }
9881 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
9882 }
9883 }
9884
9885 /* Route Refresh */
9886 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
9887 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
9888 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9889 {
9890 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)))
9891 {
9892 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
9893 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
9894 else
9895 {
9896 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9897 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
9898 else
9899 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
9900 }
9901 }
9902 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
9903 json_object_string_add(json_cap, "routeRefresh", "advertised");
9904 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
9905 json_object_string_add(json_cap, "routeRefresh", "received");
9906 }
9907
9908 /* Multiprotocol Extensions */
9909 json_object *json_multi = NULL;
9910 json_multi = json_object_new_object();
9911
9912 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9913 {
9914 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9915 {
9916 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
9917 {
9918 json_object *json_exten = NULL;
9919 json_exten = json_object_new_object();
9920
9921 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
9922 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
9923 else if (p->afc_adv[afi][safi])
9924 json_object_boolean_true_add(json_exten, "advertised");
9925 else if (p->afc_recv[afi][safi])
9926 json_object_boolean_true_add(json_exten, "received");
9927
9928 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
9929 }
9930 }
9931 }
9932 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
9933
9934 /* Gracefull Restart */
9935 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
9936 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
9937 {
9938 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9939 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
9940 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
9941 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
9942 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9943 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
9944
9945 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
9946 {
9947 int restart_af_count = 0;
9948 json_object *json_restart = NULL;
9949 json_restart = json_object_new_object();
9950
9951 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
9952
9953 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
9954 {
9955 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
9956 {
9957 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
9958 {
9959 json_object *json_sub = NULL;
9960 json_sub = json_object_new_object();
9961
9962 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
9963 json_object_boolean_true_add(json_sub, "preserved");
9964 restart_af_count++;
9965 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
9966 }
9967 }
9968 }
9969 if (! restart_af_count)
9970 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
9971 else
9972 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
9973 }
9974 }
9975 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
9976 }
9977 else
9978 {
9979 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
9980
9981 /* AS4 */
9982 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
9983 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9984 {
9985 vty_out (vty, " 4 Byte AS:");
9986 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
9987 vty_out (vty, " advertised");
9988 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
9989 vty_out (vty, " %sreceived",
9990 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
9991 vty_out (vty, "%s", VTY_NEWLINE);
9992 }
9993
9994 /* AddPath */
9995 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
9996 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
9997 {
9998 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
9999
10000 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10001 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10002 {
10003 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
10004 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10005 {
10006 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
10007
10008 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
10009 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
10010
10011 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
10012 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
10013
10014 vty_out (vty, "%s", VTY_NEWLINE);
10015 }
10016
10017 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
10018 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10019 {
10020 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
10021
10022 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
10023 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
10024
10025 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
10026 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
10027
10028 vty_out (vty, "%s", VTY_NEWLINE);
10029 }
10030 }
10031 }
10032
10033 /* Dynamic */
10034 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
10035 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10036 {
10037 vty_out (vty, " Dynamic:");
10038 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
10039 vty_out (vty, " advertised");
10040 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
10041 vty_out (vty, " %sreceived",
10042 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
10043 vty_out (vty, "%s", VTY_NEWLINE);
10044 }
10045
10046 /* Extended nexthop */
10047 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
10048 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
10049 {
10050 vty_out (vty, " Extended nexthop:");
10051 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
10052 vty_out (vty, " advertised");
10053 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10054 vty_out (vty, " %sreceived",
10055 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
10056 vty_out (vty, "%s", VTY_NEWLINE);
10057
10058 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
10059 {
10060 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
10061 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10062 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
10063 vty_out (vty, " %s%s",
10064 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
10065 }
10066 }
10067
10068 /* Route Refresh */
10069 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
10070 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
10071 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10072 {
10073 vty_out (vty, " Route refresh:");
10074 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
10075 vty_out (vty, " advertised");
10076 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
10077 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
10078 vty_out (vty, " %sreceived(%s)",
10079 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
10080 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
10081 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
10082 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
10083
10084 vty_out (vty, "%s", VTY_NEWLINE);
10085 }
10086
10087 /* Multiprotocol Extensions */
10088 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10089 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10090 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
10091 {
10092 vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
10093 if (p->afc_adv[afi][safi])
10094 vty_out (vty, " advertised");
10095 if (p->afc_recv[afi][safi])
10096 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
10097 vty_out (vty, "%s", VTY_NEWLINE);
10098 }
10099
10100 /* Hostname capability */
10101 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
10102 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
10103 {
10104 vty_out (vty, " Hostname Capability:");
10105 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
10106 vty_out (vty, " advertised");
10107 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
10108 vty_out (vty, " %sreceived",
10109 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
10110 vty_out (vty, "%s", VTY_NEWLINE);
10111 }
10112
10113 /* Gracefull Restart */
10114 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
10115 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
10116 {
10117 vty_out (vty, " Graceful Restart Capabilty:");
10118 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
10119 vty_out (vty, " advertised");
10120 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10121 vty_out (vty, " %sreceived",
10122 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
10123 vty_out (vty, "%s", VTY_NEWLINE);
10124
10125 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
10126 {
10127 int restart_af_count = 0;
10128
10129 vty_out (vty, " Remote Restart timer is %d seconds%s",
10130 p->v_gr_restart, VTY_NEWLINE);
10131 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
10132
10133 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10134 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10135 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
10136 {
10137 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
10138 afi_safi_print (afi, safi),
10139 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
10140 "preserved" : "not preserved");
10141 restart_af_count++;
10142 }
10143 if (! restart_af_count)
10144 vty_out (vty, "none");
10145 vty_out (vty, "%s", VTY_NEWLINE);
10146 }
10147 }
10148 }
10149 }
10150 }
10151
10152 /* graceful restart information */
10153 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
10154 || p->t_gr_restart
10155 || p->t_gr_stale)
10156 {
10157 json_object *json_grace = NULL;
10158 json_object *json_grace_send = NULL;
10159 json_object *json_grace_recv = NULL;
10160 int eor_send_af_count = 0;
10161 int eor_receive_af_count = 0;
10162
10163 if (use_json)
10164 {
10165 json_grace = json_object_new_object();
10166 json_grace_send = json_object_new_object();
10167 json_grace_recv = json_object_new_object();
10168
10169 if (p->status == Established)
10170 {
10171 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10172 {
10173 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10174 {
10175 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
10176 {
10177 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
10178 eor_send_af_count++;
10179 }
10180 }
10181 }
10182 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10183 {
10184 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10185 {
10186 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
10187 {
10188 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
10189 eor_receive_af_count++;
10190 }
10191 }
10192 }
10193 }
10194
10195 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
10196 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
10197
10198 if (p->t_gr_restart)
10199 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
10200
10201 if (p->t_gr_stale)
10202 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
10203
10204 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
10205 }
10206 else
10207 {
10208 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
10209 if (p->status == Established)
10210 {
10211 vty_out (vty, " End-of-RIB send: ");
10212 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10213 {
10214 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10215 {
10216 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
10217 {
10218 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
10219 afi_safi_print (afi, safi));
10220 eor_send_af_count++;
10221 }
10222 }
10223 }
10224 vty_out (vty, "%s", VTY_NEWLINE);
10225 vty_out (vty, " End-of-RIB received: ");
10226 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10227 {
10228 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10229 {
10230 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
10231 {
10232 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
10233 afi_safi_print (afi, safi));
10234 eor_receive_af_count++;
10235 }
10236 }
10237 }
10238 vty_out (vty, "%s", VTY_NEWLINE);
10239 }
10240
10241 if (p->t_gr_restart)
10242 vty_out (vty, " The remaining time of restart timer is %ld%s",
10243 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
10244
10245 if (p->t_gr_stale)
10246 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
10247 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
10248 }
10249 }
10250 if (use_json)
10251 {
10252 json_object *json_stat = NULL;
10253 json_stat = json_object_new_object();
10254 /* Packet counts. */
10255 json_object_int_add(json_stat, "depthInq", 0);
10256 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
10257 json_object_int_add(json_stat, "opensSent", p->open_out);
10258 json_object_int_add(json_stat, "opensRecv", p->open_in);
10259 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
10260 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
10261 json_object_int_add(json_stat, "updatesSent", p->update_out);
10262 json_object_int_add(json_stat, "updatesRecv", p->update_in);
10263 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
10264 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
10265 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
10266 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
10267 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
10268 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
10269 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);
10270 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);
10271 json_object_object_add(json_neigh, "messageStats", json_stat);
10272 }
10273 else
10274 {
10275 /* Packet counts. */
10276 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
10277 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
10278 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
10279 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
10280 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
10281 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
10282 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
10283 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
10284 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
10285 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
10286 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
10287 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
10288 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
10289 p->dynamic_cap_in, VTY_NEWLINE);
10290 }
10291
10292 if (use_json)
10293 {
10294 /* advertisement-interval */
10295 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
10296
10297 /* Update-source. */
10298 if (p->update_if || p->update_source)
10299 {
10300 if (p->update_if)
10301 json_object_string_add(json_neigh, "updateSource", p->update_if);
10302 else if (p->update_source)
10303 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
10304 }
10305
10306 /* Default weight */
10307 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
10308 json_object_int_add(json_neigh, "defaultWeight", p->weight);
10309
10310 }
10311 else
10312 {
10313 /* advertisement-interval */
10314 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
10315 p->v_routeadv, VTY_NEWLINE);
10316
10317 /* Update-source. */
10318 if (p->update_if || p->update_source)
10319 {
10320 vty_out (vty, " Update source is ");
10321 if (p->update_if)
10322 vty_out (vty, "%s", p->update_if);
10323 else if (p->update_source)
10324 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
10325 vty_out (vty, "%s", VTY_NEWLINE);
10326 }
10327
10328 /* Default weight */
10329 if (CHECK_FLAG (p->config, PEER_CONFIG_WEIGHT))
10330 vty_out (vty, " Default weight %d%s", p->weight, VTY_NEWLINE);
10331
10332 vty_out (vty, "%s", VTY_NEWLINE);
10333 }
10334
10335 /* Address Family Information */
10336 json_object *json_hold = NULL;
10337
10338 if (use_json)
10339 json_hold = json_object_new_object();
10340
10341 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
10342 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10343 if (p->afc[afi][safi])
10344 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
10345
10346 if (use_json)
10347 {
10348 json_object_int_add(json_hold, "connectionsEstablished", p->established);
10349 json_object_int_add(json_hold, "connectionsDropped", p->dropped);
10350 }
10351 else
10352 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
10353 VTY_NEWLINE);
10354
10355 if (! p->last_reset)
10356 {
10357 if (use_json)
10358 json_object_string_add(json_hold, "lastReset", "never");
10359 else
10360 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
10361 }
10362 else
10363 {
10364 if (use_json)
10365 {
10366 time_t uptime;
10367 struct tm *tm;
10368
10369 uptime = bgp_clock();
10370 uptime -= p->resettime;
10371 tm = gmtime(&uptime);
10372 json_object_int_add(json_hold, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
10373 json_object_string_add(json_hold, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
10374 if (p->last_reset_cause_size)
10375 {
10376 msg = p->last_reset_cause;
10377 char adapter[BUFSIZ];
10378 sprintf(adapter, "%s", msg);
10379 json_object_string_add(json_hold, "messageReceivedThatCausedBgpNotification", adapter);
10380 }
10381 }
10382 else
10383 {
10384 vty_out (vty, " Last reset %s, ",
10385 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
10386
10387 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
10388 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
10389 {
10390 code_str = bgp_notify_code_str(p->notify.code);
10391 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
10392 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
10393 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
10394 code_str, subcode_str, VTY_NEWLINE);
10395 }
10396 else
10397 {
10398 vty_out (vty, "due to %s%s",
10399 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
10400 }
10401
10402 if (p->last_reset_cause_size)
10403 {
10404 msg = p->last_reset_cause;
10405 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
10406 for (i = 1; i <= p->last_reset_cause_size; i++)
10407 {
10408 vty_out(vty, "%02X", *msg++);
10409
10410 if (i != p->last_reset_cause_size)
10411 {
10412 if (i % 16 == 0)
10413 {
10414 vty_out(vty, "%s ", VTY_NEWLINE);
10415 }
10416 else if (i % 4 == 0)
10417 {
10418 vty_out(vty, " ");
10419 }
10420 }
10421 }
10422 vty_out(vty, "%s", VTY_NEWLINE);
10423 }
10424 }
10425 }
10426
10427 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10428 {
10429 if (use_json)
10430 json_object_boolean_true_add(json_hold, "prefixesConfigExceedMax");
10431 else
10432 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
10433
10434 if (p->t_pmax_restart)
10435 {
10436 if (use_json)
10437 {
10438 json_object_string_add(json_hold, "reducePrefixNumFrom", p->host);
10439 json_object_int_add(json_hold, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
10440 }
10441 else
10442 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
10443 p->host, thread_timer_remain_second (p->t_pmax_restart),
10444 VTY_NEWLINE);
10445 }
10446 else
10447 {
10448 if (use_json)
10449 json_object_string_add(json_hold, "reducePrefixNumAndClearIpBgp", p->host);
10450 else
10451 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
10452 p->host, VTY_NEWLINE);
10453 }
10454 }
10455
10456 if (use_json)
10457 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
10458
10459 /* EBGP Multihop and GTSM */
10460 if (p->sort != BGP_PEER_IBGP)
10461 {
10462 if (use_json)
10463 {
10464 if (p->gtsm_hops > 0)
10465 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
10466 else if (p->ttl > 1)
10467 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
10468 }
10469 else
10470 {
10471 if (p->gtsm_hops > 0)
10472 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
10473 p->gtsm_hops, VTY_NEWLINE);
10474 else if (p->ttl > 1)
10475 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
10476 p->ttl, VTY_NEWLINE);
10477 }
10478 }
10479 else
10480 {
10481 if (p->gtsm_hops > 0)
10482 {
10483 if (use_json)
10484 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
10485 else
10486 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
10487 p->gtsm_hops, VTY_NEWLINE);
10488 }
10489 }
10490
10491 /* Local address. */
10492 if (p->su_local)
10493 {
10494 if (use_json)
10495 {
10496 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
10497 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
10498 }
10499 else
10500 vty_out (vty, "Local host: %s, Local port: %d%s",
10501 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
10502 ntohs (p->su_local->sin.sin_port),
10503 VTY_NEWLINE);
10504 }
10505
10506 /* Remote address. */
10507 if (p->su_remote)
10508 {
10509 if (use_json)
10510 {
10511 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
10512 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
10513 }
10514 else
10515 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
10516 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
10517 ntohs (p->su_remote->sin.sin_port),
10518 VTY_NEWLINE);
10519 }
10520
10521 /* Nexthop display. */
10522 if (p->su_local)
10523 {
10524 if (use_json)
10525 {
10526 json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ));
10527 #ifdef HAVE_IPV6
10528 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ));
10529 json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ));
10530 if (p->shared_network)
10531 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
10532 else
10533 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
10534 #endif /* HAVE_IPV6 */
10535 }
10536 else
10537 {
10538 vty_out (vty, "Nexthop: %s%s",
10539 inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
10540 VTY_NEWLINE);
10541 #ifdef HAVE_IPV6
10542 vty_out (vty, "Nexthop global: %s%s",
10543 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
10544 VTY_NEWLINE);
10545 vty_out (vty, "Nexthop local: %s%s",
10546 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
10547 VTY_NEWLINE);
10548 vty_out (vty, "BGP connection: %s%s",
10549 p->shared_network ? "shared network" : "non shared network",
10550 VTY_NEWLINE);
10551 #endif /* HAVE_IPV6 */
10552 }
10553 }
10554
10555 /* Timer information. */
10556 if (use_json)
10557 {
10558 if (p->t_start)
10559 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
10560 if (p->t_connect)
10561 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
10562 if (p->t_routeadv)
10563 {
10564 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
10565 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
10566 }
10567
10568 if (p->t_read)
10569 json_object_string_add(json_neigh, "readThread", "on");
10570 else
10571 json_object_string_add(json_neigh, "readThread", "off");
10572 if (p->t_write)
10573 json_object_string_add(json_neigh, "writeThread", "on");
10574 else
10575 json_object_string_add(json_neigh, "writeThread", "off");
10576 }
10577 else
10578 {
10579 if (p->t_start)
10580 vty_out (vty, "Next start timer due in %ld seconds%s",
10581 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
10582 if (p->t_connect)
10583 vty_out (vty, "Next connect timer due in %ld seconds%s",
10584 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
10585 if (p->t_routeadv)
10586 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
10587 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
10588 VTY_NEWLINE);
10589
10590 vty_out (vty, "Read thread: %s Write thread: %s%s",
10591 p->t_read ? "on" : "off",
10592 p->t_write ? "on" : "off",
10593 VTY_NEWLINE);
10594 }
10595
10596 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
10597 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
10598 bgp_capability_vty_out (vty, p, use_json, json_neigh);
10599
10600 if (!use_json)
10601 vty_out (vty, "%s", VTY_NEWLINE);
10602
10603 /* BFD information. */
10604 bgp_bfd_show_info(vty, p, use_json, json_neigh);
10605
10606 if (use_json)
10607 {
10608 if (p->conf_if) /* Configured interface name. */
10609 json_object_object_add(json, p->conf_if, json_neigh);
10610 else /* Configured IP address. */
10611 json_object_object_add(json, p->host, json_neigh);
10612 }
10613 }
10614
10615 static int
10616 bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
10617 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
10618 {
10619 struct listnode *node, *nnode;
10620 struct peer *peer;
10621 int find = 0;
10622 json_object *json_neigh = NULL;
10623
10624 if (use_json)
10625 json_neigh = json_object_new_object();
10626
10627 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
10628 {
10629 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
10630 continue;
10631
10632 switch (type)
10633 {
10634 case show_all:
10635 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10636 break;
10637 case show_peer:
10638 if (conf_if)
10639 {
10640 if (peer->conf_if && !strcmp(peer->conf_if, conf_if))
10641 {
10642 find = 1;
10643 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10644 }
10645 }
10646 else
10647 {
10648 if (sockunion_same (&peer->su, su))
10649 {
10650 find = 1;
10651 bgp_show_peer (vty, peer, use_json, json, json_neigh);
10652 }
10653 }
10654 break;
10655 }
10656 }
10657
10658 if (type == show_peer && ! find)
10659 {
10660 if (use_json)
10661 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
10662 else
10663 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
10664 }
10665
10666 if (use_json)
10667 {
10668 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
10669 json_object_free(json);
10670 }
10671 else
10672 {
10673 vty_out (vty, "%s", VTY_NEWLINE);
10674 }
10675
10676 return CMD_SUCCESS;
10677 }
10678
10679 static int
10680 bgp_show_neighbor_vty (struct vty *vty, const char *name,
10681 enum show_type type, const char *ip_str, u_char use_json)
10682 {
10683 int ret;
10684 struct bgp *bgp;
10685 union sockunion su;
10686 json_object *json = NULL;
10687
10688 if (use_json)
10689 json = json_object_new_object();
10690
10691 if (name)
10692 {
10693 bgp = bgp_lookup_by_name (name);
10694 if (! bgp)
10695 {
10696 if (use_json)
10697 {
10698 json_object_boolean_true_add(json, "bgpNoSuchInstance");
10699 vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
10700 json_object_free(json);
10701 }
10702 else
10703 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10704
10705 return CMD_WARNING;
10706 }
10707 }
10708 else
10709 {
10710 bgp = bgp_get_default ();
10711 }
10712
10713 if (bgp)
10714 {
10715 if (ip_str)
10716 {
10717 ret = str2sockunion (ip_str, &su);
10718 if (ret < 0)
10719 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
10720 else
10721 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
10722 }
10723 else
10724 {
10725 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
10726 }
10727 }
10728
10729 return CMD_SUCCESS;
10730 }
10731
10732 /* "show ip bgp neighbors" commands. */
10733 DEFUN (show_ip_bgp_neighbors,
10734 show_ip_bgp_neighbors_cmd,
10735 "show ip bgp neighbors {json}",
10736 SHOW_STR
10737 IP_STR
10738 BGP_STR
10739 "Detailed information on TCP and BGP neighbor connections\n"
10740 "JavaScript Object Notation\n")
10741 {
10742 u_char uj = use_json(argc, argv);
10743
10744 return bgp_show_neighbor_vty (vty, NULL, show_all, NULL, uj);
10745 }
10746
10747 ALIAS (show_ip_bgp_neighbors,
10748 show_ip_bgp_ipv4_neighbors_cmd,
10749 "show ip bgp ipv4 (unicast|multicast) neighbors {json}",
10750 SHOW_STR
10751 IP_STR
10752 BGP_STR
10753 "Address family\n"
10754 "Address Family modifier\n"
10755 "Address Family modifier\n"
10756 "Detailed information on TCP and BGP neighbor connections\n"
10757 "JavaScript Object Notation\n")
10758
10759 ALIAS (show_ip_bgp_neighbors,
10760 show_ip_bgp_vpnv4_all_neighbors_cmd,
10761 "show ip bgp vpnv4 all neighbors {json}",
10762 SHOW_STR
10763 IP_STR
10764 BGP_STR
10765 "Display VPNv4 NLRI specific information\n"
10766 "Display information about all VPNv4 NLRIs\n"
10767 "Detailed information on TCP and BGP neighbor connections\n"
10768 "JavaScript Object Notation\n")
10769
10770 ALIAS (show_ip_bgp_neighbors,
10771 show_ip_bgp_vpnv4_rd_neighbors_cmd,
10772 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}",
10773 SHOW_STR
10774 IP_STR
10775 BGP_STR
10776 "Display VPNv4 NLRI specific information\n"
10777 "Display information for a route distinguisher\n"
10778 "VPN Route Distinguisher\n"
10779 "Detailed information on TCP and BGP neighbor connections\n"
10780 "JavaScript Object Notation\n")
10781
10782 ALIAS (show_ip_bgp_neighbors,
10783 show_bgp_neighbors_cmd,
10784 "show bgp neighbors {json}",
10785 SHOW_STR
10786 BGP_STR
10787 "Detailed information on TCP and BGP neighbor connections\n"
10788 "JavaScript Object Notation\n")
10789
10790 ALIAS (show_ip_bgp_neighbors,
10791 show_bgp_ipv6_neighbors_cmd,
10792 "show bgp ipv6 neighbors {json}",
10793 SHOW_STR
10794 BGP_STR
10795 "Address family\n"
10796 "Detailed information on TCP and BGP neighbor connections\n"
10797 "JavaScript Object Notation\n")
10798
10799 DEFUN (show_ip_bgp_neighbors_peer,
10800 show_ip_bgp_neighbors_peer_cmd,
10801 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10802 SHOW_STR
10803 IP_STR
10804 BGP_STR
10805 "Detailed information on TCP and BGP neighbor connections\n"
10806 "Neighbor to display information about\n"
10807 "Neighbor to display information about\n"
10808 "Neighbor on bgp configured interface\n"
10809 "JavaScript Object Notation\n")
10810 {
10811 u_char uj = use_json(argc, argv);
10812
10813 return bgp_show_neighbor_vty (vty, NULL, show_peer, argv[argc - 2], uj);
10814 }
10815
10816 ALIAS (show_ip_bgp_neighbors_peer,
10817 show_ip_bgp_ipv4_neighbors_peer_cmd,
10818 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10819 SHOW_STR
10820 IP_STR
10821 BGP_STR
10822 "Address family\n"
10823 "Address Family modifier\n"
10824 "Address Family modifier\n"
10825 "Detailed information on TCP and BGP neighbor connections\n"
10826 "Neighbor to display information about\n"
10827 "Neighbor to display information about\n"
10828 "Neighbor on bgp configured interface\n"
10829 "JavaScript Object Notation\n")
10830
10831 ALIAS (show_ip_bgp_neighbors_peer,
10832 show_ip_bgp_vpnv4_all_neighbors_peer_cmd,
10833 "show ip bgp vpnv4 all neighbors A.B.C.D {json}",
10834 SHOW_STR
10835 IP_STR
10836 BGP_STR
10837 "Display VPNv4 NLRI specific information\n"
10838 "Display information about all VPNv4 NLRIs\n"
10839 "Detailed information on TCP and BGP neighbor connections\n"
10840 "Neighbor to display information about\n"
10841 "JavaScript Object Notation\n")
10842
10843 ALIAS (show_ip_bgp_neighbors_peer,
10844 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd,
10845 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}",
10846 SHOW_STR
10847 IP_STR
10848 BGP_STR
10849 "Display VPNv4 NLRI specific information\n"
10850 "Display information about all VPNv4 NLRIs\n"
10851 "Detailed information on TCP and BGP neighbor connections\n"
10852 "Neighbor to display information about\n"
10853 "JavaScript Object Notation\n")
10854
10855 ALIAS (show_ip_bgp_neighbors_peer,
10856 show_bgp_neighbors_peer_cmd,
10857 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10858 SHOW_STR
10859 BGP_STR
10860 "Detailed information on TCP and BGP neighbor connections\n"
10861 "Neighbor to display information about\n"
10862 "Neighbor to display information about\n"
10863 "Neighbor on bgp configured interface\n"
10864 "JavaScript Object Notation\n")
10865
10866 ALIAS (show_ip_bgp_neighbors_peer,
10867 show_bgp_ipv6_neighbors_peer_cmd,
10868 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10869 SHOW_STR
10870 BGP_STR
10871 "Address family\n"
10872 "Detailed information on TCP and BGP neighbor connections\n"
10873 "Neighbor to display information about\n"
10874 "Neighbor to display information about\n"
10875 "Neighbor on bgp configured interface\n"
10876 "JavaScript Object Notation\n")
10877
10878 DEFUN (show_ip_bgp_instance_neighbors,
10879 show_ip_bgp_instance_neighbors_cmd,
10880 "show ip bgp " BGP_INSTANCE_CMD " neighbors {json}",
10881 SHOW_STR
10882 IP_STR
10883 BGP_STR
10884 BGP_INSTANCE_HELP_STR
10885 "Detailed information on TCP and BGP neighbor connections\n"
10886 "JavaScript Object Notation\n")
10887 {
10888 u_char uj = use_json(argc, argv);
10889
10890 return bgp_show_neighbor_vty (vty, argv[1], show_all, NULL, uj);
10891 }
10892
10893 ALIAS (show_ip_bgp_instance_neighbors,
10894 show_bgp_instance_neighbors_cmd,
10895 "show bgp " BGP_INSTANCE_CMD " neighbors {json}",
10896 SHOW_STR
10897 BGP_STR
10898 BGP_INSTANCE_HELP_STR
10899 "Detailed information on TCP and BGP neighbor connections\n"
10900 "JavaScript Object Notation\n")
10901
10902 ALIAS (show_ip_bgp_instance_neighbors,
10903 show_bgp_instance_ipv6_neighbors_cmd,
10904 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors {json}",
10905 SHOW_STR
10906 BGP_STR
10907 BGP_INSTANCE_HELP_STR
10908 "Address family\n"
10909 "Detailed information on TCP and BGP neighbor connections\n"
10910 "JavaScript Object Notation\n")
10911
10912 DEFUN (show_ip_bgp_instance_neighbors_peer,
10913 show_ip_bgp_instance_neighbors_peer_cmd,
10914 "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10915 SHOW_STR
10916 IP_STR
10917 BGP_STR
10918 BGP_INSTANCE_HELP_STR
10919 "Detailed information on TCP and BGP neighbor connections\n"
10920 "Neighbor to display information about\n"
10921 "Neighbor to display information about\n"
10922 "Neighbor on bgp configured interface\n"
10923 "JavaScript Object Notation\n")
10924 {
10925 u_char uj = use_json(argc, argv);
10926
10927 return bgp_show_neighbor_vty (vty, argv[1], show_peer, argv[2], uj);
10928 }
10929
10930 ALIAS (show_ip_bgp_instance_neighbors_peer,
10931 show_bgp_instance_neighbors_peer_cmd,
10932 "show bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10933 SHOW_STR
10934 BGP_STR
10935 BGP_INSTANCE_HELP_STR
10936 "Detailed information on TCP and BGP neighbor connections\n"
10937 "Neighbor to display information about\n"
10938 "Neighbor to display information about\n"
10939 "Neighbor on bgp configured interface\n"
10940 "JavaScript Object Notation\n")
10941
10942 ALIAS (show_ip_bgp_instance_neighbors_peer,
10943 show_bgp_instance_ipv6_neighbors_peer_cmd,
10944 "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) {json}",
10945 SHOW_STR
10946 BGP_STR
10947 BGP_INSTANCE_HELP_STR
10948 "Address family\n"
10949 "Detailed information on TCP and BGP neighbor connections\n"
10950 "Neighbor to display information about\n"
10951 "Neighbor to display information about\n"
10952 "Neighbor on bgp configured interface\n"
10953 "JavaScript Object Notation\n")
10954
10955 /* Show BGP's AS paths internal data. There are both `show ip bgp
10956 paths' and `show ip mbgp paths'. Those functions results are the
10957 same.*/
10958 DEFUN (show_ip_bgp_paths,
10959 show_ip_bgp_paths_cmd,
10960 "show ip bgp paths",
10961 SHOW_STR
10962 IP_STR
10963 BGP_STR
10964 "Path information\n")
10965 {
10966 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
10967 aspath_print_all_vty (vty);
10968 return CMD_SUCCESS;
10969 }
10970
10971 DEFUN (show_ip_bgp_ipv4_paths,
10972 show_ip_bgp_ipv4_paths_cmd,
10973 "show ip bgp ipv4 (unicast|multicast) paths",
10974 SHOW_STR
10975 IP_STR
10976 BGP_STR
10977 "Address family\n"
10978 "Address Family modifier\n"
10979 "Address Family modifier\n"
10980 "Path information\n")
10981 {
10982 vty_out (vty, "Address Refcnt Path\r\n");
10983 aspath_print_all_vty (vty);
10984
10985 return CMD_SUCCESS;
10986 }
10987
10988 #include "hash.h"
10989
10990 static void
10991 community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
10992 {
10993 struct community *com;
10994
10995 com = (struct community *) backet->data;
10996 vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt,
10997 community_str (com), VTY_NEWLINE);
10998 }
10999
11000 /* Show BGP's community internal data. */
11001 DEFUN (show_ip_bgp_community_info,
11002 show_ip_bgp_community_info_cmd,
11003 "show ip bgp community-info",
11004 SHOW_STR
11005 IP_STR
11006 BGP_STR
11007 "List all bgp community information\n")
11008 {
11009 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
11010
11011 hash_iterate (community_hash (),
11012 (void (*) (struct hash_backet *, void *))
11013 community_show_all_iterator,
11014 vty);
11015
11016 return CMD_SUCCESS;
11017 }
11018
11019 DEFUN (show_ip_bgp_attr_info,
11020 show_ip_bgp_attr_info_cmd,
11021 "show ip bgp attribute-info",
11022 SHOW_STR
11023 IP_STR
11024 BGP_STR
11025 "List all bgp attribute information\n")
11026 {
11027 attr_show_all (vty);
11028 return CMD_SUCCESS;
11029 }
11030
11031 static int bgp_show_update_groups(struct vty *vty, const char *name,
11032 int afi, int safi,
11033 u_int64_t subgrp_id)
11034 {
11035 struct bgp *bgp;
11036
11037 if (name)
11038 bgp = bgp_lookup_by_name (name);
11039 else
11040 bgp = bgp_get_default ();
11041
11042 if (bgp)
11043 update_group_show(bgp, afi, safi, vty, subgrp_id);
11044 return CMD_SUCCESS;
11045 }
11046
11047 DEFUN (show_ip_bgp_updgrps,
11048 show_ip_bgp_updgrps_cmd,
11049 "show ip bgp update-groups",
11050 SHOW_STR
11051 IP_STR
11052 BGP_STR
11053 "Detailed info about dynamic update groups\n")
11054 {
11055 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, 0));
11056 }
11057
11058 DEFUN (show_ip_bgp_instance_updgrps,
11059 show_ip_bgp_instance_updgrps_cmd,
11060 "show ip bgp " BGP_INSTANCE_CMD " update-groups",
11061 SHOW_STR
11062 IP_STR
11063 BGP_STR
11064 BGP_INSTANCE_HELP_STR
11065 "Detailed info about dynamic update groups\n")
11066 {
11067 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, 0));
11068 }
11069
11070 DEFUN (show_bgp_ipv6_updgrps,
11071 show_bgp_ipv6_updgrps_cmd,
11072 "show bgp update-groups",
11073 SHOW_STR
11074 BGP_STR
11075 "Detailed info about v6 dynamic update groups\n")
11076 {
11077 return (bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, 0));
11078 }
11079
11080 DEFUN (show_bgp_instance_ipv6_updgrps,
11081 show_bgp_instance_ipv6_updgrps_cmd,
11082 "show bgp " BGP_INSTANCE_CMD " update-groups",
11083 SHOW_STR
11084 BGP_STR
11085 BGP_INSTANCE_HELP_STR
11086 "Detailed info about v6 dynamic update groups\n")
11087 {
11088 return (bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, 0));
11089 }
11090
11091 DEFUN (show_bgp_updgrps,
11092 show_bgp_updgrps_cmd,
11093 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups",
11094 SHOW_STR
11095 BGP_STR
11096 "Address family\n"
11097 "Address family\n"
11098 "Address Family modifier\n"
11099 "Address Family modifier\n"
11100 "Detailed info about dynamic update groups\n")
11101 {
11102 afi_t afi;
11103 safi_t safi;
11104
11105 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11106 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11107 return (bgp_show_update_groups(vty, NULL, afi, safi, 0));
11108 }
11109
11110 DEFUN (show_ip_bgp_updgrps_s,
11111 show_ip_bgp_updgrps_s_cmd,
11112 "show ip bgp update-groups SUBGROUP-ID",
11113 SHOW_STR
11114 IP_STR
11115 BGP_STR
11116 "Detailed info about dynamic update groups\n"
11117 "Specific subgroup to display detailed info for\n")
11118 {
11119 u_int64_t subgrp_id;
11120
11121 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11122 return (bgp_show_update_groups(vty, NULL, AFI_IP, SAFI_UNICAST, subgrp_id));
11123 }
11124
11125 DEFUN (show_ip_bgp_instance_updgrps_s,
11126 show_ip_bgp_instance_updgrps_s_cmd,
11127 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
11128 SHOW_STR
11129 IP_STR
11130 BGP_STR
11131 BGP_INSTANCE_HELP_STR
11132 "Detailed info about dynamic update groups\n"
11133 "Specific subgroup to display detailed info for\n")
11134 {
11135 u_int64_t subgrp_id;
11136
11137 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11138 return (bgp_show_update_groups(vty, argv[1], AFI_IP, SAFI_UNICAST, subgrp_id));
11139 }
11140
11141 DEFUN (show_bgp_ipv6_updgrps_s,
11142 show_bgp_ipv6_updgrps_s_cmd,
11143 "show bgp update-groups SUBGROUP-ID",
11144 SHOW_STR
11145 BGP_STR
11146 "Detailed info about v6 dynamic update groups\n"
11147 "Specific subgroup to display detailed info for\n")
11148 {
11149 u_int64_t subgrp_id;
11150
11151 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11152 return(bgp_show_update_groups(vty, NULL, AFI_IP6, SAFI_UNICAST, subgrp_id));
11153 }
11154
11155 DEFUN (show_bgp_instance_ipv6_updgrps_s,
11156 show_bgp_instance_ipv6_updgrps_s_cmd,
11157 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID",
11158 SHOW_STR
11159 BGP_STR
11160 "Detailed info about v6 dynamic update groups\n"
11161 "Specific subgroup to display detailed info for\n")
11162 {
11163 u_int64_t subgrp_id;
11164
11165 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11166 return(bgp_show_update_groups(vty, argv[1], AFI_IP6, SAFI_UNICAST, subgrp_id));
11167 }
11168
11169 DEFUN (show_bgp_updgrps_s,
11170 show_bgp_updgrps_s_cmd,
11171 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID",
11172 SHOW_STR
11173 BGP_STR
11174 "Address family\n"
11175 "Address family\n"
11176 "Address Family modifier\n"
11177 "Address Family modifier\n"
11178 "Detailed info about v6 dynamic update groups\n"
11179 "Specific subgroup to display detailed info for")
11180 {
11181 afi_t afi;
11182 safi_t safi;
11183 u_int64_t subgrp_id;
11184
11185 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11186 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11187
11188 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11189 return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id));
11190 }
11191
11192 DEFUN (show_bgp_updgrps_stats,
11193 show_bgp_updgrps_stats_cmd,
11194 "show bgp update-groups statistics",
11195 SHOW_STR
11196 BGP_STR
11197 "BGP update groups\n"
11198 "Statistics\n")
11199 {
11200 struct bgp *bgp;
11201
11202 bgp = bgp_get_default();
11203 if (bgp)
11204 update_group_show_stats(bgp, vty);
11205
11206 return CMD_SUCCESS;
11207 }
11208
11209 DEFUN (show_bgp_instance_updgrps_stats,
11210 show_bgp_instance_updgrps_stats_cmd,
11211 "show bgp " BGP_INSTANCE_CMD " update-groups statistics",
11212 SHOW_STR
11213 BGP_STR
11214 BGP_INSTANCE_HELP_STR
11215 "BGP update groups\n"
11216 "Statistics\n")
11217 {
11218 struct bgp *bgp;
11219
11220 bgp = bgp_lookup_by_name (argv[1]);
11221 if (bgp)
11222 update_group_show_stats(bgp, vty);
11223
11224 return CMD_SUCCESS;
11225 }
11226
11227 static void
11228 show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
11229 afi_t afi, safi_t safi,
11230 const char *what, u_int64_t subgrp_id)
11231 {
11232 struct bgp *bgp;
11233
11234 if (name)
11235 bgp = bgp_lookup_by_name (name);
11236 else
11237 bgp = bgp_get_default ();
11238
11239 if (bgp)
11240 {
11241 if (!strcmp(what, "advertise-queue"))
11242 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
11243 else if (!strcmp(what, "advertised-routes"))
11244 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
11245 else if (!strcmp(what, "packet-queue"))
11246 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
11247 }
11248 }
11249
11250 DEFUN (show_ip_bgp_updgrps_adj,
11251 show_ip_bgp_updgrps_adj_cmd,
11252 "show ip bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
11253 SHOW_STR
11254 IP_STR
11255 BGP_STR
11256 "BGP update groups\n"
11257 "Advertisement queue\n"
11258 "Announced routes\n"
11259 "Packet queue\n")
11260
11261 {
11262 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[0], 0);
11263 return CMD_SUCCESS;
11264 }
11265
11266 DEFUN (show_ip_bgp_instance_updgrps_adj,
11267 show_ip_bgp_instance_updgrps_adj_cmd,
11268 "show ip bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
11269 SHOW_STR
11270 IP_STR
11271 BGP_STR
11272 BGP_INSTANCE_HELP_STR
11273 "BGP update groups\n"
11274 "Advertisement queue\n"
11275 "Announced routes\n"
11276 "Packet queue\n")
11277
11278 {
11279 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[2], 0);
11280 return CMD_SUCCESS;
11281 }
11282
11283 DEFUN (show_bgp_updgrps_afi_adj,
11284 show_bgp_updgrps_afi_adj_cmd,
11285 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)",
11286 SHOW_STR
11287 BGP_STR
11288 "Address family\n"
11289 "Address family\n"
11290 "Address Family modifier\n"
11291 "Address Family modifier\n"
11292 "BGP update groups\n"
11293 "Advertisement queue\n"
11294 "Announced routes\n"
11295 "Packet queue\n"
11296 "Specific subgroup info wanted for\n")
11297 {
11298 afi_t afi;
11299 safi_t safi;
11300
11301 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11302 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11303 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0);
11304 return CMD_SUCCESS;
11305 }
11306
11307 DEFUN (show_bgp_updgrps_adj,
11308 show_bgp_updgrps_adj_cmd,
11309 "show bgp update-groups (advertise-queue|advertised-routes|packet-queue)",
11310 SHOW_STR
11311 BGP_STR
11312 "BGP update groups\n"
11313 "Advertisement queue\n"
11314 "Announced routes\n"
11315 "Packet queue\n")
11316 {
11317 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[0], 0);
11318 return CMD_SUCCESS;
11319 }
11320
11321 DEFUN (show_bgp_instance_updgrps_adj,
11322 show_bgp_instance_updgrps_adj_cmd,
11323 "show bgp " BGP_INSTANCE_CMD " update-groups (advertise-queue|advertised-routes|packet-queue)",
11324 SHOW_STR
11325 BGP_STR
11326 BGP_INSTANCE_HELP_STR
11327 "BGP update groups\n"
11328 "Advertisement queue\n"
11329 "Announced routes\n"
11330 "Packet queue\n")
11331 {
11332 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[2], 0);
11333 return CMD_SUCCESS;
11334 }
11335
11336 DEFUN (show_ip_bgp_updgrps_adj_s,
11337 show_ip_bgp_updgrps_adj_s_cmd,
11338 "show ip bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11339 SHOW_STR
11340 IP_STR
11341 BGP_STR
11342 "BGP update groups\n"
11343 "Specific subgroup to display info for\n"
11344 "Advertisement queue\n"
11345 "Announced routes\n"
11346 "Packet queue\n")
11347
11348 {
11349 u_int64_t subgrp_id;
11350
11351 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11352
11353 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[1], subgrp_id);
11354 return CMD_SUCCESS;
11355 }
11356
11357 DEFUN (show_ip_bgp_instance_updgrps_adj_s,
11358 show_ip_bgp_instance_updgrps_adj_s_cmd,
11359 "show ip bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11360 SHOW_STR
11361 IP_STR
11362 BGP_STR
11363 BGP_INSTANCE_HELP_STR
11364 "BGP update groups\n"
11365 "Specific subgroup to display info for\n"
11366 "Advertisement queue\n"
11367 "Announced routes\n"
11368 "Packet queue\n")
11369
11370 {
11371 u_int64_t subgrp_id;
11372
11373 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11374
11375 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP, SAFI_UNICAST, argv[3], subgrp_id);
11376 return CMD_SUCCESS;
11377 }
11378
11379 DEFUN (show_bgp_updgrps_afi_adj_s,
11380 show_bgp_updgrps_afi_adj_s_cmd,
11381 "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11382 SHOW_STR
11383 BGP_STR
11384 "Address family\n"
11385 "Address family\n"
11386 "Address Family modifier\n"
11387 "Address Family modifier\n"
11388 "BGP update groups\n"
11389 "Specific subgroup to display info for\n"
11390 "Advertisement queue\n"
11391 "Announced routes\n"
11392 "Packet queue\n"
11393 "Specific subgroup info wanted for\n")
11394 {
11395 afi_t afi;
11396 safi_t safi;
11397 u_int64_t subgrp_id;
11398
11399 afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6;
11400 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
11401 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11402
11403 show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id);
11404 return CMD_SUCCESS;
11405 }
11406
11407 DEFUN (show_bgp_updgrps_adj_s,
11408 show_bgp_updgrps_adj_s_cmd,
11409 "show bgp update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11410 SHOW_STR
11411 BGP_STR
11412 "BGP update groups\n"
11413 "Specific subgroup to display info for\n"
11414 "Advertisement queue\n"
11415 "Announced routes\n"
11416 "Packet queue\n")
11417 {
11418 u_int64_t subgrp_id;
11419
11420 VTY_GET_ULL("subgroup-id", subgrp_id, argv[0]);
11421
11422 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[1], subgrp_id);
11423 return CMD_SUCCESS;
11424 }
11425
11426 DEFUN (show_bgp_instance_updgrps_adj_s,
11427 show_bgp_instance_updgrps_adj_s_cmd,
11428 "show bgp " BGP_INSTANCE_CMD " update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)",
11429 SHOW_STR
11430 BGP_STR
11431 BGP_INSTANCE_HELP_STR
11432 "BGP update groups\n"
11433 "Specific subgroup to display info for\n"
11434 "Advertisement queue\n"
11435 "Announced routes\n"
11436 "Packet queue\n")
11437 {
11438 u_int64_t subgrp_id;
11439
11440 VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]);
11441
11442 show_bgp_updgrps_adj_info_aux(vty, argv[1], AFI_IP6, SAFI_UNICAST, argv[3], subgrp_id);
11443 return CMD_SUCCESS;
11444 }
11445
11446
11447
11448 static int
11449 bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
11450 {
11451 struct listnode *node, *nnode;
11452 struct prefix *range;
11453 struct peer *conf;
11454 struct peer *peer;
11455 char buf[PREFIX2STR_BUFFER];
11456 afi_t afi;
11457 safi_t safi;
11458 const char *peer_status;
11459 const char *af_str;
11460 int lr_count;
11461 int dynamic;
11462 int af_cfgd;
11463
11464 conf = group->conf;
11465
11466 if (conf->as_type == AS_SPECIFIED ||
11467 conf->as_type == AS_EXTERNAL) {
11468 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
11469 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
11470 } else if (conf->as_type == AS_INTERNAL) {
11471 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
11472 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
11473 } else {
11474 vty_out (vty, "%sBGP peer-group %s%s",
11475 VTY_NEWLINE, group->name, VTY_NEWLINE);
11476 }
11477
11478 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
11479 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
11480 else
11481 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
11482
11483 /* Display AFs configured. */
11484 vty_out (vty, " Configured address-families:");
11485 for (afi = AFI_IP; afi < AFI_MAX; afi++)
11486 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
11487 {
11488 if (conf->afc[afi][safi])
11489 {
11490 af_cfgd = 1;
11491 vty_out (vty, " %s;", afi_safi_print(afi, safi));
11492 }
11493 }
11494 if (!af_cfgd)
11495 vty_out (vty, " none%s", VTY_NEWLINE);
11496 else
11497 vty_out (vty, "%s", VTY_NEWLINE);
11498
11499 /* Display listen ranges (for dynamic neighbors), if any */
11500 for (afi = AFI_IP; afi < AFI_MAX; afi++)
11501 {
11502 if (afi == AFI_IP)
11503 af_str = "IPv4";
11504 else if (afi == AFI_IP6)
11505 af_str = "IPv6";
11506 lr_count = listcount(group->listen_range[afi]);
11507 if (lr_count)
11508 {
11509 vty_out(vty,
11510 " %d %s listen range(s)%s",
11511 lr_count, af_str, VTY_NEWLINE);
11512
11513
11514 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
11515 nnode, range))
11516 {
11517 prefix2str(range, buf, sizeof(buf));
11518 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
11519 }
11520 }
11521 }
11522
11523 /* Display group members and their status */
11524 if (listcount(group->peer))
11525 {
11526 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
11527 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
11528 {
11529 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
11530 peer_status = "Idle (Admin)";
11531 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
11532 peer_status = "Idle (PfxCt)";
11533 else
11534 peer_status = LOOKUP(bgp_status_msg, peer->status);
11535
11536 dynamic = peer_dynamic_neighbor(peer);
11537 vty_out (vty, " %s %s %s %s",
11538 peer->host, dynamic ? "(dynamic)" : "",
11539 peer_status, VTY_NEWLINE);
11540 }
11541 }
11542
11543 return CMD_SUCCESS;
11544 }
11545
11546 /* Show BGP peer group's information. */
11547 enum show_group_type
11548 {
11549 show_all_groups,
11550 show_peer_group
11551 };
11552
11553 static int
11554 bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
11555 enum show_group_type type, const char *group_name)
11556 {
11557 struct listnode *node, *nnode;
11558 struct peer_group *group;
11559 int find = 0;
11560
11561 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
11562 {
11563 switch (type)
11564 {
11565 case show_all_groups:
11566 bgp_show_one_peer_group (vty, group);
11567 break;
11568 case show_peer_group:
11569 if (group_name && (strcmp(group->name, group_name) == 0))
11570 {
11571 find = 1;
11572 bgp_show_one_peer_group (vty, group);
11573 }
11574 break;
11575 }
11576 }
11577
11578 if (type == show_peer_group && ! find)
11579 vty_out (vty, "%% No such peer-groupr%s", VTY_NEWLINE);
11580
11581 return CMD_SUCCESS;
11582 }
11583
11584 static int
11585 bgp_show_peer_group_vty (struct vty *vty, const char *name,
11586 enum show_group_type type, const char *group_name)
11587 {
11588 struct bgp *bgp;
11589 int ret = CMD_SUCCESS;
11590
11591 if (name)
11592 bgp = bgp_lookup_by_name (name);
11593 else
11594 bgp = bgp_get_default ();
11595
11596 if (! bgp)
11597 {
11598 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
11599 return CMD_WARNING;
11600 }
11601
11602 ret = bgp_show_peer_group (vty, bgp, type, group_name);
11603
11604 return ret;
11605 }
11606
11607 DEFUN (show_ip_bgp_peer_groups,
11608 show_ip_bgp_peer_groups_cmd,
11609 "show ip bgp peer-group",
11610 SHOW_STR
11611 IP_STR
11612 BGP_STR
11613 "Detailed information on all BGP peer groups\n")
11614 {
11615 return bgp_show_peer_group_vty (vty, NULL, show_all_groups, NULL);
11616 }
11617
11618 DEFUN (show_ip_bgp_instance_peer_groups,
11619 show_ip_bgp_instance_peer_groups_cmd,
11620 "show ip bgp " BGP_INSTANCE_CMD " peer-group",
11621 SHOW_STR
11622 IP_STR
11623 BGP_STR
11624 BGP_INSTANCE_HELP_STR
11625 "Detailed information on all BGP peer groups\n")
11626 {
11627 return bgp_show_peer_group_vty (vty, argv[1], show_all_groups, NULL);
11628 }
11629
11630 DEFUN (show_ip_bgp_peer_group,
11631 show_ip_bgp_peer_group_cmd,
11632 "show ip bgp peer-group WORD",
11633 SHOW_STR
11634 IP_STR
11635 BGP_STR
11636 "BGP peer-group name\n"
11637 "Detailed information on a BGP peer group\n")
11638 {
11639 return bgp_show_peer_group_vty (vty, NULL, show_peer_group, argv[0]);
11640 }
11641
11642 DEFUN (show_ip_bgp_instance_peer_group,
11643 show_ip_bgp_instance_peer_group_cmd,
11644 "show ip bgp " BGP_INSTANCE_CMD " peer-group WORD",
11645 SHOW_STR
11646 IP_STR
11647 BGP_STR
11648 BGP_INSTANCE_HELP_STR
11649 "BGP peer-group name\n"
11650 "Detailed information on a BGP peer group\n")
11651 {
11652 return bgp_show_peer_group_vty (vty, argv[1], show_peer_group, argv[2]);
11653 }
11654
11655 /* Redistribute VTY commands. */
11656
11657 DEFUN (bgp_redistribute_ipv4,
11658 bgp_redistribute_ipv4_cmd,
11659 "redistribute " QUAGGA_IP_REDIST_STR_BGPD,
11660 "Redistribute information from another routing protocol\n"
11661 QUAGGA_IP_REDIST_HELP_STR_BGPD)
11662 {
11663 int type;
11664
11665 type = proto_redistnum (AFI_IP, argv[0]);
11666 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11667 {
11668 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11669 return CMD_WARNING;
11670 }
11671 bgp_redist_add(vty->index, AFI_IP, type, 0);
11672 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
11673 }
11674
11675 DEFUN (bgp_redistribute_ipv4_rmap,
11676 bgp_redistribute_ipv4_rmap_cmd,
11677 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
11678 "Redistribute information from another routing protocol\n"
11679 QUAGGA_IP_REDIST_HELP_STR_BGPD
11680 "Route map reference\n"
11681 "Pointer to route-map entries\n")
11682 {
11683 int type;
11684 struct bgp_redist *red;
11685
11686 type = proto_redistnum (AFI_IP, argv[0]);
11687 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11688 {
11689 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11690 return CMD_WARNING;
11691 }
11692
11693 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11694 bgp_redistribute_rmap_set (red, argv[1]);
11695 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
11696 }
11697
11698 DEFUN (bgp_redistribute_ipv4_metric,
11699 bgp_redistribute_ipv4_metric_cmd,
11700 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
11701 "Redistribute information from another routing protocol\n"
11702 QUAGGA_IP_REDIST_HELP_STR_BGPD
11703 "Metric for redistributed routes\n"
11704 "Default metric\n")
11705 {
11706 int type;
11707 u_int32_t metric;
11708 struct bgp_redist *red;
11709
11710 type = proto_redistnum (AFI_IP, argv[0]);
11711 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11712 {
11713 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11714 return CMD_WARNING;
11715 }
11716 VTY_GET_INTEGER ("metric", metric, argv[1]);
11717
11718 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11719 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
11720 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
11721 }
11722
11723 DEFUN (bgp_redistribute_ipv4_rmap_metric,
11724 bgp_redistribute_ipv4_rmap_metric_cmd,
11725 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
11726 "Redistribute information from another routing protocol\n"
11727 QUAGGA_IP_REDIST_HELP_STR_BGPD
11728 "Route map reference\n"
11729 "Pointer to route-map entries\n"
11730 "Metric for redistributed routes\n"
11731 "Default metric\n")
11732 {
11733 int type;
11734 u_int32_t metric;
11735 struct bgp_redist *red;
11736
11737 type = proto_redistnum (AFI_IP, argv[0]);
11738 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11739 {
11740 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11741 return CMD_WARNING;
11742 }
11743 VTY_GET_INTEGER ("metric", metric, argv[2]);
11744
11745 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11746 bgp_redistribute_rmap_set (red, argv[1]);
11747 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
11748 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
11749 }
11750
11751 DEFUN (bgp_redistribute_ipv4_metric_rmap,
11752 bgp_redistribute_ipv4_metric_rmap_cmd,
11753 "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
11754 "Redistribute information from another routing protocol\n"
11755 QUAGGA_IP_REDIST_HELP_STR_BGPD
11756 "Metric for redistributed routes\n"
11757 "Default metric\n"
11758 "Route map reference\n"
11759 "Pointer to route-map entries\n")
11760 {
11761 int type;
11762 u_int32_t metric;
11763 struct bgp_redist *red;
11764
11765 type = proto_redistnum (AFI_IP, argv[0]);
11766 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11767 {
11768 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11769 return CMD_WARNING;
11770 }
11771 VTY_GET_INTEGER ("metric", metric, argv[1]);
11772
11773 red = bgp_redist_add(vty->index, AFI_IP, type, 0);
11774 bgp_redistribute_metric_set(vty->index, red, AFI_IP, type, metric);
11775 bgp_redistribute_rmap_set (red, argv[2]);
11776 return bgp_redistribute_set (vty->index, AFI_IP, type, 0);
11777 }
11778
11779 DEFUN (bgp_redistribute_ipv4_ospf,
11780 bgp_redistribute_ipv4_ospf_cmd,
11781 "redistribute (ospf|table) <1-65535>",
11782 "Redistribute information from another routing protocol\n"
11783 "Open Shortest Path First (OSPFv2)\n"
11784 "Non-main Kernel Routing Table\n"
11785 "Instance ID/Table ID\n")
11786 {
11787 u_short instance;
11788 u_short protocol;
11789
11790 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11791
11792 if (strncmp(argv[0], "o", 1) == 0)
11793 protocol = ZEBRA_ROUTE_OSPF;
11794 else
11795 protocol = ZEBRA_ROUTE_TABLE;
11796
11797 bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11798 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
11799 }
11800
11801 DEFUN (bgp_redistribute_ipv4_ospf_rmap,
11802 bgp_redistribute_ipv4_ospf_rmap_cmd,
11803 "redistribute (ospf|table) <1-65535> route-map WORD",
11804 "Redistribute information from another routing protocol\n"
11805 "Open Shortest Path First (OSPFv2)\n"
11806 "Non-main Kernel Routing Table\n"
11807 "Instance ID/Table ID\n"
11808 "Route map reference\n"
11809 "Pointer to route-map entries\n")
11810 {
11811 struct bgp_redist *red;
11812 u_short instance;
11813 int protocol;
11814
11815 if (strncmp(argv[0], "o", 1) == 0)
11816 protocol = ZEBRA_ROUTE_OSPF;
11817 else
11818 protocol = ZEBRA_ROUTE_TABLE;
11819
11820 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11821 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11822 bgp_redistribute_rmap_set (red, argv[2]);
11823 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
11824 }
11825
11826 DEFUN (bgp_redistribute_ipv4_ospf_metric,
11827 bgp_redistribute_ipv4_ospf_metric_cmd,
11828 "redistribute (ospf|table) <1-65535> metric <0-4294967295>",
11829 "Redistribute information from another routing protocol\n"
11830 "Open Shortest Path First (OSPFv2)\n"
11831 "Non-main Kernel Routing Table\n"
11832 "Instance ID/Table ID\n"
11833 "Metric for redistributed routes\n"
11834 "Default metric\n")
11835 {
11836 u_int32_t metric;
11837 struct bgp_redist *red;
11838 u_short instance;
11839 int protocol;
11840
11841 if (strncmp(argv[0], "o", 1) == 0)
11842 protocol = ZEBRA_ROUTE_OSPF;
11843 else
11844 protocol = ZEBRA_ROUTE_TABLE;
11845
11846 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11847 VTY_GET_INTEGER ("metric", metric, argv[2]);
11848
11849 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11850 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
11851 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
11852 }
11853
11854 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
11855 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
11856 "redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
11857 "Redistribute information from another routing protocol\n"
11858 "Open Shortest Path First (OSPFv2)\n"
11859 "Non-main Kernel Routing Table\n"
11860 "Instance ID/Table ID\n"
11861 "Route map reference\n"
11862 "Pointer to route-map entries\n"
11863 "Metric for redistributed routes\n"
11864 "Default metric\n")
11865 {
11866 u_int32_t metric;
11867 struct bgp_redist *red;
11868 u_short instance;
11869 int protocol;
11870
11871 if (strncmp(argv[0], "o", 1) == 0)
11872 protocol = ZEBRA_ROUTE_OSPF;
11873 else
11874 protocol = ZEBRA_ROUTE_TABLE;
11875
11876 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11877 VTY_GET_INTEGER ("metric", metric, argv[3]);
11878
11879 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11880 bgp_redistribute_rmap_set (red, argv[2]);
11881 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
11882 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
11883 }
11884
11885 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
11886 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
11887 "redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
11888 "Redistribute information from another routing protocol\n"
11889 "Open Shortest Path First (OSPFv2)\n"
11890 "Non-main Kernel Routing Table\n"
11891 "Instance ID/Table ID\n"
11892 "Metric for redistributed routes\n"
11893 "Default metric\n"
11894 "Route map reference\n"
11895 "Pointer to route-map entries\n")
11896 {
11897 u_int32_t metric;
11898 struct bgp_redist *red;
11899 u_short instance;
11900 int protocol;
11901
11902 if (strncmp(argv[0], "o", 1) == 0)
11903 protocol = ZEBRA_ROUTE_OSPF;
11904 else
11905 protocol = ZEBRA_ROUTE_TABLE;
11906
11907 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11908 VTY_GET_INTEGER ("metric", metric, argv[2]);
11909
11910 red = bgp_redist_add(vty->index, AFI_IP, protocol, instance);
11911 bgp_redistribute_metric_set(vty->index, red, AFI_IP, protocol, metric);
11912 bgp_redistribute_rmap_set (red, argv[3]);
11913 return bgp_redistribute_set (vty->index, AFI_IP, protocol, instance);
11914 }
11915
11916 DEFUN (no_bgp_redistribute_ipv4_ospf,
11917 no_bgp_redistribute_ipv4_ospf_cmd,
11918 "no redistribute (ospf|table) <1-65535>",
11919 NO_STR
11920 "Redistribute information from another routing protocol\n"
11921 "Open Shortest Path First (OSPFv2)\n"
11922 "Non-main Kernel Routing Table\n"
11923 "Instance ID/Table ID\n")
11924 {
11925 u_short instance;
11926 int protocol;
11927
11928 if (strncmp(argv[0], "o", 1) == 0)
11929 protocol = ZEBRA_ROUTE_OSPF;
11930 else
11931 protocol = ZEBRA_ROUTE_TABLE;
11932
11933 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
11934 return bgp_redistribute_unset (vty->index, AFI_IP, protocol, instance);
11935 }
11936
11937 ALIAS (no_bgp_redistribute_ipv4_ospf,
11938 no_bgp_redistribute_ipv4_ospf_rmap_cmd,
11939 "no redistribute (ospf|table) <1-65535> route-map WORD",
11940 NO_STR
11941 "Redistribute information from another routing protocol\n"
11942 "Open Shortest Path First (OSPFv2)\n"
11943 "Non-main Kernel Routing Table\n"
11944 "Instance ID/Table ID\n"
11945 "Route map reference\n"
11946 "Pointer to route-map entries\n")
11947
11948 ALIAS (no_bgp_redistribute_ipv4_ospf,
11949 no_bgp_redistribute_ipv4_ospf_metric_cmd,
11950 "no redistribute (ospf|table) <1-65535> metric <0-4294967295>",
11951 NO_STR
11952 "Redistribute information from another routing protocol\n"
11953 "Open Shortest Path First (OSPFv2)\n"
11954 "Non-main Kernel Routing Table\n"
11955 "Instance ID/Table ID\n"
11956 "Metric for redistributed routes\n"
11957 "Default metric\n")
11958
11959 ALIAS (no_bgp_redistribute_ipv4_ospf,
11960 no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
11961 "no redistribute (ospf|table) <1-65535> route-map WORD metric <0-4294967295>",
11962 NO_STR
11963 "Redistribute information from another routing protocol\n"
11964 "Open Shortest Path First (OSPFv2)\n"
11965 "Non-main Kernel Routing Table\n"
11966 "Instance ID/Table ID\n"
11967 "Route map reference\n"
11968 "Pointer to route-map entries\n"
11969 "Metric for redistributed routes\n"
11970 "Default metric\n")
11971
11972 ALIAS (no_bgp_redistribute_ipv4_ospf,
11973 no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
11974 "no redistribute (ospf|table) <1-65535> metric <0-4294967295> route-map WORD",
11975 NO_STR
11976 "Redistribute information from another routing protocol\n"
11977 "Open Shortest Path First (OSPFv2)\n"
11978 "Non-main Kernel Routing Table\n"
11979 "Instance ID/Table ID\n"
11980 "Metric for redistributed routes\n"
11981 "Default metric\n"
11982 "Route map reference\n"
11983 "Pointer to route-map entries\n")
11984
11985 DEFUN (no_bgp_redistribute_ipv4,
11986 no_bgp_redistribute_ipv4_cmd,
11987 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD,
11988 NO_STR
11989 "Redistribute information from another routing protocol\n"
11990 QUAGGA_IP_REDIST_HELP_STR_BGPD)
11991 {
11992 int type;
11993
11994 type = proto_redistnum (AFI_IP, argv[0]);
11995 if (type < 0 || type == ZEBRA_ROUTE_BGP)
11996 {
11997 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
11998 return CMD_WARNING;
11999 }
12000 return bgp_redistribute_unset (vty->index, AFI_IP, type, 0);
12001 }
12002
12003 ALIAS (no_bgp_redistribute_ipv4,
12004 no_bgp_redistribute_ipv4_rmap_cmd,
12005 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD",
12006 NO_STR
12007 "Redistribute information from another routing protocol\n"
12008 QUAGGA_IP_REDIST_HELP_STR_BGPD
12009 "Route map reference\n"
12010 "Pointer to route-map entries\n")
12011
12012 ALIAS (no_bgp_redistribute_ipv4,
12013 no_bgp_redistribute_ipv4_metric_cmd,
12014 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>",
12015 NO_STR
12016 "Redistribute information from another routing protocol\n"
12017 QUAGGA_IP_REDIST_HELP_STR_BGPD
12018 "Metric for redistributed routes\n"
12019 "Default metric\n")
12020
12021 ALIAS (no_bgp_redistribute_ipv4,
12022 no_bgp_redistribute_ipv4_rmap_metric_cmd,
12023 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
12024 NO_STR
12025 "Redistribute information from another routing protocol\n"
12026 QUAGGA_IP_REDIST_HELP_STR_BGPD
12027 "Route map reference\n"
12028 "Pointer to route-map entries\n"
12029 "Metric for redistributed routes\n"
12030 "Default metric\n")
12031
12032 ALIAS (no_bgp_redistribute_ipv4,
12033 no_bgp_redistribute_ipv4_metric_rmap_cmd,
12034 "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
12035 NO_STR
12036 "Redistribute information from another routing protocol\n"
12037 QUAGGA_IP_REDIST_HELP_STR_BGPD
12038 "Metric for redistributed routes\n"
12039 "Default metric\n"
12040 "Route map reference\n"
12041 "Pointer to route-map entries\n")
12042
12043 #ifdef HAVE_IPV6
12044 DEFUN (bgp_redistribute_ipv6,
12045 bgp_redistribute_ipv6_cmd,
12046 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
12047 "Redistribute information from another routing protocol\n"
12048 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
12049 {
12050 int type;
12051
12052 type = proto_redistnum (AFI_IP6, argv[0]);
12053 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12054 {
12055 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12056 return CMD_WARNING;
12057 }
12058
12059 bgp_redist_add(vty->index, AFI_IP6, type, 0);
12060 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
12061 }
12062
12063 DEFUN (bgp_redistribute_ipv6_rmap,
12064 bgp_redistribute_ipv6_rmap_cmd,
12065 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
12066 "Redistribute information from another routing protocol\n"
12067 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12068 "Route map reference\n"
12069 "Pointer to route-map entries\n")
12070 {
12071 int type;
12072 struct bgp_redist *red;
12073
12074 type = proto_redistnum (AFI_IP6, argv[0]);
12075 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12076 {
12077 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12078 return CMD_WARNING;
12079 }
12080
12081 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12082 bgp_redistribute_rmap_set (red, argv[1]);
12083 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
12084 }
12085
12086 DEFUN (bgp_redistribute_ipv6_metric,
12087 bgp_redistribute_ipv6_metric_cmd,
12088 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
12089 "Redistribute information from another routing protocol\n"
12090 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12091 "Metric for redistributed routes\n"
12092 "Default metric\n")
12093 {
12094 int type;
12095 u_int32_t metric;
12096 struct bgp_redist *red;
12097
12098 type = proto_redistnum (AFI_IP6, argv[0]);
12099 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12100 {
12101 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12102 return CMD_WARNING;
12103 }
12104 VTY_GET_INTEGER ("metric", metric, argv[1]);
12105
12106 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12107 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
12108 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
12109 }
12110
12111 DEFUN (bgp_redistribute_ipv6_rmap_metric,
12112 bgp_redistribute_ipv6_rmap_metric_cmd,
12113 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
12114 "Redistribute information from another routing protocol\n"
12115 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12116 "Route map reference\n"
12117 "Pointer to route-map entries\n"
12118 "Metric for redistributed routes\n"
12119 "Default metric\n")
12120 {
12121 int type;
12122 u_int32_t metric;
12123 struct bgp_redist *red;
12124
12125 type = proto_redistnum (AFI_IP6, argv[0]);
12126 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12127 {
12128 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12129 return CMD_WARNING;
12130 }
12131 VTY_GET_INTEGER ("metric", metric, argv[2]);
12132
12133 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12134 bgp_redistribute_rmap_set (red, argv[1]);
12135 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, type, metric);
12136 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
12137 }
12138
12139 DEFUN (bgp_redistribute_ipv6_metric_rmap,
12140 bgp_redistribute_ipv6_metric_rmap_cmd,
12141 "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
12142 "Redistribute information from another routing protocol\n"
12143 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12144 "Metric for redistributed routes\n"
12145 "Default metric\n"
12146 "Route map reference\n"
12147 "Pointer to route-map entries\n")
12148 {
12149 int type;
12150 u_int32_t metric;
12151 struct bgp_redist *red;
12152
12153 type = proto_redistnum (AFI_IP6, argv[0]);
12154 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12155 {
12156 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12157 return CMD_WARNING;
12158 }
12159 VTY_GET_INTEGER ("metric", metric, argv[1]);
12160
12161 red = bgp_redist_add(vty->index, AFI_IP6, type, 0);
12162 bgp_redistribute_metric_set(vty->index, red, AFI_IP6, SAFI_UNICAST, metric);
12163 bgp_redistribute_rmap_set (red, argv[2]);
12164 return bgp_redistribute_set (vty->index, AFI_IP6, type, 0);
12165 }
12166
12167 DEFUN (no_bgp_redistribute_ipv6,
12168 no_bgp_redistribute_ipv6_cmd,
12169 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD,
12170 NO_STR
12171 "Redistribute information from another routing protocol\n"
12172 QUAGGA_IP6_REDIST_HELP_STR_BGPD)
12173 {
12174 int type;
12175
12176 type = proto_redistnum (AFI_IP6, argv[0]);
12177 if (type < 0 || type == ZEBRA_ROUTE_BGP)
12178 {
12179 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
12180 return CMD_WARNING;
12181 }
12182
12183 return bgp_redistribute_unset (vty->index, AFI_IP6, type, 0);
12184 }
12185
12186 ALIAS (no_bgp_redistribute_ipv6,
12187 no_bgp_redistribute_ipv6_rmap_cmd,
12188 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD",
12189 NO_STR
12190 "Redistribute information from another routing protocol\n"
12191 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12192 "Route map reference\n"
12193 "Pointer to route-map entries\n")
12194
12195 ALIAS (no_bgp_redistribute_ipv6,
12196 no_bgp_redistribute_ipv6_metric_cmd,
12197 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>",
12198 NO_STR
12199 "Redistribute information from another routing protocol\n"
12200 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12201 "Metric for redistributed routes\n"
12202 "Default metric\n")
12203
12204 ALIAS (no_bgp_redistribute_ipv6,
12205 no_bgp_redistribute_ipv6_rmap_metric_cmd,
12206 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>",
12207 NO_STR
12208 "Redistribute information from another routing protocol\n"
12209 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12210 "Route map reference\n"
12211 "Pointer to route-map entries\n"
12212 "Metric for redistributed routes\n"
12213 "Default metric\n")
12214
12215 ALIAS (no_bgp_redistribute_ipv6,
12216 no_bgp_redistribute_ipv6_metric_rmap_cmd,
12217 "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD",
12218 NO_STR
12219 "Redistribute information from another routing protocol\n"
12220 QUAGGA_IP6_REDIST_HELP_STR_BGPD
12221 "Metric for redistributed routes\n"
12222 "Default metric\n"
12223 "Route map reference\n"
12224 "Pointer to route-map entries\n")
12225 #endif /* HAVE_IPV6 */
12226
12227 int
12228 bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
12229 safi_t safi, int *write)
12230 {
12231 int i;
12232
12233 /* Unicast redistribution only. */
12234 if (safi != SAFI_UNICAST)
12235 return 0;
12236
12237 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
12238 {
12239 /* Redistribute BGP does not make sense. */
12240 if (i != ZEBRA_ROUTE_BGP)
12241 {
12242 struct list *red_list;
12243 struct listnode *node;
12244 struct bgp_redist *red;
12245
12246 red_list = bgp->redist[afi][i];
12247 if (!red_list)
12248 continue;
12249
12250 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
12251 {
12252 /* Display "address-family" when it is not yet diplayed. */
12253 bgp_config_write_family_header (vty, afi, safi, write);
12254
12255 /* "redistribute" configuration. */
12256 vty_out (vty, " redistribute %s", zebra_route_string(i));
12257 if (red->instance)
12258 vty_out (vty, " %d", red->instance);
12259 if (red->redist_metric_flag)
12260 vty_out (vty, " metric %u", red->redist_metric);
12261 if (red->rmap.name)
12262 vty_out (vty, " route-map %s", red->rmap.name);
12263 vty_out (vty, "%s", VTY_NEWLINE);
12264 }
12265 }
12266 }
12267 return *write;
12268 }
12269
12270 /* BGP node structure. */
12271 static struct cmd_node bgp_node =
12272 {
12273 BGP_NODE,
12274 "%s(config-router)# ",
12275 1,
12276 };
12277
12278 static struct cmd_node bgp_ipv4_unicast_node =
12279 {
12280 BGP_IPV4_NODE,
12281 "%s(config-router-af)# ",
12282 1,
12283 };
12284
12285 static struct cmd_node bgp_ipv4_multicast_node =
12286 {
12287 BGP_IPV4M_NODE,
12288 "%s(config-router-af)# ",
12289 1,
12290 };
12291
12292 static struct cmd_node bgp_ipv6_unicast_node =
12293 {
12294 BGP_IPV6_NODE,
12295 "%s(config-router-af)# ",
12296 1,
12297 };
12298
12299 static struct cmd_node bgp_ipv6_multicast_node =
12300 {
12301 BGP_IPV6M_NODE,
12302 "%s(config-router-af)# ",
12303 1,
12304 };
12305
12306 static struct cmd_node bgp_vpnv4_node =
12307 {
12308 BGP_VPNV4_NODE,
12309 "%s(config-router-af)# ",
12310 1
12311 };
12312
12313 static void community_list_vty (void);
12314
12315 void
12316 bgp_vty_init (void)
12317 {
12318 /* Install bgp top node. */
12319 install_node (&bgp_node, bgp_config_write);
12320 install_node (&bgp_ipv4_unicast_node, NULL);
12321 install_node (&bgp_ipv4_multicast_node, NULL);
12322 install_node (&bgp_ipv6_unicast_node, NULL);
12323 install_node (&bgp_ipv6_multicast_node, NULL);
12324 install_node (&bgp_vpnv4_node, NULL);
12325
12326 /* Install default VTY commands to new nodes. */
12327 install_default (BGP_NODE);
12328 install_default (BGP_IPV4_NODE);
12329 install_default (BGP_IPV4M_NODE);
12330 install_default (BGP_IPV6_NODE);
12331 install_default (BGP_IPV6M_NODE);
12332 install_default (BGP_VPNV4_NODE);
12333
12334 /* "bgp multiple-instance" commands. */
12335 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
12336 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
12337
12338 /* "bgp config-type" commands. */
12339 install_element (CONFIG_NODE, &bgp_config_type_cmd);
12340 install_element (CONFIG_NODE, &no_bgp_config_type_val_cmd);
12341
12342 /* Dummy commands (Currently not supported) */
12343 install_element (BGP_NODE, &no_synchronization_cmd);
12344 install_element (BGP_NODE, &no_auto_summary_cmd);
12345
12346 /* "router bgp" commands. */
12347 install_element (CONFIG_NODE, &router_bgp_cmd);
12348 install_element (CONFIG_NODE, &router_bgp_instance_cmd);
12349 install_element (CONFIG_NODE, &router_bgp_noasn_cmd);
12350
12351 /* "no router bgp" commands. */
12352 install_element (CONFIG_NODE, &no_router_bgp_cmd);
12353 install_element (CONFIG_NODE, &no_router_bgp_instance_cmd);
12354
12355 /* "bgp router-id" commands. */
12356 install_element (BGP_NODE, &bgp_router_id_cmd);
12357 install_element (BGP_NODE, &no_bgp_router_id_cmd);
12358 install_element (BGP_NODE, &no_bgp_router_id_val_cmd);
12359
12360 /* "bgp cluster-id" commands. */
12361 install_element (BGP_NODE, &bgp_cluster_id_cmd);
12362 install_element (BGP_NODE, &bgp_cluster_id32_cmd);
12363 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
12364 install_element (BGP_NODE, &no_bgp_cluster_id_ip_cmd);
12365 install_element (BGP_NODE, &no_bgp_cluster_id_decimal_cmd);
12366
12367 /* "bgp confederation" commands. */
12368 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
12369 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
12370 install_element (BGP_NODE, &no_bgp_confederation_identifier_arg_cmd);
12371
12372 /* "bgp confederation peers" commands. */
12373 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
12374 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
12375
12376 /* bgp max-med command */
12377 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
12378 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
12379 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
12380 install_element (BGP_NODE, &no_bgp_maxmed_admin_medv_cmd);
12381 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
12382 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
12383 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_cmd);
12384 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
12385 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_period_medv_cmd);
12386
12387 /* bgp disable-ebgp-connected-nh-check */
12388 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
12389 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
12390
12391 /* bgp update-delay command */
12392 install_element (BGP_NODE, &bgp_update_delay_cmd);
12393 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
12394 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
12395 install_element (BGP_NODE, &no_bgp_update_delay_establish_wait_cmd);
12396
12397 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
12398 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
12399
12400 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
12401 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
12402
12403 /* "maximum-paths" commands. */
12404 install_element (BGP_NODE, &bgp_maxpaths_cmd);
12405 install_element (BGP_NODE, &no_bgp_maxpaths_cmd);
12406 install_element (BGP_NODE, &no_bgp_maxpaths_arg_cmd);
12407 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
12408 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
12409 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_arg_cmd);
12410 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
12411 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
12412 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_arg_cmd);
12413 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd);
12414 install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
12415 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd);
12416 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
12417 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
12418 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
12419 install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
12420 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
12421 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
12422 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
12423 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
12424 install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
12425 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
12426 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_arg_cmd);
12427 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cluster_cmd);
12428
12429 /* "timers bgp" commands. */
12430 install_element (BGP_NODE, &bgp_timers_cmd);
12431 install_element (BGP_NODE, &no_bgp_timers_cmd);
12432 install_element (BGP_NODE, &no_bgp_timers_arg_cmd);
12433
12434 /* route-map delay-timer commands */
12435 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
12436 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
12437 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_val_cmd);
12438
12439 /* "bgp client-to-client reflection" commands */
12440 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
12441 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
12442
12443 /* "bgp always-compare-med" commands */
12444 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
12445 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
12446
12447 /* "bgp deterministic-med" commands */
12448 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
12449 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
12450
12451 /* "bgp graceful-restart" commands */
12452 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
12453 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
12454 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
12455 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
12456 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
12457
12458 /* "bgp fast-external-failover" commands */
12459 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
12460 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
12461
12462 /* "bgp enforce-first-as" commands */
12463 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
12464 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
12465
12466 /* "bgp bestpath compare-routerid" commands */
12467 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
12468 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
12469
12470 /* "bgp bestpath as-path ignore" commands */
12471 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
12472 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
12473
12474 /* "bgp bestpath as-path confed" commands */
12475 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
12476 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
12477
12478 /* "bgp bestpath as-path multipath-relax" commands */
12479 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
12480 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
12481
12482 /* "bgp log-neighbor-changes" commands */
12483 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
12484 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
12485
12486 /* "bgp bestpath med" commands */
12487 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
12488 install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
12489 install_element (BGP_NODE, &bgp_bestpath_med3_cmd);
12490 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
12491 install_element (BGP_NODE, &no_bgp_bestpath_med2_cmd);
12492 install_element (BGP_NODE, &no_bgp_bestpath_med3_cmd);
12493
12494 /* "no bgp default ipv4-unicast" commands. */
12495 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
12496 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
12497
12498 /* "bgp network import-check" commands. */
12499 install_element (BGP_NODE, &bgp_network_import_check_cmd);
12500 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
12501
12502 /* "bgp default local-preference" commands. */
12503 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
12504 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
12505 install_element (BGP_NODE, &no_bgp_default_local_preference_val_cmd);
12506
12507 /* bgp default show-hostname */
12508 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
12509 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
12510
12511 /* "bgp default subgroup-pkt-queue-max" commands. */
12512 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
12513 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
12514 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_val_cmd);
12515
12516 /* bgp ibgp-allow-policy-mods command */
12517 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
12518 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
12519
12520 /* "bgp listen limit" commands. */
12521 install_element (BGP_NODE, &bgp_listen_limit_cmd);
12522 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
12523 install_element (BGP_NODE, &no_bgp_listen_limit_val_cmd);
12524
12525 /* "bgp listen range" commands. */
12526 install_element (BGP_NODE, &bgp_listen_range_cmd);
12527 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
12528
12529 /* "neighbor remote-as" commands. */
12530 install_element (BGP_NODE, &neighbor_remote_as_cmd);
12531 install_element (BGP_NODE, &neighbor_interface_config_cmd);
12532 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
12533 install_element (BGP_NODE, &neighbor_interface_config_peergroup_cmd);
12534 install_element (BGP_NODE, &neighbor_interface_config_v6only_peergroup_cmd);
12535 install_element (BGP_NODE, &no_neighbor_cmd);
12536 install_element (BGP_NODE, &no_neighbor_remote_as_cmd);
12537 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
12538 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_cmd);
12539 install_element (BGP_NODE, &no_neighbor_interface_config_peergroup_cmd);
12540 install_element (BGP_NODE, &no_neighbor_interface_config_v6only_peergroup_cmd);
12541
12542 /* "neighbor peer-group" commands. */
12543 install_element (BGP_NODE, &neighbor_peer_group_cmd);
12544 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
12545 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
12546
12547 /* "neighbor local-as" commands. */
12548 install_element (BGP_NODE, &neighbor_local_as_cmd);
12549 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
12550 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
12551 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
12552 install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
12553 install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
12554 install_element (BGP_NODE, &no_neighbor_local_as_val3_cmd);
12555
12556 /* "neighbor solo" commands. */
12557 install_element (BGP_NODE, &neighbor_solo_cmd);
12558 install_element (BGP_NODE, &no_neighbor_solo_cmd);
12559
12560 /* "neighbor password" commands. */
12561 install_element (BGP_NODE, &neighbor_password_cmd);
12562 install_element (BGP_NODE, &no_neighbor_password_cmd);
12563 install_element (BGP_NODE, &no_neighbor_password_val_cmd);
12564
12565 /* "neighbor activate" commands. */
12566 install_element (BGP_NODE, &neighbor_activate_cmd);
12567 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
12568 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
12569 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
12570 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
12571 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
12572
12573 /* "no neighbor activate" commands. */
12574 install_element (BGP_NODE, &no_neighbor_activate_cmd);
12575 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
12576 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
12577 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
12578 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
12579 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
12580
12581 /* "neighbor peer-group" set commands.
12582 * Long term we should only accept this command under BGP_NODE and not all of
12583 * the afi/safi sub-contexts. For now though we need to accept it for backwards
12584 * compatibility. This changed when we stopped requiring that peers be assigned
12585 * to their peer-group under each address-family sub-context.
12586 */
12587 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
12588 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd);
12589 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd);
12590 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
12591 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
12592 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
12593
12594 /* "no neighbor peer-group unset" commands. */
12595 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
12596 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
12597 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd);
12598 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
12599 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
12600 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
12601
12602 /* "neighbor softreconfiguration inbound" commands.*/
12603 install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
12604 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
12605 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
12606 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
12607 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
12608 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
12609 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
12610 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
12611 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
12612 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
12613 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
12614 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
12615
12616 /* "neighbor attribute-unchanged" commands. */
12617 install_element (BGP_NODE, &neighbor_attr_unchanged_cmd);
12618 install_element (BGP_NODE, &neighbor_attr_unchanged1_cmd);
12619 install_element (BGP_NODE, &neighbor_attr_unchanged2_cmd);
12620 install_element (BGP_NODE, &neighbor_attr_unchanged3_cmd);
12621 install_element (BGP_NODE, &neighbor_attr_unchanged4_cmd);
12622 install_element (BGP_NODE, &neighbor_attr_unchanged5_cmd);
12623 install_element (BGP_NODE, &neighbor_attr_unchanged6_cmd);
12624 install_element (BGP_NODE, &neighbor_attr_unchanged7_cmd);
12625 install_element (BGP_NODE, &neighbor_attr_unchanged8_cmd);
12626 install_element (BGP_NODE, &neighbor_attr_unchanged9_cmd);
12627 install_element (BGP_NODE, &neighbor_attr_unchanged10_cmd);
12628 install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd);
12629 install_element (BGP_NODE, &no_neighbor_attr_unchanged1_cmd);
12630 install_element (BGP_NODE, &no_neighbor_attr_unchanged2_cmd);
12631 install_element (BGP_NODE, &no_neighbor_attr_unchanged3_cmd);
12632 install_element (BGP_NODE, &no_neighbor_attr_unchanged4_cmd);
12633 install_element (BGP_NODE, &no_neighbor_attr_unchanged5_cmd);
12634 install_element (BGP_NODE, &no_neighbor_attr_unchanged6_cmd);
12635 install_element (BGP_NODE, &no_neighbor_attr_unchanged7_cmd);
12636 install_element (BGP_NODE, &no_neighbor_attr_unchanged8_cmd);
12637 install_element (BGP_NODE, &no_neighbor_attr_unchanged9_cmd);
12638 install_element (BGP_NODE, &no_neighbor_attr_unchanged10_cmd);
12639 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
12640 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged1_cmd);
12641 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged2_cmd);
12642 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged3_cmd);
12643 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged4_cmd);
12644 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged5_cmd);
12645 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged6_cmd);
12646 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged7_cmd);
12647 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged8_cmd);
12648 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged9_cmd);
12649 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged10_cmd);
12650 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
12651 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged1_cmd);
12652 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged2_cmd);
12653 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged3_cmd);
12654 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged4_cmd);
12655 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged5_cmd);
12656 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged6_cmd);
12657 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged7_cmd);
12658 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged8_cmd);
12659 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged9_cmd);
12660 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged10_cmd);
12661 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
12662 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged1_cmd);
12663 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged2_cmd);
12664 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged3_cmd);
12665 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged4_cmd);
12666 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged5_cmd);
12667 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged6_cmd);
12668 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged7_cmd);
12669 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged8_cmd);
12670 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged9_cmd);
12671 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged10_cmd);
12672 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
12673 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged1_cmd);
12674 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged2_cmd);
12675 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged3_cmd);
12676 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged4_cmd);
12677 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged5_cmd);
12678 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged6_cmd);
12679 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged7_cmd);
12680 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged8_cmd);
12681 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged9_cmd);
12682 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged10_cmd);
12683 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
12684 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged1_cmd);
12685 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged2_cmd);
12686 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged3_cmd);
12687 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged4_cmd);
12688 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged5_cmd);
12689 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged6_cmd);
12690 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged7_cmd);
12691 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged8_cmd);
12692 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged9_cmd);
12693 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged10_cmd);
12694 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
12695 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged1_cmd);
12696 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged2_cmd);
12697 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged3_cmd);
12698 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged4_cmd);
12699 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged5_cmd);
12700 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged6_cmd);
12701 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged7_cmd);
12702 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged8_cmd);
12703 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged9_cmd);
12704 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged10_cmd);
12705 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
12706 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged1_cmd);
12707 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged2_cmd);
12708 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged3_cmd);
12709 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged4_cmd);
12710 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged5_cmd);
12711 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged6_cmd);
12712 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged7_cmd);
12713 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged8_cmd);
12714 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged9_cmd);
12715 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged10_cmd);
12716 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
12717 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged1_cmd);
12718 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged2_cmd);
12719 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged3_cmd);
12720 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged4_cmd);
12721 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged5_cmd);
12722 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged6_cmd);
12723 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged7_cmd);
12724 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged8_cmd);
12725 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged9_cmd);
12726 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged10_cmd);
12727 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
12728 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged1_cmd);
12729 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged2_cmd);
12730 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged3_cmd);
12731 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged4_cmd);
12732 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged5_cmd);
12733 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged6_cmd);
12734 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged7_cmd);
12735 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged8_cmd);
12736 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged9_cmd);
12737 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged10_cmd);
12738 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
12739 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged1_cmd);
12740 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged2_cmd);
12741 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged3_cmd);
12742 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged4_cmd);
12743 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged5_cmd);
12744 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged6_cmd);
12745 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged7_cmd);
12746 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged8_cmd);
12747 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged9_cmd);
12748 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged10_cmd);
12749
12750 /* "nexthop-local unchanged" commands */
12751 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
12752 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
12753
12754 /* "neighbor next-hop-self" commands. */
12755 install_element (BGP_NODE, &neighbor_nexthop_self_cmd);
12756 install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd);
12757 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
12758 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
12759 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
12760 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
12761 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
12762 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
12763 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
12764 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
12765 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
12766 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
12767
12768 /* "neighbor next-hop-self force" commands. */
12769 install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
12770 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
12771 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
12772 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
12773 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
12774 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
12775 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
12776 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
12777 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
12778 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
12779 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
12780 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
12781
12782 /* "neighbor as-override" commands. */
12783 install_element (BGP_NODE, &neighbor_as_override_cmd);
12784 install_element (BGP_NODE, &no_neighbor_as_override_cmd);
12785 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
12786 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
12787 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
12788 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
12789 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
12790 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
12791 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
12792 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
12793 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
12794 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
12795
12796 /* "neighbor remove-private-AS" commands. */
12797 install_element (BGP_NODE, &neighbor_remove_private_as_cmd);
12798 install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd);
12799 install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd);
12800 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd);
12801 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd);
12802 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12803 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12804 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12805 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
12806 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
12807 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
12808 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
12809 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
12810 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12811 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12812 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12813 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
12814 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
12815 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
12816 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
12817 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
12818 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12819 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12820 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12821 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
12822 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
12823 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
12824 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
12825 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
12826 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12827 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12828 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12829 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
12830 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
12831 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
12832 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
12833 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
12834 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12835 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12836 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12837 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
12838 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
12839 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
12840 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
12841 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
12842 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
12843 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
12844 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
12845
12846 /* "neighbor send-community" commands.*/
12847 install_element (BGP_NODE, &neighbor_send_community_cmd);
12848 install_element (BGP_NODE, &neighbor_send_community_type_cmd);
12849 install_element (BGP_NODE, &no_neighbor_send_community_cmd);
12850 install_element (BGP_NODE, &no_neighbor_send_community_type_cmd);
12851 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
12852 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
12853 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
12854 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
12855 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
12856 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
12857 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
12858 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
12859 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
12860 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
12861 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
12862 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
12863 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
12864 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
12865 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
12866 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
12867 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
12868 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
12869 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
12870 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
12871
12872 /* "neighbor route-reflector" commands.*/
12873 install_element (BGP_NODE, &neighbor_route_reflector_client_cmd);
12874 install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd);
12875 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
12876 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
12877 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
12878 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
12879 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
12880 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
12881 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
12882 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
12883 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
12884 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
12885
12886 /* "neighbor route-server" commands.*/
12887 install_element (BGP_NODE, &neighbor_route_server_client_cmd);
12888 install_element (BGP_NODE, &no_neighbor_route_server_client_cmd);
12889 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
12890 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
12891 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
12892 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
12893 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
12894 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
12895 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
12896 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
12897 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
12898 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
12899
12900 /* "neighbor addpath-tx-all-paths" commands.*/
12901 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd);
12902 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12903 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
12904 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12905 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
12906 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12907 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
12908 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12909 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
12910 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12911 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
12912 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
12913
12914 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12915 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12916 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12917 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12918 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12919 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12920 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12921 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12922 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12923 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12924 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12925 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
12926 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
12927
12928 /* "neighbor passive" commands. */
12929 install_element (BGP_NODE, &neighbor_passive_cmd);
12930 install_element (BGP_NODE, &no_neighbor_passive_cmd);
12931
12932
12933 /* "neighbor shutdown" commands. */
12934 install_element (BGP_NODE, &neighbor_shutdown_cmd);
12935 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
12936
12937 /* "neighbor capability extended-nexthop" commands.*/
12938 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
12939 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
12940
12941 /* "neighbor capability orf prefix-list" commands.*/
12942 install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd);
12943 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd);
12944 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
12945 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
12946 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
12947 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
12948 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
12949 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
12950 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
12951 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
12952
12953 /* "neighbor capability dynamic" commands.*/
12954 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
12955 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
12956
12957 /* "neighbor dont-capability-negotiate" commands. */
12958 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
12959 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
12960
12961 /* "neighbor ebgp-multihop" commands. */
12962 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
12963 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
12964 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
12965 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_ttl_cmd);
12966
12967 /* "neighbor disable-connected-check" commands. */
12968 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
12969 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
12970 install_element (BGP_NODE, &neighbor_enforce_multihop_cmd);
12971 install_element (BGP_NODE, &no_neighbor_enforce_multihop_cmd);
12972
12973 /* "neighbor description" commands. */
12974 install_element (BGP_NODE, &neighbor_description_cmd);
12975 install_element (BGP_NODE, &no_neighbor_description_cmd);
12976 install_element (BGP_NODE, &no_neighbor_description_val_cmd);
12977
12978 /* "neighbor update-source" commands. "*/
12979 install_element (BGP_NODE, &neighbor_update_source_cmd);
12980 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
12981
12982 /* "neighbor default-originate" commands. */
12983 install_element (BGP_NODE, &neighbor_default_originate_cmd);
12984 install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd);
12985 install_element (BGP_NODE, &no_neighbor_default_originate_cmd);
12986 install_element (BGP_NODE, &no_neighbor_default_originate_rmap_cmd);
12987 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
12988 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
12989 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
12990 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_rmap_cmd);
12991 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
12992 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
12993 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
12994 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_rmap_cmd);
12995 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
12996 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
12997 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
12998 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_rmap_cmd);
12999 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
13000 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
13001 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
13002 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_rmap_cmd);
13003
13004 /* "neighbor port" commands. */
13005 install_element (BGP_NODE, &neighbor_port_cmd);
13006 install_element (BGP_NODE, &no_neighbor_port_cmd);
13007 install_element (BGP_NODE, &no_neighbor_port_val_cmd);
13008
13009 /* "neighbor weight" commands. */
13010 install_element (BGP_NODE, &neighbor_weight_cmd);
13011 install_element (BGP_NODE, &no_neighbor_weight_cmd);
13012 install_element (BGP_NODE, &no_neighbor_weight_val_cmd);
13013
13014 /* "neighbor override-capability" commands. */
13015 install_element (BGP_NODE, &neighbor_override_capability_cmd);
13016 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
13017
13018 /* "neighbor strict-capability-match" commands. */
13019 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
13020 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
13021
13022 /* "neighbor timers" commands. */
13023 install_element (BGP_NODE, &neighbor_timers_cmd);
13024 install_element (BGP_NODE, &no_neighbor_timers_cmd);
13025 install_element (BGP_NODE, &no_neighbor_timers_val_cmd);
13026
13027 /* "neighbor timers connect" commands. */
13028 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
13029 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
13030 install_element (BGP_NODE, &no_neighbor_timers_connect_val_cmd);
13031
13032 /* "neighbor advertisement-interval" commands. */
13033 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
13034 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
13035 install_element (BGP_NODE, &no_neighbor_advertise_interval_val_cmd);
13036
13037 /* "neighbor interface" commands. */
13038 install_element (BGP_NODE, &neighbor_interface_cmd);
13039 install_element (BGP_NODE, &no_neighbor_interface_cmd);
13040
13041 /* "neighbor distribute" commands. */
13042 install_element (BGP_NODE, &neighbor_distribute_list_cmd);
13043 install_element (BGP_NODE, &no_neighbor_distribute_list_cmd);
13044 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
13045 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
13046 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
13047 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
13048 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
13049 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
13050 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
13051 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
13052 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
13053 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
13054
13055 /* "neighbor prefix-list" commands. */
13056 install_element (BGP_NODE, &neighbor_prefix_list_cmd);
13057 install_element (BGP_NODE, &no_neighbor_prefix_list_cmd);
13058 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
13059 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
13060 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
13061 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
13062 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
13063 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
13064 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
13065 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
13066 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
13067 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
13068
13069 /* "neighbor filter-list" commands. */
13070 install_element (BGP_NODE, &neighbor_filter_list_cmd);
13071 install_element (BGP_NODE, &no_neighbor_filter_list_cmd);
13072 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
13073 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
13074 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
13075 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
13076 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
13077 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
13078 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
13079 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
13080 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
13081 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
13082
13083 /* "neighbor route-map" commands. */
13084 install_element (BGP_NODE, &neighbor_route_map_cmd);
13085 install_element (BGP_NODE, &no_neighbor_route_map_cmd);
13086 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
13087 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
13088 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
13089 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
13090 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
13091 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
13092 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
13093 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
13094 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
13095 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
13096
13097 /* "neighbor unsuppress-map" commands. */
13098 install_element (BGP_NODE, &neighbor_unsuppress_map_cmd);
13099 install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd);
13100 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
13101 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
13102 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
13103 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
13104 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
13105 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
13106 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
13107 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
13108 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
13109 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
13110
13111 /* "neighbor maximum-prefix" commands. */
13112 install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
13113 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd);
13114 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd);
13115 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13116 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd);
13117 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13118 install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd);
13119 install_element (BGP_NODE, &no_neighbor_maximum_prefix_val_cmd);
13120 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13121 install_element (BGP_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13122 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13123 install_element (BGP_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13124 install_element (BGP_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13125 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
13126 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
13127 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
13128 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13129 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
13130 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13131 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
13132 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
13133 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13134 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13135 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13136 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13137 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13138 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
13139 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
13140 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
13141 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13142 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
13143 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13144 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
13145 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_val_cmd);
13146 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13147 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13148 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13149 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13150 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13151 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
13152 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
13153 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
13154 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13155 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
13156 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13157 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
13158 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_val_cmd);
13159 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13160 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13161 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13162 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13163 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13164 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
13165 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
13166 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
13167 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13168 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
13169 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13170 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
13171 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_val_cmd);
13172 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13173 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13174 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13175 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13176 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13177 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
13178 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
13179 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
13180 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
13181 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
13182 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
13183 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
13184 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_val_cmd);
13185 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_cmd);
13186 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_warning_cmd);
13187 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_warning_cmd);
13188 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_restart_cmd);
13189 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_threshold_restart_cmd);
13190
13191 /* "neighbor allowas-in" */
13192 install_element (BGP_NODE, &neighbor_allowas_in_cmd);
13193 install_element (BGP_NODE, &neighbor_allowas_in_arg_cmd);
13194 install_element (BGP_NODE, &no_neighbor_allowas_in_cmd);
13195 install_element (BGP_NODE, &no_neighbor_allowas_in_val_cmd);
13196 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
13197 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_arg_cmd);
13198 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
13199 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_val_cmd);
13200 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
13201 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_arg_cmd);
13202 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
13203 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_val_cmd);
13204 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
13205 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_arg_cmd);
13206 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
13207 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_val_cmd);
13208 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
13209 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_arg_cmd);
13210 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
13211 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_val_cmd);
13212 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
13213 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_arg_cmd);
13214 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
13215 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_val_cmd);
13216
13217 /* address-family commands. */
13218 install_element (BGP_NODE, &address_family_ipv4_cmd);
13219 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
13220 #ifdef HAVE_IPV6
13221 install_element (BGP_NODE, &address_family_ipv6_cmd);
13222 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
13223 #endif /* HAVE_IPV6 */
13224 install_element (BGP_NODE, &address_family_vpnv4_cmd);
13225 install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);
13226
13227 /* "exit-address-family" command. */
13228 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
13229 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
13230 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
13231 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
13232 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
13233
13234 /* "clear ip bgp commands" */
13235 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
13236 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_cmd);
13237 install_element (ENABLE_NODE, &clear_ip_bgp_as_cmd);
13238 install_element (ENABLE_NODE, &clear_ip_bgp_peer_cmd);
13239 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_cmd);
13240 install_element (ENABLE_NODE, &clear_ip_bgp_external_cmd);
13241 #ifdef HAVE_IPV6
13242 install_element (ENABLE_NODE, &clear_bgp_all_cmd);
13243 install_element (ENABLE_NODE, &clear_bgp_instance_all_cmd);
13244 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_cmd);
13245 install_element (ENABLE_NODE, &clear_bgp_peer_cmd);
13246 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_cmd);
13247 install_element (ENABLE_NODE, &clear_bgp_peer_group_cmd);
13248 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_cmd);
13249 install_element (ENABLE_NODE, &clear_bgp_external_cmd);
13250 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_cmd);
13251 install_element (ENABLE_NODE, &clear_bgp_as_cmd);
13252 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_cmd);
13253 #endif /* HAVE_IPV6 */
13254
13255 /* "clear ip bgp neighbor soft in" */
13256 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_in_cmd);
13257 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_in_cmd);
13258 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_cmd);
13259 install_element (ENABLE_NODE, &clear_ip_bgp_all_in_prefix_filter_cmd);
13260 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_in_prefix_filter_cmd);
13261 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_in_cmd);
13262 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_cmd);
13263 install_element (ENABLE_NODE, &clear_ip_bgp_peer_in_prefix_filter_cmd);
13264 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_in_cmd);
13265 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_cmd);
13266 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_in_prefix_filter_cmd);
13267 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_in_cmd);
13268 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_cmd);
13269 install_element (ENABLE_NODE, &clear_ip_bgp_external_in_prefix_filter_cmd);
13270 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_in_cmd);
13271 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_cmd);
13272 install_element (ENABLE_NODE, &clear_ip_bgp_as_in_prefix_filter_cmd);
13273 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_in_cmd);
13274 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_in_cmd);
13275 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_cmd);
13276 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_in_prefix_filter_cmd);
13277 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd);
13278 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_in_cmd);
13279 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_cmd);
13280 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd);
13281 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_in_cmd);
13282 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_cmd);
13283 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd);
13284 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_in_cmd);
13285 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_cmd);
13286 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_in_prefix_filter_cmd);
13287 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_in_cmd);
13288 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd);
13289 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd);
13290 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd);
13291 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd);
13292 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd);
13293 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd);
13294 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd);
13295 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd);
13296 #ifdef HAVE_IPV6
13297 install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd);
13298 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd);
13299 install_element (ENABLE_NODE, &clear_bgp_all_in_cmd);
13300 install_element (ENABLE_NODE, &clear_bgp_all_in_prefix_filter_cmd);
13301 install_element (ENABLE_NODE, &clear_bgp_peer_soft_in_cmd);
13302 install_element (ENABLE_NODE, &clear_bgp_peer_in_cmd);
13303 install_element (ENABLE_NODE, &clear_bgp_peer_in_prefix_filter_cmd);
13304 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_in_cmd);
13305 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_cmd);
13306 install_element (ENABLE_NODE, &clear_bgp_peer_group_in_prefix_filter_cmd);
13307 install_element (ENABLE_NODE, &clear_bgp_external_soft_in_cmd);
13308 install_element (ENABLE_NODE, &clear_bgp_external_in_cmd);
13309 install_element (ENABLE_NODE, &clear_bgp_external_in_prefix_filter_cmd);
13310 install_element (ENABLE_NODE, &clear_bgp_as_soft_in_cmd);
13311 install_element (ENABLE_NODE, &clear_bgp_as_in_cmd);
13312 install_element (ENABLE_NODE, &clear_bgp_as_in_prefix_filter_cmd);
13313 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_in_cmd);
13314 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_cmd);
13315 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_in_prefix_filter_cmd);
13316 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_in_cmd);
13317 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_cmd);
13318 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_in_prefix_filter_cmd);
13319 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_in_cmd);
13320 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_cmd);
13321 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_in_prefix_filter_cmd);
13322 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_in_cmd);
13323 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_cmd);
13324 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_in_prefix_filter_cmd);
13325 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_in_cmd);
13326 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_cmd);
13327 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_in_prefix_filter_cmd);
13328 #endif /* HAVE_IPV6 */
13329
13330 /* clear ip bgp prefix */
13331 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
13332 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
13333
13334 /* "clear ip bgp neighbor soft out" */
13335 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_out_cmd);
13336 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_out_cmd);
13337 install_element (ENABLE_NODE, &clear_ip_bgp_all_out_cmd);
13338 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_out_cmd);
13339 install_element (ENABLE_NODE, &clear_ip_bgp_peer_out_cmd);
13340 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_out_cmd);
13341 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_out_cmd);
13342 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_out_cmd);
13343 install_element (ENABLE_NODE, &clear_ip_bgp_external_out_cmd);
13344 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_out_cmd);
13345 install_element (ENABLE_NODE, &clear_ip_bgp_as_out_cmd);
13346 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_out_cmd);
13347 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_out_cmd);
13348 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_out_cmd);
13349 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_out_cmd);
13350 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_out_cmd);
13351 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_out_cmd);
13352 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_out_cmd);
13353 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_out_cmd);
13354 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_out_cmd);
13355 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_out_cmd);
13356 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd);
13357 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd);
13358 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd);
13359 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd);
13360 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd);
13361 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd);
13362 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd);
13363 #ifdef HAVE_IPV6
13364 install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd);
13365 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd);
13366 install_element (ENABLE_NODE, &clear_bgp_all_out_cmd);
13367 install_element (ENABLE_NODE, &clear_bgp_peer_soft_out_cmd);
13368 install_element (ENABLE_NODE, &clear_bgp_peer_out_cmd);
13369 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_out_cmd);
13370 install_element (ENABLE_NODE, &clear_bgp_peer_group_out_cmd);
13371 install_element (ENABLE_NODE, &clear_bgp_external_soft_out_cmd);
13372 install_element (ENABLE_NODE, &clear_bgp_external_out_cmd);
13373 install_element (ENABLE_NODE, &clear_bgp_as_soft_out_cmd);
13374 install_element (ENABLE_NODE, &clear_bgp_as_out_cmd);
13375 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_out_cmd);
13376 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_out_cmd);
13377 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_out_cmd);
13378 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_out_cmd);
13379 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_out_cmd);
13380 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_out_cmd);
13381 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_out_cmd);
13382 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_out_cmd);
13383 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_out_cmd);
13384 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_out_cmd);
13385 #endif /* HAVE_IPV6 */
13386
13387 /* "clear ip bgp neighbor soft" */
13388 install_element (ENABLE_NODE, &clear_ip_bgp_all_soft_cmd);
13389 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_soft_cmd);
13390 install_element (ENABLE_NODE, &clear_ip_bgp_peer_soft_cmd);
13391 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_soft_cmd);
13392 install_element (ENABLE_NODE, &clear_ip_bgp_external_soft_cmd);
13393 install_element (ENABLE_NODE, &clear_ip_bgp_as_soft_cmd);
13394 install_element (ENABLE_NODE, &clear_ip_bgp_all_ipv4_soft_cmd);
13395 install_element (ENABLE_NODE, &clear_ip_bgp_instance_all_ipv4_soft_cmd);
13396 install_element (ENABLE_NODE, &clear_ip_bgp_peer_ipv4_soft_cmd);
13397 install_element (ENABLE_NODE, &clear_ip_bgp_peer_group_ipv4_soft_cmd);
13398 install_element (ENABLE_NODE, &clear_ip_bgp_external_ipv4_soft_cmd);
13399 install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd);
13400 install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd);
13401 install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd);
13402 install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd);
13403 #ifdef HAVE_IPV6
13404 install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd);
13405 install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd);
13406 install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd);
13407 install_element (ENABLE_NODE, &clear_bgp_peer_group_soft_cmd);
13408 install_element (ENABLE_NODE, &clear_bgp_external_soft_cmd);
13409 install_element (ENABLE_NODE, &clear_bgp_as_soft_cmd);
13410 install_element (ENABLE_NODE, &clear_bgp_ipv6_all_soft_cmd);
13411 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_soft_cmd);
13412 install_element (ENABLE_NODE, &clear_bgp_ipv6_peer_group_soft_cmd);
13413 install_element (ENABLE_NODE, &clear_bgp_ipv6_external_soft_cmd);
13414 install_element (ENABLE_NODE, &clear_bgp_ipv6_as_soft_cmd);
13415 #endif /* HAVE_IPV6 */
13416
13417 /* "show ip bgp summary" commands. */
13418 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
13419 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
13420 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_cmd);
13421 install_element (VIEW_NODE, &show_bgp_updgrps_cmd);
13422 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_cmd);
13423 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
13424 install_element (VIEW_NODE, &show_ip_bgp_updgrps_s_cmd);
13425 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
13426 install_element (VIEW_NODE, &show_bgp_updgrps_s_cmd);
13427 install_element (VIEW_NODE, &show_bgp_ipv6_updgrps_s_cmd);
13428 install_element (VIEW_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
13429 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
13430 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
13431 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
13432 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
13433 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
13434 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13435 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
13436 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
13437 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
13438 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
13439 install_element (VIEW_NODE, &show_ip_bgp_instance_summary_cmd);
13440 install_element (VIEW_NODE, &show_ip_bgp_ipv4_summary_cmd);
13441 install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd);
13442 install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
13443 install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
13444 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13445 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13446 #ifdef HAVE_IPV6
13447 install_element (VIEW_NODE, &show_bgp_summary_cmd);
13448 install_element (VIEW_NODE, &show_bgp_instance_summary_cmd);
13449 install_element (VIEW_NODE, &show_bgp_ipv6_summary_cmd);
13450 install_element (VIEW_NODE, &show_bgp_ipv6_safi_summary_cmd);
13451 install_element (VIEW_NODE, &show_bgp_instance_ipv6_summary_cmd);
13452 install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
13453 #endif /* HAVE_IPV6 */
13454 install_element (RESTRICTED_NODE, &show_ip_bgp_summary_cmd);
13455 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_cmd);
13456 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_cmd);
13457 install_element (RESTRICTED_NODE, &show_bgp_updgrps_cmd);
13458 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_cmd);
13459 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
13460 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_s_cmd);
13461 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
13462 install_element (RESTRICTED_NODE, &show_bgp_updgrps_s_cmd);
13463 install_element (RESTRICTED_NODE, &show_bgp_ipv6_updgrps_s_cmd);
13464 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
13465 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_cmd);
13466 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
13467 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_cmd);
13468 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_cmd);
13469 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_cmd);
13470 install_element (RESTRICTED_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13471 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
13472 install_element (RESTRICTED_NODE, &show_bgp_updgrps_adj_s_cmd);
13473 install_element (RESTRICTED_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
13474 install_element (RESTRICTED_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
13475 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_summary_cmd);
13476 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_summary_cmd);
13477 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_summary_cmd);
13478 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
13479 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
13480 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13481 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13482 #ifdef HAVE_IPV6
13483 install_element (RESTRICTED_NODE, &show_bgp_summary_cmd);
13484 install_element (RESTRICTED_NODE, &show_bgp_instance_summary_cmd);
13485 install_element (RESTRICTED_NODE, &show_bgp_ipv6_summary_cmd);
13486 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_summary_cmd);
13487 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_summary_cmd);
13488 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
13489 #endif /* HAVE_IPV6 */
13490 install_element (ENABLE_NODE, &show_ip_bgp_summary_cmd);
13491 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_cmd);
13492 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_cmd);
13493 install_element (ENABLE_NODE, &show_bgp_updgrps_cmd);
13494 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_cmd);
13495 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_cmd);
13496 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_s_cmd);
13497 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_s_cmd);
13498 install_element (ENABLE_NODE, &show_bgp_updgrps_s_cmd);
13499 install_element (ENABLE_NODE, &show_bgp_ipv6_updgrps_s_cmd);
13500 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_updgrps_s_cmd);
13501 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_cmd);
13502 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
13503 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_cmd);
13504 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_cmd);
13505 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_cmd);
13506 install_element (ENABLE_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
13507 install_element (ENABLE_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
13508 install_element (ENABLE_NODE, &show_bgp_updgrps_adj_s_cmd);
13509 install_element (ENABLE_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
13510 install_element (ENABLE_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
13511 install_element (ENABLE_NODE, &show_ip_bgp_instance_summary_cmd);
13512 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_summary_cmd);
13513 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_summary_cmd);
13514 install_element (ENABLE_NODE, &show_ip_bgp_instance_ipv4_summary_cmd);
13515 install_element (ENABLE_NODE, &show_bgp_instance_ipv4_safi_summary_cmd);
13516 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_summary_cmd);
13517 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd);
13518 #ifdef HAVE_IPV6
13519 install_element (ENABLE_NODE, &show_bgp_summary_cmd);
13520 install_element (ENABLE_NODE, &show_bgp_instance_summary_cmd);
13521 install_element (ENABLE_NODE, &show_bgp_ipv6_summary_cmd);
13522 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_summary_cmd);
13523 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_summary_cmd);
13524 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
13525 #endif /* HAVE_IPV6 */
13526
13527 /* "show ip bgp neighbors" commands. */
13528 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
13529 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
13530 install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd);
13531 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13532 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
13533 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
13534 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13535 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13536 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd);
13537 install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
13538 install_element (RESTRICTED_NODE, &show_ip_bgp_neighbors_peer_cmd);
13539 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13540 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13541 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13542 install_element (RESTRICTED_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
13543 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_cmd);
13544 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
13545 install_element (ENABLE_NODE, &show_ip_bgp_neighbors_peer_cmd);
13546 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd);
13547 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd);
13548 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd);
13549 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd);
13550 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd);
13551 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_cmd);
13552 install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbors_peer_cmd);
13553
13554 #ifdef HAVE_IPV6
13555 install_element (VIEW_NODE, &show_bgp_neighbors_cmd);
13556 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
13557 install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
13558 install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
13559 install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
13560 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
13561 install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
13562 install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
13563 install_element (RESTRICTED_NODE, &show_bgp_neighbors_peer_cmd);
13564 install_element (RESTRICTED_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
13565 install_element (RESTRICTED_NODE, &show_bgp_instance_neighbors_peer_cmd);
13566 install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
13567 install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
13568 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
13569 install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
13570 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
13571 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
13572 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
13573 install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
13574 install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
13575
13576 /* Old commands. */
13577 install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
13578 install_element (VIEW_NODE, &show_ipv6_mbgp_summary_cmd);
13579 install_element (ENABLE_NODE, &show_ipv6_bgp_summary_cmd);
13580 install_element (ENABLE_NODE, &show_ipv6_mbgp_summary_cmd);
13581 #endif /* HAVE_IPV6 */
13582
13583 /* "show ip bgp peer-group" commands. */
13584 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
13585 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_groups_cmd);
13586 install_element (VIEW_NODE, &show_ip_bgp_peer_group_cmd);
13587 install_element (VIEW_NODE, &show_ip_bgp_instance_peer_group_cmd);
13588 install_element (ENABLE_NODE, &show_ip_bgp_peer_groups_cmd);
13589 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_groups_cmd);
13590 install_element (ENABLE_NODE, &show_ip_bgp_peer_group_cmd);
13591 install_element (ENABLE_NODE, &show_ip_bgp_instance_peer_group_cmd);
13592
13593 /* "show ip bgp paths" commands. */
13594 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
13595 install_element (VIEW_NODE, &show_ip_bgp_ipv4_paths_cmd);
13596 install_element (ENABLE_NODE, &show_ip_bgp_paths_cmd);
13597 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_paths_cmd);
13598
13599 /* "show ip bgp community" commands. */
13600 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
13601 install_element (ENABLE_NODE, &show_ip_bgp_community_info_cmd);
13602
13603 /* "show ip bgp attribute-info" commands. */
13604 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
13605 install_element (ENABLE_NODE, &show_ip_bgp_attr_info_cmd);
13606
13607 /* "redistribute" commands. */
13608 install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd);
13609 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd);
13610 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd);
13611 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
13612 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd);
13613 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
13614 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
13615 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
13616 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
13617 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
13618 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd);
13619 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
13620 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
13621 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
13622 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
13623 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
13624 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13625 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13626 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
13627 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
13628 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
13629 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
13630 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
13631 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_cmd);
13632 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
13633 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_cmd);
13634 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
13635 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
13636 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_rmap_metric_cmd);
13637 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_metric_rmap_cmd);
13638 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
13639 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
13640 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
13641 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_cmd);
13642 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
13643 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_cmd);
13644 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13645 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
13646 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
13647 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
13648 #ifdef HAVE_IPV6
13649 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
13650 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
13651 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
13652 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_cmd);
13653 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
13654 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_cmd);
13655 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
13656 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
13657 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_rmap_metric_cmd);
13658 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_metric_rmap_cmd);
13659 #endif /* HAVE_IPV6 */
13660
13661 /* ttl_security commands */
13662 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
13663 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
13664
13665 /* "show bgp memory" commands. */
13666 install_element (VIEW_NODE, &show_bgp_memory_cmd);
13667 install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
13668 install_element (ENABLE_NODE, &show_bgp_memory_cmd);
13669
13670 /* "show bgp views" commands. */
13671 install_element (VIEW_NODE, &show_bgp_views_cmd);
13672 install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
13673 install_element (ENABLE_NODE, &show_bgp_views_cmd);
13674
13675 /* "show bgp vrfs" commands. */
13676 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
13677 install_element (RESTRICTED_NODE, &show_bgp_vrfs_cmd);
13678 install_element (ENABLE_NODE, &show_bgp_vrfs_cmd);
13679
13680 /* Community-list. */
13681 community_list_vty ();
13682 }
13683
13684 #include "memory.h"
13685 #include "bgp_regex.h"
13686 #include "bgp_clist.h"
13687 #include "bgp_ecommunity.h"
13688
13689 /* VTY functions. */
13690
13691 /* Direction value to string conversion. */
13692 static const char *
13693 community_direct_str (int direct)
13694 {
13695 switch (direct)
13696 {
13697 case COMMUNITY_DENY:
13698 return "deny";
13699 case COMMUNITY_PERMIT:
13700 return "permit";
13701 default:
13702 return "unknown";
13703 }
13704 }
13705
13706 /* Display error string. */
13707 static void
13708 community_list_perror (struct vty *vty, int ret)
13709 {
13710 switch (ret)
13711 {
13712 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
13713 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
13714 break;
13715 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
13716 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
13717 break;
13718 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
13719 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
13720 break;
13721 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
13722 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
13723 break;
13724 }
13725 }
13726
13727 /* VTY interface for community_set() function. */
13728 static int
13729 community_list_set_vty (struct vty *vty, int argc, const char **argv,
13730 int style, int reject_all_digit_name)
13731 {
13732 int ret;
13733 int direct;
13734 char *str;
13735
13736 /* Check the list type. */
13737 if (strncmp (argv[1], "p", 1) == 0)
13738 direct = COMMUNITY_PERMIT;
13739 else if (strncmp (argv[1], "d", 1) == 0)
13740 direct = COMMUNITY_DENY;
13741 else
13742 {
13743 vty_out (vty, "%% Matching condition must be permit or deny%s",
13744 VTY_NEWLINE);
13745 return CMD_WARNING;
13746 }
13747
13748 /* All digit name check. */
13749 if (reject_all_digit_name && all_digit (argv[0]))
13750 {
13751 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
13752 return CMD_WARNING;
13753 }
13754
13755 /* Concat community string argument. */
13756 if (argc > 1)
13757 str = argv_concat (argv, argc, 2);
13758 else
13759 str = NULL;
13760
13761 /* When community_list_set() return nevetive value, it means
13762 malformed community string. */
13763 ret = community_list_set (bgp_clist, argv[0], str, direct, style);
13764
13765 /* Free temporary community list string allocated by
13766 argv_concat(). */
13767 if (str)
13768 XFREE (MTYPE_TMP, str);
13769
13770 if (ret < 0)
13771 {
13772 /* Display error string. */
13773 community_list_perror (vty, ret);
13774 return CMD_WARNING;
13775 }
13776
13777 return CMD_SUCCESS;
13778 }
13779
13780 /* Communiyt-list entry delete. */
13781 static int
13782 community_list_unset_vty (struct vty *vty, int argc, const char **argv,
13783 int style, int delete_all)
13784 {
13785 int ret;
13786 int direct = 0;
13787 char *str = NULL;
13788
13789 if (argc > 1)
13790 {
13791 /* Check the list direct. */
13792 if (strncmp (argv[1], "p", 1) == 0)
13793 direct = COMMUNITY_PERMIT;
13794 else if (strncmp (argv[1], "d", 1) == 0)
13795 direct = COMMUNITY_DENY;
13796 else
13797 {
13798 vty_out (vty, "%% Matching condition must be permit or deny%s",
13799 VTY_NEWLINE);
13800 return CMD_WARNING;
13801 }
13802
13803 /* Concat community string argument. */
13804 str = argv_concat (argv, argc, 2);
13805 }
13806
13807 /* Unset community list. */
13808 ret = community_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
13809
13810 /* Free temporary community list string allocated by
13811 argv_concat(). */
13812 if (str)
13813 XFREE (MTYPE_TMP, str);
13814
13815 if (ret < 0)
13816 {
13817 community_list_perror (vty, ret);
13818 return CMD_WARNING;
13819 }
13820
13821 return CMD_SUCCESS;
13822 }
13823
13824 /* "community-list" keyword help string. */
13825 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13826 #define COMMUNITY_VAL_STR "Community number in aa:nn format or internet|local-AS|no-advertise|no-export\n"
13827
13828 DEFUN (ip_community_list_standard,
13829 ip_community_list_standard_cmd,
13830 "ip community-list <1-99> (deny|permit) .AA:NN",
13831 IP_STR
13832 COMMUNITY_LIST_STR
13833 "Community list number (standard)\n"
13834 "Specify community to reject\n"
13835 "Specify community to accept\n"
13836 COMMUNITY_VAL_STR)
13837 {
13838 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
13839 }
13840
13841 ALIAS (ip_community_list_standard,
13842 ip_community_list_standard2_cmd,
13843 "ip community-list <1-99> (deny|permit)",
13844 IP_STR
13845 COMMUNITY_LIST_STR
13846 "Community list number (standard)\n"
13847 "Specify community to reject\n"
13848 "Specify community to accept\n")
13849
13850 DEFUN (ip_community_list_expanded,
13851 ip_community_list_expanded_cmd,
13852 "ip community-list <100-500> (deny|permit) .LINE",
13853 IP_STR
13854 COMMUNITY_LIST_STR
13855 "Community list number (expanded)\n"
13856 "Specify community to reject\n"
13857 "Specify community to accept\n"
13858 "An ordered list as a regular-expression\n")
13859 {
13860 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
13861 }
13862
13863 DEFUN (ip_community_list_name_standard,
13864 ip_community_list_name_standard_cmd,
13865 "ip community-list standard WORD (deny|permit) .AA:NN",
13866 IP_STR
13867 COMMUNITY_LIST_STR
13868 "Add a standard community-list entry\n"
13869 "Community list name\n"
13870 "Specify community to reject\n"
13871 "Specify community to accept\n"
13872 COMMUNITY_VAL_STR)
13873 {
13874 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
13875 }
13876
13877 ALIAS (ip_community_list_name_standard,
13878 ip_community_list_name_standard2_cmd,
13879 "ip community-list standard WORD (deny|permit)",
13880 IP_STR
13881 COMMUNITY_LIST_STR
13882 "Add a standard community-list entry\n"
13883 "Community list name\n"
13884 "Specify community to reject\n"
13885 "Specify community to accept\n")
13886
13887 DEFUN (ip_community_list_name_expanded,
13888 ip_community_list_name_expanded_cmd,
13889 "ip community-list expanded WORD (deny|permit) .LINE",
13890 IP_STR
13891 COMMUNITY_LIST_STR
13892 "Add an expanded community-list entry\n"
13893 "Community list name\n"
13894 "Specify community to reject\n"
13895 "Specify community to accept\n"
13896 "An ordered list as a regular-expression\n")
13897 {
13898 return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
13899 }
13900
13901 DEFUN (no_ip_community_list_standard_all,
13902 no_ip_community_list_standard_all_cmd,
13903 "no ip community-list <1-99>",
13904 NO_STR
13905 IP_STR
13906 COMMUNITY_LIST_STR
13907 "Community list number (standard)\n")
13908 {
13909 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
13910 }
13911
13912 DEFUN (no_ip_community_list_standard_direction,
13913 no_ip_community_list_standard_direction_cmd,
13914 "no ip community-list <1-99> (deny|permit)",
13915 NO_STR
13916 IP_STR
13917 COMMUNITY_LIST_STR
13918 "Community list number (standard)\n"
13919 "Specify community to reject\n"
13920 "Specify community to accept\n")
13921 {
13922 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
13923 }
13924
13925
13926 DEFUN (no_ip_community_list_expanded_all,
13927 no_ip_community_list_expanded_all_cmd,
13928 "no ip community-list <100-500>",
13929 NO_STR
13930 IP_STR
13931 COMMUNITY_LIST_STR
13932 "Community list number (expanded)\n")
13933 {
13934 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
13935 }
13936
13937 DEFUN (no_ip_community_list_name_standard_all,
13938 no_ip_community_list_name_standard_all_cmd,
13939 "no ip community-list standard WORD",
13940 NO_STR
13941 IP_STR
13942 COMMUNITY_LIST_STR
13943 "Add a standard community-list entry\n"
13944 "Community list name\n")
13945 {
13946 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
13947 }
13948
13949 DEFUN (no_ip_community_list_name_expanded_all,
13950 no_ip_community_list_name_expanded_all_cmd,
13951 "no ip community-list expanded WORD",
13952 NO_STR
13953 IP_STR
13954 COMMUNITY_LIST_STR
13955 "Add an expanded community-list entry\n"
13956 "Community list name\n")
13957 {
13958 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 1);
13959 }
13960
13961 DEFUN (no_ip_community_list_standard,
13962 no_ip_community_list_standard_cmd,
13963 "no ip community-list <1-99> (deny|permit) .AA:NN",
13964 NO_STR
13965 IP_STR
13966 COMMUNITY_LIST_STR
13967 "Community list number (standard)\n"
13968 "Specify community to reject\n"
13969 "Specify community to accept\n"
13970 COMMUNITY_VAL_STR)
13971 {
13972 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
13973 }
13974
13975 DEFUN (no_ip_community_list_expanded,
13976 no_ip_community_list_expanded_cmd,
13977 "no ip community-list <100-500> (deny|permit) .LINE",
13978 NO_STR
13979 IP_STR
13980 COMMUNITY_LIST_STR
13981 "Community list number (expanded)\n"
13982 "Specify community to reject\n"
13983 "Specify community to accept\n"
13984 "An ordered list as a regular-expression\n")
13985 {
13986 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
13987 }
13988
13989 DEFUN (no_ip_community_list_name_standard,
13990 no_ip_community_list_name_standard_cmd,
13991 "no ip community-list standard WORD (deny|permit) .AA:NN",
13992 NO_STR
13993 IP_STR
13994 COMMUNITY_LIST_STR
13995 "Specify a standard community-list\n"
13996 "Community list name\n"
13997 "Specify community to reject\n"
13998 "Specify community to accept\n"
13999 COMMUNITY_VAL_STR)
14000 {
14001 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
14002 }
14003
14004 DEFUN (no_ip_community_list_name_standard_brief,
14005 no_ip_community_list_name_standard_brief_cmd,
14006 "no ip community-list standard WORD (deny|permit)",
14007 NO_STR
14008 IP_STR
14009 COMMUNITY_LIST_STR
14010 "Specify a standard community-list\n"
14011 "Community list name\n"
14012 "Specify community to reject\n"
14013 "Specify community to accept\n")
14014 {
14015 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 0);
14016 }
14017
14018 DEFUN (no_ip_community_list_name_expanded,
14019 no_ip_community_list_name_expanded_cmd,
14020 "no ip community-list expanded WORD (deny|permit) .LINE",
14021 NO_STR
14022 IP_STR
14023 COMMUNITY_LIST_STR
14024 "Specify an expanded community-list\n"
14025 "Community list name\n"
14026 "Specify community to reject\n"
14027 "Specify community to accept\n"
14028 "An ordered list as a regular-expression\n")
14029 {
14030 return community_list_unset_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
14031 }
14032
14033 static void
14034 community_list_show (struct vty *vty, struct community_list *list)
14035 {
14036 struct community_entry *entry;
14037
14038 for (entry = list->head; entry; entry = entry->next)
14039 {
14040 if (entry == list->head)
14041 {
14042 if (all_digit (list->name))
14043 vty_out (vty, "Community %s list %s%s",
14044 entry->style == COMMUNITY_LIST_STANDARD ?
14045 "standard" : "(expanded) access",
14046 list->name, VTY_NEWLINE);
14047 else
14048 vty_out (vty, "Named Community %s list %s%s",
14049 entry->style == COMMUNITY_LIST_STANDARD ?
14050 "standard" : "expanded",
14051 list->name, VTY_NEWLINE);
14052 }
14053 if (entry->any)
14054 vty_out (vty, " %s%s",
14055 community_direct_str (entry->direct), VTY_NEWLINE);
14056 else
14057 vty_out (vty, " %s %s%s",
14058 community_direct_str (entry->direct),
14059 entry->style == COMMUNITY_LIST_STANDARD
14060 ? community_str (entry->u.com) : entry->config,
14061 VTY_NEWLINE);
14062 }
14063 }
14064
14065 DEFUN (show_ip_community_list,
14066 show_ip_community_list_cmd,
14067 "show ip community-list",
14068 SHOW_STR
14069 IP_STR
14070 "List community-list\n")
14071 {
14072 struct community_list *list;
14073 struct community_list_master *cm;
14074
14075 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
14076 if (! cm)
14077 return CMD_SUCCESS;
14078
14079 for (list = cm->num.head; list; list = list->next)
14080 community_list_show (vty, list);
14081
14082 for (list = cm->str.head; list; list = list->next)
14083 community_list_show (vty, list);
14084
14085 return CMD_SUCCESS;
14086 }
14087
14088 DEFUN (show_ip_community_list_arg,
14089 show_ip_community_list_arg_cmd,
14090 "show ip community-list (<1-500>|WORD)",
14091 SHOW_STR
14092 IP_STR
14093 "List community-list\n"
14094 "Community-list number\n"
14095 "Community-list name\n")
14096 {
14097 struct community_list *list;
14098
14099 list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
14100 if (! list)
14101 {
14102 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
14103 return CMD_WARNING;
14104 }
14105
14106 community_list_show (vty, list);
14107
14108 return CMD_SUCCESS;
14109 }
14110
14111 static int
14112 extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
14113 int style, int reject_all_digit_name)
14114 {
14115 int ret;
14116 int direct;
14117 char *str;
14118
14119 /* Check the list type. */
14120 if (strncmp (argv[1], "p", 1) == 0)
14121 direct = COMMUNITY_PERMIT;
14122 else if (strncmp (argv[1], "d", 1) == 0)
14123 direct = COMMUNITY_DENY;
14124 else
14125 {
14126 vty_out (vty, "%% Matching condition must be permit or deny%s",
14127 VTY_NEWLINE);
14128 return CMD_WARNING;
14129 }
14130
14131 /* All digit name check. */
14132 if (reject_all_digit_name && all_digit (argv[0]))
14133 {
14134 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
14135 return CMD_WARNING;
14136 }
14137
14138 /* Concat community string argument. */
14139 if (argc > 1)
14140 str = argv_concat (argv, argc, 2);
14141 else
14142 str = NULL;
14143
14144 ret = extcommunity_list_set (bgp_clist, argv[0], str, direct, style);
14145
14146 /* Free temporary community list string allocated by
14147 argv_concat(). */
14148 if (str)
14149 XFREE (MTYPE_TMP, str);
14150
14151 if (ret < 0)
14152 {
14153 community_list_perror (vty, ret);
14154 return CMD_WARNING;
14155 }
14156 return CMD_SUCCESS;
14157 }
14158
14159 static int
14160 extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
14161 int style, int delete_all)
14162 {
14163 int ret;
14164 int direct = 0;
14165 char *str = NULL;
14166
14167 if (argc > 1)
14168 {
14169 /* Check the list direct. */
14170 if (strncmp (argv[1], "p", 1) == 0)
14171 direct = COMMUNITY_PERMIT;
14172 else if (strncmp (argv[1], "d", 1) == 0)
14173 direct = COMMUNITY_DENY;
14174 else
14175 {
14176 vty_out (vty, "%% Matching condition must be permit or deny%s",
14177 VTY_NEWLINE);
14178 return CMD_WARNING;
14179 }
14180
14181 /* Concat community string argument. */
14182 str = argv_concat (argv, argc, 2);
14183 }
14184
14185 /* Unset community list. */
14186 ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style, delete_all);
14187
14188 /* Free temporary community list string allocated by
14189 argv_concat(). */
14190 if (str)
14191 XFREE (MTYPE_TMP, str);
14192
14193 if (ret < 0)
14194 {
14195 community_list_perror (vty, ret);
14196 return CMD_WARNING;
14197 }
14198
14199 return CMD_SUCCESS;
14200 }
14201
14202 /* "extcommunity-list" keyword help string. */
14203 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14204 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14205
14206 DEFUN (ip_extcommunity_list_standard,
14207 ip_extcommunity_list_standard_cmd,
14208 "ip extcommunity-list <1-99> (deny|permit) .AA:NN",
14209 IP_STR
14210 EXTCOMMUNITY_LIST_STR
14211 "Extended Community list number (standard)\n"
14212 "Specify community to reject\n"
14213 "Specify community to accept\n"
14214 EXTCOMMUNITY_VAL_STR)
14215 {
14216 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14217 }
14218
14219 ALIAS (ip_extcommunity_list_standard,
14220 ip_extcommunity_list_standard2_cmd,
14221 "ip extcommunity-list <1-99> (deny|permit)",
14222 IP_STR
14223 EXTCOMMUNITY_LIST_STR
14224 "Extended Community list number (standard)\n"
14225 "Specify community to reject\n"
14226 "Specify community to accept\n")
14227
14228 DEFUN (ip_extcommunity_list_expanded,
14229 ip_extcommunity_list_expanded_cmd,
14230 "ip extcommunity-list <100-500> (deny|permit) .LINE",
14231 IP_STR
14232 EXTCOMMUNITY_LIST_STR
14233 "Extended Community list number (expanded)\n"
14234 "Specify community to reject\n"
14235 "Specify community to accept\n"
14236 "An ordered list as a regular-expression\n")
14237 {
14238 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
14239 }
14240
14241 DEFUN (ip_extcommunity_list_name_standard,
14242 ip_extcommunity_list_name_standard_cmd,
14243 "ip extcommunity-list standard WORD (deny|permit) .AA:NN",
14244 IP_STR
14245 EXTCOMMUNITY_LIST_STR
14246 "Specify standard extcommunity-list\n"
14247 "Extended Community list name\n"
14248 "Specify community to reject\n"
14249 "Specify community to accept\n"
14250 EXTCOMMUNITY_VAL_STR)
14251 {
14252 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
14253 }
14254
14255 ALIAS (ip_extcommunity_list_name_standard,
14256 ip_extcommunity_list_name_standard2_cmd,
14257 "ip extcommunity-list standard WORD (deny|permit)",
14258 IP_STR
14259 EXTCOMMUNITY_LIST_STR
14260 "Specify standard extcommunity-list\n"
14261 "Extended Community list name\n"
14262 "Specify community to reject\n"
14263 "Specify community to accept\n")
14264
14265 DEFUN (ip_extcommunity_list_name_expanded,
14266 ip_extcommunity_list_name_expanded_cmd,
14267 "ip extcommunity-list expanded WORD (deny|permit) .LINE",
14268 IP_STR
14269 EXTCOMMUNITY_LIST_STR
14270 "Specify expanded extcommunity-list\n"
14271 "Extended Community list name\n"
14272 "Specify community to reject\n"
14273 "Specify community to accept\n"
14274 "An ordered list as a regular-expression\n")
14275 {
14276 return extcommunity_list_set_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
14277 }
14278
14279 DEFUN (no_ip_extcommunity_list_standard_all,
14280 no_ip_extcommunity_list_standard_all_cmd,
14281 "no ip extcommunity-list <1-99>",
14282 NO_STR
14283 IP_STR
14284 EXTCOMMUNITY_LIST_STR
14285 "Extended Community list number (standard)\n")
14286 {
14287 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
14288 }
14289
14290 DEFUN (no_ip_extcommunity_list_standard_direction,
14291 no_ip_extcommunity_list_standard_direction_cmd,
14292 "no ip extcommunity-list <1-99> (deny|permit)",
14293 NO_STR
14294 IP_STR
14295 EXTCOMMUNITY_LIST_STR
14296 "Extended Community list number (standard)\n"
14297 "Specify community to reject\n"
14298 "Specify community to accept\n")
14299 {
14300 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14301 }
14302
14303 DEFUN (no_ip_extcommunity_list_expanded_all,
14304 no_ip_extcommunity_list_expanded_all_cmd,
14305 "no ip extcommunity-list <100-500>",
14306 NO_STR
14307 IP_STR
14308 EXTCOMMUNITY_LIST_STR
14309 "Extended Community list number (expanded)\n")
14310 {
14311 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
14312 }
14313
14314 DEFUN (no_ip_extcommunity_list_name_standard_all,
14315 no_ip_extcommunity_list_name_standard_all_cmd,
14316 "no ip extcommunity-list standard WORD",
14317 NO_STR
14318 IP_STR
14319 EXTCOMMUNITY_LIST_STR
14320 "Specify standard extcommunity-list\n"
14321 "Extended Community list name\n")
14322 {
14323 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 1);
14324 }
14325
14326 DEFUN (no_ip_extcommunity_list_name_expanded_all,
14327 no_ip_extcommunity_list_name_expanded_all_cmd,
14328 "no ip extcommunity-list expanded WORD",
14329 NO_STR
14330 IP_STR
14331 EXTCOMMUNITY_LIST_STR
14332 "Specify expanded extcommunity-list\n"
14333 "Extended Community list name\n")
14334 {
14335 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 1);
14336 }
14337
14338 DEFUN (no_ip_extcommunity_list_standard,
14339 no_ip_extcommunity_list_standard_cmd,
14340 "no ip extcommunity-list <1-99> (deny|permit) .AA:NN",
14341 NO_STR
14342 IP_STR
14343 EXTCOMMUNITY_LIST_STR
14344 "Extended Community list number (standard)\n"
14345 "Specify community to reject\n"
14346 "Specify community to accept\n"
14347 EXTCOMMUNITY_VAL_STR)
14348 {
14349 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14350 }
14351
14352 DEFUN (no_ip_extcommunity_list_expanded,
14353 no_ip_extcommunity_list_expanded_cmd,
14354 "no ip extcommunity-list <100-500> (deny|permit) .LINE",
14355 NO_STR
14356 IP_STR
14357 EXTCOMMUNITY_LIST_STR
14358 "Extended Community list number (expanded)\n"
14359 "Specify community to reject\n"
14360 "Specify community to accept\n"
14361 "An ordered list as a regular-expression\n")
14362 {
14363 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
14364 }
14365
14366 DEFUN (no_ip_extcommunity_list_name_standard,
14367 no_ip_extcommunity_list_name_standard_cmd,
14368 "no ip extcommunity-list standard WORD (deny|permit) .AA:NN",
14369 NO_STR
14370 IP_STR
14371 EXTCOMMUNITY_LIST_STR
14372 "Specify standard extcommunity-list\n"
14373 "Extended Community list name\n"
14374 "Specify community to reject\n"
14375 "Specify community to accept\n"
14376 EXTCOMMUNITY_VAL_STR)
14377 {
14378 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14379 }
14380
14381 DEFUN (no_ip_extcommunity_list_name_standard_brief,
14382 no_ip_extcommunity_list_name_standard_brief_cmd,
14383 "no ip extcommunity-list standard WORD (deny|permit)",
14384 NO_STR
14385 IP_STR
14386 EXTCOMMUNITY_LIST_STR
14387 "Specify standard extcommunity-list\n"
14388 "Extended Community list name\n"
14389 "Specify community to reject\n"
14390 "Specify community to accept\n")
14391 {
14392 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_STANDARD, 0);
14393 }
14394
14395 DEFUN (no_ip_extcommunity_list_name_expanded,
14396 no_ip_extcommunity_list_name_expanded_cmd,
14397 "no ip extcommunity-list expanded WORD (deny|permit) .LINE",
14398 NO_STR
14399 IP_STR
14400 EXTCOMMUNITY_LIST_STR
14401 "Specify expanded extcommunity-list\n"
14402 "Community list name\n"
14403 "Specify community to reject\n"
14404 "Specify community to accept\n"
14405 "An ordered list as a regular-expression\n")
14406 {
14407 return extcommunity_list_unset_vty (vty, argc, argv, EXTCOMMUNITY_LIST_EXPANDED, 0);
14408 }
14409
14410 static void
14411 extcommunity_list_show (struct vty *vty, struct community_list *list)
14412 {
14413 struct community_entry *entry;
14414
14415 for (entry = list->head; entry; entry = entry->next)
14416 {
14417 if (entry == list->head)
14418 {
14419 if (all_digit (list->name))
14420 vty_out (vty, "Extended community %s list %s%s",
14421 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14422 "standard" : "(expanded) access",
14423 list->name, VTY_NEWLINE);
14424 else
14425 vty_out (vty, "Named extended community %s list %s%s",
14426 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14427 "standard" : "expanded",
14428 list->name, VTY_NEWLINE);
14429 }
14430 if (entry->any)
14431 vty_out (vty, " %s%s",
14432 community_direct_str (entry->direct), VTY_NEWLINE);
14433 else
14434 vty_out (vty, " %s %s%s",
14435 community_direct_str (entry->direct),
14436 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
14437 entry->u.ecom->str : entry->config,
14438 VTY_NEWLINE);
14439 }
14440 }
14441
14442 DEFUN (show_ip_extcommunity_list,
14443 show_ip_extcommunity_list_cmd,
14444 "show ip extcommunity-list",
14445 SHOW_STR
14446 IP_STR
14447 "List extended-community list\n")
14448 {
14449 struct community_list *list;
14450 struct community_list_master *cm;
14451
14452 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
14453 if (! cm)
14454 return CMD_SUCCESS;
14455
14456 for (list = cm->num.head; list; list = list->next)
14457 extcommunity_list_show (vty, list);
14458
14459 for (list = cm->str.head; list; list = list->next)
14460 extcommunity_list_show (vty, list);
14461
14462 return CMD_SUCCESS;
14463 }
14464
14465 DEFUN (show_ip_extcommunity_list_arg,
14466 show_ip_extcommunity_list_arg_cmd,
14467 "show ip extcommunity-list (<1-500>|WORD)",
14468 SHOW_STR
14469 IP_STR
14470 "List extended-community list\n"
14471 "Extcommunity-list number\n"
14472 "Extcommunity-list name\n")
14473 {
14474 struct community_list *list;
14475
14476 list = community_list_lookup (bgp_clist, argv[0], EXTCOMMUNITY_LIST_MASTER);
14477 if (! list)
14478 {
14479 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
14480 return CMD_WARNING;
14481 }
14482
14483 extcommunity_list_show (vty, list);
14484
14485 return CMD_SUCCESS;
14486 }
14487
14488 /* Return configuration string of community-list entry. */
14489 static const char *
14490 community_list_config_str (struct community_entry *entry)
14491 {
14492 const char *str;
14493
14494 if (entry->any)
14495 str = "";
14496 else
14497 {
14498 if (entry->style == COMMUNITY_LIST_STANDARD)
14499 str = community_str (entry->u.com);
14500 else
14501 str = entry->config;
14502 }
14503 return str;
14504 }
14505
14506 /* Display community-list and extcommunity-list configuration. */
14507 static int
14508 community_list_config_write (struct vty *vty)
14509 {
14510 struct community_list *list;
14511 struct community_entry *entry;
14512 struct community_list_master *cm;
14513 int write = 0;
14514
14515 /* Community-list. */
14516 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
14517
14518 for (list = cm->num.head; list; list = list->next)
14519 for (entry = list->head; entry; entry = entry->next)
14520 {
14521 vty_out (vty, "ip community-list %s %s %s%s",
14522 list->name, community_direct_str (entry->direct),
14523 community_list_config_str (entry),
14524 VTY_NEWLINE);
14525 write++;
14526 }
14527 for (list = cm->str.head; list; list = list->next)
14528 for (entry = list->head; entry; entry = entry->next)
14529 {
14530 vty_out (vty, "ip community-list %s %s %s %s%s",
14531 entry->style == COMMUNITY_LIST_STANDARD
14532 ? "standard" : "expanded",
14533 list->name, community_direct_str (entry->direct),
14534 community_list_config_str (entry),
14535 VTY_NEWLINE);
14536 write++;
14537 }
14538
14539 /* Extcommunity-list. */
14540 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
14541
14542 for (list = cm->num.head; list; list = list->next)
14543 for (entry = list->head; entry; entry = entry->next)
14544 {
14545 vty_out (vty, "ip extcommunity-list %s %s %s%s",
14546 list->name, community_direct_str (entry->direct),
14547 community_list_config_str (entry), VTY_NEWLINE);
14548 write++;
14549 }
14550 for (list = cm->str.head; list; list = list->next)
14551 for (entry = list->head; entry; entry = entry->next)
14552 {
14553 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
14554 entry->style == EXTCOMMUNITY_LIST_STANDARD
14555 ? "standard" : "expanded",
14556 list->name, community_direct_str (entry->direct),
14557 community_list_config_str (entry), VTY_NEWLINE);
14558 write++;
14559 }
14560 return write;
14561 }
14562
14563 static struct cmd_node community_list_node =
14564 {
14565 COMMUNITY_LIST_NODE,
14566 "",
14567 1 /* Export to vtysh. */
14568 };
14569
14570 static void
14571 community_list_vty (void)
14572 {
14573 install_node (&community_list_node, community_list_config_write);
14574
14575 /* Community-list. */
14576 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
14577 install_element (CONFIG_NODE, &ip_community_list_standard2_cmd);
14578 install_element (CONFIG_NODE, &ip_community_list_expanded_cmd);
14579 install_element (CONFIG_NODE, &ip_community_list_name_standard_cmd);
14580 install_element (CONFIG_NODE, &ip_community_list_name_standard2_cmd);
14581 install_element (CONFIG_NODE, &ip_community_list_name_expanded_cmd);
14582 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
14583 install_element (CONFIG_NODE, &no_ip_community_list_standard_direction_cmd);
14584 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
14585 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_all_cmd);
14586 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_all_cmd);
14587 install_element (CONFIG_NODE, &no_ip_community_list_standard_cmd);
14588 install_element (CONFIG_NODE, &no_ip_community_list_expanded_cmd);
14589 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_cmd);
14590 install_element (CONFIG_NODE, &no_ip_community_list_name_standard_brief_cmd);
14591 install_element (CONFIG_NODE, &no_ip_community_list_name_expanded_cmd);
14592 install_element (VIEW_NODE, &show_ip_community_list_cmd);
14593 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
14594 install_element (ENABLE_NODE, &show_ip_community_list_cmd);
14595 install_element (ENABLE_NODE, &show_ip_community_list_arg_cmd);
14596
14597 /* Extcommunity-list. */
14598 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
14599 install_element (CONFIG_NODE, &ip_extcommunity_list_standard2_cmd);
14600 install_element (CONFIG_NODE, &ip_extcommunity_list_expanded_cmd);
14601 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard_cmd);
14602 install_element (CONFIG_NODE, &ip_extcommunity_list_name_standard2_cmd);
14603 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
14604 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
14605 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_direction_cmd);
14606 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
14607 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_all_cmd);
14608 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_all_cmd);
14609 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_cmd);
14610 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_cmd);
14611 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_cmd);
14612 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_standard_brief_cmd);
14613 install_element (CONFIG_NODE, &no_ip_extcommunity_list_name_expanded_cmd);
14614 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
14615 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
14616 install_element (ENABLE_NODE, &show_ip_extcommunity_list_cmd);
14617 install_element (ENABLE_NODE, &show_ip_extcommunity_list_arg_cmd);
14618 }