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